#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 * | create () |
Singleton creation 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. | |
Static Private Attributes | |
static HistoHandler * | _instance = 0 |
typedef const AnalysisObject* HistoHandle [private] |
Typedef for histo pointer, to allow conversion to a smart pointer in this context.
Definition at line 101 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 108 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 111 of file HistoHandler.hh.
HistoHandler | ( | ) | [inline, private] |
The standard constructor.
Definition at line 32 of file HistoHandler.hh.
Referenced by HistoHandler::create().
~HistoHandler | ( | ) | [private] |
Private destructor means no inheritance from this class.
Definition at line 38 of file HistoHandler.cc.
References HistoHandler::clear().
00038 { 00039 clear(); 00040 }
HistoHandler | ( | const HistoHandler & | ) | [private] |
The copy constructor is hidden.
HistoHandler& operator= | ( | const HistoHandler & | ) | [private] |
The assignment operator is hidden.
HistoHandler * create | ( | ) | [static] |
Singleton creation function.
Definition at line 15 of file HistoHandler.cc.
References HistoHandler::_instance, Log::getLog(), HistoHandler::HistoHandler(), and Log::TRACE.
00015 { 00016 if (!_instance) { 00017 _instance = new HistoHandler(); 00018 Log::getLog("Rivet.HistoHandler") 00019 << Log::TRACE << "Created new HistoHandler at " 00020 << _instance << endl; 00021 } 00022 return _instance; 00023 }
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 43 of file HistoHandler.cc.
References HistoHandler::_namedhistos, HistoHandler::getLog(), Analysis::name(), and Log::TRACE.
00045 { 00046 getLog() << Log::TRACE << "Trying to register" 00047 << " analysis object " << &ao 00048 << " for parent " << &parent << "(" << parent.name() << ")" 00049 << " with name '" << name << "'" << endl; 00050 00051 // If this name is already registered for this analysis, throw a complaint 00052 NamedHistosMap::const_iterator nhs = _namedhistos.find(&parent); 00053 if (nhs != _namedhistos.end()) { 00054 NamedHistos::const_iterator nh = nhs->second.find(name); 00055 if (nh != nhs->second.end()) { 00056 stringstream ss; 00057 ss << "Histogram \"" << name 00058 << "\" already exists for parent analysis " << &parent; 00059 throw Error(ss.str()); 00060 } 00061 } 00062 00063 _namedhistos[&parent][name] = &ao; 00064 //return *(_namedhistos[&parent][name]); 00065 return const_cast<AnalysisObject*>(_namedhistos[&parent][name]); 00066 }
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 69 of file HistoHandler.hh.
References HistoHandler::_getAnalysisObject().
00070 { 00071 return _getAnalysisObject(parent, name); 00072 }
AnalysisObject* getAnalysisObject | ( | const Analysis & | parent, | |
const string & | name | |||
) | [inline] |
Retrieve a named histo for the given Analysis parent (non-const version).
Definition at line 76 of file HistoHandler.hh.
References HistoHandler::_getAnalysisObject().
00077 { 00078 return _getAnalysisObject(parent, name); 00079 }
void clear | ( | ) |
Histo clearing method: deletes all known histos and empties the reference collections.
Definition at line 32 of file HistoHandler.cc.
References HistoHandler::_namedhistos.
Referenced by HistoHandler::~HistoHandler().
00032 { 00033 _namedhistos.clear(); 00034 }
AnalysisObject * _getAnalysisObject | ( | const Analysis & | parent, | |
const string & | name | |||
) | const [private] |
Definition at line 70 of file HistoHandler.cc.
References HistoHandler::_namedhistos, HistoHandler::getLog(), and Log::TRACE.
Referenced by HistoHandler::getAnalysisObject().
00071 { 00072 getLog() << Log::TRACE << "Searching for child histo '" 00073 << name << "' of " << &parent << endl; 00074 00075 NamedHistosMap::const_iterator nhs = _namedhistos.find(&parent); 00076 if (nhs == _namedhistos.end()) { 00077 stringstream ss; 00078 ss << "Couldn't find any histograms for parent analysis " << &parent; 00079 throw Error(ss.str()); 00080 } 00081 00082 NamedHistos::const_iterator nh = nhs->second.find(name); 00083 if (nh == nhs->second.end()) { 00084 stringstream ss; 00085 ss << "Couldn't find histogram \"" << name 00086 << "\" for parent analysis " << &parent; 00087 throw Error(ss.str()); 00088 } 00089 00090 //return *(nh->second); 00091 AnalysisObject* rtn = const_cast<AnalysisObject*>(nh->second); 00092 return rtn; 00093 }
Log & getLog | ( | ) | const [private] |
Get a logger.
Definition at line 27 of file HistoHandler.cc.
References Log::getLog().
Referenced by HistoHandler::_getAnalysisObject(), and HistoHandler::registerAnalysisObject().
00027 { 00028 return Log::getLog("Rivet.HistoHandler"); 00029 }
HistoHandler * _instance = 0 [static, private] |
Singleton instance
Definition at line 37 of file HistoHandler.hh.
Referenced by HistoHandler::create().
NamedHistosMap _namedhistos [private] |
Core data member, associating a given Analysis to its histos.
Definition at line 114 of file HistoHandler.hh.
Referenced by HistoHandler::_getAnalysisObject(), HistoHandler::clear(), and HistoHandler::registerAnalysisObject().