30 #pragma warning( disable : 4661 ) // incomplete explicit templates 37 constexpr
struct releaseAndClear_t {
42 if ( i.second ) i.second->release();
47 constexpr
struct ordered_t {
59 template <
class PBASE>
72 if ( produceNTuples() ) {
74 if ( this->ntupleSvc() == 0 ) {
75 return this->Error(
"INTupleSvc* points to NULL!" );
82 this->debug() <<
"Production of N-Tuples is switched OFF" <<
endmsg;
85 if ( produceEvtCols() ) {
87 if ( 0 == this->evtColSvc() ) {
88 return this->Error(
"INTupleSvc* points to NULL!" );
95 this->debug() <<
"Production of Event Collections is switched OFF" <<
endmsg;
104 template <
class PBASE>
113 if ( !( nTupleMapTitle().empty() && nTupleMapID().empty() && evtColMapTitle().empty() && evtColMapID().empty() ) ) {
114 const int nNtuples = nTupleMapID().size();
115 const int nEvtCols = evtColMapID().size();
116 this->always() <<
"Booked " << nNtuples <<
" N-Tuples and " << nEvtCols <<
" Event Tag Collections" <<
endmsg;
119 if ( produceNTuples() && tuplesPrint() ) {
122 if ( produceEvtCols() && evtColsPrint() ) {
127 releaseAndClear( m_nTupleMapTitle );
130 releaseAndClear( m_nTupleMapID );
133 releaseAndClear( m_evtColMapTitle );
136 releaseAndClear( m_evtColMapID );
139 return PBASE::finalize();
145 template <
class PBASE>
149 auto* tuple = m_nTupleMapTitle[title];
151 return Tuple( tuple );
155 if ( this->useNumericAutoIDs() || title.
empty() ) {
156 if ( !this->useNumericAutoIDs() ) {
158 "Cannot generate automatic literal ID from an empty title ! Using numeric ID instead for nTuple ID",
162 ID =
TupleID( m_nTupleMapID.size() + 1 + nTupleOffSet() );
164 while ( nTupleExists( ID ) || evtColExists( ID ) ) {
169 ID =
TupleID( this->convertTitleToID( title ) );
171 while ( nTupleExists( ID ) || evtColExists( ID ) ) {
176 return nTuple( ID, title, clid );
183 template <
class PBASE>
189 return Tuple( tuple );
193 if ( this->useNumericAutoIDs() || title.
empty() ) {
194 if ( !this->useNumericAutoIDs() ) {
196 "Cannot generate automatic literal ID from an empty title ! Using numeric ID instead for evtCol ID",
200 ID =
TupleID( m_evtColMapID.size() + 1 + evtColOffSet() );
202 while ( nTupleExists( ID ) || evtColExists( ID ) ) {
207 ID =
TupleID( this->convertTitleToID( title ) );
209 while ( nTupleExists( ID ) || evtColExists( ID ) ) {
214 return evtCol( ID, title, clid );
221 template <
class PBASE>
226 this->Error(
"Undefined NTuple ID : Title='" + title1 +
"'" );
233 return Tuple( tuple );
243 if ( produceNTuples() ) {
247 tup = this->ntupleSvc()->book( nTuplePath(), ID.
numericID(), clid, title );
249 tup = this->ntupleSvc()->book( nTuplePath(), ID.
literalID(), clid, title );
251 this->Error(
"Undefined NTuple ID" );
255 this->Assert( tup,
"Could not book the N-Tuple='" + title +
"'" );
258 this->debug() <<
"Booked NTuple '" << title <<
"' ID=" << tID <<
"' Path='" << nTuplePath() <<
"' TS='" 262 tuple = createNTuple( title, tup, clid );
269 m_nTupleMapID[ID] = tuple;
272 m_nTupleMapTitle[title] = tuple;
274 return Tuple( tuple );
277 template <
class PBASE>
282 this->Error(
"Undefined NTuple ID : Title='" + title1 +
"'" );
289 return Tuple( tuple );
299 if ( produceEvtCols() ) {
303 tup = this->evtColSvc()->book( evtColPath(), ID.
numericID(), clid, title );
305 tup = this->evtColSvc()->book( evtColPath(), ID.
literalID(), clid, title );
307 this->Error(
"Undefined NTuple ID" );
311 this->Assert( tup,
"Could not book the EvtCol='" + title +
"'" );
314 this->debug() <<
"Booked EvtCol '" << title <<
"' ID=" << tID <<
"' Path='" << evtColPath() <<
"' TS='" 318 tuple = createEvtCol( title, tup, clid );
325 m_evtColMapID[ID] = tuple;
328 m_evtColMapTitle[title] = tuple;
330 return Tuple( tuple );
335 template <
class PBASE>
337 const CLID& clid )
const 346 template <
class PBASE>
348 const CLID& clid )
const 355 template <
class PBASE>
359 if ( nTupleMapTitle().empty() && nTupleMapID().empty() ) {
360 if ( this->msgLevel(
MSG::DEBUG ) ) this->debug() <<
"No N-Tuples are booked" <<
endmsg;
362 this->always() <<
"List of booked N-Tuples in directory " 363 <<
"\"" << nTuplePath() <<
"\"" <<
endmsg;
366 for (
const auto& entry : ordered( nTupleMapID() ) ) {
367 if ( !entry.second ) {
372 this->error() <<
" NTuple::Tuple* points to NULL" <<
endmsg;
378 return this->nTupleMapID().size();
383 template <
class PBASE>
386 if ( evtColMapTitle().empty() && evtColMapID().empty() ) {
387 this->always() <<
"No Event Tag Collections are booked" <<
endmsg;
389 this->always() <<
"List of booked Event Tag Collections in directory " 390 <<
"\"" << evtColPath() <<
"\"" <<
endmsg;
392 for (
const auto& entry : ordered( evtColMapID() ) ) {
393 if ( !entry.second ) {
396 const auto tuple = entry.second->tuple();
398 this->error() <<
" NTuple::Tuple* points to NULL" <<
endmsg;
405 return this->evtColMapID().size();
410 template <
class PBASE>
413 return m_nTupleMapID.end() != m_nTupleMapID.find( ID );
418 template <
class PBASE>
421 return m_evtColMapID.end() != m_evtColMapID.find( ID );
426 template <
class PBASE>
433 if ( this->tuplesPrint() ) {
440 template <
class PBASE>
447 if ( this->evtColsPrint() ) {
448 this->printEvtCols();
454 template <
class PBASE>
457 const std::string path = nTupleLUN() +
"/" + nTupleTopDir() + nTupleDir();
458 return ( splitNTupleDir() ? dirHbookName( path ) : path );
463 template <
class PBASE>
467 return ( splitEvtColDir() ? dirHbookName( path ) : path );
static std::string print(const INTuple *tuple, const GaudiAlg::TupleID &ID)
bool nTupleExists(const TupleID &ID) const
check the existence AND validity of the N-Tuple with the given ID
virtual Tuples::TupleObj * createEvtCol(const std::string &name, NTuple::Tuple *tuple, const CLID &clid) const
create TupleObj for event tag collection
Templated base class providing common 'ntupling' methods.
Header file for class TupleObj.
NumericID numericID() const noexcept
Returns the numerical ID.
TupleObj * createTupleObj(const OWNER *owner, const std::string &name, NTuple::Tuple *tuple, const CLID &clid=CLID_ColumnWiseTuple, const Tuples::Type type=Tuples::NTUPLE)
Templated helper functions allow to avoid heavy semantics of dealing with explicit type of class Tupl...
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
void printNTupleHandler(Gaudi::Details::PropertyBase &)
handler for "NTuplePrint" property
Tuple evtCol(const std::string &title, const CLID &clid=CLID_ColumnWiseTuple) const
Access an Event Tag Collection object (book on-demand) with unique identifier.
few useful function to construct names of Hbook histograms and directories functions are imported fro...
bool isFailure() const
Test for a status code of FAILURE.
IRegistry * registry() const
Get pointer to Registry.
void printEvtColHandler(Gaudi::Details::PropertyBase &)
handler for "EvtColsPrint" property
A simple wrapper class over standard Gaudi NTuple::Tuple facility.
long printTuples() const
perform the actual printout of N-tuples
virtual const id_type & identifier() const =0
Full identifier (or key)
A simple wrapper class over standard Gaudi NTuple::Tuple facility.
long printEvtCols() const
perform the actual printout of Event Tag Collections
This class is used for returning status codes from appropriate routines.
Tuple nTuple(const std::string &title, const CLID &clid=CLID_ColumnWiseTuple) const
Access an N-Tuple object (book on-demand) with unique identifier.
bool literal() const noexcept
Is this ID numeric.
GaudiAlg::ID TupleID
the actual type for N-Tuple identifier (HBOOK-style)
collection of useful utilities to print certain objects (currently used for implementation in class G...
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
unsigned int CLID
Class ID definition.
bool evtColExists(const TupleID &ID) const
check the existence AND validity of the Event Tag Collection with the given ID
unsigned long addRef()
add the reference to TupleObj
Collection of few 'technical' methods for instantiation of tuples.
Abstract base class which allows the user to interact with the actual N tuple implementation.
virtual Tuples::TupleObj * createNTuple(const std::string &name, NTuple::Tuple *tuple, const CLID &clid) const
create TupleObj
std::string evtColPath() const
get the constructed Event Tag Collection path
virtual Out operator()(const vector_of_const_< In > &inputs) const =0
std::string nTuplePath() const
get the constructed N-Tuple path
const LiteralID & literalID() const noexcept
Returns the ID as a LiteralID.
GAUDI_API LiteralID idAsString() const
Return ID as string, for both numeric and literal IDs.
bool numeric() const noexcept
Is this ID numeric.
implementation of various functions for streaming.
bool undefined() const noexcept
Is this ID undefined.
ID class for Histogram and Ntuples.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Header file for class : Tuple.