9 |
|
|
10 |
#include "EffCollection.h" |
#include "EffCollection.h" |
11 |
|
|
12 |
|
extern "C" { |
13 |
|
bool efficiency_(Int_t*, Int_t*, Double_t*, Double_t*, Double_t*); |
14 |
|
} |
15 |
|
|
16 |
EffCollection::EffCollection(const char *collectionName, TString outFileBase) : |
EffCollection::EffCollection(const char *collectionName, TString outFileBase) : |
17 |
VerboseCollection(collectionName), _selCollection("selCollection"), _detCollection("detCollection"), _outFileBase( |
VerboseCollection(collectionName), _selCollection("selCollection"), _detCollection("detCollection"), _outFileBase( |
18 |
outFileBase), _det(0), _sel(0) { |
outFileBase), _det(0), _sel(0) { |
59 |
// Now all the cuts are in place, and VerboseCollection can print its report |
// Now all the cuts are in place, and VerboseCollection can print its report |
60 |
VerboseCollection::Finalize(); |
VerboseCollection::Finalize(); |
61 |
|
|
62 |
// Add some info about efficiency |
// Compute the error |
63 |
float eff; |
Int_t sel = (Int_t) _sel; |
64 |
if (_sel != 0.) |
Int_t det = (Int_t) _det; |
65 |
eff = (float)_det / (float)_sel; |
Double_t eff, errLow, errHigh; |
66 |
else |
efficiency_(&sel, &det, &eff, &errLow, &errHigh); |
67 |
eff = 0.; |
|
68 |
|
// Add some info about efficiency to the stdout |
69 |
cout << " ****** Efficiency informations ******\n"; |
cout << " ****** Efficiency informations ******\n"; |
70 |
cout << " Detector cuts:\n"; |
cout << " Detector cuts:\n"; |
71 |
for (unsigned int i = 0; i < _detCollection.GetSize(); i++) |
for (unsigned int i = 0; i < _detCollection.GetSize(); i++) |
72 |
cout << " - " << _detCollection.GetCut(i)->GetName() << "\n"; |
cout << " - " << _detCollection.GetCut(i)->GetName() << "\n"; |
73 |
cout << " Total detector efficiency: " << eff << endl; |
cout << " Total detector efficiency: " << eff << " +" << errHigh << "-" << errLow << endl; |
74 |
|
|
75 |
// Write the output file |
// Write the output file |
76 |
if (_outFileBase != "") { |
if (_outFileBase != "") { |
77 |
|
|
78 |
ofstream outTextFile((_outFileBase + "-eff.txt").Data(), ios_base::out); |
ofstream outTextFile((_outFileBase + "-eff.txt").Data(), ios_base::out); |
79 |
outTextFile << _det << " " << _sel << " " << eff << endl; |
streamsize newPrec = 4; |
80 |
|
outTextFile.precision(newPrec); |
81 |
|
outTextFile.setf(ios::fixed, ios::floatfield); |
82 |
|
outTextFile << setw(10) << det << setw(10) << sel << setw(10) << eff << setw(10) << errLow << setw(10) << errHigh |
83 |
|
<< endl; |
84 |
outTextFile.close(); |
outTextFile.close(); |
85 |
} |
} |
86 |
|
|