33 #pragma warning ( disable:4661 ) // incomplete explicit templates
38 template <
class PBASE>
43 template <
class PBASE>
56 if ( produceNTuples() )
59 if ( this->ntupleSvc() == 0 )
60 {
return this->Error(
"INTupleSvc* points to NULL!" ); }
62 this->Print(
"The N-Tuple path is set to be '" + nTuplePath() +
"'",
66 { this->debug() <<
"Production of N-Tuples is switched OFF" <<
endmsg; }
68 if ( produceEvtCols() )
71 if ( 0 == this->evtColSvc() )
72 {
return this->Error(
"INTupleSvc* points to NULL!" ); }
74 this->Print(
"The EventCol path is set to be '" + evtColPath() +
"'",
78 { this->debug() <<
"Production of Event Collections is switched OFF" <<
endmsg; }
86 template <
class PBASE>
95 if ( !( nTupleMapTitle () . empty () &&
96 nTupleMapID () . empty () &&
97 evtColMapTitle () . empty () &&
98 evtColMapID () . empty ()
101 const int nNtuples = nTupleMapID () . size () ;
102 const int nEvtCols = evtColMapID () . size ();
104 <<
"Booked " << nNtuples <<
" N-Tuples and " << nEvtCols
105 <<
" Event Tag Collections" <<
endmsg ;
108 if ( produceNTuples () && tuplesPrint () ) { printTuples () ; }
109 if ( produceEvtCols () && evtColsPrint () ) { printEvtCols () ; }
113 m_nTupleMapTitle.end() != itup ; ++itup )
114 {
if( 0 != itup->second ) { itup->second->release() ; } }
115 m_nTupleMapTitle.clear() ;
119 m_nTupleMapID.end() != itup ; ++itup )
120 {
if( 0 != itup->second ) { itup->second->release() ; } }
121 m_nTupleMapID.clear();
125 m_evtColMapTitle.end() != itup ; ++itup )
126 {
if( 0 != itup->second ) { itup->second->release() ; } }
127 m_evtColMapTitle.clear();
131 m_evtColMapID.end() != itup ; ++itup )
132 {
if( 0 != itup->second ) { itup->second->release() ; } }
133 m_evtColMapID.clear() ;
136 return PBASE::finalize();
142 template <
class PBASE>
144 (
const std::string& title ,
145 const CLID& clid )
const
149 if ( 0 != tuple ) {
return Tuple( tuple ) ; }
152 if ( this->useNumericAutoIDs() || title.empty() )
154 if ( ! this->useNumericAutoIDs() )
156 this -> Warning(
"Cannot generate automatic literal ID from an empty title ! Using numeric ID instead for nTuple ID",
160 ID =
TupleID ( m_nTupleMapID.size() + 1 + nTupleOffSet() );
162 while ( nTupleExists(ID) || evtColExists(ID) )
168 ID =
TupleID( this->convertTitleToID(title) );
170 while ( nTupleExists(ID) || evtColExists(ID) )
174 return nTuple( ID , title , clid ) ;
181 template <
class PBASE>
183 (
const std::string& title ,
184 const CLID& clid )
const
188 if ( 0 != tuple ) {
return Tuple( tuple ) ; }
191 if ( this->useNumericAutoIDs() || title.empty() )
193 if ( ! this->useNumericAutoIDs() )
195 this -> Warning(
"Cannot generate automatic literal ID from an empty title ! Using numeric ID instead for evtCol ID",
199 ID =
TupleID ( m_evtColMapID.size() + 1 + evtColOffSet() ) ;
201 while ( nTupleExists(ID) || evtColExists(ID) )
207 ID =
TupleID( this->convertTitleToID(title) );
209 while ( nTupleExists(ID) || evtColExists(ID) )
213 return evtCol( ID , title , clid ) ;
220 template <
class PBASE>
223 const std::string& title1 ,
224 const CLID& clid )
const
228 { this->Error(
"Undefined NTuple ID : Title='"+title1+
"'");
return Tuple(0); }
232 if( 0 != tuple ) {
return Tuple( tuple ) ; }
238 const std::string title = title1.empty() ? (
"NTuple #" + tID ) : title1 ;
241 if( produceNTuples() )
247 tup = this->ntupleSvc() ->
book ( nTuplePath() , ID.
numericID() , clid , title );
251 tup = this->ntupleSvc() ->
book ( nTuplePath() , ID.
literalID() , clid , title );
253 else { this->Error(
"Undefined NTuple ID" ); }
256 this->Assert( 0 != tup ,
"Could not book the N-Tuple='" + title +
"'" ) ;
259 { this->debug() <<
"Booked NTuple '" << title <<
"' ID=" << tID
260 <<
"' Path='" << nTuplePath() <<
"' TS='"
263 tuple = createNTuple ( title , tup , clid ) ;
272 m_nTupleMapID [ ID ] = tuple ;
275 m_nTupleMapTitle[ title ] = tuple ;
277 return Tuple( tuple ) ;
280 template <
class PBASE>
283 const std::string& title1 ,
284 const CLID& clid )
const
288 { this->Error(
"Undefined NTuple ID : Title='"+title1+
"'");
return Tuple(0); }
292 if ( 0 != tuple ) {
return Tuple( tuple ) ; }
298 const std::string title = title1.empty() ? (
"EvtCol #" + tID ) : title1 ;
301 if( produceEvtCols() )
307 tup = this->evtColSvc()->book ( evtColPath() , ID.
numericID() , clid , title ) ;
311 tup = this->evtColSvc()->book ( evtColPath() , ID.
literalID() , clid , title ) ;
313 else { this->Error(
"Undefined NTuple ID" ); }
316 this->Assert( 0 != tup ,
"Could not book the EvtCol='" + title +
"'" ) ;
319 { this->debug() <<
"Booked EvtCol '" << title <<
"' ID=" << tID
320 <<
"' Path='" << evtColPath() <<
"' TS='"
323 tuple = createEvtCol ( title , tup , clid ) ;
332 m_evtColMapID [ ID ] = tuple ;
335 m_evtColMapTitle[ title ] = tuple ;
337 return Tuple( tuple ) ;
342 template <
class PBASE>
344 (
const std::string& name ,
346 const CLID& clid )
const
349 (
this ,
"Tuple '" + name +
"'" , tuple , clid ,
Tuples::NTUPLE ) ;
356 template <
class PBASE>
358 (
const std::string& name ,
360 const CLID& clid )
const
363 (
this ,
"EvtCol '" + name +
"'" , tuple , clid ,
Tuples::EVTCOL ) ;
368 template <
class PBASE>
372 if ( nTupleMapTitle().empty() && nTupleMapID().empty() )
373 {
if (this->msgLevel(
MSG::DEBUG)) this->debug() <<
"No N-Tuples are booked" <<
endmsg ; }
375 { this->always() <<
"List of booked N-Tuples in directory "
376 <<
"\"" << nTuplePath() <<
"\"" <<
endmsg ; }
379 typedef std::map<TupleID,const Tuples::TupleObj*> OrderedMapType;
380 OrderedMapType OrderedMap ( nTupleMapID().begin() , nTupleMapID().
end() ) ;
382 for ( OrderedMapType::const_iterator entry = OrderedMap.begin() ;
383 OrderedMap.end() != entry ; ++entry )
385 if ( 0 == entry->second ) { continue ; }
388 { this->error() <<
" NTuple::Tuple* points to NULL" <<
endmsg ; continue ; }
392 return this->nTupleMapID().size() ;
397 template <
class PBASE>
400 if ( evtColMapTitle().empty() && evtColMapID().empty() )
401 { this->always() <<
"No Event Tag Collections are booked" <<
endmsg ; }
403 { this->always() <<
"List of booked Event Tag Collections in directory "
404 <<
"\"" << evtColPath() <<
"\"" <<
endmsg ; }
407 typedef std::map<TupleID,const Tuples::TupleObj*> OrderedMapType;
408 OrderedMapType OrderedMap ( evtColMapID().begin() , evtColMapID().
end() ) ;
410 for ( OrderedMapType::const_iterator entry = OrderedMap.begin() ;
411 OrderedMap.end() != entry ; ++entry )
413 if ( 0 == entry->second ) { continue ; }
416 { this->error() <<
" NTuple::Tuple* points to NULL" <<
endmsg ; continue ; }
422 return this->evtColMapID().size() ;
427 template <
class PBASE>
430 return m_nTupleMapID.end() != m_nTupleMapID.find ( ID ) ;
435 template <
class PBASE>
438 return m_evtColMapID.end() != m_evtColMapID.find ( ID ) ;
443 template <
class PBASE>
448 if (
this -> tuplesPrint() ) {
this -> printTuples () ; }
453 template <
class PBASE>
458 if (
this -> evtColsPrint() ) {
this -> printEvtCols () ; }
463 template <
class PBASE>
466 const std::string
path = nTupleLUN() +
"/" + nTupleTopDir() + nTupleDir();
467 return ( splitNTupleDir() ? dirHbookName( path ) : path ) ;
472 template <
class PBASE>
475 std::string
path = evtColLUN() +
"/" + evtColTopDir() + evtColDir();
476 return ( splitEvtColDir() ? dirHbookName( path ) : path );
static std::string print(const INTuple *tuple, const GaudiAlg::TupleID &ID)
GAUDI_API AIDA::IHistogram1D * book(IHistogramSvc *svc, const std::string &path, const Gaudi::Histo1DDef &hist)
helper function to book 1D-histogram
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.
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
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.
A simple wrapper class over standard Gaudi NTuple::Tuple facility.
void printEvtColHandler(Property &)
handler for "EvtColsPrint" property
NumericID numericID() const
Returns the numerical ID.
def nTuple
Retrieve (book-on-demand) 'Smart'-N-tuple object.
long printTuples() const
perform the actual printout of N-tuples
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.
const LiteralID & literalID() const
Returns the ID as a LiteralID.
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...
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
Collection of few 'technical' methods for instantiation of tuples.
Abstract base class which allows the user to interact with the actual N tuple implementation.
GAUDI_API std::string path(const AIDA::IBaseHistogram *aida)
get the path in THS for AIDA histogram
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 ~GaudiTuples()
Destructor.
Property base class allowing Property* collections to be "homogeneous".
map_type::iterator iterator
bool undefined() const
Is this ID undefined.
std::string nTuplePath() const
get the constructed N-Tuple path
GAUDI_API LiteralID idAsString() const
Return ID as string, for both numeric and literal IDs.
bool literal() const
Is this ID numeric.
void printNTupleHandler(Property &)
handler for "NTuplePrint" property
implemenattiono fvarioud functions for streaming.
ID class for Histogram and Ntuples.
bool numeric() const
Is this ID numeric.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Header file for class : Tuple.