1 |
#include "CEffUser1D.hh"
|
2 |
#include <iomanip>
|
3 |
|
4 |
using namespace std;
|
5 |
|
6 |
CEffUser1D::CEffUser1D():graph(0){}
|
7 |
CEffUser1D::~CEffUser1D(){}
|
8 |
|
9 |
//--------------------------------------------------------------------------------------------------
|
10 |
void CEffUser1D::loadEff(TGraphAsymmErrors* gr)
|
11 |
{
|
12 |
graph = gr;
|
13 |
}
|
14 |
|
15 |
//--------------------------------------------------------------------------------------------------
|
16 |
Float_t CEffUser1D::getEff(const Double_t x)
|
17 |
{
|
18 |
if(!graph) {
|
19 |
cout << "Efficiency graph not loaded! Aborting..." << endl;
|
20 |
assert(0);
|
21 |
}
|
22 |
return graph->GetY()[getBin(x)];
|
23 |
}
|
24 |
|
25 |
//--------------------------------------------------------------------------------------------------
|
26 |
Float_t CEffUser1D::getErrLow(const Double_t x)
|
27 |
{
|
28 |
if(!graph) {
|
29 |
cout << "Efficiency graph not loaded! Aborting..." << endl;
|
30 |
assert(0);
|
31 |
}
|
32 |
return graph->GetEYlow()[getBin(x)];
|
33 |
}
|
34 |
|
35 |
//--------------------------------------------------------------------------------------------------
|
36 |
Float_t CEffUser1D::getErrHigh(const Double_t x)
|
37 |
{
|
38 |
if(!graph) {
|
39 |
cout << "Efficiency graph not loaded! Aborting..." << endl;
|
40 |
assert(0);
|
41 |
}
|
42 |
return graph->GetEYhigh()[getBin(x)];
|
43 |
}
|
44 |
|
45 |
//--------------------------------------------------------------------------------------------------
|
46 |
void CEffUser1D::printEff(ostream& os)
|
47 |
{
|
48 |
if(!graph) {
|
49 |
cout << "Efficiency graph not loaded! Aborting..." << endl;
|
50 |
assert(0);
|
51 |
}
|
52 |
os << "Efficiency:" << endl;
|
53 |
os << "-----------" << endl;
|
54 |
print(graph->GetY(),os);
|
55 |
}
|
56 |
|
57 |
//--------------------------------------------------------------------------------------------------
|
58 |
void CEffUser1D::printErrLow(ostream& os)
|
59 |
{
|
60 |
if(!graph) {
|
61 |
cout << "Efficiency graph not loaded! Aborting..." << endl;
|
62 |
assert(0);
|
63 |
}
|
64 |
os << "Low Errors:" << endl;
|
65 |
os << "-----------" << endl;
|
66 |
print(graph->GetEYlow(),os);
|
67 |
}
|
68 |
|
69 |
//--------------------------------------------------------------------------------------------------
|
70 |
void CEffUser1D::printErrHigh(ostream& os)
|
71 |
{
|
72 |
if(!graph) {
|
73 |
cout << "Efficiency graph not loaded! Aborting..." << endl;
|
74 |
assert(0);
|
75 |
}
|
76 |
os << "High Errors:" << endl;
|
77 |
os << "------------" << endl;
|
78 |
print(graph->GetEYhigh(),os);
|
79 |
}
|
80 |
|
81 |
//--------------------------------------------------------------------------------------------------
|
82 |
void CEffUser1D::print(const Double_t *yval, std::ostream& os)
|
83 |
{
|
84 |
const Double_t *xval = graph->GetX();
|
85 |
const Double_t *xerrl = graph->GetEXlow();
|
86 |
const Double_t *xerrh = graph->GetEXhigh();
|
87 |
|
88 |
for(Int_t i=0; i<graph->GetN(); i++) {
|
89 |
os << "[" << setw(4) << xval[i]-xerrl[i] << "," << setw(4) << xval[i]+xerrh[i] << "]";
|
90 |
}
|
91 |
os << endl;
|
92 |
for(Int_t i=0; i<graph->GetN(); i++) {
|
93 |
ios_base::fmtflags flags = os.flags();
|
94 |
os.precision(7);
|
95 |
os << " " << setw(9) << fixed << yval[i] << " ";
|
96 |
os.flags(flags);
|
97 |
}
|
98 |
os << endl;
|
99 |
}
|
100 |
|
101 |
//--------------------------------------------------------------------------------------------------
|
102 |
Int_t CEffUser1D::getBin(const Double_t x)
|
103 |
{
|
104 |
if(!graph) {
|
105 |
cout << "Efficiency graph not loaded! Aborting..." << endl;
|
106 |
assert(0);
|
107 |
}
|
108 |
const Double_t *xval = graph->GetX();
|
109 |
const Double_t *xerrl = graph->GetEXlow();
|
110 |
const Double_t *xerrh = graph->GetEXhigh();
|
111 |
for(Int_t i=0; i<graph->GetN(); i++) {
|
112 |
if((x >= (xval[i]-xerrl[i])) && (x < (xval[i]+xerrh[i]))) return i;
|
113 |
}
|
114 |
return -1;
|
115 |
}
|