--- PamCut/CollectionActions/Histo1DActions/Histo1DAction/Histo1DAction.h 2009/09/25 15:36:36 1.1 +++ PamCut/CollectionActions/Histo1DActions/Histo1DAction/Histo1DAction.h 2010/03/11 19:14:03 1.5 @@ -85,7 +85,7 @@ /*! @brief Sets up the histogram * - * This routine effectively prepares the histogram, after the desired parameters has been set by #SetXAxis() and #SetYAxis(). + * This routine effectively prepares the histogram, after the desired parameters has been set by #SetXAxis(). * * @param events Pointer to PamLevel2 events (unused). */ @@ -108,7 +108,11 @@ return _histo; } - /*! Fills the ROOT and the vector histogram. */ + /*! Fills the ROOT and the vector histogram. + * + * @param value The value of the X coordinate associated to the event. + * @param weight The weight which will be applied to the event. + */ void Fill(double value, double weight = 1.); /*! @brief The number of events which fell below the lower histogram limit. */ @@ -123,20 +127,22 @@ protected: + /*! @brief The vector containing the limits of the bins(from lower to higher). */ std::vector _bins; + /*! @brief A vector containing the value of the histogram for each bin. */ vector _histo; + /*! @brief The ROOT histogram. */ TH1 *_rootHisto; -private: - - unsigned int _underflow, _overflow; - TString _outFileBase; TString _mode; TString _title, _xLabel; + +private: + + HistoType _underflow, _overflow; bool _outRoot; bool _outText; - void _CreateHisto(); void _InitHistos(); }; @@ -147,11 +153,22 @@ // No ROOT histogram for generic type; see template specializations in .cpp file. _rootHisto = NULL; } +// Specializations for _CreateHistos(). See Histo1DAction.cpp +template<> +void Histo1DAction::_CreateHisto(); + +template<> +void Histo1DAction::_CreateHisto(); + +template<> +void Histo1DAction::_CreateHisto(); template void Histo1DAction::_InitHistos() { _CreateHisto(); + if (_bins.size() < 2) // SetXAxis not called by the main program, or wrongly filled (only 1 bin limit) + SetXAxis("Default X", 10, 0., 1.); if (_rootHisto) { Double_t *auxArray = new Double_t[_bins.size()]; @@ -176,13 +193,17 @@ template Histo1DAction::~Histo1DAction() { + + delete _rootHisto; + _rootHisto = NULL; + } template Histo1DAction::Histo1DAction(const char *actionName, TString title, TString outFileBase, TString mode, bool outRoot, bool outText) : CollectionAction(actionName), _bins(0), _histo(0), _rootHisto(NULL), _outFileBase(outFileBase), _mode(mode), _title( - title), _xLabel(""), _outRoot(outRoot), _outText(outText) { + title), _xLabel(""), _underflow(0), _overflow(0), _outRoot(outRoot), _outText(outText) { }