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 |
|
|
#include <TH1F.h> |
15 |
|
|
#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 |
|
|
* lower limit of the rigidity axis, then the live time will be added to the "zero bin", eg., a special bin |
24 |
|
|
* 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 |
|
|
* outFileBase is the base name for output file: #Finalize will add .txt for ASCII output |
33 |
pam-fi |
1.2 |
* and .root for ROOT output. "-report" will be also added for the report file (in which |
34 |
|
|
* the content of the zero bin will be saved). outFileBase has to contain the path (otherwise, |
35 |
|
|
* 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 |
|
|
* the content of the zero bins will be saved). outFileBase has to contain the path (otherwise, |
53 |
|
|
* 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 |
|
|
* lower limit, the live time will be added to the "zero bin". |
72 |
|
|
* |
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 |
|
|
* histogram (TH1F) is saved. Additionally, another text file will store the content of the "zero bin" |
81 |
|
|
* and the total live time. |
82 |
|
|
*/ |
83 |
|
|
void Finalize(); |
84 |
|
|
|
85 |
pam-fi |
1.2 |
/*! @brief Returns the histogram. |
86 |
|
|
* |
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 |
|
|
std::vector<float> &GetHisto() { |
95 |
|
|
return _textHisto; |
96 |
|
|
} |
97 |
|
|
|
98 |
pam-fi |
1.1 |
/*! @brief Returns the live time spent at rigidities below the lower limit (the "zero bin"). */ |
99 |
|
|
float GetZeroBin() { |
100 |
|
|
return _zeroBin; |
101 |
|
|
} |
102 |
|
|
|
103 |
|
|
/*! @brief Returns the total live time. */ |
104 |
|
|
float GetTotalLT() { |
105 |
|
|
return _total; |
106 |
|
|
} |
107 |
|
|
|
108 |
|
|
private: |
109 |
|
|
|
110 |
|
|
TString _outFileBase; |
111 |
|
|
vector<float> _bins; |
112 |
|
|
TH1F _rootHisto; |
113 |
|
|
vector<float> _textHisto; |
114 |
|
|
float _thresholdCoeff; |
115 |
|
|
|
116 |
|
|
float _total; |
117 |
|
|
float _zeroBin; |
118 |
|
|
|
119 |
pam-fi |
1.2 |
void _InitHistos(vector<float> &bins); |
120 |
|
|
|
121 |
pam-fi |
1.1 |
#ifdef DEBUGPAMCUT |
122 |
|
|
int _outUp, _outDown; |
123 |
|
|
#endif |
124 |
|
|
|
125 |
|
|
}; |
126 |
|
|
|
127 |
|
|
#endif /* LIVETIMEACTION_H_ */ |