Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Member Functions | Static Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
CP::ShowerDepthUtil Class Reference

#include <ShowerDepthUtil.h>

Collaboration diagram for CP::ShowerDepthUtil:

Public Member Functions

 ShowerDepthUtil ()
 
float getCorrectedShowerDepthEM1 (float etas1, float phi, bool isData=true) const
 Shower depth (in mm) on EM1 vs. More...
 
float getCorrectedShowerDepthEM2 (float etas2, float phi, bool isData=true) const
 Shower depth (in mm) on EM2 vs. More...
 
std::pair< float, float > getCorrectedRZ (float eta, float phi, bool isData=true, int sampling=1) const
 Return the shower depth in R,Z considering misalignments. More...
 
float getRZCorrection (float eta, float phi, bool isData=true) const
 Return the calorimeter displacement in R(Z) for barrel (endcap) More...
 
float getCorrectedEtaDirection (float zvertex, float eta, float phi, bool isData=true, int sampling=1) const
 Eta direction from zvertex to the shower in the given sampling. More...
 
std::optional< float > getCaloPointingEta (float etas1, float etas2, float phi, bool isData=true) const
 Eta direction from samplings 1 and 2 (pointing) More...
 

Static Public Member Functions

static float getShowerDepthEM1 (float etas1)
 Shower depth (in mm) vs. More...
 
static float getShowerDepthEM2 (float etas2)
 Shower depth (in mm) vs. More...
 
static std::pair< float, float > getRZ (float eta, int sampling)
 Shower depth in R,Z for the given sampling. More...
 
static float getEtaDirection (float zvertex, float R, float z)
 

Static Private Member Functions

static std::unique_ptr< TH1 > getHistoFromFile (const char *fileName, const char *histoName)
 Return TH1* from file given fileName, histoName. More...
 

Private Attributes

std::unique_ptr< TH1 > m_hData
 
std::unique_ptr< TH1 > m_hMC
 

Detailed Description

Definition at line 17 of file ShowerDepthUtil.h.

Constructor & Destructor Documentation

◆ ShowerDepthUtil()

CP::ShowerDepthUtil::ShowerDepthUtil ( )

Definition at line 38 of file ShowerDepthUtil.cxx.

38  {
39  const std::string filename = PathResolverFindCalibFile(CONFIG_FILE_NAME);
40 
41  m_hData = getHistoFromFile(filename.c_str(), DATA_HISTO_NAME);
42  m_hMC = getHistoFromFile(filename.c_str(), MC_HISTO_NAME);
43  if(!m_hData || !m_hMC){
44  throw std::runtime_error("Could not create instance of ShowerDepthUtil");
45  }
46 }

Member Function Documentation

◆ getCaloPointingEta()

std::optional< float > CP::ShowerDepthUtil::getCaloPointingEta ( float  etas1,
float  etas2,
float  phi,
bool  isData = true 
) const

Eta direction from samplings 1 and 2 (pointing)

Definition at line 124 of file ShowerDepthUtil.cxx.

126  {
127  std::pair<float, float> RZ1 = getCorrectedRZ(etas1, phi, isData, 1);
128  std::pair<float, float> RZ2 = getCorrectedRZ(etas2, phi, isData, 2);
129  // Sanity check
130  if (std::abs(RZ2.first - RZ1.first) < epsilon) {
131  return std::nullopt;
132  }
133 
134  return {std::asinh((RZ2.second - RZ1.second) / (RZ2.first - RZ1.first))};
135 }

◆ getCorrectedEtaDirection()

float CP::ShowerDepthUtil::getCorrectedEtaDirection ( float  zvertex,
float  eta,
float  phi,
bool  isData = true,
int  sampling = 1 
) const

Eta direction from zvertex to the shower in the given sampling.

Definition at line 104 of file ShowerDepthUtil.cxx.

106  {
107  std::pair<float, float> RZ = getCorrectedRZ(eta, phi, isData, sampling);
108  return getEtaDirection(zvertex, RZ.first, RZ.second);
109 }

◆ getCorrectedRZ()

