25const char*
const CONFIG_FILE_NAME =
26 "ElectronIsolationSelection/v1/CaloDeltaRZ.root";
27const char*
const DATA_HISTO_NAME =
"hData";
28const char*
const MC_HISTO_NAME =
"hMC";
36using namespace ShowerDepthUtilMessaging;
44 throw std::runtime_error(
"Could not create instance of ShowerDepthUtil");
66 float radius, aetas1 = std::abs(etas1);
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);
75 if (etas1 < 0. and aetas1 > 1.5) {
88 float radius, aetas2 = std::abs(etas2);
90 radius = (1698.990944 - 49.431767 * aetas2 - 24.504976 * aetas2 * aetas2);
91 }
else if (aetas2 < 1.5) {
92 radius = (8027.574119 - 2717.653528 * aetas2);
95 radius = (3473.473909 + 453.941515 * aetas2 - 119.101945 * aetas2 * aetas2);
97 if (etas2 < 0. and aetas2 > 1.5) {
105 float phi,
bool isData,
106 int sampling)
const {
112 if ((sampling != 1 && sampling != 2) || (std::abs(
eta) > 10)) {
114 "Invalid sampling, eta: " << sampling <<
", " <<
eta);
115 return std::make_pair(0., 0.);
119 if (std::abs(
eta) < 1.5)
125 float etas2,
float phi,
130 if (std::abs(RZ2.first - RZ1.first) < epsilon) {
134 return {std::asinh((RZ2.second - RZ1.second) / (RZ2.first - RZ1.first))};
139 int sampling)
const {
140 if ((sampling != 1 && sampling != 2) || (std::abs(
eta) > 10)) {
142 "Invalid sampling, eta: " << sampling <<
", " <<
eta);
143 return std::make_pair(0., 0.);
147 if (std::abs(
eta) < 1.5)
156 const TH1* histo = (isData ?
m_hData.get() :
m_hMC.get());
161 const Int_t
etaBin = histo->GetXaxis()->FindFixBin(
eta);
163 const float etaOld =
eta;
164 eta = histo->GetXaxis()->GetBinLowEdge(1) + epsilon;
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;
171 "Using eta " <<
eta <<
" instead of " << etaOld);
173 const Int_t
phiBin = histo->GetYaxis()->FindFixBin(
phi);
175 const float phiOld =
phi;
176 phi = histo->GetYaxis()->GetBinLowEdge(1) + epsilon;
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;
183 "Using phi " <<
phi <<
" instead of " << phiOld);
186 return histo->Interpolate(
eta,
phi);
190 return std::asinh((
z - zvertex) / R);
194 const char* histoName) {
195 std::unique_ptr<TFile> f(TFile::Open(fileName,
"READ"));
198 "Could not open file: \"" << fileName <<
"\"");
201 TH1*
h =
dynamic_cast<TH1*
>(f->Get(histoName));
204 << histoName <<
"\" from file: \""
205 << fileName <<
"\"");
209 h->SetDirectory(
nullptr);
210 return std::unique_ptr<TH1>(
h);
Scalar eta() const
pseudorapidity method
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
float getCorrectedShowerDepthEM1(float etas1, float phi, bool isData=true) const
Shower depth (in mm) on EM1 vs.
std::unique_ptr< TH1 > m_hMC
std::unique_ptr< TH1 > m_hData
std::optional< float > getCaloPointingEta(float etas1, float etas2, float phi, bool isData=true) const
Eta direction from samplings 1 and 2 (pointing)
static float getShowerDepthEM2(float etas2)
Shower depth (in mm) vs.
static std::unique_ptr< TH1 > getHistoFromFile(const char *fileName, const char *histoName)
Return TH1* from file given fileName, histoName.
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.
float getCorrectedShowerDepthEM2(float etas2, float phi, bool isData=true) const
Shower depth (in mm) on EM2 vs.
static float getShowerDepthEM1(float etas1)
Shower depth (in mm) vs.
float getRZCorrection(float eta, float phi, bool isData=true) const
Return the calorimeter displacement in R(Z) for barrel (endcap)
static float getEtaDirection(float zvertex, float R, float z)
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.
static std::pair< float, float > getRZ(float eta, int sampling)
Shower depth in R,Z for the given sampling.
std::string depth
tag string for intendation
Select isolated Photons, Electrons and Muons.
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setPhiMap phiBin
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap etaBin