18 get_object(TFile&
file,
const std::string&
name)
22 throw std::runtime_error(
"object " +
name +
" not found");
24 obj->SetDirectory(
nullptr);
25 return std::unique_ptr<T>(
obj);
32 static const std::map<std::string, std::array<std::string, 4>> fileMap = {
34 {
"ElectronPhotonFourMomentumCorrection/v5/"
35 "resolutionFit_electron_run1.root",
36 "ElectronPhotonFourMomentumCorrection/v5/"
37 "resolutionFit_recoUnconv_run1.root",
38 "ElectronPhotonFourMomentumCorrection/v5/"
39 "resolutionFit_recoConv_run1.root",
40 "ElectronPhotonFourMomentumCorrection/v5/"
41 "resolutionFit_trueUnconv_run1.root"}},
43 {
"ElectronPhotonFourMomentumCorrection/v5/"
44 "resolutionFit_electron_run2_pre.root",
45 "ElectronPhotonFourMomentumCorrection/v5/"
46 "resolutionFit_recoUnconv_run2_pre.root",
47 "ElectronPhotonFourMomentumCorrection/v5/"
48 "resolutionFit_recoConv_run2_pre.root",
49 "ElectronPhotonFourMomentumCorrection/v5/"
50 "resolutionFit_trueUnconv_run2_pre.root"}},
52 {
"ElectronPhotonFourMomentumCorrection/v20/"
53 "resolutionFit_electron_run2_release21_es2017_R21_v1.root",
54 "ElectronPhotonFourMomentumCorrection/v20/"
55 "resolutionFit_recoUnconv_run2_release21_es2017_R21_v1.root",
56 "ElectronPhotonFourMomentumCorrection/v20/"
57 "resolutionFit_recoConv_run2_release21_es2017_R21_v1.root",
58 "ElectronPhotonFourMomentumCorrection/v20/"
59 "resolutionFit_trueUnconvertedPhoton_run2_release21_es2017_R21_v1.root"}}};
60 std::unique_ptr<TFile> file0;
61 std::unique_ptr<TFile> file1;
62 std::unique_ptr<TFile> file2;
63 std::unique_ptr<TFile> file3;
65 auto config = fileMap.find(configuration);
67 if (
config != fileMap.end()) {
68 const std::array<std::string, 4>&
files =
config->second;
79 if (!file0 or !file1 or !file2 or !file3) {
80 throw std::runtime_error(
"cannot find input file for resolutions");
84 m_hSampling[0][0] = get_object<TH1>(*file0,
"hsamplingG");
85 m_hSampling[0][1] = get_object<TH1>(*file0,
"hsampling80");
86 m_hSampling[0][2] = get_object<TH1>(*file0,
"hsampling90");
87 m_hSampling[1][0] = get_object<TH1>(*file1,
"hsamplingG");
88 m_hSampling[1][1] = get_object<TH1>(*file1,
"hsampling80");
89 m_hSampling[1][2] = get_object<TH1>(*file1,
"hsampling90");
90 m_hSampling[2][0] = get_object<TH1>(*file2,
"hsamplingG");
91 m_hSampling[2][1] = get_object<TH1>(*file2,
"hsampling80");
92 m_hSampling[2][2] = get_object<TH1>(*file2,
"hsampling90");
93 m_hSampling[3][0] = get_object<TH1>(*file3,
"hsamplingG");
94 m_hSampling[3][1] = get_object<TH1>(*file3,
"hsampling80");
95 m_hSampling[3][2] = get_object<TH1>(*file3,
"hsampling90");
98 m_hNoise[0][0] = get_object<TH1>(*file0,
"hnoiseG");
99 m_hNoise[0][1] = get_object<TH1>(*file0,
"hnoise80");
100 m_hNoise[0][2] = get_object<TH1>(*file0,
"hnoise90");
101 m_hNoise[1][0] = get_object<TH1>(*file1,
"hnoiseG");
102 m_hNoise[1][1] = get_object<TH1>(*file1,
"hnoise80");
103 m_hNoise[1][2] = get_object<TH1>(*file1,
"hnoise90");
104 m_hNoise[2][0] = get_object<TH1>(*file2,
"hnoiseG");
105 m_hNoise[2][1] = get_object<TH1>(*file2,
"hnoise80");
106 m_hNoise[2][2] = get_object<TH1>(*file2,
"hnoise90");
107 m_hNoise[3][0] = get_object<TH1>(*file3,
"hnoiseG");
108 m_hNoise[3][1] = get_object<TH1>(*file3,
"hnoise80");
109 m_hNoise[3][2] = get_object<TH1>(*file3,
"hnoise90");
112 m_hConst[0][0] = get_object<TH1>(*file0,
"hconstG");
113 m_hConst[0][1] = get_object<TH1>(*file0,
"hconst80");
114 m_hConst[0][2] = get_object<TH1>(*file0,
"hconst90");
115 m_hConst[1][0] = get_object<TH1>(*file1,
"hconstG");
116 m_hConst[1][1] = get_object<TH1>(*file1,
"hconst80");
117 m_hConst[1][2] = get_object<TH1>(*file1,
"hconst90");
118 m_hConst[2][0] = get_object<TH1>(*file2,
"hconstG");
119 m_hConst[2][1] = get_object<TH1>(*file2,
"hconst80");
120 m_hConst[2][2] = get_object<TH1>(*file2,
"hconst90");
121 m_hConst[3][0] = get_object<TH1>(*file3,
"hconstG");
122 m_hConst[3][1] = get_object<TH1>(*file3,
"hconst80");
123 m_hConst[3][2] = get_object<TH1>(*file3,
"hconst90");
139 int resolution_type)
const
142 if (particle_type < 0 || particle_type > 3) {
143 throw std::runtime_error(
"particle type must be 1, 2 or 3");
146 if (resolution_type < 0 || resolution_type > 2) {
147 throw std::runtime_error(
"resolution type must be 0, 1, 2");
150 const float aeta = std::abs(
eta);
154 if (aeta < m_etaBins->GetAt(
i)) {
161 if (ibinEta < 0 || ibinEta >=
m_etaBins->GetSize()) {
162 throw std::runtime_error(
"eta outside range");
165 const double energyGeV =
energy * 1
E-3;
166 const double rsampling =
168 const double rnoise =
170 const double rconst =
173 const double sigma2 = rsampling * rsampling / energyGeV +
174 rnoise * rnoise / energyGeV / energyGeV +
181 int resolution_type)
const
191 const double Rconv =
static_cast<float>(hypot(
pos.x(),
pos.y()));
192 if (Rconv > 0 and Rconv < 800) {