rivet is hosted by Hepforge, IPPP Durham

The projection handler is a central repository for histograms (and other analysis stats objects) to be used in a Rivet analysis run. This eliminates the need for analysis classes to contain large numbers of histogram pointer members, and allows histograms to be accessed via more user-friendly names than C++ variable names allow. More...

#include <HistoHandler.hh>

Collaboration diagram for HistoHandler:

List of all members.

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 HistoHandlergetInstance ()
 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< HistoHandleHistoHandles
 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

AnalysisObject * _getAnalysisObject (const Analysis &parent, const string &name) const
LoggetLog () const
 Get a logger.
Construction. */
 HistoHandler ()
 The standard constructor.
 ~HistoHandler ()
 Private destructor means no inheritance from this class.
HistoHandleroperator= (const HistoHandler &)
 The assignment operator is hidden.
 HistoHandler (const HistoHandler &)
 The copy constructor is hidden.

Private Attributes

NamedHistosMap _namedhistos
 Core data member, associating a given Analysis to its histos.

Detailed Description

The projection handler is a central repository for histograms (and other analysis stats objects) to be used in a Rivet analysis run. This eliminates the need for analysis classes to contain large numbers of histogram pointer members, and allows histograms to be accessed via more user-friendly names than C++ variable names allow.

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.


Member Typedef Documentation

typedef const AnalysisObject* HistoHandle [private]

Typedef for histo pointer, to allow conversion to a smart pointer in this context.

Definition at line 104 of file HistoHandler.hh.

typedef vector<HistoHandle> HistoHandles [private]

Typedef for a vector of histo pointers.

Definition at line 107 of file HistoHandler.hh.

typedef map<const string, HistoHandle> NamedHistos [private]

Typedef for the structure used to contain named histos for a particular containing Analysis.

Definition at line 111 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 114 of file HistoHandler.hh.


Constructor & Destructor Documentation

HistoHandler ( ) [inline, private]

The standard constructor.

Definition at line 33 of file HistoHandler.hh.

{ }
~HistoHandler ( ) [private]

Private destructor means no inheritance from this class.

Definition at line 23 of file HistoHandler.cc.

References HistoHandler::clear().

                              {
    clear();
  }
HistoHandler ( const HistoHandler ) [private]

The copy constructor is hidden.


Member Function Documentation

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().

                                                                                   {
    getLog() << Log::TRACE << "Searching for child histo '"
             << name << "' of " << &parent << endl;

    NamedHistosMap::const_iterator nhs = _namedhistos.find(&parent);
    if (nhs == _namedhistos.end()) {
      stringstream ss;
      ss << "Couldn't find any histograms for parent analysis " << &parent;
      throw Error(ss.str());
    }

    NamedHistos::const_iterator nh = nhs->second.find(name);
    if (nh == nhs->second.end()) {
      stringstream ss;
      ss << "Couldn't find histogram \"" << name
         << "\" for parent analysis " << &parent;
      throw Error(ss.str());
    }

    //return *(nh->second);
    AnalysisObject* rtn = const_cast<AnalysisObject*>(nh->second);
    return rtn;
  }
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().

                           {
    _namedhistos.clear();
  }
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 72 of file HistoHandler.hh.

References HistoHandler::_getAnalysisObject().

                                                                      {
      return _getAnalysisObject(parent, name);
    }
AnalysisObject* getAnalysisObject ( const Analysis parent,
const string &  name 
) [inline]

Retrieve a named histo for the given Analysis parent (non-const version).

Definition at line 79 of file HistoHandler.hh.

References HistoHandler::_getAnalysisObject().

                                                          {
      return _getAnalysisObject(parent, name);
    }
static HistoHandler& getInstance ( ) [inline, static]

Singleton getter function.

Definition at line 50 of file HistoHandler.hh.

                                       {
      static HistoHandler _instance;
      return _instance;
    }
Log & getLog ( ) const [private]

Get a logger.

Definition at line 12 of file HistoHandler.cc.

Referenced by HistoHandler::_getAnalysisObject(), and HistoHandler::registerAnalysisObject().

                                  {
    return Log::getLog("Rivet.HistoHandler");
  }
HistoHandler& operator= ( const HistoHandler ) [private]

The assignment operator is hidden.

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.

                                                                                 {
    getLog() << Log::TRACE << "Trying to register"
             << " analysis object " << &ao
             << " for parent " << &parent << "(" << parent.name() << ")"
             << " with name '" << name << "'" << endl;

    // If this name is already registered for this analysis, throw a complaint
    NamedHistosMap::const_iterator nhs = _namedhistos.find(&parent);
    if (nhs != _namedhistos.end()) {
      NamedHistos::const_iterator nh = nhs->second.find(name);
      if (nh != nhs->second.end()) {
        stringstream ss;
        ss << "Histogram \"" << name
           << "\" already exists for parent analysis " << &parent;
        throw Error(ss.str());
      }
    }

    _namedhistos[&parent][name] = &ao;
    //return *(_namedhistos[&parent][name]);
    return const_cast<AnalysisObject*>(_namedhistos[&parent][name]);
  }

Member Data Documentation

Core data member, associating a given Analysis to its histos.

Definition at line 117 of file HistoHandler.hh.

Referenced by HistoHandler::_getAnalysisObject(), HistoHandler::clear(), and HistoHandler::registerAnalysisObject().


The documentation for this class was generated from the following files: