Obtain photon plots.
93 cout << __func__ <<
' ' << slice <<
" start" << endl;
96 auto tIn = flow.GetInputTree(slice);
97 auto [fOut,tOut] = flow.GetOutput(output);
100 auto isMC = metainfo.Get<
bool>(
"flags",
"isMC");
101 JMEmatching<vector<RecPhoton>, vector<GenPhoton>>::maxDR = 0.1;
103 auto recEvt = flow.GetBranchReadOnly<RecEvent>(
"recEvent");
104 auto genEvt =
isMC ? flow.GetBranchReadOnly<GenEvent>(
"genEvent") :
nullptr;
106 auto recPhotons = flow.GetBranchReadOnly<vector<RecPhoton>>(
"recPhotons");
107 auto genPhotons =
isMC ? flow.GetBranchReadOnly<vector<GenPhoton>>(
"genPhotons") :
nullptr;
109 map<TString, PerformanceHist> histograms;
110 for (TString
name: {
"rec",
"gen"}) {
111 histograms.insert({
name, PerformanceHist(
name)});
113 histograms.insert({
name, PerformanceHist(
name)});
116 vector<double> pt_eff_edges {0, 10, 20, 35, 50, 65, 80, 100, 120, 150, 200, 500};
117 TEfficiency h_eff_fake_ph(
"eff_fake_ph",
"", pt_eff_edges.size() - 1, pt_eff_edges.data(),
119 TEfficiency h_eff_miss_ph(
"eff_miss_ph",
"", pt_eff_edges.size() - 1, pt_eff_edges.data(),
122 for (
DT::Looper looper(tIn); looper(); ++looper) {
126 double w_rec_ev = recEvt->Weight(),
129 double w_gen_ev = genEvt->Weight();
133 const float minPt = 20;
135 for (
const auto& recPhoton : *recPhotons) {
136 if (recPhoton.CorrPt() <
minPt)
continue;
137 double w_rec_ph = recPhoton.Weight();
138 histograms.at(
"rec").FillUnmatched(recPhoton, w_ev * w_rec_ph);
143 for (
const auto& genPhoton : *genPhotons) {
144 if (genPhoton.CorrPt() <
minPt)
continue;
145 double w_gen_ph = genPhoton.Weight();
146 histograms.at(
"gen").FillUnmatched(genPhoton, w_ev * w_gen_ph);
150 JMEmatching matching(*recPhotons, *genPhotons);
151 auto fake_its = matching.fake_its;
152 auto miss_its = matching.miss_its;
155 for (
const auto& [rec_it, gen_it]: matching.match_its) {
156 if (rec_it->CorrPt() <
minPt)
continue;
157 if (gen_it->CorrPt() <
minPt)
continue;
160 double w_rec_ph = rec_it->Weight(),
161 w_gen_ph = gen_it->Weight();
163 for (
const auto& rec_it: fake_its) {
164 double w_rec_ph = rec_it->Weight();
165 h_eff_fake_ph.FillWeighted(matched, w_rec_ph, rec_it->CorrPt(), rec_it->CorrP4().Eta());
167 for (
const auto& gen_it: miss_its) {
168 double w_gen_ph = gen_it->Weight();
169 h_eff_miss_ph.FillWeighted(matched, w_gen_ph, gen_it->CorrPt(), gen_it->CorrP4().Eta());
172 histograms.at(
"matched_rec").FillMatched(rec_it, w_ev * w_rec_ph);
173 histograms.at(
"matched_gen").FillMatched(gen_it, w_ev * w_gen_ph);
177 for (
const auto& rec_it: fake_its) {
178 double w_rec_ph = rec_it->Weight();
179 h_eff_fake_ph.FillWeighted(matched, w_rec_ph, rec_it->CorrPt(), rec_it->CorrP4().Eta());
181 for (
const auto& gen_it: miss_its) {
182 double w_gen_ph = gen_it->Weight();
183 h_eff_miss_ph.FillWeighted(matched, w_gen_ph, gen_it->CorrPt(), gen_it->CorrP4().Eta());
187 for (
auto& h: histograms)
188 h.second.Write(fOut);
190 for (
auto eff: {&h_eff_fake_ph, &h_eff_miss_ph}) {
191 eff->SetDirectory(fOut);
195 metainfo.Set<
bool>(
"git",
"complete",
true);
197 cout << __func__ <<
' ' << slice <<
" stop" << endl;