std::pair< float, float > CP::ShowerDepthUtil::getCorrectedRZ ( float  eta,
float  phi,
bool  isData = true,
int  sampling = 1 
) const

Return the shower depth in R,Z considering misalignments.

Definition at line 137 of file ShowerDepthUtil.cxx.

139  {
140  if ((sampling != 1 && sampling != 2) || (std::abs(eta) > 10)) {
141  ANA_MSG_LVL_SERIOUS(MSG::WARNING,
142  "Invalid sampling, eta: " << sampling << ", " << eta);
143  return std::make_pair(0., 0.);
144  }
145  float depth = (sampling == 1 ? getCorrectedShowerDepthEM1(eta, phi, isData)
146  : getCorrectedShowerDepthEM2(eta, phi, isData));
147  if (std::abs(eta) < 1.5)
148  return std::make_pair(depth, depth * std::sinh(eta));
149  return std::make_pair(depth / std::sinh(eta), depth);
150 }

◆ getCorrectedShowerDepthEM1()

float CP::ShowerDepthUtil::getCorrectedShowerDepthEM1 ( float  etas1,
float  phi,
bool  isData = true 
) const

Shower depth (in mm) on EM1 vs.

eta, considering misalignments

Definition at line 49 of file ShowerDepthUtil.cxx.

50  {
51  return getShowerDepthEM1(etas1) - getRZCorrection(etas1, phi, isData);
52 }

◆ getCorrectedShowerDepthEM2()

float CP::ShowerDepthUtil::getCorrectedShowerDepthEM2 ( float  etas2,
float  phi,
bool  isData = true 
) const

Shower depth (in mm) on EM2 vs.

eta, considering misalignments

Definition at line 55 of file ShowerDepthUtil.cxx.

56  {
57  return getShowerDepthEM2(etas2) - getRZCorrection(etas2, phi, isData);
58 }

◆ getEtaDirection()

float CP::ShowerDepthUtil::getEtaDirection ( float  zvertex,
float  R,
float  z 
)
static

Definition at line 189 of file ShowerDepthUtil.cxx.

189  {
190  return std::asinh((z - zvertex) / R);
191 }

◆ getHistoFromFile()

std::unique_ptr< TH1 > CP::ShowerDepthUtil::getHistoFromFile ( const char *  fileName,
const char *  histoName 
)
staticprivate

Return TH1* from file given fileName, histoName.

Definition at line 193 of file ShowerDepthUtil.cxx.

194  {
195  std::unique_ptr<TFile> f(TFile::Open(fileName, "READ"));
196  if (!f) {
197  ANA_MSG_LVL_SERIOUS(MSG::WARNING,
198  "Could not open file: \"" << fileName << "\"");
199  return {};
200  }
201  TH1* h = dynamic_cast<TH1*>(f->Get(histoName));
202  if (!h) {
203  ANA_MSG_LVL_SERIOUS(MSG::WARNING, "Could not get histogram: \""
204  << histoName << "\" from file: \""
205  << fileName << "\"");
206  return {};
207  }
208  // The file will be deleted. We take ownership.
209  h->SetDirectory(nullptr);
210  return std::unique_ptr<TH1>(h);
211 }

◆ getRZ()

std::pair< float, float > CP::ShowerDepthUtil::getRZ ( float  eta,
int  sampling 
)
static

Shower depth in R,Z for the given sampling.

Definition at line 111 of file ShowerDepthUtil.cxx.

111  {
112  if ((sampling != 1 && sampling != 2) || (std::abs(eta) > 10)) {
113  ANA_MSG_LVL_SERIOUS(MSG::WARNING,
114  "Invalid sampling, eta: " << sampling << ", " << eta);
115  return std::make_pair(0., 0.);
116  }
117  float depth =
118  (sampling == 1 ? getShowerDepthEM1(eta) : getShowerDepthEM2(eta));
119  if (std::abs(eta) < 1.5)
120  return std::make_pair(depth, depth * std::sinh(eta));
121  return std::make_pair(depth / std::sinh(eta), depth);
122 }

◆ getRZCorrection()

float CP::ShowerDepthUtil::getRZCorrection ( float  eta,
float  phi,
bool  isData = true 
) const

Return the calorimeter displacement in R(Z) for barrel (endcap)

Definition at line 153 of file ShowerDepthUtil.cxx.

154  {
155  // Get the correct histogram.
156  const TH1* histo = (isData ? m_hData.get() : m_hMC.get());
157  if (!histo) {
158  return 0;
159  }
160  // Make sure that we can perform the interpolation in both eta and phi.
161  const Int_t etaBin = histo->GetXaxis()->FindFixBin(eta);
162  if (etaBin < 1) {
163  const float etaOld = eta;
164  eta = histo->GetXaxis()->GetBinLowEdge(1) + epsilon;
165  ANA_MSG_LVL_SERIOUS(MSG::WARNING,
166  "Using eta " << eta << " instead of " << etaOld);
167  } else if (etaBin > histo->GetNbinsX()) {
168  const float etaOld = eta;
169  eta = histo->GetXaxis()->GetBinUpEdge(histo->GetNbinsX()) - epsilon;
170  ANA_MSG_LVL_SERIOUS(MSG::WARNING,
171  "Using eta " << eta << " instead of " << etaOld);
172  }
173  const Int_t phiBin = histo->GetYaxis()->FindFixBin(phi);
174  if (phiBin < 1) {
175  const float phiOld = phi;
176  phi = histo->GetYaxis()->GetBinLowEdge(1) + epsilon;
177  ANA_MSG_LVL_SERIOUS(MSG::WARNING,
178  "Using phi " << phi << " instead of " << phiOld);
179  } else if (phiBin > histo->GetNbinsY()) {
180  const float phiOld = phi;
181  phi = histo->GetYaxis()->GetBinUpEdge(histo->GetNbinsY()) - epsilon;
182  ANA_MSG_LVL_SERIOUS(MSG::WARNING,
183  "Using phi " << phi << " instead of " << phiOld);
184  }
185  // Get the correction as an interpolation.
186  return histo->Interpolate(eta, phi);
187 }

◆ getShowerDepthEM1()

float CP::ShowerDepthUtil::getShowerDepthEM1 ( float  etas1)
static

Shower depth (in mm) vs.

Return the shower depth in sampling 1.

eta on EM1

Found by finding the depth where the eta resolution is optimal. See Calorimeter/CaloDetDescr/src/CaloDepthTool.cxx

Definition at line 65 of file ShowerDepthUtil.cxx.

65  {
66  float radius, aetas1 = std::abs(etas1);
67  if (aetas1 < 0.8) {
68  radius = (1558.859292 - 4.990838 * aetas1 - 21.144279 * aetas1 * aetas1);
69  } else if (aetas1 < 1.5) {
70  radius = (1522.775373 + 27.970192 * aetas1 - 21.104108 * aetas1 * aetas1);
71  } else {
72  // endcap so Z
73  radius = 3790.671754;
74  }
75  if (etas1 < 0. and aetas1 > 1.5) {
76  // negative endcap
77  return -radius;
78  }
79  return radius;
80 }

◆ getShowerDepthEM2()

float CP::ShowerDepthUtil::getShowerDepthEM2 ( float  etas2)
static

Shower depth (in mm) vs.

Return the shower depth in sampling 1.

eta on EM2

Found by finding the depth where the eta resolution is optimal. See Calorimeter/CaloDetDescr/src/CaloDepthTool.cxx

Definition at line 87 of file ShowerDepthUtil.cxx.

87  {
88  float radius, aetas2 = std::abs(etas2);
89  if (aetas2 < 1.425) { // Barrel
90  radius = (1698.990944 - 49.431767 * aetas2 - 24.504976 * aetas2 * aetas2);
91  } else if (aetas2 < 1.5) { // EME2 in tool
92  radius = (8027.574119 - 2717.653528 * aetas2);
93  } else {
94  // endcap so Z
95  radius = (3473.473909 + 453.941515 * aetas2 - 119.101945 * aetas2 * aetas2);
96  }
97  if (etas2 < 0. and aetas2 > 1.5) {
98  // negative endcap
99  return -radius;
100  }
101  return radius;
102 }

