ATLAS Offline Software
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Efficiency2D Class Reference

#include <Efficiency2D.h>

Inheritance diagram for Efficiency2D:
Collaboration diagram for Efficiency2D:

Public Member Functions

 Efficiency2D (TH2F *h, const std::string &n="")
 
 Efficiency2D (TH2F *hnum, TH2F *hden, const std::string &n, double scale=100)
 
 ~Efficiency2D ()
 
void Fill (double x, double y, double w=1)
 fill methods ... More...
 
void FillDenom (double x, double y, float w=1)
 
TGraphAsymmErrors * BayesX (int slice, double scale=100)
 evaluate the uncertainties correctly ... More...
 
TGraphAsymmErrors * BayesY (int slice, double scale=100)
 
TH1DsliceX (int i)
 
TH1DsliceY (int i)
 
int slicesX () const
 
int slicesY () const
 
std::string name () const
 
TH2FHist ()
 
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)
 
std::string slicename (const std::string &s, int i) const
 
TGraphAsymmErrors * BayesInternal (TH1 *hn, TH1 *hd, double scale=100) const
 

Protected Attributes

std::string m_name
 
TH2Fm_hnumer
 
TH2Fm_hdenom
 
TH2Fm_hmissed
 
TH2Fm_heff
 
std::vector< int > m_ibin
 

Detailed Description

Definition at line 19 of file Efficiency2D.h.

Constructor & Destructor Documentation

◆ Efficiency2D() [1/2]

Efficiency2D::Efficiency2D ( TH2F h,
const std::string &  n = "" 
)
inline

Definition at line 23 of file Efficiency2D.h.

23  :
24  T_Efficiency<TH2F>( h, n ) { }

◆ Efficiency2D() [2/2]

Efficiency2D::Efficiency2D ( TH2F hnum,
TH2F hden,
const std::string &  n,
double  scale = 100 
)
inline

Definition at line 26 of file Efficiency2D.h.

26  :
27  T_Efficiency<TH2F>( hnum, hden, n, scale ) {
28  getibinvec(true);
29  finalise( scale );
30  }

◆ ~Efficiency2D()

Efficiency2D::~Efficiency2D ( )
inline

Definition at line 32 of file Efficiency2D.h.

32 { }

Member Function Documentation

◆ BayesInternal()

TGraphAsymmErrors* T_Efficiency< TH2F >::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++ ) {
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  }

◆ BayesX()

TGraphAsymmErrors* Efficiency2D::BayesX ( int  slice,
double  scale = 100 
)
inline

evaluate the uncertainties correctly ...

Definition at line 49 of file Efficiency2D.h.

49  {
50 
51  if ( slice<0 || slice>=slicesX() ) return 0;
52 
53  TH1D* hn = 0;
54  TH1D* hd = 0;
55 
56  if ( m_hnumer ) {
57  // get some slice from the numerator histo
58  hn = m_hnumer->ProjectionY( slicename( name()+"_yslice", slice).c_str(), slice+1, slice+1, "e");
59  }
60 
61  if ( m_hdenom ) {
62  // get some slice from the denominator histo
63  hd = m_hdenom->ProjectionY( slicename( name()+"_yslice", slice).c_str(), slice+1, slice+1, "e");
64  }
65 
66  return BayesInternal( hn, hd, scale );
67 
68  }

◆ BayesY()

TGraphAsymmErrors* Efficiency2D::BayesY ( int  slice,
double  scale = 100 
)
inline

Definition at line 72 of file Efficiency2D.h.

72  {
73 
74  if ( slice<0 || slice>=slicesY() ) return 0;
75 
76  TH1D* hn = 0;
77  TH1D* hd = 0;
78 
79  if ( m_hnumer ) {
80  // get some slice from the numerator histo
81  hn = m_hnumer->ProjectionX( slicename( name()+"_yslice", slice).c_str(), slice+1, slice+1, "e");
82  }
83 
84  if ( m_hdenom ) {
85  // get some slice from the denominator histo
86  hd = m_hdenom->ProjectionX( slicename( name()+"_yslice", slice).c_str(), slice+1, slice+1, "e");
87  }
88 
89  return BayesInternal( hn, hd, scale );
90 
91  }

◆ Fill()

void Efficiency2D::Fill ( double  x,
double  y,
double  w = 1 
)
inline

fill methods ...

Definition at line 36 of file Efficiency2D.h.

36  {
37  m_hnumer->Fill( float(x), float(y), float(w) );
38  m_hdenom->Fill( float(x), float(y), float(w) );
39  }

◆ FillDenom()

void Efficiency2D::FillDenom ( double  x,
double  y,
float  w = 1 
)
inline

Definition at line 41 of file Efficiency2D.h.

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

◆ finalise()

void T_Efficiency< TH2F >::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...
96  m_heff->SetBinError( m_ibin[i], scale*std::sqrt(ee) );
97 
98  }
99  }

◆ findTotalEfficiency()

double T_Efficiency< TH2F >::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 Efficiency2D::getibinvec ( bool  force = false)
inlineprotectedvirtual

Implements T_Efficiency< TH2F >.

Definition at line 118 of file Efficiency2D.h.

118  {
119  if ( !force && !m_ibin.empty() ) return;
120  for ( int i=1 ; i<=m_hdenom->GetNbinsX() ; i++ ) {
121  for ( int j=1 ; j<=m_hdenom->GetNbinsY() ; j++ ) {
122  m_ibin.push_back( m_hdenom->GetBin(i,j) );
123  }
124  }
125  }

