101 cout << __func__ <<
' ' << slice <<
" start" << endl;
104 auto tIn = flow.GetInputTree(slice);
105 auto [fOut, tOut] = flow.GetOutput(output);
108 auto isMC = metainfo.Get<
bool>(
"flags",
"isMC");
109 auto year = metainfo.Get<
int>(
"flags",
"year");
111 auto gEv =
isMC ? flow.GetBranchReadOnly<GenEvent>(
"genEvent") :
nullptr;
112 auto rEv = flow.GetBranchReadOnly<RecEvent>(
"recEvent");
113 auto met = flow.GetBranchReadOnly<MET >(
"met" );
114 auto recJets = flow.GetBranchReadOnly<vector<RecJet>>(
"recJets");
116 if (!metainfo.Find(
"corrections",
"METfilters"))
117 BOOST_THROW_EXCEPTION(
DE::BadInput(
"No MET filters in this tree", tOut) );
119 fs::path p_METfilters =
config.get<fs::path>(
"corrections.METfilters");
120 if (metainfo.Get<fs::path>(
"corrections",
"METfilters") != p_METfilters) {
121 cerr <<
orange <<
"You are now using a different list of MET filters w.r.t. n-tuplisation.\n" <<
def;
122 metainfo.Set<
bool>(
"git",
"reproducible",
false);
124 MissingET::Filters metfilters(p_METfilters);
128 MissingET::FractionCut beforeCut(
"beforeMETcut"),
129 afterCut(
"afterMETcut");
131 ControlPlots METbefore(
"METbefore"),
132 METafterAllMETfilters(
"METafterAllMETfilters"),
133 METafterMETfraction(
"METafterMETfraction"),
134 METafterAllMETfiltersAndMETfraction(
"METafterAllMETfiltersAndMETfraction");
137 for (
const string& METname: metfilters.names)
140 auto totRecWgt = [&](
size_t i) {
141 return (
isMC ? gEv->weights.front().v : 1) * rEv->weights.at(i).v;
144 for (
DT::Looper looper(tIn); looper(); ++looper) {
148 beforeCut.Fill(
met, recJets, totRecWgt(0));
149 METbefore(*recJets, totRecWgt(0));
152 afterCut.Fill(
met, recJets, totRecWgt(0));
153 METafterMETfraction(*recJets, totRecWgt(0));
159 metfilters(*
met, *rEv);
161 METafterAllMETfilters(*recJets, totRecWgt(0));
164 METafterAllMETfiltersAndMETfraction(*recJets, totRecWgt(0));
166 if (steering &
DT::fill) tOut->Fill();
169 cout <<
"Saving MET variables before and after the MET fraction cut" << endl;
170 auto dMETcut = fOut->mkdir(
"METfraction");
171 beforeCut.Write(dMETcut);
172 afterCut.Write(dMETcut);
174 cout <<
"Saving control observables before and after the MET fraction cut and/or MET filters" << endl;
175 auto dCP = fOut->mkdir(
"controlplots");
176 METbefore.Write(dCP);
177 METafterMETfraction.Write(dCP);
178 METafterAllMETfilters.Write(dCP);
179 METafterAllMETfiltersAndMETfraction.Write(dCP);
181 cout <<
"Saving control observables for each MET filter individually" << endl;
182 auto dMETfilters = fOut->mkdir(
"METfilters");
184 filt.Write(dMETfilters);
186 metainfo.Set<
bool>(
"git",
"complete",
true);
188 cout << __func__ <<
' ' << slice <<
" end" << endl;