1 |
pam-fi |
1.1 |
/* |
2 |
|
|
* TrkChi2DeflTimeCut.h |
3 |
|
|
* |
4 |
|
|
* Created on: 6-oct-2009 |
5 |
|
|
* Author: S. Ricciarini |
6 |
|
|
*/ |
7 |
|
|
|
8 |
|
|
/*! @file TrkChi2DeflTimeCut.h The TrkChi2DeflTimeCut class definition file */ |
9 |
|
|
|
10 |
|
|
#ifndef TRKCHI2DEFLTIMECUT_H_ |
11 |
|
|
#define TRKCHI2DEFLTIMECUT_H_ |
12 |
|
|
|
13 |
|
|
#include "../../PamCutBase/PamCutBase.h" |
14 |
|
|
|
15 |
|
|
#include <TH2F.h> |
16 |
|
|
#include <TTimeStamp.h> |
17 |
|
|
|
18 |
pam-fi |
1.3 |
/*! @brief The tracker chi2 vs |deflection| cut. |
19 |
pam-fi |
1.1 |
* |
20 |
pam-fi |
1.3 |
* Events whose track has been fitted with a chi2 greater than Chi2(|eta|) are discarded. |
21 |
pam-fi |
1.4 |
* Chi2(|eta|) is a function which gives the value of chi2 distribution, corresponding to a given quantile (depending on the calibration text file), as a function of |deflection| (|eta|); in current implementation it is parameterized as: |
22 |
|
|
* |
23 |
|
|
* 4 parameters p0...p3: |
24 |
pam-fi |
1.1 |
* |
25 |
pam-fi |
1.3 |
* Chi2(|eta|) = p0 + ( p1 * |eta|^p2 * (1 + (p3 * |eta|)^2) ) |
26 |
|
|
* with eta expressed in GV^-1 |
27 |
pam-fi |
1.1 |
* |
28 |
pam-fi |
1.4 |
* 5 parameters p0..p4 |
29 |
|
|
* |
30 |
|
|
* Chi2(|eta|) = p0 + ( p1 * |eta|^p2 * (1 + (p3 * |eta|)^p4) ) |
31 |
|
|
* with eta expressed in GV^-1 |
32 |
|
|
* |
33 |
|
|
* The parameters are read from a calibration text file (prepared for a given quantile, e.g. 95%), whose format must be: |
34 |
pam-fi |
1.3 |
* ... |
35 |
pam-fi |
1.4 |
* first_day last_day p0 p1 p2 ... |
36 |
pam-fi |
1.3 |
* with first_day and last_day expressed in the format YYMMDD |
37 |
|
|
* ... |
38 |
|
|
* where each row corresponds to a given time interval (first_day,last_day) |
39 |
pam-fi |
1.5 |
* The calibration text file can vary with nHitX of the event: in the current implementation, a text file must be specified for events with nHitX=3 and for events with nHitX>=4. |
40 |
pam-fi |
1.3 |
* For a given event the associated day is determined; the FIRST (starting from first row) time interval of the calibration file, which contains the event day, gives the parameters to be inserted in the Chi2(|eta|) for the given event. |
41 |
|
|
* If the event day does not fall in any of the intervals of the calibration file, then the event is discarded. |
42 |
pam-fi |
1.1 |
* |
43 |
|
|
*/ |
44 |
|
|
|
45 |
|
|
class TrkChi2DeflTimeCut: public PamCut { |
46 |
|
|
|
47 |
|
|
public: |
48 |
|
|
/*! @brief Constructor. |
49 |
|
|
* |
50 |
|
|
* @param cutName The cut's name. |
51 |
pam-fi |
1.5 |
* @param calibFile_nHitX3 Path for the calibration text file, used for events with nHitX=3. |
52 |
|
|
* @param calibFile_nHitX4 Path for the calibration text file, used for events with nHitX>=4. |
53 |
|
|
* @param nPar Number of parameters used for the Chi2 function. Maximum allowed: 5. Default: 5. |
54 |
pam-fi |
1.1 |
*/ |
55 |
pam-fi |
1.6 |
TrkChi2DeflTimeCut(const char *cutName, const char *trkAlg, const char *calibFile_nHitX3, const char *calibFile_nHitX4, int nPar=5) : |
56 |
|
|
PamCut(cutName), _trkAlg(trkAlg), _calibFile_nHitX3(calibFile_nHitX3), _calibFile_nHitX4(calibFile_nHitX4), _nPar(nPar) { |
57 |
pam-fi |
1.1 |
|
58 |
pam-fi |
1.5 |
_chi2CutTable_nHitX3.open(_calibFile_nHitX3); |
59 |
|
|
while (! _chi2CutTable_nHitX3.eof()) { |
60 |
|
|
|
61 |
|
|
_chi2CutTable_nHitX3 >> _tstringtemp; |
62 |
|
|
_iDayFirst_nHitX3.push_back(_tstringtemp.Atoi()); |
63 |
|
|
|
64 |
|
|
_chi2CutTable_nHitX3 >> _tstringtemp; |
65 |
|
|
_iDayLast_nHitX3.push_back(_tstringtemp.Atoi()); |
66 |
|
|
|
67 |
|
|
if (_nPar>=0 && _nPar<=5) { |
68 |
|
|
for (int iPar=0; iPar<_nPar; iPar++) { |
69 |
|
|
|
70 |
|
|
_chi2CutTable_nHitX3 >> _tstringtemp; |
71 |
|
|
_p_nHitX3[iPar].push_back(_tstringtemp.Atof()); |
72 |
|
|
|
73 |
|
|
} |
74 |
|
|
} |
75 |
|
|
|
76 |
|
|
} |
77 |
|
|
_chi2CutTable_nHitX3.close(); |
78 |
|
|
|
79 |
|
|
_chi2CutTable_nHitX4.open(_calibFile_nHitX4); |
80 |
|
|
while (! _chi2CutTable_nHitX4.eof()) { |
81 |
pam-fi |
1.1 |
|
82 |
pam-fi |
1.5 |
_chi2CutTable_nHitX4 >> _tstringtemp; |
83 |
|
|
_iDayFirst_nHitX4.push_back(_tstringtemp.Atoi()); |
84 |
pam-fi |
1.3 |
|
85 |
pam-fi |
1.5 |
_chi2CutTable_nHitX4 >> _tstringtemp; |
86 |
|
|
_iDayLast_nHitX4.push_back(_tstringtemp.Atoi()); |
87 |
pam-fi |
1.1 |
|
88 |
pam-fi |
1.4 |
if (_nPar>=0 && _nPar<=5) { |
89 |
|
|
for (int iPar=0; iPar<_nPar; iPar++) { |
90 |
pam-fi |
1.1 |
|
91 |
pam-fi |
1.5 |
_chi2CutTable_nHitX4 >> _tstringtemp; |
92 |
|
|
_p_nHitX4[iPar].push_back(_tstringtemp.Atof()); |
93 |
pam-fi |
1.4 |
|
94 |
|
|
} |
95 |
|
|
} |
96 |
|
|
|
97 |
pam-fi |
1.1 |
} |
98 |
pam-fi |
1.5 |
_chi2CutTable_nHitX4.close(); |
99 |
|
|
|
100 |
pam-fi |
1.1 |
|
101 |
|
|
} |
102 |
|
|
|
103 |
|
|
/*! @brief Destructor. */ |
104 |
|
|
~TrkChi2DeflTimeCut() { |
105 |
|
|
|
106 |
|
|
} |
107 |
|
|
|
108 |
pam-fi |
1.3 |
/*! @brief The tracker chi2 vs |deflection| check. |
109 |
pam-fi |
1.1 |
* |
110 |
|
|
* |
111 |
|
|
* @param event The event to analyze. |
112 |
pam-fi |
1.3 |
* @return #CUTOK if chi2 < Chi2(|eta|). |
113 |
pam-fi |
1.1 |
* @return 0 if not |
114 |
|
|
*/ |
115 |
|
|
int Check(PamLevel2 *event); |
116 |
|
|
|
117 |
pam-fi |
1.6 |
protected: |
118 |
|
|
|
119 |
|
|
const char *_trkAlg; |
120 |
|
|
|
121 |
|
|
|
122 |
|
|
private: |
123 |
pam-fi |
1.1 |
|
124 |
pam-fi |
1.2 |
virtual double _GetChi2(PamLevel2 *event); |
125 |
|
|
|
126 |
pam-fi |
1.5 |
const char* _calibFile_nHitX3; |
127 |
|
|
const char* _calibFile_nHitX4; |
128 |
|
|
Int_t _nPar; |
129 |
pam-fi |
1.1 |
|
130 |
|
|
TString _tstringtemp; |
131 |
|
|
|
132 |
pam-fi |
1.5 |
std::vector<Int_t> _iDayFirst_nHitX3; |
133 |
|
|
std::vector<Int_t> _iDayFirst_nHitX4; |
134 |
pam-fi |
1.3 |
std::vector<Int_t> _iDayFirst; |
135 |
pam-fi |
1.5 |
|
136 |
|
|
std::vector<Int_t> _iDayLast_nHitX3; |
137 |
|
|
std::vector<Int_t> _iDayLast_nHitX4; |
138 |
pam-fi |
1.3 |
std::vector<Int_t> _iDayLast; |
139 |
pam-fi |
1.5 |
|
140 |
|
|
std::vector<Double_t> _p_nHitX3[5]; |
141 |
|
|
std::vector<Double_t> _p_nHitX4[5]; |
142 |
pam-fi |
1.4 |
std::vector<Double_t> _p[5]; |
143 |
pam-fi |
1.5 |
|
144 |
|
|
ifstream _chi2CutTable_nHitX3; |
145 |
|
|
ifstream _chi2CutTable_nHitX4; |
146 |
pam-fi |
1.1 |
|
147 |
pam-fi |
1.4 |
Double_t _pSel[5]; |
148 |
pam-fi |
1.1 |
|
149 |
|
|
TTimeStamp _time; |
150 |
|
|
|
151 |
|
|
}; |
152 |
|
|
#endif /* TRKCHI2DEFLTIMECUT_H_ */ |