11 |
#include "TGraphAsymmErrors.h" |
#include "TGraphAsymmErrors.h" |
12 |
|
|
13 |
extern "C" { |
extern "C" { |
14 |
bool efficiency_(Int_t*, Int_t*, Double_t*, Double_t*, Double_t*); |
/*! @brief Fortran routine by Sergio Ricciarini which computes errors on the efficiency. |
15 |
|
* |
16 |
|
* This routine has been developed to carefully evaluate the error bars on the efficiency, |
17 |
|
* which must have a value between 0 and 1. See the appendix of Sergio's PhD thesis for more |
18 |
|
* details. |
19 |
|
* The important thing is that the computed efficiency will have the unphysical value 1.1 |
20 |
|
* if there are less than 8 events in the efficiency sample (eg., the sample used to compute the |
21 |
|
* efficiency). This is necessary to have a reliable estimate of the errors. |
22 |
|
* |
23 |
|
* @param sel Pointer to an Int_t variable containing the number of events in the efficiency sample. |
24 |
|
* @param det Pointer to an Int_t variable containing the number of events in the efficiency sample |
25 |
|
* which satisfied the set of cuts for which the efficiency is being measured. |
26 |
|
* @param eff Pointer to a Double_t variable where the computed efficiency will be returned. |
27 |
|
* @param errLow Pointer to a Double_t variable where the length of the lower error bar will |
28 |
|
* be returned. |
29 |
|
* @param errHigh Pointer to a Double_t variable where the length of the upper error bar will |
30 |
|
* be returned. |
31 |
|
* @return Not clear at this point... ignore it. |
32 |
|
*/ |
33 |
|
bool efficiency_(Int_t* sel, Int_t* det, Double_t* eff, Double_t* errLow, Double_t* errHigh); |
34 |
} |
} |
35 |
|
|
36 |
EffCollection::EffCollection(const char *collectionName, TString outFileBase, int errMethod) : |
EffCollection::EffCollection(const char *collectionName, TString outFileBase, int errMethod, bool owns) : |
37 |
VerboseCollection(collectionName), _selCollection("selCollection"), _detCollection("detCollection"), _outFileBase( |
VerboseCollection(collectionName, owns), _selCollection("selCollection"), _detCollection("detCollection"), _outFileBase( |
38 |
outFileBase), _errMethod(errMethod), _det(0), _sel(0) { |
outFileBase), _errMethod(errMethod), _det(0), _sel(0) { |
39 |
|
|
40 |
} |
} |
41 |
|
|
42 |
void EffCollection::AddDetectorCut(PamCut &cut) { |
void EffCollection::AddDetectorCut(PamCut *cut) { |
43 |
_detCollection.AddCut(cut); |
_detCollection.AddCut(cut); |
44 |
} |
} |
45 |
|
|
46 |
void EffCollection::AddSelectionCut(PamCut &cut) { |
void EffCollection::AddSelectionCut(PamCut *cut) { |
47 |
_selCollection.AddCut(cut); |
_selCollection.AddCut(cut); |
48 |
} |
} |
49 |
|
|
50 |
void EffCollection::AddDetectorAction(CollectionAction &action) { |
void EffCollection::AddDetectorAction(CollectionAction *action) { |
51 |
_detCollection.AddAction(action); |
_detCollection.AddAction(action); |
52 |
} |
} |
53 |
|
|
54 |
void EffCollection::AddSelectionAction(CollectionAction &action) { |
void EffCollection::AddSelectionAction(CollectionAction *action) { |
55 |
_selCollection.AddAction(action); |
_selCollection.AddAction(action); |
56 |
} |
} |
57 |
|
|
83 |
Int_t sel = (Int_t) _sel; |
Int_t sel = (Int_t) _sel; |
84 |
Int_t det = (Int_t) _det; |
Int_t det = (Int_t) _det; |
85 |
Double_t eff, errLow, errHigh; |
Double_t eff, errLow, errHigh; |
86 |
if (_errMethod == EFFRIG_ROOT) { |
if (_errMethod == EFFERR_ROOT) { |
87 |
if (sel < 8) { |
if (sel < 8) { |
88 |
eff = 1.1; |
eff = 1.1; |
89 |
errLow = errHigh = 0.; |
errLow = errHigh = 0.; |
101 |
errHigh = errGraph.GetErrorYhigh(0); |
errHigh = errGraph.GetErrorYhigh(0); |
102 |
} |
} |
103 |
} |
} |
104 |
if (_errMethod == EFFRIG_SERGIO) { |
if (_errMethod == EFFERR_SERGIO) { |
105 |
efficiency_(&sel, &det, &eff, &errLow, &errHigh); |
efficiency_(&sel, &det, &eff, &errLow, &errHigh); |
106 |
} |
} |
107 |
|
|
115 |
// Write the output file |
// Write the output file |
116 |
if (_outFileBase != "") { |
if (_outFileBase != "") { |
117 |
|
|
118 |
ofstream outTextFile((_outFileBase + "-eff.txt").Data(), ios_base::out); |
ofstream outTextFile((_outFileBase + "-" + GetName() + ".txt").Data(), ios_base::out); |
119 |
streamsize newPrec = 4; |
streamsize newPrec = 4; |
120 |
outTextFile.precision(newPrec); |
outTextFile.precision(newPrec); |
121 |
outTextFile.setf(ios::fixed, ios::floatfield); |
outTextFile.setf(ios::fixed, ios::floatfield); |