ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
CP::ShowerDepthTool Class Reference

#include <ShowerDepthTool.h>

Collaboration diagram for CP::ShowerDepthTool:

Public Member Functions

 ShowerDepthTool ()
 
 ~ShowerDepthTool ()
 
bool initialize ()
 Function initialising the tool. More...
 
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< TH1getHistoFromFile (const char *fileName, const char *histoName)
 Return TH1* from file given fileName, histoName. More...
 

Private Attributes

std::unique_ptr< TH1m_hData
 
std::unique_ptr< TH1m_hMC
 

Detailed Description

Definition at line 18 of file ShowerDepthTool.h.

Constructor & Destructor Documentation

◆ ShowerDepthTool()

CP::ShowerDepthTool::ShowerDepthTool ( )
default

◆ ~ShowerDepthTool()

CP::ShowerDepthTool::~ShowerDepthTool ( )
default

Member Function Documentation

◆ getCaloPointingEta()

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

Eta direction from samplings 1 and 2 (pointing)

Definition at line 120 of file ShowerDepthTool.cxx.

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

◆ getCorrectedEtaDirection()

float CP::ShowerDepthTool::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 100 of file ShowerDepthTool.cxx.

102  {
103  std::pair<float, float> RZ = getCorrectedRZ(eta, phi, isData, sampling);
104  return getEtaDirection(zvertex, RZ.first, RZ.second);
105 }

◆ getCorrectedRZ()

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

Return the shower depth in R,Z considering misalignments.

Definition at line 135 of file ShowerDepthTool.cxx.

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

◆ getCorrectedShowerDepthEM1()

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

Shower depth (in mm) on EM1 vs.

eta, considering misalignments

Definition at line 45 of file ShowerDepthTool.cxx.

46  {
47  return getShowerDepthEM1(etas1) - getRZCorrection(etas1, phi, isData);
48 }

◆ getCorrectedShowerDepthEM2()

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

Shower depth (in mm) on EM2 vs.

eta, considering misalignments

Definition at line 51 of file ShowerDepthTool.cxx.

52  {
53  return getShowerDepthEM2(etas2) - getRZCorrection(etas2, phi, isData);
54 }

◆ getEtaDirection()

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

Definition at line 190 of file ShowerDepthTool.cxx.

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

◆ getHistoFromFile()

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

Return TH1* from file given fileName, histoName.

Definition at line 194 of file ShowerDepthTool.cxx.

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

◆ getRZ()

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

Shower depth in R,Z for the given sampling.

Definition at line 107 of file ShowerDepthTool.cxx.

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

◆ getRZCorrection()

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

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

Definition at line 151 of file ShowerDepthTool.cxx.

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

◆ getShowerDepthEM1()

float CP::ShowerDepthTool::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 61 of file ShowerDepthTool.cxx.

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

◆ getShowerDepthEM2()

float CP::ShowerDepthTool::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 83 of file ShowerDepthTool.cxx.

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

◆ initialize()

bool CP::ShowerDepthTool::initialize ( )

Function initialising the tool.

Definition at line 35 of file ShowerDepthTool.cxx.

35  {
36  const std::string filename = PathResolverFindCalibFile(CONFIG_FILE_NAME);
37 
38  m_hData = getHistoFromFile(filename.c_str(), DATA_HISTO_NAME);
39  m_hMC = getHistoFromFile(filename.c_str(), MC_HISTO_NAME);
40 
41  return (m_hData && m_hMC);
42 }

Member Data Documentation

◆ m_hData

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

Definition at line 65 of file ShowerDepthTool.h.

◆ m_hMC

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

Definition at line 66 of file ShowerDepthTool.h.


The documentation for this class was generated from the following files:
python.CaloRecoConfig.f
f
Definition: CaloRecoConfig.py:127
CP::ShowerDepthTool::getShowerDepthEM1
static float getShowerDepthEM1(float etas1)
Shower depth (in mm) vs.
Definition: ShowerDepthTool.cxx:61
egammaParameters::depth
@ depth
pointing depth of the shower as calculated in egammaqgcld
Definition: egammaParamDefs.h:276
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
CP::ShowerDepthTool::getRZCorrection
float getRZCorrection(float eta, float phi, bool isData=true) const
Return the calorimeter displacement in R(Z) for barrel (endcap)
Definition: ShowerDepthTool.cxx:151
egammaParameters::zvertex
@ zvertex
pointing z at vertex reconstructed from the cluster
Definition: egammaParamDefs.h:270
CP::ShowerDepthTool::getCorrectedShowerDepthEM1
float getCorrectedShowerDepthEM1(float etas1, float phi, bool isData=true) const
Shower depth (in mm) on EM1 vs.
Definition: ShowerDepthTool.cxx:45
CP::ShowerDepthTool::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: ShowerDepthTool.cxx:135
xAOD::etaBin
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap etaBin
Definition: L2StandAloneMuon_v1.cxx:148
FortranAlgorithmOptions.fileName
fileName
Definition: FortranAlgorithmOptions.py:13
z
#define z
h
CP::ShowerDepthTool::getCorrectedShowerDepthEM2
float getCorrectedShowerDepthEM2(float etas2, float phi, bool isData=true) const
Shower depth (in mm) on EM2 vs.
Definition: ShowerDepthTool.cxx:51
python.Dumpers.asinh
def asinh(x)
helper methods ---------------------------------------------------------—
Definition: Dumpers.py:89
xAOD::phiBin
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setPhiMap phiBin
Definition: L2StandAloneMuon_v2.cxx:144
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::ShowerDepthTool::getShowerDepthEM2
static float getShowerDepthEM2(float etas2)
Shower depth (in mm) vs.
Definition: ShowerDepthTool.cxx:83
PathResolverFindCalibFile
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Definition: PathResolver.cxx:431
CP::ShowerDepthTool::m_hMC
std::unique_ptr< TH1 > m_hMC
Definition: ShowerDepthTool.h:66
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
CP::ShowerDepthTool::getEtaDirection
static float getEtaDirection(float zvertex, float R, float z)
Definition: ShowerDepthTool.cxx:190
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
python.grid.isData
def isData(dataset)
Definition: grid.py:491
plotBeamSpotCompare.histo
histo
Definition: plotBeamSpotCompare.py:415
CP::ShowerDepthTool::m_hData
std::unique_ptr< TH1 > m_hData
Definition: ShowerDepthTool.h:65
CP::ShowerDepthTool::getHistoFromFile
static std::unique_ptr< TH1 > getHistoFromFile(const char *fileName, const char *histoName)
Return TH1* from file given fileName, histoName.
Definition: ShowerDepthTool.cxx:194