--- PamCut/CollectionActions/Histo2DActions/Histo2DAction/Histo2DAction.h 2009/10/27 10:17:48 1.2 +++ PamCut/CollectionActions/Histo2DActions/Histo2DAction/Histo2DAction.h 2009/12/08 17:38:39 1.5 @@ -143,10 +143,18 @@ return _histo; } + /*! @brief Returns a pointer to the ROOT histogram. + * + * @return A pointer to the root histogram + */ + TH2 *GetRootHisto() { + return _rootHisto; + } + /*! Fills the ROOT and the vector histogram. * - * @param value The value of the X coordinate associated to the event. - * @param value The value of the Y coordinate associated to the event. + * @param xValue The value of the X coordinate associated to the event. + * @param yValue The value of the Y coordinate associated to the event. * @param weight The weight which will be applied to the event. */ void Fill(double xValue, double yValue, double weight = 1.); @@ -273,22 +281,24 @@ _rootHisto = NULL; } +// Specializations for _CreateHistos(). See Histo2DAction.cpp +template<> +void Histo2DAction::_CreateHisto(); + +template<> +void Histo2DAction::_CreateHisto(); + +template<> +void Histo2DAction::_CreateHisto(); + template void Histo2DAction::_InitHistos() { _CreateHisto(); - - if (_xBins.size() < 2) { - _xBins.resize(2); - _xBins[0] = 0.; - _xBins[1] = 1.; - } - - if (_yBins.size() < 2) { - _yBins.resize(2); - _yBins[0] = 0.; - _yBins[1] = 1.; - } + if (_xBins.size() < 2) // SetXAxis not called by the main program, or wrongly filled (only 1 bin limit) + SetXAxis("Default X", 10, 0., 1.); + if (_yBins.size() < 2) // SetYAxis not called by the main program, or wrongly filled (only 1 bin limit) + SetYAxis("Default Y", 10, 0., 1.); if (_rootHisto) { Double_t *auxXArray = new Double_t[_xBins.size()]; @@ -325,6 +335,9 @@ template Histo2DAction::~Histo2DAction() { + + delete _rootHisto; + _rootHisto = NULL; } template @@ -455,7 +468,7 @@ } template -inline void Histo2DAction::Fill(double xValue, double yValue, double weight) { +void Histo2DAction::Fill(double xValue, double yValue, double weight) { _rootHisto->Fill(xValue, yValue, weight); @@ -468,7 +481,7 @@ UOflow = true; } - if (xValue > _xBins.back()) { + if (xValue >= _xBins.back()) { xBin = _xBins.size(); UOflow = true; } @@ -478,7 +491,7 @@ UOflow = true; } - if (yValue > _yBins.back()) { + if (yValue >= _yBins.back()) { yBin = _yBins.size(); UOflow = true; }