14 template <
typename TargetPtr,
typename SourcePtr>
15 TargetPtr checked_cast(SourcePtr ptr) {
17 "attempt to cast to no ptr object");
19 "attempt to cast from no ptr object");
21 throw std::runtime_error(
22 "Attempt to cast from nullptr in get_MaterialResolutionEffect");
24 TargetPtr
obj =
dynamic_cast<TargetPtr
>(ptr);
26 throw std::runtime_error(
"failed dynamic cast for " +
27 std::string(ptr->GetName()) +
28 " get_MaterialResolutionEffect");
35 :
asg::AsgMessaging(
"get_MaterialResolutionEffect") {
37 const std::string pType[3] = {
"Elec",
"Unconv",
"Conv"};
38 const std::string sType[
s_nSys] = {
"A",
"CD",
"EL",
"FMX"};
41 "ElectronPhotonFourMomentumCorrection/v8/"
42 "histos-systematics-material.root");
44 std::unique_ptr<TFile> file0(TFile::Open(
filename.c_str(),
"READ"));
46 for (Int_t isys = 0; isys <
s_nSys; isys++) {
47 for (Int_t ieta = 0; ieta <
s_nEtaBins; ieta++) {
48 for (Int_t iconv = 0; iconv < 3;
51 sprintf(
name,
"syst%s_%s_etaBin_%d", pType[iconv].c_str(),
52 sType[isys].c_str(), ieta);
54 checked_cast<TH1*>(file0->Get(
name)));
55 m_hSystPeak.at(isys).at(ieta).at(iconv)->SetDirectory(
nullptr);
57 sprintf(
name,
"syst%s_sigmaG_%s_etaBin_%d", pType[iconv].c_str(),
58 sType[isys].c_str(), ieta);
60 checked_cast<TH1*>(file0->Get(
name)));
61 m_hSystResol.at(isys).at(ieta).at(iconv)->SetDirectory(
nullptr);
68 checked_cast<TH2*>(file0->Get(
"systElec_IBLPP0")));
72 checked_cast<TH2*>(file0->Get(
"systUnconv_IBLPP0")));
76 checked_cast<TH2*>(file0->Get(
"systConv_IBLPP0")));
93 double eta,
int response_type,
97 if (particle_type < 0 || particle_type > 2)
99 if (response_type < 0 || response_type > 1)
102 float aeta = std::fabs(
eta);
103 double energyGeV =
energy * 0.001;
104 double et = energyGeV / cosh(
eta);
125 }
else if (aeta < 0.8) {
127 }
else if (aeta < 1.1) {
129 }
else if (aeta < 1.37) {
131 }
else if (aeta < 1.52) {
133 }
else if (aeta < 1.80) {
135 }
else if (aeta < 2.10) {
141 int ibinEt =
m_etBins->GetSize() - 2;
149 if (response_type == 0) {
153 ->GetBinContent(ibinEt + 1);
158 ->GetBinContent(ibinEt + 1);