BinnedHistogram Class Template Reference

#include <BinnedHistogram.hh>

Inheritance diagram for BinnedHistogram:

Inheritance graph
[legend]

Collaboration diagram for BinnedHistogram:

Collaboration graph
[legend]

List of all members.


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 PT in different eta regions.

Definition at line 16 of file BinnedHistogram.hh.


Public Member Functions

 BinnedHistogram ()
 Create a new empty BinnedHistogram.
const BinnedHistogram< T > & addHistogram (const T &binMin, const T &binMax, AIDA::IHistogram1D *histo)
AIDA::IHistogram1D * fill (const T &bin, const T &val, double weight)
const vector
< AIDA::IHistogram1D * > & 
getHistograms () const
vector< AIDA::IHistogram1D * > & getHistograms ()

Private Attributes

map< T, AIDA::IHistogram1D * > _histosByUpperBound
map< T, AIDA::IHistogram1D * > _histosByLowerBound
vector< AIDA::IHistogram1D * > _histos

Constructor & Destructor Documentation

BinnedHistogram (  )  [inline]

Create a new empty BinnedHistogram.

Definition at line 20 of file BinnedHistogram.hh.

00020                       {
00021       return;
00022     }


Member Function Documentation

const BinnedHistogram< T > & addHistogram ( const T &  binMin,
const T &  binMax,
AIDA::IHistogram1D *  histo 
) [inline]

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

Definition at line 10 of file BinnedHistogram.cc.

References BinnedHistogram::_histos, BinnedHistogram::_histosByLowerBound, and BinnedHistogram::_histosByUpperBound.

Referenced by D0_2010_S8570965::init(), D0_2010_S8566488::init(), D0_2009_S8320160::init(), D0_1996_S3324664::init(), CDF_2008_S7828950::init(), CDF_2007_S7057202::init(), CDF_2001_S4517016::init(), and CDF_1996_S3418421::init().

00012                                                                                      {
00013     if (binMin > binMax) {
00014       throw Error
00015         ("Cannot add a binned histogram where the lower bin edge is above the upper edge");
00016     } 
00017     _histosByUpperBound[binMax] = histo;
00018     _histosByLowerBound[binMin] = histo;
00019     bool found = false;
00020     foreach (AIDA::IHistogram1D* hist, _histos) {
00021       if (hist == histo) {
00022         found = true;
00023         break;
00024       }
00025     }
00026     
00027     if (!found){
00028       _histos.push_back(histo);
00029     }
00030     
00031     return *this;
00032   }

AIDA::IHistogram1D * fill ( const T &  bin,
const T &  val,
double  weight 
) [inline]

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

Definition at line 37 of file BinnedHistogram.cc.

References BinnedHistogram::_histosByLowerBound, and BinnedHistogram::_histosByUpperBound.

Referenced by D0_2010_S8570965::analyze(), D0_2010_S8566488::analyze(), D0_2009_S8320160::analyze(), D0_1996_S3324664::analyze(), CDF_2008_S7828950::analyze(), CDF_2007_S7057202::analyze(), CDF_2001_S4517016::analyze(), and CDF_1996_S3418421::analyze().

00039                                                                     {
00040 
00041     typename map<T, AIDA::IHistogram1D*>::iterator histIt =
00042       _histosByUpperBound.upper_bound(bin);
00043     //check that the bin is not out of range
00044     if (histIt == _histosByUpperBound.end()) {
00045       return 0;
00046     }
00047  
00048     AIDA::IHistogram1D* histo = histIt->second;
00049     histIt = _histosByLowerBound.lower_bound(bin);
00050 
00051     // No need to check going beyond the upper bound if we already passed above
00052     // (given that upper bound > lower bound is checked)
00053     // Check it is not before the start of the map
00054     if (histIt == _histosByLowerBound.begin()) {
00055       return 0;
00056     }
00057     // By-lower-bound actually gives us the iterator one above the nearest element,
00058     // so decrement it. This is safe because we already checked we're not at the start!
00059     --histIt;
00060  
00061     if (histo != histIt->second) {
00062       return 0;
00063     }
00064     
00065     histo->fill(val, weight);
00066     
00067     return histo;
00068   }

const vector<AIDA::IHistogram1D*>& getHistograms (  )  const [inline]

vector<AIDA::IHistogram1D*>& getHistograms (  )  [inline]

Definition at line 37 of file BinnedHistogram.hh.

00037 { return _histos; }


Member Data Documentation

map<T, AIDA::IHistogram1D*> _histosByUpperBound [private]

Definition at line 42 of file BinnedHistogram.hh.

Referenced by BinnedHistogram::addHistogram(), and BinnedHistogram::fill().

map<T, AIDA::IHistogram1D*> _histosByLowerBound [private]

Definition at line 43 of file BinnedHistogram.hh.

Referenced by BinnedHistogram::addHistogram(), and BinnedHistogram::fill().

vector<AIDA::IHistogram1D*> _histos [private]


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