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 <TH1D.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 "inferior 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 #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 |
* the content of the inferior bin will be saved). outFileBase has to contain the path (otherwise, |
35 |
* files will be saved in the current directory). |
36 |
* 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 |
* @param outFileBase The output file base name. If "" is given as name, |
42 |
* no file output will be performed. |
43 |
* @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 |
/*! @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 inferior bin 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 |
/*! @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 "inferior 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 "inferior bin" |
81 |
* and the total live time for all the "normal" bins. |
82 |
*/ |
83 |
void Finalize(); |
84 |
|
85 |
/*! @brief Returns the histogram for normal bins. |
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<double> &GetHisto() { |
95 |
return _textHisto; |
96 |
} |
97 |
|
98 |
/*! @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 |
} |
102 |
|
103 |
/*! @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 |
} |
117 |
|
118 |
private: |
119 |
|
120 |
TString _outFileBase; |
121 |
vector<float> _bins; |
122 |
TH1D _rootHisto; |
123 |
vector<double> _textHisto; |
124 |
float _thresholdCoeff; |
125 |
|
126 |
double _totalNorm; |
127 |
double _infBin; |
128 |
|
129 |
void _InitHistos(vector<float> &bins); |
130 |
|
131 |
UInt_t _nGoodHisto; |
132 |
UInt_t _nGoodInfBin; |
133 |
|
134 |
#ifdef DEBUGPAMCUT |
135 |
int _outUp, _outDown; |
136 |
#endif |
137 |
|
138 |
}; |
139 |
|
140 |
#endif /* LIVETIMEACTION_H_ */ |