#include <HistoHandler.hh>
The core of the HistoHandler design is that it is a singleton class, essentially a wrapper around a map of AnalysisObject*
, indexed by a hash of the registering object and its local name for the registered projection.
Definition at line 26 of file HistoHandler.hh.
Public Member Functions | |
void | clear () |
Histo registration. */ | |
const AnalysisObject * | registerAnalysisObject (const Analysis &parent, const AnalysisObject &histo, const string &name) |
Copy an analysis object into a central collection and return the copy. | |
Histo retrieval. */ | |
const AnalysisObject * | getAnalysisObject (const Analysis &parent, const string &name) const |
Retrieve a named histo for the given Analysis parent (const version). | |
AnalysisObject * | getAnalysisObject (const Analysis &parent, const string &name) |
Retrieve a named histo for the given Analysis parent (non-const version). | |
Static Public Member Functions | |
static HistoHandler & | getInstance () |
Singleton getter function. | |
Private Types | |
typedef const AnalysisObject * | HistoHandle |
Typedef for histo pointer, to allow conversion to a smart pointer in this context. | |
typedef vector< HistoHandle > | HistoHandles |
Typedef for a vector of histo pointers. | |
typedef map< const string, HistoHandle > | NamedHistos |
Typedef for the structure used to contain named histos for a particular containing Analysis. | |
typedef map< const Analysis *, NamedHistos > | NamedHistosMap |
Structure used to map a containing Analysis to its set of histos. | |
Private Member Functions | |
~HistoHandler () | |
Private destructor means no inheritance from this class. | |
HistoHandler & | operator= (const HistoHandler &) |
The assignment operator is hidden. | |
HistoHandler (const HistoHandler &) | |
The copy constructor is hidden. | |
AnalysisObject * | _getAnalysisObject (const Analysis &parent, const string &name) const |
Log & | getLog () const |
Get a logger. | |
Construction. */ | |
HistoHandler () | |
The standard constructor. | |
Private Attributes | |
NamedHistosMap | _namedhistos |
Core data member, associating a given Analysis to its histos. |
typedef const AnalysisObject* HistoHandle [private] |
Typedef for histo pointer, to allow conversion to a smart pointer in this context.
Definition at line 102 of file HistoHandler.hh.
typedef vector<HistoHandle> HistoHandles [private] |
typedef map<const string, HistoHandle> NamedHistos [private] |
Typedef for the structure used to contain named histos for a particular containing Analysis.
Definition at line 109 of file HistoHandler.hh.
typedef map<const Analysis*, NamedHistos> NamedHistosMap [private] |
Structure used to map a containing Analysis to its set of histos.
Definition at line 112 of file HistoHandler.hh.
HistoHandler | ( | ) | [inline, private] |
~HistoHandler | ( | ) | [private] |
Private destructor means no inheritance from this class.
Definition at line 23 of file HistoHandler.cc.
References HistoHandler::clear().
00023 { 00024 clear(); 00025 }
HistoHandler | ( | const HistoHandler & | ) | [private] |
The copy constructor is hidden.
HistoHandler& operator= | ( | const HistoHandler & | ) | [private] |
The assignment operator is hidden.
static HistoHandler& getInstance | ( | ) | [inline, static] |
Singleton getter function.
Definition at line 48 of file HistoHandler.hh.
00048 { 00049 static HistoHandler _instance; 00050 return _instance; 00051 }
const AnalysisObject * registerAnalysisObject | ( | const Analysis & | parent, | |
const AnalysisObject & | histo, | |||
const string & | name | |||
) |
Copy an analysis object into a central collection and return the copy.
Definition at line 28 of file HistoHandler.cc.
References HistoHandler::_namedhistos, HistoHandler::getLog(), Analysis::name(), and Log::TRACE.
00030 { 00031 getLog() << Log::TRACE << "Trying to register" 00032 << " analysis object " << &ao 00033 << " for parent " << &parent << "(" << parent.name() << ")" 00034 << " with name '" << name << "'" << endl; 00035 00036 // If this name is already registered for this analysis, throw a complaint 00037 NamedHistosMap::const_iterator nhs = _namedhistos.find(&parent); 00038 if (nhs != _namedhistos.end()) { 00039 NamedHistos::const_iterator nh = nhs->second.find(name); 00040 if (nh != nhs->second.end()) { 00041 stringstream ss; 00042 ss << "Histogram \"" << name 00043 << "\" already exists for parent analysis " << &parent; 00044 throw Error(ss.str()); 00045 } 00046 } 00047 00048 _namedhistos[&parent][name] = &ao; 00049 //return *(_namedhistos[&parent][name]); 00050 return const_cast<AnalysisObject*>(_namedhistos[&parent][name]); 00051 }
const AnalysisObject* getAnalysisObject | ( | const Analysis & | parent, | |
const string & | name | |||
) | const [inline] |
Retrieve a named histo for the given Analysis parent (const version).
Definition at line 70 of file HistoHandler.hh.
References HistoHandler::_getAnalysisObject().
00071 { 00072 return _getAnalysisObject(parent, name); 00073 }
AnalysisObject* getAnalysisObject | ( | const Analysis & | parent, | |
const string & | name | |||
) | [inline] |
Retrieve a named histo for the given Analysis parent (non-const version).
Definition at line 77 of file HistoHandler.hh.
References HistoHandler::_getAnalysisObject().
00078 { 00079 return _getAnalysisObject(parent, name); 00080 }
void clear | ( | ) |
Histo clearing method: deletes all known histos and empties the reference collections.
Definition at line 17 of file HistoHandler.cc.
References HistoHandler::_namedhistos.
Referenced by HistoHandler::~HistoHandler().
00017 { 00018 _namedhistos.clear(); 00019 }
AnalysisObject * _getAnalysisObject | ( | const Analysis & | parent, | |
const string & | name | |||
) | const [private] |
Definition at line 55 of file HistoHandler.cc.
References HistoHandler::_namedhistos, HistoHandler::getLog(), and Log::TRACE.
Referenced by HistoHandler::getAnalysisObject().
00056 { 00057 getLog() << Log::TRACE << "Searching for child histo '" 00058 << name << "' of " << &parent << endl; 00059 00060 NamedHistosMap::const_iterator nhs = _namedhistos.find(&parent); 00061 if (nhs == _namedhistos.end()) { 00062 stringstream ss; 00063 ss << "Couldn't find any histograms for parent analysis " << &parent; 00064 throw Error(ss.str()); 00065 } 00066 00067 NamedHistos::const_iterator nh = nhs->second.find(name); 00068 if (nh == nhs->second.end()) { 00069 stringstream ss; 00070 ss << "Couldn't find histogram \"" << name 00071 << "\" for parent analysis " << &parent; 00072 throw Error(ss.str()); 00073 } 00074 00075 //return *(nh->second); 00076 AnalysisObject* rtn = const_cast<AnalysisObject*>(nh->second); 00077 return rtn; 00078 }
Log & getLog | ( | ) | const [private] |
Get a logger.
Definition at line 12 of file HistoHandler.cc.
References Log::getLog().
Referenced by HistoHandler::_getAnalysisObject(), and HistoHandler::registerAnalysisObject().
00012 { 00013 return Log::getLog("Rivet.HistoHandler"); 00014 }
NamedHistosMap _namedhistos [private] |
Core data member, associating a given Analysis to its histos.
Definition at line 115 of file HistoHandler.hh.
Referenced by HistoHandler::_getAnalysisObject(), HistoHandler::clear(), and HistoHandler::registerAnalysisObject().