23 static const char*
const CONFIG_FILE_NAME =
24 "ElectronIsolationSelection/v1/CaloDeltaRZ.root";
25 static const char*
const DATA_HISTO_NAME =
"hData";
26 static const char*
const MC_HISTO_NAME =
"hMC";
30 using namespace ShowerDepthToolMessaging;
38 m_hData = getHistoFromFile(
filename.c_str(), DATA_HISTO_NAME);
39 m_hMC = getHistoFromFile(
filename.c_str(), MC_HISTO_NAME);
41 return (m_hData && m_hMC);
47 return getShowerDepthEM1(etas1) - getRZCorrection(etas1,
phi, isData);
53 return getShowerDepthEM2(etas2) - getRZCorrection(etas2,
phi, isData);
62 float radius, aetas1 = std::abs(etas1);
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);
71 if (etas1 < 0. and aetas1 > 1.5) {
84 float radius, aetas2 = std::abs(etas2);
86 radius = (1698.990944 - 49.431767 * aetas2 - 24.504976 * aetas2 * aetas2);
87 }
else if (aetas2 < 1.5) {
88 radius = (8027.574119 - 2717.653528 * aetas2);
91 radius = (3473.473909 + 453.941515 * aetas2 - 119.101945 * aetas2 * aetas2);
93 if (etas2 < 0. and aetas2 > 1.5) {
101 float phi,
bool isData,
102 int sampling)
const {
103 std::pair<float, float> RZ = getCorrectedRZ(eta,
phi, isData, sampling);
104 return getEtaDirection(
zvertex, RZ.first, RZ.second);
108 if ((sampling != 1 && sampling != 2) || (std::abs(eta) > 10)) {
110 "Invalid sampling, eta: " << sampling <<
", " << eta);
111 return std::make_pair(0., 0.);
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);
121 float etas2,
float phi,
123 std::pair<float, float> RZ1 = getCorrectedRZ(etas1,
phi, isData, 1);
124 std::pair<float, float> RZ2 = getCorrectedRZ(etas2,
phi, isData, 2);
127 constexpr
float epsilon = 1
e-6;
128 if (std::abs(RZ2.first - RZ1.first) < epsilon){
132 return {
std::asinh((RZ2.second - RZ1.second) / (RZ2.first - RZ1.first))};
137 int sampling)
const {
138 if ((sampling != 1 && sampling != 2) || (std::abs(eta) > 10)) {
140 "Invalid sampling, eta: " << sampling <<
", " << eta);
141 return std::make_pair(0., 0.);
143 float depth = (sampling == 1 ? getCorrectedShowerDepthEM1(eta,
phi, isData)
144 : getCorrectedShowerDepthEM2(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);
154 const TH1*
histo = (isData ? m_hData.get() : m_hMC.get());
161 static constexpr
float epsilon = 1
e-6
f;
162 const Int_t
etaBin =
histo->GetXaxis()->FindFixBin(eta);
164 const float etaOld = eta;
165 eta =
histo->GetXaxis()->GetBinLowEdge(1) + epsilon;
167 "Using eta " << eta <<
" instead of " << etaOld);
169 const float etaOld = eta;
170 eta =
histo->GetXaxis()->GetBinUpEdge(
histo->GetNbinsX()) - epsilon;
172 "Using eta " << eta <<
" instead of " << etaOld);
176 const float phiOld =
phi;
177 phi =
histo->GetYaxis()->GetBinLowEdge(1) + epsilon;
179 "Using phi " <<
phi <<
" instead of " << phiOld);
181 const float phiOld =
phi;
182 phi =
histo->GetYaxis()->GetBinUpEdge(
histo->GetNbinsY()) - epsilon;
184 "Using phi " <<
phi <<
" instead of " << phiOld);
187 return histo->Interpolate(eta,
phi);
195 const char* histoName) {
196 std::unique_ptr<TFile>
f(TFile::Open(
fileName,
"READ"));
199 "Could not open file: \"" <<
fileName <<
"\"");
202 TH1*
h =
dynamic_cast<TH1*
>(
f->Get(histoName));
205 << histoName <<
"\" from file: \""
210 h->SetDirectory(
nullptr);
211 return std::unique_ptr<TH1>(
h);