ATLAS Offline Software
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
T_Efficiency< T > Class Template Referenceabstract

#include <T_Efficiency.h>

Collaboration diagram for T_Efficiency< T >:

Public Member Functions

 T_Efficiency (T *h, const std::string &n)
 
 T_Efficiency (T *hnum, T *hden, const std::string &n, double)
 
virtual ~T_Efficiency ()
 
const std::string & name () const
 
T * 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)=0
 
TGraphAsymmErrors * BayesInternal (TH1 *hn, TH1 *hd, double scale=100) const
 

Protected Attributes

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

Detailed Description

template<typename T>
class T_Efficiency< T >

Definition at line 24 of file T_Efficiency.h.

Constructor & Destructor Documentation

◆ T_Efficiency() [1/2]

template<typename T >
T_Efficiency< T >::T_Efficiency ( T *  h,
const std::string &  n 
)
inline

Definition at line 28 of file T_Efficiency.h.

28  :
29  m_name(n.empty() ? std::string(h->GetName())+"_eff" : n) {
30 
31  m_hnumer = (T*)h->Clone( (m_name+"_n").c_str() );
32  m_hdenom = (T*)h->Clone( (m_name+"_d").c_str() );
33  m_heff = (T*)h->Clone( m_name.c_str() );
34 
35  m_hmissed = (T*)h->Clone( (m_name+"_missed").c_str() );
36 
37  m_hnumer->Reset();
38  m_hdenom->Reset();
39  m_heff->Reset();
40  m_hmissed->Reset();
41 
42  }

◆ T_Efficiency() [2/2]

template<typename T >
T_Efficiency< T >::T_Efficiency ( T *  hnum,
T *  hden,
const std::string &  n,
double   
)
inline

can't call finialise here - need to call it in the derived class this->finalise(scale);

Definition at line 45 of file T_Efficiency.h.

45  :
46  m_name(n+"_eff") {
47 
48  m_hnumer = (T*)hnum->Clone( (m_name+"_n").c_str() );
49  m_hdenom = (T*)hden->Clone( (m_name+"_d").c_str() );
50  m_heff = (T*)hnum->Clone( m_name.c_str() );
51 
52  m_hmissed = (T*)hnum->Clone( (m_name+"_missed").c_str() );
53 
54  m_heff->Reset();
55  m_hmissed->Reset();
56 
60  }

◆ ~T_Efficiency()

template<typename T >
virtual T_Efficiency< T >::~T_Efficiency ( )
inlinevirtual

Definition at line 62 of file T_Efficiency.h.

62 { }

Member Function Documentation

◆ BayesInternal()

template<typename T >
TGraphAsymmErrors* T_Efficiency< T >::BayesInternal ( TH1 *  hn,
TH1 *  hd,
double  scale = 100 
) const
inlineprotected

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  }

◆ finalise()

template<typename T >
void T_Efficiency< T >::finalise ( double  scale = 100)
inline

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  }

◆ findTotalEfficiency()

template<typename T >
double T_Efficiency< T >::findTotalEfficiency ( )
inline

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()

template<typename T >
virtual void T_Efficiency< T >::getibinvec ( bool  force = false)
protectedpure virtual

Implemented in Efficiency2D, and Efficiency1D.

◆ Hist()

template<typename T >
T* T_Efficiency< T >::Hist ( )
inline

Definition at line 66 of file T_Efficiency.h.

66 { return m_heff; }

◆ name()

template<typename T >
const std::string& T_Efficiency< T >::name ( ) const
inline

Definition at line 64 of file T_Efficiency.h.

64 { return m_name; }

◆ Write()

template<typename T >
void T_Efficiency< T >::Write ( )
inline

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

template<typename T >
T* T_Efficiency< T >::m_hdenom
protected

Definition at line 227 of file T_Efficiency.h.

◆ m_heff

template<typename T >
T* T_Efficiency< T >::m_heff
protected

Definition at line 231 of file T_Efficiency.h.

◆ m_hmissed

template<typename T >
T* T_Efficiency< T >::m_hmissed
protected

Definition at line 229 of file T_Efficiency.h.

◆ m_hnumer

template<typename T >
T* T_Efficiency< T >::m_hnumer
protected

Definition at line 226 of file T_Efficiency.h.

◆ m_ibin

template<typename T >
std::vector<int> T_Efficiency< T >::m_ibin
protected

Definition at line 233 of file T_Efficiency.h.

◆ m_name

template<typename T >
std::string T_Efficiency< T >::m_name
protected

Definition at line 224 of file T_Efficiency.h.


The documentation for this class was generated from the following file:
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
T_Efficiency::getibinvec
virtual void getibinvec(bool force=false)=0
hist_file_dump.d
d
Definition: hist_file_dump.py:137
T_Efficiency::m_name
std::string m_name
Definition: T_Efficiency.h:224
yodamerge_tmp.scale
scale
Definition: yodamerge_tmp.py:138
x
#define x
T_Efficiency::m_hmissed
T * m_hmissed
Definition: T_Efficiency.h:229
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::m_heff
T * m_heff
Definition: T_Efficiency.h:231
y
#define y
h
T_Efficiency::m_ibin
std::vector< int > m_ibin
Definition: T_Efficiency.h:233
T_Efficiency::m_hdenom
T * m_hdenom
Definition: T_Efficiency.h:227
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
T_Efficiency::m_hnumer
T * m_hnumer
Definition: T_Efficiency.h:226