◆ Hist()

TH2F * T_Efficiency< TH2F >::Hist
inlineinherited

Definition at line 75 of file T_Efficiency.h.

75 { return m_heff; }

◆ name()

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

Definition at line 73 of file T_Efficiency.h.

73 { return m_name; }

◆ slicename()

std::string Efficiency2D::slicename ( const std::string &  s,
int  i 
) const
inlineprotected

Definition at line 128 of file Efficiency2D.h.

128  {
129  if ( i<10 ) return s + "0" + std::to_string(i);
130  else return s + std::to_string(i);
131  }

◆ slicesX()

int Efficiency2D::slicesX ( ) const
inline

Definition at line 105 of file Efficiency2D.h.

105  {
106  if ( m_hdenom ) return m_hdenom->GetXaxis()->GetNbins();
107  return 0;
108  }

◆ slicesY()

int Efficiency2D::slicesY ( ) const
inline

Definition at line 111 of file Efficiency2D.h.

111  {
112  if ( m_hdenom ) return m_hdenom->GetYaxis()->GetNbins();
113  return 0;
114  }

◆ sliceX()

TH1D* Efficiency2D::sliceX ( int  i)
inline

Definition at line 94 of file Efficiency2D.h.

94  {
95  if ( i<0 || i>=slicesX() ) return 0;
96  return m_heff->ProjectionY( slicename( name()+"_xslice", i).c_str(), i+1, i+1, "e");
97  }

◆ sliceY()

TH1D* Efficiency2D::sliceY ( int  i)
inline

Definition at line 99 of file Efficiency2D.h.

99  {
100  if ( i<0 || i>=slicesY() ) return 0;
101  return m_heff->ProjectionX( slicename( name()+"_yslice", i).c_str(), i+1, i+1, "e");
102  }

◆ Write()

void T_Efficiency< TH2F >::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

TH2F * T_Efficiency< TH2F >::m_hdenom
protectedinherited

Definition at line 236 of file T_Efficiency.h.

◆ m_heff

TH2F * T_Efficiency< TH2F >::m_heff
protectedinherited

Definition at line 240 of file T_Efficiency.h.

◆ m_hmissed

TH2F * T_Efficiency< TH2F >::m_hmissed
protectedinherited

Definition at line 238 of file T_Efficiency.h.

◆ m_hnumer

TH2F * T_Efficiency< TH2F >::m_hnumer
protectedinherited

Definition at line 235 of file T_Efficiency.h.

◆ m_ibin

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

Definition at line 242 of file T_Efficiency.h.

◆ m_name

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

Definition at line 233 of file T_Efficiency.h.


The documentation for this class was generated from the following file:
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
calibdata.force
bool force
Definition: calibdata.py:19
T_Efficiency< TH2F >::getibinvec
virtual void getibinvec(bool force=false)=0
hist_file_dump.d
d
Definition: hist_file_dump.py:137
T_Efficiency< TH2F >::m_name
std::string m_name
Definition: T_Efficiency.h:233
TH1D
Definition: rootspy.cxx:342
T_Efficiency< TH2F >::finalise
void finalise(double scale=100)
actually calculate the efficiencies
Definition: T_Efficiency.h:80
yodamerge_tmp.scale
scale
Definition: yodamerge_tmp.py:138
Efficiency2D::slicesY
int slicesY() const
Definition: Efficiency2D.h:111
x
#define x
T_Efficiency< TH2F >
T_Efficiency< TH2F >::m_hmissed
TH2F * m_hmissed
Definition: T_Efficiency.h:238
perfmonmt-refit.slice
slice
Definition: perfmonmt-refit.py:52
TH1::SetBinContent
void SetBinContent(int, double)
Definition: rootspy.cxx:301
lumiFormat.i
int i
Definition: lumiFormat.py:92
beamspotman.n
n
Definition: beamspotman.py:731
perfmonmt-refit.n_tot
n_tot
Definition: perfmonmt-refit.py:104
TH2F::GetBinContent
double GetBinContent(int) const
Definition: rootspy.cxx:425
TH2F::SetBinContent
void SetBinContent(int, double)
Definition: rootspy.cxx:426
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
T_Efficiency< TH2F >::m_heff
TH2F * m_heff
Definition: T_Efficiency.h:240
TH1::GetBinContent
double GetBinContent(int) const
Definition: rootspy.cxx:298
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
y
#define y
h
Efficiency2D::slicesX
int slicesX() const
Definition: Efficiency2D.h:105
T_Efficiency< TH2F >::m_ibin
std::vector< int > m_ibin
Definition: T_Efficiency.h:242
Efficiency2D::getibinvec
virtual void getibinvec(bool force=false)
Definition: Efficiency2D.h:118
T_Efficiency< TH2F >::name
std::string name() const
Definition: T_Efficiency.h:73
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
Efficiency2D::slicename
std::string slicename(const std::string &s, int i) const
Definition: Efficiency2D.h:128
T_Efficiency< TH2F >::m_hdenom
TH2F * m_hdenom
Definition: T_Efficiency.h:236
T_Efficiency< TH2F >::BayesInternal
TGraphAsymmErrors * BayesInternal(TH1 *hn, TH1 *hd, double scale=100) const
Definition: T_Efficiency.h:175
T_Efficiency< TH2F >::m_hnumer
TH2F * m_hnumer
Definition: T_Efficiency.h:235