15 |
#include <TH2F.h> |
#include <TH2F.h> |
16 |
#include <TTimeStamp.h> |
#include <TTimeStamp.h> |
17 |
|
|
18 |
/*! @brief The tracker chi2 vs deflection cut. |
/*! @brief The tracker chi2 vs |deflection| cut. |
19 |
* |
* |
20 |
* Events whose track has been fitted with a chi2 greater than Chi2(eta) are discarded. |
* Events whose track has been fitted with a chi2 greater than Chi2(|eta|) are discarded. |
21 |
* Chi2(eta) is a function which gives the maximum value of chi2 associated to a certain |
* 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: |
|
* deflection eta; in current implementation it is parameterized as: |
|
22 |
* |
* |
23 |
* Chi2(eta) = p0 + p1 * eta^2 + p2 * eta ^4 |
* 4 parameters p0...p3: |
24 |
* |
* |
25 |
* where p0, p1 and p2 are parameters. These are read from a file, and are supposed to be |
* Chi2(|eta|) = p0 + ( p1 * |eta|^p2 * (1 + (p3 * |eta|)^2) ) |
26 |
* computed month by month. |
* with eta expressed in GV^-1 |
27 |
|
* |
28 |
|
* 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 |
|
* ... |
35 |
|
* first_day last_day p0 p1 p2 ... |
36 |
|
* 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 |
|
* |
40 |
|
* 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 |
* |
* |
43 |
*/ |
*/ |
44 |
|
|
48 |
/*! @brief Constructor. |
/*! @brief Constructor. |
49 |
* |
* |
50 |
* @param cutName The cut's name. |
* @param cutName The cut's name. |
51 |
* @param calibFile Path for the calibration file. The format of the file's rows is: |
* @param calibFile Path for the calibration text file. |
52 |
* YYMM efficiency p0 p1 p2 |
* @param nPar Number of parameters used for the Chi2 function. Maximum allowed: 5. Default: 4. |
53 |
*/ |
*/ |
54 |
TrkChi2DeflTimeCut(const char *cutName, const char *calibFile) : |
TrkChi2DeflTimeCut(const char *cutName, const char *calibFile, int nPar=4) : |
55 |
PamCut(cutName), _calibFile(calibFile) { |
PamCut(cutName), _calibFile(calibFile), _nPar(nPar) { |
56 |
|
|
57 |
_chi2CutTable.open(_calibFile); |
_chi2CutTable.open(_calibFile); |
58 |
while (! _chi2CutTable.eof()) { |
while (! _chi2CutTable.eof()) { |
59 |
|
|
60 |
_chi2CutTable >> _tstringtemp; |
_chi2CutTable >> _tstringtemp; |
61 |
_iMonth.push_back(_tstringtemp.Atoi()); |
_iDayFirst.push_back(_tstringtemp.Atoi()); |
|
|
|
|
_chi2CutTable >> _tstringtemp; |
|
|
|
|
|
_chi2CutTable >> _tstringtemp; |
|
|
_p0.push_back(_tstringtemp.Atof()); |
|
|
|
|
|
_chi2CutTable >> _tstringtemp; |
|
|
_p1.push_back(_tstringtemp.Atof()); |
|
62 |
|
|
63 |
_chi2CutTable >> _tstringtemp; |
_chi2CutTable >> _tstringtemp; |
64 |
_p2.push_back(_tstringtemp.Atof()); |
_iDayLast.push_back(_tstringtemp.Atoi()); |
65 |
|
|
66 |
|
if (_nPar>=0 && _nPar<=5) { |
67 |
|
for (int iPar=0; iPar<_nPar; iPar++) { |
68 |
|
|
69 |
|
_chi2CutTable >> _tstringtemp; |
70 |
|
_p[iPar].push_back(_tstringtemp.Atof()); |
71 |
|
|
72 |
|
} |
73 |
|
} |
74 |
|
|
75 |
} |
} |
76 |
_chi2CutTable.close(); |
_chi2CutTable.close(); |
77 |
|
|
|
#ifdef DEBUGPAMCUT |
|
|
|
|
|
TString hId; |
|
|
TString hTitle; |
|
|
|
|
|
for (UInt_t j = 0; j < 2; j++) { |
|
|
hId.Form("h_trk_chi2_vs_defl_%i_", j); |
|
|
hId.Append(TString(cutName)); |
|
|
hTitle.Form("TRK chi2 vs defl (%i)", j); |
|
|
h_trk_chi2_defl[j] = new TH2F(hId.Data(), hTitle.Data(), 50, 0, 2.5, 50, 0, 20); |
|
|
} |
|
|
|
|
|
#endif |
|
|
|
|
78 |
} |
} |
79 |
|
|
80 |
/*! @brief Destructor. */ |
/*! @brief Destructor. */ |
81 |
~TrkChi2DeflTimeCut() { |
~TrkChi2DeflTimeCut() { |
82 |
|
|
|
#ifdef DEBUGPAMCUT |
|
|
|
|
|
for (UInt_t j = 0; j < 2; j++) { |
|
|
h_trk_chi2_defl[j]->Write(); |
|
|
} |
|
|
|
|
|
#endif |
|
|
|
|
83 |
} |
} |
84 |
|
|
85 |
/*! @brief The tracker chi2 vs deflection check. |
/*! @brief The tracker chi2 vs |deflection| check. |
86 |
* |
* |
87 |
* |
* |
88 |
* @param event The event to analyze. |
* @param event The event to analyze. |
89 |
* @return #CUTOK if chi2 < Chi2(eta). |
* @return #CUTOK if chi2 < Chi2(|eta|). |
90 |
* @return 0 if not |
* @return 0 if not |
91 |
*/ |
*/ |
92 |
int Check(PamLevel2 *event); |
int Check(PamLevel2 *event); |
93 |
|
|
94 |
private: |
private: |
95 |
|
|
|
#ifdef DEBUGPAMCUT |
|
|
|
|
|
TH2F* h_trk_chi2_defl[2]; |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
96 |
virtual double _GetChi2(PamLevel2 *event); |
virtual double _GetChi2(PamLevel2 *event); |
97 |
|
|
98 |
const char* _calibFile; |
const char* _calibFile; |
99 |
|
int _nPar; |
100 |
|
|
101 |
TString _tstringtemp; |
TString _tstringtemp; |
102 |
|
|
103 |
std::vector<Int_t> _iMonth; |
std::vector<Int_t> _iDayFirst; |
104 |
std::vector<Double_t> _p0; |
std::vector<Int_t> _iDayLast; |
105 |
std::vector<Double_t> _p1; |
std::vector<Double_t> _p[5]; |
|
std::vector<Double_t> _p2; |
|
106 |
|
|
107 |
ifstream _chi2CutTable; |
ifstream _chi2CutTable; |
108 |
|
|
109 |
Double_t _p0sel, _p1sel, _p2sel; |
Double_t _pSel[5]; |
110 |
|
|
111 |
TTimeStamp _time; |
TTimeStamp _time; |
112 |
|
|