40 # pragma warning( disable : 4661 ) // incomplete explicit templates
46 template <
class PBASE>
52 if ( produceNTuples() ) {
54 if ( this->ntupleSvc() == 0 ) {
return this->Error(
"INTupleSvc* points to NULL!" ); }
58 this->debug() <<
"Production of N-Tuples is switched OFF" <<
endmsg;
61 if ( produceEvtCols() ) {
63 if ( 0 == this->evtColSvc() ) {
return this->Error(
"INTupleSvc* points to NULL!" ); }
67 this->debug() <<
"Production of Event Collections is switched OFF" <<
endmsg;
76 template <
class PBASE>
78 if ( !( m_nTupleMap.empty() && m_evtColMap.empty() ) ) {
79 const int nNtuples = m_nTupleMap.size();
80 const int nEvtCols = m_evtColMap.size();
81 this->always() <<
"Booked " << nNtuples <<
" N-Tuples and " << nEvtCols <<
" Event Tag Collections" <<
endmsg;
84 if ( produceNTuples() && tuplesPrint() ) printTuples();
85 if ( produceEvtCols() && evtColsPrint() ) printEvtCols();
94 return PBASE::finalize();
100 template <
class PBASE>
103 auto&
m = nTupleByTitle();
104 auto tuple =
m.find( title );
105 if ( tuple !=
m.end() )
return Tuple( tuple->tuple );
108 if ( this->useNumericAutoIDs() || title.
empty() ) {
109 if ( !this->useNumericAutoIDs() ) {
111 "Cannot generate automatic literal ID from an empty title ! Using numeric ID instead for nTuple ID",
116 ID =
TupleID( m_nTupleMap.size() + 1 + nTupleOffSet() );
118 while ( nTupleExists( ID ) || evtColExists( ID ) ) { ID =
TupleID( ID.
numeric() + 1 ); }
121 ID =
TupleID( this->convertTitleToID( title ) );
123 while ( nTupleExists( ID ) || evtColExists( ID ) ) { ID =
TupleID( ID.
idAsString() +
"_" ); }
126 return nTuple( ID, title, clid );
133 template <
class PBASE>
136 auto&
m = evtColByTitle();
137 auto tuple =
m.find( title );
138 if ( tuple !=
m.end() )
return Tuple( tuple->tuple );
141 if ( this->useNumericAutoIDs() || title.
empty() ) {
142 if ( !this->useNumericAutoIDs() ) {
144 "Cannot generate automatic literal ID from an empty title ! Using numeric ID instead for evtCol ID",
149 ID =
TupleID( m_evtColMap.size() + 1 + evtColOffSet() );
151 while ( nTupleExists( ID ) || evtColExists( ID ) ) { ID =
TupleID( ID.
numeric() + 1 ); }
154 ID =
TupleID( this->convertTitleToID( title ) );
156 while ( nTupleExists( ID ) || evtColExists( ID ) ) { ID =
TupleID( ID.
idAsString() +
"_" ); }
159 return evtCol( ID, title, clid );
166 template <
class PBASE>
170 this->Error(
"Undefined NTuple ID : Title='" + title1 +
"'" ).ignore();
175 auto&
m = nTupleByID();
176 auto tuple =
m.find( ID );
177 if ( tuple !=
m.end() )
return Tuple( tuple->tuple );
186 if ( !produceNTuples() ) {
187 auto r = m_nTupleMap.insert( nTupleMapItem{ title, ID, createNTuple( title,
nullptr, clid ) } );
188 if ( !r.second ) this->Error(
"Failure to createNTuple" ).ignore();
189 return Tuple( r.first->tuple );
194 tup = this->ntupleSvc()->book( nTuplePath(), ID.
numericID(), clid, title );
196 tup = this->ntupleSvc()->book( nTuplePath(), ID.
literalID(), clid, title );
198 this->Error(
"Undefined NTuple ID" ).ignore();
202 this->Assert( tup,
"Could not book the N-Tuple='" + title +
"'" );
205 this->debug() <<
"Booked NTuple '" << title <<
"' ID=" << tID <<
"' Path='" << nTuplePath() <<
"' TS='"
209 auto r = m_nTupleMap.insert( nTupleMapItem{ title, ID, createNTuple( title, tup, clid ) } );
210 if ( !r.second ) this->Error(
"Failure to createNTuple" ).ignore();
211 return Tuple( r.first->tuple );
215 template <
class PBASE>
219 this->Error(
"Undefined NTuple ID : Title='" + title1 +
"'" ).ignore();
224 auto& tuple = evtColByID();
225 auto i = tuple.find( ID );
226 if ( i != tuple.end() )
return Tuple( i->tuple );
235 if ( !produceEvtCols() ) {
236 auto r = m_evtColMap.insert( nTupleMapItem{ title, ID, createEvtCol( title,
nullptr, clid ) } );
237 if ( !r.second ) this->Error(
"Failure to createEvtCol" ).ignore();
238 return Tuple( r.first->tuple );
243 tup = this->evtColSvc()->book( evtColPath(), ID.
numericID(), clid, title );
245 tup = this->evtColSvc()->book( evtColPath(), ID.
literalID(), clid, title );
247 this->Error(
"Undefined NTuple ID" ).ignore();
251 this->Assert( tup,
"Could not book the EvtCol='" + title +
"'" );
254 this->debug() <<
"Booked EvtCol '" << title <<
"' ID=" << tID <<
"' Path='" << evtColPath() <<
"' TS='"
257 auto r = m_evtColMap.insert( nTupleMapItem{ title, ID, createEvtCol( title, tup, clid ) } );
258 if ( !r.second ) this->Error(
"Failure to createEvtCol" ).ignore();
264 template <
class PBASE>
266 const CLID& clid )
const {
274 template <
class PBASE>
276 const CLID& clid )
const {
282 template <
class PBASE>
285 if ( m_nTupleMap.empty() ) {
286 if ( this->msgLevel(
MSG::DEBUG ) ) this->debug() <<
"No N-Tuples are booked" <<
endmsg;
288 this->always() <<
"List of booked N-Tuples in directory "
289 <<
"\"" << nTuplePath() <<
"\"" <<
endmsg;
292 for (
const auto& entry : this->nTupleOrdered() ) {
293 if ( !entry.tuple->tuple() ) {
294 this->error() <<
" NTuple::Tuple* points to NULL" <<
endmsg;
300 return this->m_nTupleMap.size();
305 template <
class PBASE>
307 if ( m_evtColMap.empty() ) {
308 this->always() <<
"No Event Tag Collections are booked" <<
endmsg;
310 this->always() <<
"List of booked Event Tag Collections in directory "
311 <<
"\"" << evtColPath() <<
"\"" <<
endmsg;
313 for (
const auto& entry : this->evtColOrdered() ) {
314 if ( !entry.tuple->tuple() ) {
315 this->error() <<
" NTuple::Tuple* points to NULL" <<
endmsg;
322 return this->m_evtColMap.size();
327 template <
class PBASE>
329 auto&
m = nTupleByID();
330 return m.find( ID ) !=
m.end();
335 template <
class PBASE>
337 auto&
m = evtColByID();
338 return m.find( ID ) !=
m.end();
343 template <
class PBASE>
345 const std::string path = nTupleLUN() +
"/" + nTupleTopDir() + nTupleDir();
346 return splitNTupleDir() ? dirHbookName(
path ) :
path;
351 template <
class PBASE>
354 return splitEvtColDir() ? dirHbookName(
path ) :
path;