ATLAS Offline Software
Loading...
Searching...
No Matches
Efficiency1D Class Reference

#include <Efficiency1D.h>

Inheritance diagram for Efficiency1D:
Collaboration diagram for Efficiency1D:

Public Member Functions

 Efficiency1D (TH1F *h, const std::string &n="")
 Efficiency1D (TH1F *hnum, TH1F *hden, const std::string &n, double scale=100)
 ~Efficiency1D ()
virtual void Fill (double x, double w=1)
virtual void FillDenom (double x, float w=1)
TGraphAsymmErrors * Bayes (double scale=100)
 evaluate the uncertainties correctly ...
const std::string & name () const
TH1F * Hist ()
void finalise (double scale=100)
 actually calculate the efficiencies
double findTotalEfficiency ()
 these 1D and 2D Fill versionms should never be called directly in fact, are they even needed at all ?
void Write ()

Protected Member Functions

virtual void getibinvec (bool force=false)
TGraphAsymmErrors * BayesInternal (TH1 *hn, TH1 *hd, double scale=100) const

Protected Attributes

std::string m_name
TH1F * m_hnumer
TH1F * m_hdenom
TH1F * m_hmissed
TH1F * m_heff
std::vector< int > m_ibin

Detailed Description

Definition at line 19 of file Efficiency1D.h.

Constructor & Destructor Documentation

◆ Efficiency1D() [1/2]

Efficiency1D::Efficiency1D ( TH1F * h,
const std::string & n = "" )
inline

Definition at line 23 of file Efficiency1D.h.

23 :
24 T_Efficiency<TH1F>( h, n ) { }
T_Efficiency(TH1F *h, const std::string &n)

◆ Efficiency1D() [2/2]

Efficiency1D::Efficiency1D ( TH1F * hnum,
TH1F * hden,
const std::string & n,
double scale = 100 )
inline

Definition at line 26 of file Efficiency1D.h.

26 :
27 T_Efficiency<TH1F>( hnum, hden, n, scale ) {
28 getibinvec(true);
29 finalise( scale );
30 }
virtual void getibinvec(bool force=false)
void finalise(double scale=100)

◆ ~Efficiency1D()

Efficiency1D::~Efficiency1D ( )
inline

Definition at line 32 of file Efficiency1D.h.

32{ }

Member Function Documentation

◆ Bayes()

TGraphAsymmErrors * Efficiency1D::Bayes ( double scale = 100)
inline

evaluate the uncertainties correctly ...

Definition at line 49 of file Efficiency1D.h.

49 {
50 return BayesInternal( m_hnumer, m_hdenom, scale );
51 }
TGraphAsymmErrors * BayesInternal(TH1 *hn, TH1 *hd, double scale=100) const

◆ BayesInternal()

TGraphAsymmErrors * T_Efficiency< TH1F >::BayesInternal ( TH1 * hn,
TH1 * hd,
double scale = 100 ) const
inlineprotectedinherited

stupid root, told to divide, it skips bins where the nukber of entries is 0 (ok) but then complains that "number of points is not the same as the number of bins" now that would be ok, if these were user input values, but is stupid if this is some root policy. : root decides to do X and then prints a warning so instead, set the bin contents, for these bins to something really, really, really tiny ...

root is just such a pain - can't just get/set specific y values I mean - why some functions to get an x or y value and others only get all the x values, but the functions to return the errors only get ONE AT A TIME ? why isn't there a simple ScaleX() function? All this functionality no one cares about, and basic functionality missing

Definition at line 166 of file T_Efficiency.h.

166 {
167
176
177 for ( int i=1 ; i<=hd->GetNbinsX() ; i++ ) { // cppcheck-suppress [ctunullpointer, nullPointer]; false positive
178 double y = hd->GetBinContent(i);
179 if ( y==0 ) hd->SetBinContent(i, 1e-20);
180 }
181
182 TGraphAsymmErrors* tg = new TGraphAsymmErrors( hn, hd, "cl=0.683 b(1,1) mode" );
183
184
185 double* x = tg->GetX();
186 double* y = tg->GetY();
187
188 int n = tg->GetN();
189
190 for ( int i=0 ; i<n ; i++ ) {
191
192 y[i] *= scale;
193
194 double yeup = tg->GetErrorYhigh(i);
195 double yedown = tg->GetErrorYlow(i);
196
197 yeup *= scale;
198 yedown *= scale;
199
206
207 tg->SetPoint( i, x[i], y[i] );
208
209 tg->SetPointEYhigh( i, yeup );
210 tg->SetPointEYlow( i, yedown );
211
212 tg->SetPointEXhigh( i, 0 );
213 tg->SetPointEXlow( i, 0 );
214
215 }
216
217 return tg;
218
219 }

