30 #pragma warning( disable : 4661 ) // incomplete explicit templates 36 template <
class PBASE>
49 if ( produceNTuples() ) {
51 if ( this->ntupleSvc() == 0 ) {
52 return this->Error(
"INTupleSvc* points to NULL!" );
59 this->debug() <<
"Production of N-Tuples is switched OFF" <<
endmsg;
62 if ( produceEvtCols() ) {
64 if ( 0 == this->evtColSvc() ) {
65 return this->Error(
"INTupleSvc* points to NULL!" );
72 this->debug() <<
"Production of Event Collections is switched OFF" <<
endmsg;
81 template <
class PBASE>
90 if ( !( m_nTupleMap.empty() && m_evtColMap.empty() ) ) {
91 const int nNtuples = m_nTupleMap.size();
92 const int nEvtCols = m_evtColMap.size();
93 this->always() <<
"Booked " << nNtuples <<
" N-Tuples and " << nEvtCols <<
" Event Tag Collections" <<
endmsg;
96 if ( produceNTuples() && tuplesPrint() ) printTuples();
97 if ( produceEvtCols() && evtColsPrint() ) printEvtCols();
106 return PBASE::finalize();
112 template <
class PBASE>
116 auto&
m = nTupleByTitle();
117 auto tuple =
m.find( title );
118 if ( tuple !=
m.end() )
return Tuple( tuple->tuple );
121 if ( this->useNumericAutoIDs() || title.
empty() ) {
122 if ( !this->useNumericAutoIDs() ) {
124 "Cannot generate automatic literal ID from an empty title ! Using numeric ID instead for nTuple ID",
129 ID =
TupleID( m_nTupleMap.size() + 1 + nTupleOffSet() );
131 while ( nTupleExists( ID ) || evtColExists( ID ) ) {
136 ID =
TupleID( this->convertTitleToID( title ) );
138 while ( nTupleExists( ID ) || evtColExists( ID ) ) {
143 return nTuple( ID, title, clid );
150 template <
class PBASE>
154 auto&
m = evtColByTitle();
155 auto tuple =
m.find( title );
156 if ( tuple !=
m.end() )
return Tuple( tuple->tuple );
159 if ( this->useNumericAutoIDs() || title.
empty() ) {
160 if ( !this->useNumericAutoIDs() ) {
162 "Cannot generate automatic literal ID from an empty title ! Using numeric ID instead for evtCol ID",
167 ID =
TupleID( m_evtColMap.size() + 1 + evtColOffSet() );
169 while ( nTupleExists( ID ) || evtColExists( ID ) ) {
174 ID =
TupleID( this->convertTitleToID( title ) );
176 while ( nTupleExists( ID ) || evtColExists( ID ) ) {
181 return evtCol( ID, title, clid );
188 template <
class PBASE>
193 this->Error(
"Undefined NTuple ID : Title='" + title1 +
"'" ).ignore();
198 auto&
m = nTupleByID();
199 auto tuple =
m.find( ID );
200 if ( tuple !=
m.end() )
return Tuple( tuple->tuple );
209 if ( !produceNTuples() ) {
210 auto r = m_nTupleMap.
insert(
nTupleMapItem{title, ID, createNTuple( title,
nullptr, clid )} );
211 if ( !r.second ) this->Error(
"Failure to createNTuple" ).ignore();
212 return Tuple( r.first->tuple );
217 tup = this->ntupleSvc()->book( nTuplePath(), ID.
numericID(), clid, title );
219 tup = this->ntupleSvc()->book( nTuplePath(), ID.
literalID(), clid, title );
221 this->Error(
"Undefined NTuple ID" ).ignore();
225 this->Assert( tup,
"Could not book the N-Tuple='" + title +
"'" );
228 this->debug() <<
"Booked NTuple '" << title <<
"' ID=" << tID <<
"' Path='" << nTuplePath() <<
"' TS='" 232 auto r = m_nTupleMap.insert(
nTupleMapItem{title, ID, createNTuple( title, tup, clid )} );
233 if ( !r.second ) this->Error(
"Failure to createNTuple" ).ignore();
234 return Tuple( r.first->tuple );
238 template <
class PBASE>
243 this->Error(
"Undefined NTuple ID : Title='" + title1 +
"'" ).ignore();
248 auto& tuple = evtColByID();
249 auto i = tuple.find( ID );
250 if ( i != tuple.end() )
return Tuple( i->tuple );
259 if ( !produceEvtCols() ) {
260 auto r = m_evtColMap.
insert(
nTupleMapItem{title, ID, createEvtCol( title,
nullptr, clid )} );
261 if ( !r.second ) this->Error(
"Failure to createEvtCol" ).ignore();
262 return Tuple( r.first->tuple );
267 tup = this->evtColSvc()->book( evtColPath(), ID.
numericID(), clid, title );
269 tup = this->evtColSvc()->book( evtColPath(), ID.
literalID(), clid, title );
271 this->Error(
"Undefined NTuple ID" ).ignore();
275 this->Assert( tup,
"Could not book the EvtCol='" + title +
"'" );
278 this->debug() <<
"Booked EvtCol '" << title <<
"' ID=" << tID <<
"' Path='" << evtColPath() <<
"' TS='" 281 auto r = m_evtColMap.insert(
nTupleMapItem{title, ID, createEvtCol( title, tup, clid )} );
282 if ( !r.second ) this->Error(
"Failure to createEvtCol" ).ignore();
283 return Tuple( r.first->tuple );
288 template <
class PBASE>
290 const CLID& clid )
const 299 template <
class PBASE>
301 const CLID& clid )
const 308 template <
class PBASE>
312 if ( m_nTupleMap.empty() ) {
313 if ( this->msgLevel(
MSG::DEBUG ) ) this->debug() <<
"No N-Tuples are booked" <<
endmsg;
315 this->always() <<
"List of booked N-Tuples in directory " 316 <<
"\"" << nTuplePath() <<
"\"" <<
endmsg;
319 for (
const auto& entry : this->nTupleOrdered() ) {
320 if ( !entry.tuple->tuple() ) {
321 this->error() <<
" NTuple::Tuple* points to NULL" <<
endmsg;
327 return this->m_nTupleMap.size();
332 template <
class PBASE>
335 if ( m_evtColMap.empty() ) {
336 this->always() <<
"No Event Tag Collections are booked" <<
endmsg;
338 this->always() <<
"List of booked Event Tag Collections in directory " 339 <<
"\"" << evtColPath() <<
"\"" <<
endmsg;
341 for (
const auto& entry : this->evtColOrdered() ) {
342 if ( !entry.tuple->tuple() ) {
343 this->error() <<
" NTuple::Tuple* points to NULL" <<
endmsg;
350 return this->m_evtColMap.size();
355 template <
class PBASE>
358 auto&
m = nTupleByID();
359 return m.find( ID ) !=
m.end();
364 template <
class PBASE>
367 auto&
m = evtColByID();
368 return m.find( ID ) !=
m.end();
373 template <
class PBASE>
378 if ( this->tuplesPrint() ) this->printTuples();
383 template <
class PBASE>
388 if ( this->evtColsPrint() ) this->printEvtCols();
393 template <
class PBASE>
396 const std::string path = nTupleLUN() +
"/" + nTupleTopDir() + nTupleDir();
397 return splitNTupleDir() ? dirHbookName( path ) :
path;
402 template <
class PBASE>
406 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
Templated base class providing common 'ntupling' methods.
Header file for class TupleObj.
NumericID numericID() const noexcept
Returns the numerical ID.
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...
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)
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.
virtual std::unique_ptr< Tuples::TupleObj > createEvtCol(const std::string &name, NTuple::Tuple *tuple, const CLID &clid) const
create TupleObj for event tag collection
bool evtColExists(const TupleID &ID) const
check the existence AND validity of the Event Tag Collection with the given ID
constexpr static const auto SUCCESS
Collection of few 'technical' methods for instantiation of tuples.
Abstract base class which allows the user to interact with the actual N tuple implementation.
auto 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 evtColPath() const
get the constructed Event Tag Collection path
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.
virtual std::unique_ptr< Tuples::TupleObj > createNTuple(const std::string &name, NTuple::Tuple *tuple, const CLID &clid) const
create TupleObj