ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/HbbAnalysis/src/EffUtility.cc
Revision: 1.1.1.1 (vendor branch)
Committed: Wed Apr 15 10:24:16 2009 UTC (16 years ago) by amagnan
Content type: text/plain
Branch: v00-00-00, MAIN
CVS Tags: v01-00-00, beforeMETHacks, v00-05-03, v00-05-02, v00-05-01, v00-05-00, HbbAnaFor35X, v00-04-02, v00-04-01, v00-04-00, v00-03-00, v00-02-01, v00-02-00, v00-01-00, HbbAnaFor22X, HEAD
Changes since 1.1: +0 -0 lines
Log Message:
Imported sources

File Contents

# User Rev Content
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