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",
163 ID =
TupleID( m_nTupleMapID.size() + 1 + nTupleOffSet() );
165 while ( nTupleExists( ID ) || evtColExists( ID ) ) {
170 ID =
TupleID( this->convertTitleToID( title ) );
172 while ( nTupleExists( ID ) || evtColExists( ID ) ) {
177 return nTuple( ID, title, clid );
184 template <
class PBASE>
190 return Tuple( tuple );
194 if ( this->useNumericAutoIDs() || title.
empty() ) {
195 if ( !this->useNumericAutoIDs() ) {
197 "Cannot generate automatic literal ID from an empty title ! Using numeric ID instead for evtCol ID",
202 ID =
TupleID( m_evtColMapID.size() + 1 + evtColOffSet() );
204 while ( nTupleExists( ID ) || evtColExists( ID ) ) {
209 ID =
TupleID( this->convertTitleToID( title ) );
211 while ( nTupleExists( ID ) || evtColExists( ID ) ) {
216 return evtCol( ID, title, clid );
223 template <
class PBASE>
228 this->Error(
"Undefined NTuple ID : Title='" + title1 +
"'" ).ignore();
235 return Tuple( tuple );
245 if ( produceNTuples() ) {
249 tup = this->ntupleSvc()->book( nTuplePath(), ID.
numericID(), clid, title );
251 tup = this->ntupleSvc()->book( nTuplePath(), ID.
literalID(), clid, title );
253 this->Error(
"Undefined NTuple ID" ).ignore();
257 this->Assert( tup,
"Could not book the N-Tuple='" + title +
"'" );
260 this->debug() <<
"Booked NTuple '" << title <<
"' ID=" << tID <<
"' Path='" << nTuplePath() <<
"' TS='" 264 tuple = createNTuple( title, tup, clid );
271 m_nTupleMapID[ID] = tuple;
274 m_nTupleMapTitle[title] = tuple;
276 return Tuple( tuple );
279 template <
class PBASE>
284 this->Error(
"Undefined NTuple ID : Title='" + title1 +
"'" ).ignore();
291 return Tuple( tuple );
301 if ( produceEvtCols() ) {
305 tup = this->evtColSvc()->book( evtColPath(), ID.
numericID(), clid, title );
307 tup = this->evtColSvc()->book( evtColPath(), ID.
literalID(), clid, title );
309 this->Error(
"Undefined NTuple ID" ).ignore();
313 this->Assert( tup,
"Could not book the EvtCol='" + title +
"'" );
316 this->debug() <<
"Booked EvtCol '" << title <<
"' ID=" << tID <<
"' Path='" << evtColPath() <<
"' TS='" 320 tuple = createEvtCol( title, tup, clid );
327 m_evtColMapID[ID] = tuple;
330 m_evtColMapTitle[title] = tuple;
332 return Tuple( tuple );
337 template <
class PBASE>
339 const CLID& clid )
const 348 template <
class PBASE>
350 const CLID& clid )
const 357 template <
class PBASE>
361 if ( nTupleMapTitle().empty() && nTupleMapID().empty() ) {
362 if ( this->msgLevel(
MSG::DEBUG ) ) this->debug() <<
"No N-Tuples are booked" <<
endmsg;
364 this->always() <<
"List of booked N-Tuples in directory " 365 <<
"\"" << nTuplePath() <<
"\"" <<
endmsg;
368 for (
const auto& entry : ordered( nTupleMapID() ) ) {
369 if ( !entry.second ) {
374 this->error() <<
" NTuple::Tuple* points to NULL" <<
endmsg;
380 return this->nTupleMapID().size();
385 template <
class PBASE>
388 if ( evtColMapTitle().empty() && evtColMapID().empty() ) {
389 this->always() <<
"No Event Tag Collections are booked" <<
endmsg;
391 this->always() <<
"List of booked Event Tag Collections in directory " 392 <<
"\"" << evtColPath() <<
"\"" <<
endmsg;
394 for (
const auto& entry : ordered( evtColMapID() ) ) {
395 if ( !entry.second ) {
398 const auto tuple = entry.second->tuple();
400 this->error() <<
" NTuple::Tuple* points to NULL" <<
endmsg;
407 return this->evtColMapID().size();
412 template <
class PBASE>
415 return m_nTupleMapID.end() != m_nTupleMapID.find( ID );
420 template <
class PBASE>
423 return m_evtColMapID.end() != m_evtColMapID.find( ID );
428 template <
class PBASE>
435 if ( this->tuplesPrint() ) {
442 template <
class PBASE>
449 if ( this->evtColsPrint() ) {
450 this->printEvtCols();
456 template <
class PBASE>
459 const std::string path = nTupleLUN() +
"/" + nTupleTopDir() + nTupleDir();
460 return ( splitNTupleDir() ? dirHbookName( path ) : path );
465 template <
class PBASE>
469 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.