◆ Fill()

virtual void Efficiency1D::Fill ( double x,
double w = 1 )
inlinevirtual

Definition at line 37 of file Efficiency1D.h.

37 {
38 m_hnumer->Fill(float(x),float(w));
39 m_hdenom->Fill(float(x),float(w));
40 }
#define x

◆ FillDenom()

virtual void Efficiency1D::FillDenom ( double x,
float w = 1 )
inlinevirtual

Definition at line 42 of file Efficiency1D.h.

42 {
43 m_hdenom->Fill(float(x),float(w));
44 m_hmissed->Fill(float(x),float(w));
45 }

◆ finalise()

void T_Efficiency< TH1F >::finalise ( double scale = 100)
inlineinherited

actually calculate the efficiencies

Definition at line 71 of file T_Efficiency.h.

71 {
72 getibinvec();
73 m_heff->Reset();
74 for ( size_t i=0 ; i<m_ibin.size() ; i++ ) {
75 double n = m_hnumer->GetBinContent(m_ibin[i]);
76 double d = m_hdenom->GetBinContent(m_ibin[i]);
77
78 double e = 0;
79 double ee = 0;
80 if ( d!=0 ) {
81 e = n/d;
82 ee = e*(1-e)/d;
83 }
84
85 // need proper error calculation...
86 m_heff->SetBinContent( m_ibin[i], scale*e );
87 m_heff->SetBinError( m_ibin[i], scale*std::sqrt(ee) );
88
89 }
90 }
virtual void getibinvec(bool force=false)=0
std::vector< int > m_ibin

◆ findTotalEfficiency()

double T_Efficiency< TH1F >::findTotalEfficiency ( )
inlineinherited

these 1D and 2D Fill versionms should never be called directly in fact, are they even needed at all ?

calculate the efficiencies ...

Definition at line 131 of file T_Efficiency.h.

131 {
132
133 getibinvec();
134
135 double n_tot = 0;
136 double d_tot = 0;
137
138 for ( size_t i=0 ; i<m_ibin.size() ; i++ ) {
139 double n = m_hnumer->GetBinContent(m_ibin[i]);
140 double d = m_hdenom->GetBinContent(m_ibin[i]);
141
142 n_tot += n;
143 d_tot += d;
144 }
145
146 if ( d_tot!=0 ) {
147 return n_tot / d_tot;
148 }
149
150 return 0.;
151 }

◆ getibinvec()

virtual void Efficiency1D::getibinvec ( bool force = false)
inlineprotectedvirtual

Implements T_Efficiency< TH1F >.

Definition at line 55 of file Efficiency1D.h.

55 {
56 if ( !force && !m_ibin.empty() ) return;
57 for ( int i=1 ; i<=m_hdenom->GetNbinsX() ; i++ ) {
58 m_ibin.push_back( i );
59 }
60 }

◆ Hist()

TH1F * T_Efficiency< TH1F >::Hist ( )
inlineinherited

Definition at line 66 of file T_Efficiency.h.

66{ return m_heff; }

◆ name()

const std::string & T_Efficiency< TH1F >::name ( ) const
inlineinherited

Definition at line 64 of file T_Efficiency.h.

64{ return m_name; }

◆ Write()

void T_Efficiency< TH1F >::Write ( )
inlineinherited

Definition at line 153 of file T_Efficiency.h.

153 {
154 m_hnumer->Write();
155 m_hdenom->Write();
156 m_hmissed->Write();
157 m_heff->Write();
158 }

Member Data Documentation

◆ m_hdenom

TH1F* T_Efficiency< TH1F >::m_hdenom
protectedinherited

Definition at line 227 of file T_Efficiency.h.

◆ m_heff

TH1F* T_Efficiency< TH1F >::m_heff
protectedinherited

Definition at line 231 of file T_Efficiency.h.

◆ m_hmissed

TH1F* T_Efficiency< TH1F >::m_hmissed
protectedinherited

Definition at line 229 of file T_Efficiency.h.

◆ m_hnumer

TH1F* T_Efficiency< TH1F >::m_hnumer
protectedinherited

Definition at line 226 of file T_Efficiency.h.

◆ m_ibin

std::vector<int> T_Efficiency< TH1F >::m_ibin
protectedinherited

Definition at line 233 of file T_Efficiency.h.

◆ m_name

std::string T_Efficiency< TH1F >::m_name
protectedinherited

Definition at line 224 of file T_Efficiency.h.


The documentation for this class was generated from the following file: