ATLAS Offline Software
e1hg_systematics.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include <math.h>
8 #include <stdlib.h>
9 
11 #include "Riostream.h"
12 #include "TAxis.h"
13 
14 #ifndef ROOTCORE
16 #endif
17 
19 
20  m_file0 = TFile::Open(filename.c_str());
21 
22  for (Int_t ieta = 0; ieta < 8; ieta++) {
23  char name[60];
24  sprintf(name, "elec_%d", ieta);
25  m_helec[ieta] = (TH1D*)m_file0->Get(name);
26  sprintf(name, "unconv_%d", ieta);
27  m_hphot[ieta] = (TH1D*)m_file0->Get(name);
28  sprintf(name, "conv_%d", ieta);
29  m_hphot2[ieta] = (TH1D*)m_file0->Get(name);
30  }
31 
32  TAxis* aa = m_helec[0]->GetXaxis();
33  m_etBins = aa->GetXbins();
34 }
35 
36 //=========================================================================
38  m_file0->Close();
39 }
40 
41 //============================================================================
42 // inputs are particle_type (0=elec, 1=reco unconv photon, 2=reco conv photon)
43 // energy in MeV
44 // eta
45 //
46 // returned value is alpha = DeltaE / E
47 //
49  bool interpolate) const {
50 
51  // cout << " in getDelta " << endl;
52  if (particle_type < 0 || particle_type > 2)
53  return 0.;
54 
55  float aeta = fabs(eta);
56  int ieta = 0;
57  if (aeta < 0.4)
58  ieta = 0;
59  else if (aeta < 0.8)
60  ieta = 1;
61  else if (aeta < 1.1)
62  ieta = 2;
63  else if (aeta < 1.37)
64  ieta = 3;
65  else if (aeta < 1.52)
66  ieta = 4;
67  else if (aeta < 1.80)
68  ieta = 5;
69  else if (aeta < 2.10)
70  ieta = 6;
71  else
72  ieta = 7;
73 
74  double energyGeV = energy * 0.001;
75  double et = energyGeV / std::cosh(eta);
76 
77  int ibinEt = m_etBins->GetSize() - 2;
78  for (int i = 1; i < m_etBins->GetSize(); i++) {
79  if (et < m_etBins->GetAt(i)) {
80  ibinEt = i - 1;
81  break;
82  }
83  }
84 
85  // cout << " energy, et , ibinEt " << energyGeV << " " << et << " " <<
86  // ibinEt << endl;
87 
88  Double_t scale = 0.;
89  // HACK: some ES model dependency needs to be introduced
90  /*Default up to es2017_summer
91  if (aeta<1.80) scale=0.;
92  else if (aeta<2.3) scale = 0.050*(aeta-1.8)/0.4 /0.05;
93  else scale=0.025/0.05;
94  */
95 
96  if (aeta < 1.80)
97  scale = 0.;
98  else if (aeta < 2.3)
99  scale = (0.050 * (aeta - 1.8) / 0.4 + 0.025) / 0.05;
100  else
101  scale = 0.05 / 0.05;
102 
103  if (!interpolate) {
104  if (particle_type == 0)
105  return scale * m_helec[ieta]->GetBinContent(ibinEt + 1);
106  else if (particle_type == 1)
107  return scale * m_hphot[ieta]->GetBinContent(ibinEt + 1);
108  else
109  return scale * m_hphot2[ieta]->GetBinContent(
110  ibinEt + 1); // This is 2, since if particle_type is
111  // not 0,1,2 we have returned 0 above
112  } else {
113  if (particle_type == 0)
114  return scale * m_helec[ieta]->Interpolate(et);
115  else if (particle_type == 1)
116  return scale * m_hphot[ieta]->Interpolate(et);
117  else
118  return scale * m_hphot2[ieta]->Interpolate(
119  et); // This is 2, since if particle_type is not 0,1,2
120  // we have returned 0
121  }
122 }
et
Extra patterns decribing particle interation process.
e1hg_systematics::~e1hg_systematics
~e1hg_systematics()
Definition: e1hg_systematics.cxx:37
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
EgammaARTmonitoring_plotsMaker.particle_type
particle_type
Definition: EgammaARTmonitoring_plotsMaker.py:633
e1hg_systematics.h
e1hg_systematics::m_etBins
const TArrayD * m_etBins
Definition: e1hg_systematics.h:40
e1hg_systematics::e1hg_systematics
e1hg_systematics(const std::string &filename)
constructor (initialization done there reading root files)
Definition: e1hg_systematics.cxx:18
yodamerge_tmp.scale
scale
Definition: yodamerge_tmp.py:138
e1hg_systematics::m_file0
TFile * m_file0
Definition: e1hg_systematics.h:39
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
lumiFormat.i
int i
Definition: lumiFormat.py:85
e1hg_systematics::m_hphot2
TH1D * m_hphot2[8]
Definition: e1hg_systematics.h:38
PathResolver.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
e1hg_systematics::m_hphot
TH1D * m_hphot[8]
Definition: e1hg_systematics.h:37
e1hg_systematics::m_helec
TH1D * m_helec[8]
Definition: e1hg_systematics.h:36
e1hg_systematics::getAlpha
double getAlpha(int particle_type, double energy, double eta, bool interpolate=false) const
particle_type = 0 (electrons), 1 (unconv photons), 2 (conv photons)
Definition: e1hg_systematics.cxx:48
CaloClusterCorr::interpolate
float interpolate(const CaloRec::Array< 2 > &a, float x, unsigned int degree, unsigned int ycol=1, const CaloRec::Array< 1 > &regions=CaloRec::Array< 1 >(), int n_points=-1, bool fixZero=false)
Polynomial interpolation in a table.
Definition: interpolate.cxx:75
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
test_AnalysisBaseEventLoopJob.aa
aa
Definition: test_AnalysisBaseEventLoopJob.py:37