8 |
/*! @file EffCollection.cpp The EffCollection class implementation file. */ |
/*! @file EffCollection.cpp The EffCollection class implementation file. */ |
9 |
|
|
10 |
#include "EffCollection.h" |
#include "EffCollection.h" |
11 |
|
#include "TGraphAsymmErrors.h" |
12 |
|
|
13 |
EffCollection::EffCollection(const char *collectionName, TString outFileBase) : |
extern "C" { |
14 |
|
bool efficiency_(Int_t*, Int_t*, Double_t*, Double_t*, Double_t*); |
15 |
|
} |
16 |
|
|
17 |
|
EffCollection::EffCollection(const char *collectionName, TString outFileBase, int errMethod) : |
18 |
VerboseCollection(collectionName), _selCollection("selCollection"), _detCollection("detCollection"), _outFileBase( |
VerboseCollection(collectionName), _selCollection("selCollection"), _detCollection("detCollection"), _outFileBase( |
19 |
outFileBase), _det(0), _sel(0) { |
outFileBase), _errMethod(errMethod), _det(0), _sel(0) { |
20 |
|
|
21 |
} |
} |
22 |
|
|
60 |
// 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 |
61 |
VerboseCollection::Finalize(); |
VerboseCollection::Finalize(); |
62 |
|
|
63 |
// Add some info about efficiency |
// Compute the error |
64 |
float eff; |
Int_t sel = (Int_t) _sel; |
65 |
if (_sel != 0.) |
Int_t det = (Int_t) _det; |
66 |
eff = _det / _sel; |
Double_t eff, errLow, errHigh; |
67 |
else |
if (_errMethod == EFFERR_ROOT) { |
68 |
eff = 0.; |
if (sel < 8) { |
69 |
|
eff = 1.1; |
70 |
|
errLow = errHigh = 0.; |
71 |
|
} |
72 |
|
else { |
73 |
|
TH1I pass("pass", "pass", 1, 0., 1.); |
74 |
|
TH1I total("total", "total", 1, 0., 1.); |
75 |
|
pass.Fill(0.5, det); |
76 |
|
total.Fill(0.5, sel); |
77 |
|
TGraphAsymmErrors errGraph; |
78 |
|
errGraph.BayesDivide(&pass, &total); |
79 |
|
Double_t dummy; |
80 |
|
errGraph.GetPoint(0, dummy, eff); |
81 |
|
errLow = errGraph.GetErrorYlow(0); |
82 |
|
errHigh = errGraph.GetErrorYhigh(0); |
83 |
|
} |
84 |
|
} |
85 |
|
if (_errMethod == EFFERR_SERGIO) { |
86 |
|
efficiency_(&sel, &det, &eff, &errLow, &errHigh); |
87 |
|
} |
88 |
|
|
89 |
|
// Add some info about efficiency to the stdout |
90 |
cout << " ****** Efficiency informations ******\n"; |
cout << " ****** Efficiency informations ******\n"; |
91 |
cout << " Detector cuts:\n"; |
cout << " Detector cuts:\n"; |
92 |
for (unsigned int i = 0; i < _detCollection.GetSize(); i++) |
for (unsigned int i = 0; i < _detCollection.GetSize(); i++) |
93 |
cout << " - " << _detCollection.GetCut(i)->GetName() << "\n"; |
cout << " - " << _detCollection.GetCut(i)->GetName() << "\n"; |
94 |
cout << " Total detector efficiency: " << eff << endl; |
cout << " Total detector efficiency: " << eff << " +" << errHigh << "-" << errLow << endl; |
95 |
|
|
96 |
// Write the output file |
// Write the output file |
97 |
if (_outFileBase != "") { |
if (_outFileBase != "") { |
98 |
ofstream outTextFile((_outFileBase + "-eff.txt").Data(), ios_base::out); |
|
99 |
outTextFile << _det << " " << _sel << " " << eff << endl; |
ofstream outTextFile((_outFileBase + "-" + GetName() + ".txt").Data(), ios_base::out); |
100 |
|
streamsize newPrec = 4; |
101 |
|
outTextFile.precision(newPrec); |
102 |
|
outTextFile.setf(ios::fixed, ios::floatfield); |
103 |
|
outTextFile << setw(10) << det << setw(10) << sel << setw(10) << eff << setw(10) << errLow << setw(10) << errHigh |
104 |
|
<< endl; |
105 |
outTextFile.close(); |
outTextFile.close(); |
106 |
} |
} |
107 |
|
|