Member Data Documentation

◆ m_hData

std::unique_ptr<TH1> CP::ShowerDepthUtil::m_hData
private

Definition at line 61 of file ShowerDepthUtil.h.

◆ m_hMC

std::unique_ptr<TH1> CP::ShowerDepthUtil::m_hMC
private

Definition at line 62 of file ShowerDepthUtil.h.


The documentation for this class was generated from the following files:
test_pyathena.eta
eta
Definition: test_pyathena.py:10
egammaParameters::depth
@ depth
pointing depth of the shower as calculated in egammaqgcld
Definition: egammaParamDefs.h:276
egammaParameters::zvertex
@ zvertex
pointing z at vertex reconstructed from the cluster
Definition: egammaParamDefs.h:270
CP::ShowerDepthUtil::m_hMC
std::unique_ptr< TH1 > m_hMC
Definition: ShowerDepthUtil.h:62
xAOD::phi
setEt phi
Definition: TrigEMCluster_v1.cxx:29
xAOD::etaBin
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap etaBin
Definition: L2StandAloneMuon_v1.cxx:148
CP::ShowerDepthUtil::getShowerDepthEM2
static float getShowerDepthEM2(float etas2)
Shower depth (in mm) vs.
Definition: ShowerDepthUtil.cxx:87
z
#define z
h
CP::ShowerDepthUtil::getHistoFromFile
static std::unique_ptr< TH1 > getHistoFromFile(const char *fileName, const char *histoName)
Return TH1* from file given fileName, histoName.
Definition: ShowerDepthUtil.cxx:193
hist_file_dump.f
f
Definition: hist_file_dump.py:141
python.Dumpers.asinh
def asinh(x)
helper methods ---------------------------------------------------------—
Definition: Dumpers.py:89
CP::ShowerDepthUtil::getCorrectedShowerDepthEM1
float getCorrectedShowerDepthEM1(float etas1, float phi, bool isData=true) const
Shower depth (in mm) on EM1 vs.
Definition: ShowerDepthUtil.cxx:49
CP::ShowerDepthUtil::getShowerDepthEM1
static float getShowerDepthEM1(float etas1)
Shower depth (in mm) vs.
Definition: ShowerDepthUtil.cxx:65
xAOD::phiBin
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setPhiMap phiBin
Definition: L2StandAloneMuon_v2.cxx:144
CP::ShowerDepthUtil::getEtaDirection
static float getEtaDirection(float zvertex, float R, float z)
Definition: ShowerDepthUtil.cxx:189
CP::ShowerDepthUtil::getCorrectedRZ
std::pair< float, float > getCorrectedRZ(float eta, float phi, bool isData=true, int sampling=1) const
Return the shower depth in R,Z considering misalignments.
Definition: ShowerDepthUtil.cxx:137
ANA_MSG_LVL_SERIOUS
#define ANA_MSG_LVL_SERIOUS(lvl, xmsg)
Macro used to print "serious" messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:270
ParticleGun_SamplingFraction.radius
radius
Definition: ParticleGun_SamplingFraction.py:96
CP::ShowerDepthUtil::getCorrectedShowerDepthEM2
float getCorrectedShowerDepthEM2(float etas2, float phi, bool isData=true) const
Shower depth (in mm) on EM2 vs.
Definition: ShowerDepthUtil.cxx:55
PathResolverFindCalibFile
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Definition: PathResolver.cxx:431
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
CP::ShowerDepthUtil::m_hData
std::unique_ptr< TH1 > m_hData
Definition: ShowerDepthUtil.h:61
jobOptions.fileName
fileName
Definition: jobOptions.SuperChic_ALP2.py:39
plotBeamSpotCompare.histo
histo
Definition: plotBeamSpotCompare.py:415
CP::ShowerDepthUtil::getRZCorrection
float getRZCorrection(float eta, float phi, bool isData=true) const
Return the calorimeter displacement in R(Z) for barrel (endcap)
Definition: ShowerDepthUtil.cxx:153