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 |
|
|
* and .root for ROOT output. outFileBase has to contain the path (otherwise, files will be |
34 |
|
|
* saved in the current directory). |
35 |
|
|
* The file containing the rigidity bins must be a text file. It must contain both the |
36 |
|
|
* lower and upper limits of the rigidity axis, so that if it contains N values it |
37 |
|
|
* defines a set of N-1 bins. |
38 |
|
|
* |
39 |
|
|
* @param actionName The action's name. |
40 |
|
|
* @param outFileBase The output file base name. |
41 |
|
|
* @param rigBinsFile The file containing the rigidity bins. |
42 |
|
|
* @param thresholdCoeff The threshold rigidity coefficient. |
43 |
|
|
*/ |
44 |
|
|
LiveTimeAction(const char *actionName, TString outFileBase, TString rigBinsFile, float thresholdCoeff); |
45 |
|
|
|
46 |
|
|
/*! @brief Destructor */ |
47 |
|
|
~LiveTimeAction() { |
48 |
|
|
} |
49 |
|
|
|
50 |
|
|
/*! @brief Fills histogram with the selected event. |
51 |
|
|
* |
52 |
|
|
* The live time of the current event will be added to the lowest bin whose lower limit is greater than |
53 |
|
|
* the cutoff rigidity multiplied by the threshold coefficient. If threshold*cutoff is lower than the |
54 |
|
|
* lower limit, the live time will be added to the "zero bin". |
55 |
|
|
* |
56 |
|
|
* @param event The selected event. |
57 |
|
|
*/ |
58 |
|
|
void OnGood(PamLevel2 *event); |
59 |
|
|
|
60 |
|
|
/*! @brief Writes the histogram to the output files (ASCII and ROOT). |
61 |
|
|
* |
62 |
|
|
* The output consists of a text file and of a ROOT file where the 1-dimensional rigidity |
63 |
|
|
* histogram (TH1F) is saved. Additionally, another text file will store the content of the "zero bin" |
64 |
|
|
* and the total live time. |
65 |
|
|
*/ |
66 |
|
|
void Finalize(); |
67 |
|
|
|
68 |
|
|
/*! @brief Returns the live time spent at rigidities below the lower limit (the "zero bin"). */ |
69 |
|
|
float GetZeroBin() { |
70 |
|
|
return _zeroBin; |
71 |
|
|
} |
72 |
|
|
|
73 |
|
|
/*! @brief Returns the total live time. */ |
74 |
|
|
float GetTotalLT() { |
75 |
|
|
return _total; |
76 |
|
|
} |
77 |
|
|
|
78 |
|
|
private: |
79 |
|
|
|
80 |
|
|
TString _outFileBase; |
81 |
|
|
vector<float> _bins; |
82 |
|
|
TH1F _rootHisto; |
83 |
|
|
vector<float> _textHisto; |
84 |
|
|
float _thresholdCoeff; |
85 |
|
|
|
86 |
|
|
float _total; |
87 |
|
|
float _zeroBin; |
88 |
|
|
|
89 |
|
|
#ifdef DEBUGPAMCUT |
90 |
|
|
int _outUp, _outDown; |
91 |
|
|
#endif |
92 |
|
|
|
93 |
|
|
}; |
94 |
|
|
|
95 |
|
|
#endif /* LIVETIMEACTION_H_ */ |