/* * LiveTimeAction.h * * Created on: 13/lug/2009 * Author: Nicola Mori */ /*! @file LiveTimeAction.h The LiveTimeAction class declaration file */ #ifndef LIVETIMEACTION_H_ #define LIVETIMEACTION_H_ #include "../CollectionAction/CollectionAction.h" #include #include /*! @brief An action that fills a live time histogram. * * This action reads a rigidity binning from a file and fills a live time histogram (text and ROOT format). * The live time corresponding to each event will contribute to the bin corresponding to the cutoff rigidity * of the event, eg., the lowest bin whose lower limit is greater than the cutoff rigidity of the event times * a coefficient (threshold coefficient, see constructor). If threshold*cutoff is lower than the * lower limit of the rigidity axis, then the live time will be added to the "zero bin", eg., a special bin * ranging from 0 to the lower limit. This special bin will be saved in a separate file. * */ class LiveTimeAction: public CollectionAction { public: /*! @brief Constructor. * * outFileBase is the base name for output file: #Finalize will add .txt for ASCII output * and .root for ROOT output. outFileBase has to contain the path (otherwise, files will be * saved in the current directory). * The file containing the rigidity bins must be a text file. It must contain both the * lower and upper limits of the rigidity axis, so that if it contains N values it * defines a set of N-1 bins. * * @param actionName The action's name. * @param outFileBase The output file base name. * @param rigBinsFile The file containing the rigidity bins. * @param thresholdCoeff The threshold rigidity coefficient. */ LiveTimeAction(const char *actionName, TString outFileBase, TString rigBinsFile, float thresholdCoeff); /*! @brief Destructor */ ~LiveTimeAction() { } /*! @brief Fills histogram with the selected event. * * The live time of the current event will be added to the lowest bin whose lower limit is greater than * the cutoff rigidity multiplied by the threshold coefficient. If threshold*cutoff is lower than the * lower limit, the live time will be added to the "zero bin". * * @param event The selected event. */ void OnGood(PamLevel2 *event); /*! @brief Writes the histogram to the output files (ASCII and ROOT). * * The output consists of a text file and of a ROOT file where the 1-dimensional rigidity * histogram (TH1F) is saved. Additionally, another text file will store the content of the "zero bin" * and the total live time. */ void Finalize(); /*! @brief Returns the live time spent at rigidities below the lower limit (the "zero bin"). */ float GetZeroBin() { return _zeroBin; } /*! @brief Returns the total live time. */ float GetTotalLT() { return _total; } private: TString _outFileBase; vector _bins; TH1F _rootHisto; vector _textHisto; float _thresholdCoeff; float _total; float _zeroBin; #ifdef DEBUGPAMCUT int _outUp, _outDown; #endif }; #endif /* LIVETIMEACTION_H_ */