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 18 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)
void scale (const T &scale, Analysis *ana)
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
map< AIDA::IHistogram1D *, T > _binWidths

Constructor & Destructor Documentation

BinnedHistogram (  )  [inline]

Create a new empty BinnedHistogram.

Definition at line 22 of file BinnedHistogram.hh.

00022                       {
00023       return;
00024     }


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 11 of file BinnedHistogram.cc.

References BinnedHistogram::_binWidths, 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().

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

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

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

void scale ( const T &  scale,
Analysis ana 
) [inline]

Scale histograms taking into account its "external" binwidth, i.e. by scale/binWidth

Definition at line 74 of file BinnedHistogram.cc.

References BinnedHistogram::_binWidths, BinnedHistogram::getHistograms(), and Analysis::scale().

Referenced by D0_2010_S8570965::finalize(), D0_2010_S8566488::finalize(), CDF_2008_S7828950::finalize(), CDF_2007_S7057202::finalize(), and CDF_2001_S4517016::finalize().

00074                                                               {
00075     foreach (AIDA::IHistogram1D* hist, getHistograms()) {
00076       ana->scale(hist, scale/_binWidths[hist]);
00077     }
00078   }

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

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

Definition at line 43 of file BinnedHistogram.hh.

00043 { return _histos; }


Member Data Documentation

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

Definition at line 48 of file BinnedHistogram.hh.

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

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

Definition at line 49 of file BinnedHistogram.hh.

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

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

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

Definition at line 51 of file BinnedHistogram.hh.

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


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