1 |
amagnan |
1.1 |
#include <cmath>
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
#include "UserCode/HbbAnalysis/interface/EffUtility.hh"
|
5 |
|
|
|
6 |
|
|
namespace HbbAnalysis {//namespace
|
7 |
|
|
|
8 |
|
|
EffUtility::EffUtility():
|
9 |
|
|
isInitialised_(false),
|
10 |
|
|
nBins_(0),
|
11 |
|
|
xMin_(0),
|
12 |
|
|
xMax_(0),
|
13 |
|
|
nSelected_(0),
|
14 |
|
|
nTotal_(0)
|
15 |
|
|
{}
|
16 |
|
|
|
17 |
|
|
void EffUtility::initialise(const unsigned int aNBins, const double aXmin, const double aXmax){
|
18 |
|
|
nBins_ = aNBins;
|
19 |
|
|
xMin_ = aXmin;
|
20 |
|
|
xMax_ = aXmax;
|
21 |
|
|
nSelected_ = new unsigned int[nBins_];
|
22 |
|
|
nTotal_ = new unsigned int[nBins_];
|
23 |
|
|
|
24 |
|
|
for (unsigned int lBin(0); lBin<nBins_; lBin++){
|
25 |
|
|
nSelected_[lBin] = 0;
|
26 |
|
|
nTotal_[lBin] = 0;
|
27 |
|
|
}
|
28 |
|
|
|
29 |
|
|
isInitialised_ = true;
|
30 |
|
|
|
31 |
|
|
}
|
32 |
|
|
|
33 |
|
|
EffUtility::~EffUtility(){
|
34 |
|
|
if (isInitialised_){
|
35 |
|
|
delete[] nSelected_;
|
36 |
|
|
delete[] nTotal_;
|
37 |
|
|
}
|
38 |
|
|
}
|
39 |
|
|
|
40 |
|
|
const unsigned int EffUtility::numberOfBins(){
|
41 |
|
|
return nBins_;
|
42 |
|
|
}
|
43 |
|
|
|
44 |
|
|
|
45 |
|
|
const double EffUtility::stepSize(){
|
46 |
|
|
return (xMax_-xMin_)/nBins_;
|
47 |
|
|
}
|
48 |
|
|
|
49 |
|
|
|
50 |
|
|
const double EffUtility::xMin(){
|
51 |
|
|
return xMin_;
|
52 |
|
|
}
|
53 |
|
|
|
54 |
|
|
const double EffUtility::xMax(){
|
55 |
|
|
return xMax_;
|
56 |
|
|
}
|
57 |
|
|
|
58 |
|
|
void EffUtility::incrementPass(unsigned int aBin){
|
59 |
|
|
nSelected_[aBin]++;
|
60 |
|
|
}
|
61 |
|
|
|
62 |
|
|
void EffUtility::incrementTotal(unsigned int aBin){
|
63 |
|
|
nTotal_[aBin]++;
|
64 |
|
|
}
|
65 |
|
|
|
66 |
|
|
const float EffUtility::getRatio(unsigned int aBin){
|
67 |
|
|
if (nTotal_[aBin]>0) return static_cast<float>(nSelected_[aBin])/nTotal_[aBin];
|
68 |
|
|
return 0;
|
69 |
|
|
}
|
70 |
|
|
|
71 |
|
|
const float EffUtility::getRatioError(unsigned int aBin){
|
72 |
|
|
if (nTotal_[aBin]>0) return sqrt(getRatio(aBin)*(1-getRatio(aBin))/getTotal(aBin));
|
73 |
|
|
return 0;
|
74 |
|
|
}
|
75 |
|
|
|
76 |
|
|
const unsigned int EffUtility::getPassed(unsigned int aBin){
|
77 |
|
|
return nSelected_[aBin];
|
78 |
|
|
}
|
79 |
|
|
|
80 |
|
|
const unsigned int EffUtility::getTotal(unsigned int aBin){
|
81 |
|
|
return nTotal_[aBin];
|
82 |
|
|
}
|
83 |
|
|
|
84 |
|
|
|
85 |
|
|
}//namespace
|
86 |
|
|
|
87 |
|
|
|