ATLAS Offline Software
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
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 ... More...
 
std::string name () const
 
TH1F * Hist ()
 
void finalise (double scale=100)
 actually calculate the efficiencies More...
 
double findTotalEfficiency ()
 these 1D and 2D Fill versionms should never be called directly in fact, are they even needed at all ?
More...
 
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 ) { }

◆ 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  }

◆ ~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  {
51  }

◆ 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 175 of file T_Efficiency.h.

175  {
176 
185 
186  for ( int i=1 ; i<=hd->GetNbinsX() ; i++ ) { // cppcheck-suppress [ctunullpointer, nullPointer]; false positive
187  double y = hd->GetBinContent(i);
188  if ( y==0 ) hd->SetBinContent(i, 1e-20);
189  }
190 
191  TGraphAsymmErrors* tg = new TGraphAsymmErrors( hn, hd, "cl=0.683 b(1,1) mode" );
192 
193 
194  double* x = tg->GetX();
195  double* y = tg->GetY();
196 
197  int n = tg->GetN();
198 
199  for ( int i=0 ; i<n ; i++ ) {
200 
201  y[i] *= scale;
202 
203  double yeup = tg->GetErrorYhigh(i);
204  double yedown = tg->GetErrorYlow(i);
205 
206  yeup *= scale;
207  yedown *= scale;
208 
215 
216  tg->SetPoint( i, x[i], y[i] );
217 
218  tg->SetPointEYhigh( i, yeup );
219  tg->SetPointEYlow( i, yedown );
220 
221  tg->SetPointEXhigh( i, 0 );
222  tg->SetPointEXlow( i, 0 );
223 
224  }
225 
226  return tg;
227 
228  }

◆ 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  }

◆ 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 80 of file T_Efficiency.h.

80  {
81  getibinvec();
82  m_heff->Reset();
83  for ( size_t i=0 ; i<m_ibin.size() ; i++ ) {
84  double n = m_hnumer->GetBinContent(m_ibin[i]);
85  double d = m_hdenom->GetBinContent(m_ibin[i]);
86 
87  double e = 0;
88  double ee = 0;
89  if ( d!=0 ) {
90  e = n/d;
91  ee = e*(1-e)/d;
92  }
93 
94  // need proper error calculation...
95  m_heff->SetBinContent( m_ibin[i], scale*e );
96  m_heff->SetBinError( m_ibin[i], scale*std::sqrt(ee) );
97 
98  }
99  }

◆ 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 140 of file T_Efficiency.h.

140  {
141 
142  getibinvec();
143 
144  double n_tot = 0;
145  double d_tot = 0;
146 
147  for ( size_t i=0 ; i<m_ibin.size() ; i++ ) {
148  double n = m_hnumer->GetBinContent(m_ibin[i]);
149  double d = m_hdenom->GetBinContent(m_ibin[i]);
150 
151  n_tot += n;
152  d_tot += d;
153  }
154 
155  if ( d_tot!=0 ) {
156  return n_tot / d_tot;
157  }
158 
159  return 0.;
160  }

◆ 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 75 of file T_Efficiency.h.

75 { return m_heff; }

◆ name()

std::string T_Efficiency< TH1F >::name
inlineinherited

Definition at line 73 of file T_Efficiency.h.

73 { return m_name; }

◆ Write()

void T_Efficiency< TH1F >::Write
inlineinherited

Definition at line 162 of file T_Efficiency.h.

162  {
163  m_hnumer->Write();
164  m_hdenom->Write();
165  m_hmissed->Write();
166  m_heff->Write();
167  }

Member Data Documentation

◆ m_hdenom

TH1F * T_Efficiency< TH1F >::m_hdenom
protectedinherited

Definition at line 236 of file T_Efficiency.h.

◆ m_heff

TH1F * T_Efficiency< TH1F >::m_heff
protectedinherited

Definition at line 240 of file T_Efficiency.h.

◆ m_hmissed

TH1F * T_Efficiency< TH1F >::m_hmissed
protectedinherited

Definition at line 238 of file T_Efficiency.h.

◆ m_hnumer

TH1F * T_Efficiency< TH1F >::m_hnumer
protectedinherited

Definition at line 235 of file T_Efficiency.h.

◆ m_ibin

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

Definition at line 242 of file T_Efficiency.h.

◆ m_name

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

Definition at line 233 of file T_Efficiency.h.


The documentation for this class was generated from the following file:
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
calibdata.force
bool force
Definition: calibdata.py:19
T_Efficiency< TH1F >::getibinvec
virtual void getibinvec(bool force=false)=0
hist_file_dump.d
d
Definition: hist_file_dump.py:137
T_Efficiency< TH1F >::m_name
std::string m_name
Definition: T_Efficiency.h:233
T_Efficiency< TH1F >::finalise
void finalise(double scale=100)
actually calculate the efficiencies
Definition: T_Efficiency.h:80
yodamerge_tmp.scale
scale
Definition: yodamerge_tmp.py:138
x
#define x
Efficiency1D::getibinvec
virtual void getibinvec(bool force=false)
Definition: Efficiency1D.h:55
T_Efficiency< TH1F >
T_Efficiency< TH1F >::m_hmissed
TH1F * m_hmissed
Definition: T_Efficiency.h:238
lumiFormat.i
int i
Definition: lumiFormat.py:85
beamspotman.n
n
Definition: beamspotman.py:731
perfmonmt-refit.n_tot
n_tot
Definition: perfmonmt-refit.py:104
T_Efficiency< TH1F >::m_heff
TH1F * m_heff
Definition: T_Efficiency.h:240
y
#define y
h
T_Efficiency< TH1F >::m_ibin
std::vector< int > m_ibin
Definition: T_Efficiency.h:242
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
T_Efficiency< TH1F >::m_hdenom
TH1F * m_hdenom
Definition: T_Efficiency.h:236
T_Efficiency< TH1F >::BayesInternal
TGraphAsymmErrors * BayesInternal(TH1 *hn, TH1 *hd, double scale=100) const
Definition: T_Efficiency.h:175
T_Efficiency< TH1F >::m_hnumer
TH1F * m_hnumer
Definition: T_Efficiency.h:235