1 |
pam-fi |
1.1 |
/* |
2 |
|
|
* EffRigCollection.cpp |
3 |
|
|
* |
4 |
|
|
* Created on: 10/ago/2009 |
5 |
|
|
* Author: Nicola Mori |
6 |
|
|
*/ |
7 |
|
|
|
8 |
|
|
/*! @file EffRigCollection.cpp The EffRigCollection class implementation file. */ |
9 |
|
|
|
10 |
|
|
#include "EffRigCollection.h" |
11 |
|
|
|
12 |
|
|
EffRigCollection::EffRigCollection(const char *collectionName, TString outFileBase, TString rigBinsFile, bool absRig) : |
13 |
|
|
EffCollection(collectionName, outFileBase), _bins(0), _selVector(0), _detVector(0), _outUp(0), _outDown(0) { |
14 |
|
|
|
15 |
|
|
ifstream rigBinListFile; |
16 |
|
|
rigBinListFile.open(rigBinsFile); |
17 |
|
|
|
18 |
|
|
TString auxString; |
19 |
|
|
while (!rigBinListFile.eof()) { |
20 |
|
|
rigBinListFile >> auxString; |
21 |
|
|
if (auxString != "") { |
22 |
|
|
_bins.push_back(auxString.Atof()); |
23 |
|
|
} |
24 |
|
|
} |
25 |
|
|
rigBinListFile.close(); |
26 |
|
|
|
27 |
|
|
_selVector.resize(_bins.size() - 1, 0); |
28 |
|
|
_detVector.resize(_bins.size() - 1, 0); |
29 |
|
|
} |
30 |
|
|
|
31 |
|
|
int EffRigCollection::ApplyCut(PamLevel2 *event) { |
32 |
|
|
|
33 |
|
|
_nEv++; |
34 |
|
|
if (_selCollection.ApplyCut(event) == CUTOK) { |
35 |
|
|
// Check if the event is inside the rigidity range |
36 |
|
|
// NOTE: at this point a TrkPhSinCut should be already performed, |
37 |
|
|
// since we are going to retrieve rigidity. |
38 |
|
|
float rig; |
39 |
|
|
if (_absRig) { |
40 |
|
|
rig = event->GetTrack(0)->GetTrkTrack()->GetRigidity(); |
41 |
|
|
} |
42 |
|
|
else |
43 |
|
|
rig = 1. / event->GetTrack(0)->GetTrkTrack()->GetDeflection(); |
44 |
|
|
if (rig >= _bins[0]) { |
45 |
|
|
int i = 1; |
46 |
|
|
while (rig >= _bins[i] && i < (int) _bins.size()) { |
47 |
|
|
i++; |
48 |
|
|
} |
49 |
|
|
i--; |
50 |
|
|
|
51 |
|
|
if (i < (int) (_selVector.size())) { |
52 |
|
|
_selVector[i]++; |
53 |
|
|
if (_detCollection.ApplyCut(event) == CUTOK) { |
54 |
|
|
_detVector[i]++; |
55 |
|
|
_nGood++; |
56 |
|
|
return CUTOK; |
57 |
|
|
} |
58 |
|
|
} |
59 |
|
|
else |
60 |
|
|
_outUp++; |
61 |
|
|
|
62 |
|
|
} |
63 |
|
|
else { |
64 |
|
|
_outDown++; |
65 |
|
|
return 0; |
66 |
|
|
} |
67 |
|
|
} |
68 |
|
|
|
69 |
|
|
return 0; |
70 |
|
|
} |
71 |
|
|
|
72 |
|
|
void EffRigCollection::Finalize() { |
73 |
|
|
|
74 |
|
|
// Correct the number of selected events by subtracting events outside the rigidity interval |
75 |
|
|
_sel -= _outUp + _outDown; |
76 |
|
|
// Print the report |
77 |
|
|
EffCollection::Finalize(); |
78 |
|
|
cout << " Events below the minimum rigidity: " << _outDown << "\n"; |
79 |
|
|
cout << " Events above the maximum rigidity: " << _outUp << "\n"; |
80 |
|
|
|
81 |
|
|
// Write the output files |
82 |
|
|
if (_outFileBase != "") { |
83 |
|
|
ofstream outTextFile((_outFileBase + "-eff-rig.txt").Data(), ios_base::out); |
84 |
|
|
for (unsigned int i = 0; i < _selVector.size(); i++) { |
85 |
|
|
outTextFile << _detVector[i] << " " << _selVector[i] << " "; |
86 |
|
|
if (_selVector[i] != 0) |
87 |
|
|
outTextFile << (float) _detVector[i] / (float) _selVector[i] << "\n"; |
88 |
|
|
else |
89 |
|
|
outTextFile << "0.\n"; |
90 |
|
|
|
91 |
|
|
} |
92 |
|
|
outTextFile.close(); |
93 |
|
|
} |
94 |
|
|
|
95 |
|
|
} |