#include <BinnedHistogram.hh>
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 |
BinnedHistogram | ( | ) | [inline] |
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] |
Definition at line 42 of file BinnedHistogram.hh.
Referenced by D0_2009_S8320160::finalize(), D0_1996_S3324664::finalize(), CDF_1996_S3418421::finalize(), and BinnedHistogram::scale().
00042 { return _histos; }
vector<AIDA::IHistogram1D*>& getHistograms | ( | ) | [inline] |
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] |
Definition at line 50 of file BinnedHistogram.hh.
Referenced by BinnedHistogram::addHistogram(), and BinnedHistogram< double >::getHistograms().
map<AIDA::IHistogram1D*, T> _binWidths [private] |
Definition at line 51 of file BinnedHistogram.hh.
Referenced by BinnedHistogram::addHistogram(), and BinnedHistogram::scale().