rivet is hosted by Hepforge, IPPP Durham
BinnedHistogram< T > Class Template Reference

#include <BinnedHistogram.hh>

Inheritance diagram for BinnedHistogram< T >:
Collaboration diagram for BinnedHistogram< T >:

List of all members.

Public Member Functions

 BinnedHistogram ()
 Create a new empty BinnedHistogram.
const BinnedHistogram< T > & addHistogram (const T &binMin, const T &binMax, Histo1DPtr histo)
Histo1DPtr fill (const T &bin, const T &val, double weight)
void scale (const T &scale, Analysis *ana)
const vector< Histo1DPtr > & getHistograms () const
vector< Histo1DPtr > & getHistograms ()

Private Attributes

map< T, Histo1DPtr_histosByUpperBound
map< T, Histo1DPtr_histosByLowerBound
vector< Histo1DPtr_histos
map< Histo1DPtr, T > _binWidths

Detailed Description

template<typename T>
class Rivet::BinnedHistogram< T >

BinnedHistogram contains a series of histograms of the same quantity each in a different region of a second quantity. For example, a BinnedHistogram may contain histograms of the cross section differential in $ p_T $ in different $ \eta $ regions.

Definition at line 19 of file BinnedHistogram.hh.


Constructor & Destructor Documentation

BinnedHistogram ( ) [inline]

Create a new empty BinnedHistogram.

Definition at line 23 of file BinnedHistogram.hh.

                      {
      return;
    }

Member Function Documentation

const BinnedHistogram< T > & addHistogram ( const T &  binMin,
const T &  binMax,
Histo1DPtr  histo 
)

Add a histogram in the region between binMin and binMax to this set of BinnedHistograms.

Definition at line 11 of file BinnedHistogram.cc.

Referenced by CMS_2011_S8950903::init(), CMS_2011_S8968497::init(), CDF_2007_S7057202::init(), CMS_2011_S9086218::init(), ATLAS_2011_I930220::init(), LHCF_2012_I1115479::init(), D0_2010_S8570965::init(), ATLAS_2012_I1204784::init(), D0_2010_S8821313::init(), D0_1996_S3324664::init(), ATLAS_2010_S8817804::init(), LHCB_2011_I919315::init(), CDF_2008_S7828950::init(), LHCB_2013_I1218996::init(), D0_2009_S8320160::init(), ATLAS_2011_S8971293::init(), ATLAS_2012_I1082936::init(), D0_2010_S8566488::init(), CDF_2001_S4517016::init(), CDF_1996_S3418421::init(), ATLAS_2012_I1094564::init(), ATLAS_2012_I1125575::initializeHistograms(), and ATLAS_2011_S9126244::initializePlots().

                                                                              {
    if (binMin > binMax) {
      throw Error
        ("Cannot add a binned histogram where the lower bin edge is above the upper edge");
    }
    _histosByUpperBound[binMax] = histo;
    _histosByLowerBound[binMin] = histo;
    bool found = false;
    foreach (Histo1DPtr hist, _histos) {
      if (hist == histo) {
        found = true;
        break;
      }
    }

    if (!found){
      _histos.push_back(histo);
      _binWidths[histo]=binMax-binMin;
    }

    return *this;
  }
Histo1DPtr fill ( const T &  bin,
const T &  val,
double  weight 
)

Fill the histogram that lies in the same region as bin with the value val of weight weight.

Definition at line 39 of file BinnedHistogram.cc.

Referenced by CMS_2011_S8950903::analyze(), LHCF_2012_I1115479::analyze(), CMS_2011_S8968497::analyze(), CMS_2011_S9086218::analyze(), CDF_2007_S7057202::analyze(), D0_1996_S3324664::analyze(), CDF_2008_S7828950::analyze(), CDF_2001_S4517016::analyze(), ATLAS_2011_I930220::analyze(), D0_2010_S8570965::analyze(), LHCB_2011_I919315::analyze(), D0_2010_S8566488::analyze(), CDF_1996_S3418421::analyze(), ATLAS_2011_S8971293::analyze(), D0_2010_S8821313::analyze(), D0_2009_S8320160::analyze(), ATLAS_2010_S8817804::analyze(), LHCB_2013_I1218996::analyze(), ATLAS_2012_I1082936::analyze(), ATLAS_2012_I1094564::analyze(), ATLAS_2011_S9126244::analyzeJets(), ATLAS_2012_I1125575::fillHistograms(), and ATLAS_2012_I1204784::fillPlots().

                                                                    {

    typename map<T, Histo1DPtr>::iterator histIt =
      _histosByUpperBound.upper_bound(bin);
    //check that the bin is not out of range
    if (histIt == _histosByUpperBound.end()) {
      return Histo1DPtr();
    }

    Histo1DPtr histo = histIt->second;
    histIt = _histosByLowerBound.lower_bound(bin);

    // No need to check going beyond the upper bound if we already passed above
    // (given that upper bound > lower bound is checked)
    // Check it is not before the start of the map
    if (histIt == _histosByLowerBound.begin()) {
      return Histo1DPtr();
    }
    // By-lower-bound actually gives us the iterator one above the nearest element,
    // so decrement it. This is safe because we already checked we're not at the start!
    --histIt;

    if (histo != histIt->second) {
      return Histo1DPtr();
    }

    histo->fill(val, weight);

    return histo;
  }
vector<Histo1DPtr>& getHistograms ( ) [inline]

Definition at line 44 of file BinnedHistogram.hh.

{ return _histos; }

Member Data Documentation

map<Histo1DPtr, T> _binWidths [private]

Definition at line 52 of file BinnedHistogram.hh.

vector<Histo1DPtr> _histos [private]

Definition at line 51 of file BinnedHistogram.hh.

Referenced by BinnedHistogram< double >::getHistograms().

map<T, Histo1DPtr> _histosByLowerBound [private]

Definition at line 50 of file BinnedHistogram.hh.

map<T, Histo1DPtr> _histosByUpperBound [private]

Definition at line 49 of file BinnedHistogram.hh.


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