/[PAMELA software]/PamCut/CollectionActions/LiveTimeAction/LiveTimeAction.h
ViewVC logotype

Annotation of /PamCut/CollectionActions/LiveTimeAction/LiveTimeAction.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (hide annotations) (download)
Thu Mar 11 19:10:46 2010 UTC (14 years, 11 months ago) by pam-fi
Branch: MAIN
CVS Tags: HEAD
Changes since 1.4: +0 -0 lines
File MIME type: text/plain
FILE REMOVED
Replaced by a Histo1D-inherited version.

1 pam-fi 1.1 /*
2     * LiveTimeAction.h
3     *
4     * Created on: 13/lug/2009
5     * Author: Nicola Mori
6     */
7    
8     /*! @file LiveTimeAction.h The LiveTimeAction class declaration file */
9    
10     #ifndef LIVETIMEACTION_H_
11     #define LIVETIMEACTION_H_
12    
13     #include "../CollectionAction/CollectionAction.h"
14 pam-fi 1.4 #include <TH1D.h>
15 pam-fi 1.1 #include <stdint.h>
16    
17     /*! @brief An action that fills a live time histogram.
18     *
19     * This action reads a rigidity binning from a file and fills a live time histogram (text and ROOT format).
20     * The live time corresponding to each event will contribute to the bin corresponding to the cutoff rigidity
21     * of the event, eg., the lowest bin whose lower limit is greater than the cutoff rigidity of the event times
22     * a coefficient (threshold coefficient, see constructor). If threshold*cutoff is lower than the
23 pam-fi 1.3 * lower limit of the rigidity axis, then the live time will be added to the "inferior bin", eg., a special bin
24 pam-fi 1.1 * ranging from 0 to the lower limit. This special bin will be saved in a separate file.
25     *
26     */
27     class LiveTimeAction: public CollectionAction {
28    
29     public:
30     /*! @brief Constructor.
31     *
32 pam-fi 1.4 * outFileBase is the base name for output file: #Finalize will add #GetName() + ".txt" for ASCII output
33     * and #GetName() + ".root" for ROOT output. #GetName + "-report.txt" will be also added for the report file (in which
34 pam-fi 1.3 * the content of the inferior bin will be saved). outFileBase has to contain the path (otherwise,
35 pam-fi 1.2 * files will be saved in the current directory).
36 pam-fi 1.1 * The file containing the rigidity bins must be a text file. It must contain both the
37     * lower and upper limits of the rigidity axis, so that if it contains N values it
38     * defines a set of N-1 bins.
39     *
40     * @param actionName The action's name.
41 pam-fi 1.2 * @param outFileBase The output file base name. If "" is given as name,
42     * no file output will be performed.
43 pam-fi 1.1 * @param rigBinsFile The file containing the rigidity bins.
44     * @param thresholdCoeff The threshold rigidity coefficient.
45     */
46     LiveTimeAction(const char *actionName, TString outFileBase, TString rigBinsFile, float thresholdCoeff);
47    
48 pam-fi 1.2 /*! @brief Constructor.
49     *
50     * outFileBase is the base name for output file: #Finalize will add .txt for ASCII output
51     * and .root for ROOT output. "-report" will be also added for the report file (in which
52 pam-fi 1.3 * the content of the inferior bin will be saved). outFileBase has to contain the path (otherwise,
53 pam-fi 1.2 * files will be saved in the current directory).
54     *
55     * @param actionName The action's name.
56     * @param outFileBase The output file base name. If "" is given as name,
57     * no file output will be performed.
58     * @param bins A vector containing the bins limits.
59     * @param thresholdCoeff The threshold rigidity coefficient.
60     */
61     LiveTimeAction(const char *actionName, TString outFileBase, vector<float> &bins, float thresholdCoeff);
62    
63 pam-fi 1.1 /*! @brief Destructor */
64     ~LiveTimeAction() {
65     }
66    
67     /*! @brief Fills histogram with the selected event.
68     *
69     * The live time of the current event will be added to the lowest bin whose lower limit is greater than
70     * the cutoff rigidity multiplied by the threshold coefficient. If threshold*cutoff is lower than the
71 pam-fi 1.3 * lower limit, the live time will be added to the "inferior bin".
72 pam-fi 1.1 *
73     * @param event The selected event.
74     */
75     void OnGood(PamLevel2 *event);
76    
77     /*! @brief Writes the histogram to the output files (ASCII and ROOT).
78     *
79     * The output consists of a text file and of a ROOT file where the 1-dimensional rigidity
80 pam-fi 1.3 * histogram (TH1F) is saved. Additionally, another text file will store the content of the "inferior bin"
81     * and the total live time for all the "normal" bins.
82 pam-fi 1.1 */
83     void Finalize();
84    
85 pam-fi 1.3 /*! @brief Returns the histogram for normal bins.
86 pam-fi 1.2 *
87     * This method returns a vector filled with the LT (in seconds) corresponding to each
88     * threshold rigidity bin (in GV) defined in the binning argument of the constructor.
89     * Element 0 is the total LT for events whose threshold rigidity lies in the
90     * lowest bin and so on.
91     *
92     * @return The LT histogram binned in threshold rigidity.
93     */
94 pam-fi 1.3 std::vector<double> &GetHisto() {
95 pam-fi 1.2 return _textHisto;
96     }
97    
98 pam-fi 1.3 /*! @brief Returns the total live time (s) spent at threshold rigidities within all "normal" bins (excluding the "inferior bin") */
99     double GetTotalLTHisto() {
100     return _totalNorm;
101 pam-fi 1.1 }
102    
103 pam-fi 1.3 /*! @brief Returns the live time (s) spent at threshold rigidities within the "inferior bin". */
104     double GetLTInfBin() {
105     return _infBin;
106     }
107    
108     /*! @brief Returns the number of events at threshold rigidities within all "normal" bins (excluding the "inferior bin") */
109     UInt_t GetNGoodHisto() {
110     return _nGoodHisto;
111     }
112    
113     /*! @brief Returns the number of events within the "inferior bin" */
114     UInt_t GetNGoodInfBin() {
115     return _nGoodInfBin;
116 pam-fi 1.1 }
117    
118     private:
119    
120     TString _outFileBase;
121     vector<float> _bins;
122 pam-fi 1.4 TH1D _rootHisto;
123 pam-fi 1.3 vector<double> _textHisto;
124 pam-fi 1.1 float _thresholdCoeff;
125    
126 pam-fi 1.3 double _totalNorm;
127     double _infBin;
128 pam-fi 1.1
129 pam-fi 1.2 void _InitHistos(vector<float> &bins);
130    
131 pam-fi 1.3 UInt_t _nGoodHisto;
132     UInt_t _nGoodInfBin;
133    
134 pam-fi 1.1 #ifdef DEBUGPAMCUT
135     int _outUp, _outDown;
136     #endif
137    
138     };
139    
140     #endif /* LIVETIMEACTION_H_ */

  ViewVC Help
Powered by ViewVC 1.1.23