40 # pragma warning( disable : 4661 ) // incomplete explicit templates
46 template <
class PBASE>
58 if ( produceNTuples() ) {
60 if ( this->ntupleSvc() == 0 ) {
return this->Error(
"INTupleSvc* points to NULL!" ); }
64 this->debug() <<
"Production of N-Tuples is switched OFF" <<
endmsg;
67 if ( produceEvtCols() ) {
69 if ( 0 == this->evtColSvc() ) {
return this->Error(
"INTupleSvc* points to NULL!" ); }
73 this->debug() <<
"Production of Event Collections is switched OFF" <<
endmsg;
82 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>
115 auto&
m = nTupleByTitle();
116 auto tuple =
m.find( title );
117 if ( tuple !=
m.end() )
return Tuple( tuple->tuple );
120 if ( this->useNumericAutoIDs() || title.
empty() ) {
121 if ( !this->useNumericAutoIDs() ) {
123 "Cannot generate automatic literal ID from an empty title ! Using numeric ID instead for nTuple ID",
128 ID =
TupleID( m_nTupleMap.size() + 1 + nTupleOffSet() );
130 while ( nTupleExists( ID ) || evtColExists( ID ) ) { ID =
TupleID( ID.
numeric() + 1 ); }
133 ID =
TupleID( this->convertTitleToID( title ) );
135 while ( nTupleExists( ID ) || evtColExists( ID ) ) { ID =
TupleID( ID.
idAsString() +
"_" ); }
138 return nTuple( ID, title, clid );
145 template <
class PBASE>
148 auto&
m = evtColByTitle();
149 auto tuple =
m.find( title );
150 if ( tuple !=
m.end() )
return Tuple( tuple->tuple );
153 if ( this->useNumericAutoIDs() || title.
empty() ) {
154 if ( !this->useNumericAutoIDs() ) {
156 "Cannot generate automatic literal ID from an empty title ! Using numeric ID instead for evtCol ID",
161 ID =
TupleID( m_evtColMap.size() + 1 + evtColOffSet() );
163 while ( nTupleExists( ID ) || evtColExists( ID ) ) { ID =
TupleID( ID.
numeric() + 1 ); }
166 ID =
TupleID( this->convertTitleToID( title ) );
171 return evtCol( ID, title, clid );
178 template <
class PBASE>
182 this->Error(
"Undefined NTuple ID : Title='" + title1 +
"'" ).ignore();
187 auto&
m = nTupleByID();
188 auto tuple =
m.find( ID );
189 if ( tuple !=
m.end() )
return Tuple( tuple->tuple );
198 if ( !produceNTuples() ) {
199 auto r = m_nTupleMap.insert(
nTupleMapItem{title, ID, createNTuple( title,
nullptr, clid )} );
200 if ( !
r.second ) this->Error(
"Failure to createNTuple" ).ignore();
201 return Tuple(
r.first->tuple );
206 tup = this->ntupleSvc()->book( nTuplePath(), ID.
numericID(), clid, title );
208 tup = this->ntupleSvc()->book( nTuplePath(), ID.
literalID(), clid, title );
210 this->Error(
"Undefined NTuple ID" ).ignore();
214 this->Assert( tup,
"Could not book the N-Tuple='" + title +
"'" );
217 this->debug() <<
"Booked NTuple '" << title <<
"' ID=" << tID <<
"' Path='" << nTuplePath() <<
"' TS='"
221 auto r = m_nTupleMap.insert( nTupleMapItem{title, ID, createNTuple( title, tup, clid )} );
222 if ( !
r.second ) this->Error(
"Failure to createNTuple" ).ignore();
223 return Tuple(
r.first->tuple );
227 template <
class PBASE>
231 this->Error(
"Undefined NTuple ID : Title='" + title1 +
"'" ).ignore();
236 auto& tuple = evtColByID();
237 auto i = tuple.find( ID );
238 if ( i != tuple.end() )
return Tuple( i->tuple );
247 if ( !produceEvtCols() ) {
248 auto r = m_evtColMap.insert( nTupleMapItem{title, ID, createEvtCol( title,
nullptr, clid )} );
249 if ( !
r.second ) this->Error(
"Failure to createEvtCol" ).ignore();
255 tup = this->evtColSvc()->book( evtColPath(), ID.
numericID(), clid, title );
257 tup = this->evtColSvc()->book( evtColPath(), ID.
literalID(), clid, title );
259 this->Error(
"Undefined NTuple ID" ).ignore();
263 this->Assert( tup,
"Could not book the EvtCol='" + title +
"'" );
266 this->debug() <<
"Booked EvtCol '" << title <<
"' ID=" << tID <<
"' Path='" << evtColPath() <<
"' TS='"
269 auto r = m_evtColMap.insert( nTupleMapItem{title, ID, createEvtCol( title, tup, clid )} );
270 if ( !
r.second ) this->Error(
"Failure to createEvtCol" ).ignore();
271 return Tuple(
r.first->tuple );
276 template <
class PBASE>
278 const CLID& clid )
const {
286 template <
class PBASE>
288 const CLID& clid )
const {
294 template <
class PBASE>
297 if ( m_nTupleMap.empty() ) {
298 if ( this->msgLevel(
MSG::DEBUG ) ) this->debug() <<
"No N-Tuples are booked" <<
endmsg;
300 this->always() <<
"List of booked N-Tuples in directory "
301 <<
"\"" << nTuplePath() <<
"\"" <<
endmsg;
304 for (
const auto& entry : this->nTupleOrdered() ) {
305 if ( !entry.tuple->tuple() ) {
306 this->error() <<
" NTuple::Tuple* points to NULL" <<
endmsg;
312 return this->m_nTupleMap.size();
317 template <
class PBASE>
319 if ( m_evtColMap.empty() ) {
320 this->always() <<
"No Event Tag Collections are booked" <<
endmsg;
322 this->always() <<
"List of booked Event Tag Collections in directory "
323 <<
"\"" << evtColPath() <<
"\"" <<
endmsg;
325 for (
const auto& entry : this->evtColOrdered() ) {
326 if ( !entry.tuple->tuple() ) {
327 this->error() <<
" NTuple::Tuple* points to NULL" <<
endmsg;
334 return this->m_evtColMap.size();
339 template <
class PBASE>
341 auto&
m = nTupleByID();
342 return m.find( ID ) !=
m.end();
347 template <
class PBASE>
349 auto&
m = evtColByID();
350 return m.find( ID ) !=
m.end();
355 template <
class PBASE>
357 const std::string path = nTupleLUN() +
"/" + nTupleTopDir() + nTupleDir();
358 return splitNTupleDir() ? dirHbookName(
path ) :
path;
363 template <
class PBASE>
366 return splitEvtColDir() ? dirHbookName(
path ) :
path;