16 template <
typename TargetPtr,
typename SourcePtr>
17 TargetPtr checked_cast(SourcePtr
ptr) {
19 "attempt to cast to no ptr object");
21 "attempt to cast from no ptr object");
23 throw std::runtime_error(
24 "Attempt to cast from nullptr in get_MaterialResolutionEffect");
26 TargetPtr
obj =
dynamic_cast<TargetPtr
>(
ptr);
28 throw std::runtime_error(
"failed dynamic cast for " +
29 std::string(
ptr->GetName()) +
30 " get_MaterialResolutionEffect");
37 :
asg::AsgMessaging(
"get_MaterialResolutionEffect") {
39 const std::string pType[3] = {
"Elec",
"Unconv",
"Conv"};
40 const std::string sType[
s_nSys] = {
"A",
"CD",
"EL",
"FMX"};
43 "ElectronPhotonFourMomentumCorrection/v8/"
44 "histos-systematics-material.root");
46 std::unique_ptr<TFile> file0(TFile::Open(
filename.c_str(),
"READ"));
48 for (Int_t isys = 0; isys <
s_nSys; isys++) {
49 for (Int_t ieta = 0; ieta <
s_nEtaBins; ieta++) {
50 for (Int_t iconv = 0; iconv < 3;
53 sprintf(
name,
"syst%s_%s_etaBin_%d", pType[iconv].c_str(),
54 sType[isys].c_str(), ieta);
56 checked_cast<TH1*>(file0->Get(
name)));
57 m_hSystPeak.at(isys).at(ieta).at(iconv)->SetDirectory(
nullptr);
59 sprintf(
name,
"syst%s_sigmaG_%s_etaBin_%d", pType[iconv].c_str(),
60 sType[isys].c_str(), ieta);
62 checked_cast<TH1*>(file0->Get(
name)));
63 m_hSystResol.at(isys).at(ieta).at(iconv)->SetDirectory(
nullptr);
70 checked_cast<TH2*>(file0->Get(
"systElec_IBLPP0")));
74 checked_cast<TH2*>(file0->Get(
"systUnconv_IBLPP0")));
78 checked_cast<TH2*>(file0->Get(
"systConv_IBLPP0")));
95 double eta,
int response_type,
99 if (particle_type < 0 || particle_type > 2)
101 if (response_type < 0 || response_type > 1)
104 float aeta = std::fabs(
eta);
105 double energyGeV =
energy * 0.001;
106 double et = energyGeV / cosh(
eta);
117 if (aeta>=2.5) aeta=2.49;
132 }
else if (aeta < 0.8) {
134 }
else if (aeta < 1.1) {
136 }
else if (aeta < 1.37) {
138 }
else if (aeta < 1.52) {
140 }
else if (aeta < 1.80) {
142 }
else if (aeta < 2.10) {
148 int ibinEt =
m_etBins->GetSize() - 2;
173 for (
int ieta : std::views::iota(1,
nEtaBins + 1)) {
185 if (!
hist)
return 0.;
188 if(x<=hist->GetBinCenter(1)) {
189 return abs_bins? std::abs(
hist->GetBinContent(1)) :
hist->GetBinContent(1);
195 int xbin =
hist->FindBin(
x);
197 if(x<=hist->GetBinCenter(xbin)) {
205 double y0 = abs_bins? std::abs(
hist->GetBinContent(xbin0)) :
hist->GetBinContent(xbin0);
206 double x0 =
hist->GetBinCenter(xbin0);
207 double y1 = abs_bins? std::abs(
hist->GetBinContent(xbin1)) :
hist->GetBinContent(xbin1);
208 double x1 =
hist->GetBinCenter(xbin1);
209 return y0 + (
x-x0)*((
y1-y0)/(
x1-x0));