80 decorator_prefix = _resolve_reco_partons_prefix(self.
topology, self.outputName)
81 alg = config.createAlgorithm(
82 "EventReco::RunHyPERAlg", f
"RunHyPERAlg_{decorator_prefix}"
85 alg.btagger = self.btagger
86 alg.electrons, alg.electronSelection = config.readNameAndSelection(
89 alg.muons, alg.muonSelection = config.readNameAndSelection(self.muons)
90 alg.jets, alg.jetSelection = config.readNameAndSelection(self.jets)
91 alg.met = config.readName(self.met)
92 alg.eventSelection = self.eventSelection
95 if self.fullLogEventNumber > 0:
96 if self.OutputLevel != 3:
98 "OutputLevel must be 3 (INFO) when tracing only one particular event!"
101 alg.OutputLevel = self.OutputLevel
102 alg.fullLogEventNumber = self.fullLogEventNumber
104 def form_even_odd_path(topology, run):
105 base_path =
"TopReconstruction/HyPERModels/" + topology
106 even_path = base_path +
"_" + run +
"_trained_on_even.onnx"
107 odd_path = base_path +
"_" + run +
"_trained_on_odd.onnx"
108 return even_path, odd_path
111 if config.geometry() == LHCPeriod.Run2:
113 even_path, odd_path = form_even_odd_path(
114 "TtbarAllHadronic",
"run2"
117 even_path, odd_path = form_even_odd_path(
120 elif self.
topology ==
"TtbarLJetsNoBTag":
121 even_path, odd_path = form_even_odd_path(
122 "TtbarLJetsNoBTag",
"run2"
124 elif self.
topology ==
"TtbarDiLepton":
125 even_path, odd_path = form_even_odd_path(
130 print(
"Not being able to set the model paths for the given topology.")
131 raise ValueError(
"Unknown topology: " + self.
topology)
132 elif config.geometry() == LHCPeriod.Run3:
133 if self.
topology ==
"TtbarAllHadronic":
134 even_path, odd_path = form_even_odd_path(
135 "TtbarAllHadronic",
"run3"
138 even_path, odd_path = form_even_odd_path(
141 elif self.
topology ==
"TtbarLJetsNoBTag":
142 even_path, odd_path = form_even_odd_path(
143 "TtbarLJetsNoBTag",
"run3"
145 elif self.
topology ==
"TtbarDiLepton":
146 even_path, odd_path = form_even_odd_path(
147 "TtbarDiLepton",
"run3"
150 print(
"Not being able to set the model paths for the given topology.")
151 raise ValueError(
"Unknown topology: " + self.
topology)
153 print(
"Not being able to set the model paths for the given run period.")
155 "HyPER models not available for run period: " + config.geometry()
161 for handle, model_path
in (
162 (
"onnxToolTrainedOnEven", even_path),
163 (
"onnxToolTrainedOnOdd", odd_path),
165 config.addPrivateTool(handle,
"AthOnnx::OnnxRuntimeInferenceTool")
166 config.addPrivateTool(
167 handle +
".ORTSessionTool",
"AthOnnx::OnnxRuntimeSessionToolCPU"
169 getattr(alg, handle).ORTSessionTool.ModelFileName = model_path
172 if self.
topology ==
"TtbarDiLepton":
173 alg.top_b_p4 = decorator_prefix +
"_Top_b_p4_%SYS%"
174 alg.topbar_bbar_p4 = decorator_prefix +
"_Topbar_bbar_p4_%SYS%"
175 alg.top_lep_p4 = decorator_prefix +
"_Top_lep_p4_%SYS%"
176 alg.topbar_lepbar_p4 = decorator_prefix +
"_Topbar_lepbar_p4_%SYS%"
177 if self.
topology ==
"TtbarAllHadronic":
178 alg.top_b_p4 = decorator_prefix +
"_Top_b_p4_%SYS%"
179 alg.topbar_bbar_p4 = decorator_prefix +
"_Topbar_bbar_p4_%SYS%"
180 alg.top_Wplus_decay0_p4 = (
181 decorator_prefix +
"_Top_Wplus_decay0_p4_%SYS%"
183 alg.top_Wplus_decay1_p4 = (
184 decorator_prefix +
"_Top_Wplus_decay1_p4_%SYS%"
186 alg.topbar_Wminus_decay0_p4 = (
187 decorator_prefix +
"_Topbar_Wminus_decay0_p4_%SYS%"
189 alg.topbar_Wminus_decay1_p4 = (
190 decorator_prefix +
"_Topbar_Wminus_decay1_p4_%SYS%"
192 if self.
topology in [
"TtbarLJets",
"TtbarLJetsNoBTag"]:
193 alg.toplep_b_p4 = decorator_prefix +
"_TopLep_b_p4_%SYS%"
194 alg.toplep_lep_p4 = decorator_prefix +
"_TopLep_lep_p4_%SYS%"
195 alg.tophad_b_p4 = decorator_prefix +
"_TopHad_b_p4_%SYS%"
196 alg.tophad_w_decay0_p4 = decorator_prefix +
"_TopHad_W_decay0_p4_%SYS%"
197 alg.tophad_w_decay1_p4 = decorator_prefix +
"_TopHad_W_decay1_p4_%SYS%"
200 if self.
topology ==
"TtbarAllHadronic":
203 "TtbarAllHadronic_HyPER_Top1_Indices_%SYS%",
204 f
"{decorator_prefix}_Top1_Indices",
205 auxType=
"vector_int",
209 "TtbarAllHadronic_HyPER_Top1_Score_%SYS%",
210 f
"{decorator_prefix}_Top1_Score",
215 "TtbarAllHadronic_HyPER_Top2_Indices_%SYS%",
216 f
"{decorator_prefix}_Top2_Indices",
217 auxType=
"vector_int",
221 "TtbarAllHadronic_HyPER_Top2_Score_%SYS%",
222 f
"{decorator_prefix}_Top2_Score",
227 "TtbarAllHadronic_HyPER_W1_Indices_%SYS%",
228 f
"{decorator_prefix}_W1_Indices",
229 auxType=
"vector_int",
233 "TtbarAllHadronic_HyPER_W1_Score_%SYS%",
234 f
"{decorator_prefix}_W1_Score",
239 "TtbarAllHadronic_HyPER_W2_Indices_%SYS%",
240 f
"{decorator_prefix}_W2_Indices",
241 auxType=
"vector_int",
245 "TtbarAllHadronic_HyPER_W2_Score_%SYS%",
246 f
"{decorator_prefix}_W2_Score",
251 (
"top_b_p4", decorator_prefix +
"_Top_b_p4"),
252 (
"topbar_bbar_p4", decorator_prefix +
"_Topbar_bbar_p4"),
254 "top_Wplus_decay0_p4",
255 decorator_prefix +
"_Top_Wplus_decay0_p4",
258 "top_Wplus_decay1_p4",
259 decorator_prefix +
"_Top_Wplus_decay1_p4",
262 "topbar_Wminus_decay0_p4",
263 decorator_prefix +
"_Topbar_Wminus_decay0_p4",
266 "topbar_Wminus_decay1_p4",
267 decorator_prefix +
"_Topbar_Wminus_decay1_p4",
272 getattr(alg, output_var[0]),
274 auxType=
"PtEtaPhiMVector",
280 "TtbarLJets_HyPER_Classification_Score_%SYS%",
281 f
"{decorator_prefix}_Classification_Score",
286 "TtbarLJets_HyPER_TopHad_Indices_%SYS%",
287 f
"{decorator_prefix}_TopHad_Indices",
288 auxType=
"vector_int",
292 "TtbarLJets_HyPER_TopHad_Score_%SYS%",
293 f
"{decorator_prefix}_TopHad_Score",
298 "TtbarLJets_HyPER_TopHad_IDs_%SYS%",
299 f
"{decorator_prefix}_TopHad_IDs",
300 auxType=
"vector_int",
304 "TtbarLJets_HyPER_TopLep_Indices_%SYS%",
305 f
"{decorator_prefix}_TopLep_Indices",
306 auxType=
"vector_int",
310 "TtbarLJets_HyPER_TopLep_Score_%SYS%",
311 f
"{decorator_prefix}_TopLep_Score",
316 "TtbarLJets_HyPER_TopLep_IDs_%SYS%",
317 f
"{decorator_prefix}_TopLep_IDs",
318 auxType=
"vector_int",
322 "TtbarLJets_HyPER_WHad_Indices_%SYS%",
323 f
"{decorator_prefix}_WHad_Indices",
324 auxType=
"vector_int",
328 "TtbarLJets_HyPER_WHad_Score_%SYS%",
329 f
"{decorator_prefix}_WHad_Score",
334 "TtbarLJets_HyPER_WLep_Indices_%SYS%",
335 f
"{decorator_prefix}_WLep_Indices",
336 auxType=
"vector_int",
340 "TtbarLJets_HyPER_WLep_Score_%SYS%",
341 f
"{decorator_prefix}_WLep_Score",
346 (
"toplep_b_p4", decorator_prefix +
"_TopLep_b_p4"),
347 (
"toplep_lep_p4", decorator_prefix +
"_TopLep_lep_p4"),
348 (
"tophad_b_p4", decorator_prefix +
"_TopHad_b_p4"),
350 "tophad_w_decay0_p4",
351 decorator_prefix +
"_TopHad_W_decay0_p4",
354 "tophad_w_decay1_p4",
355 decorator_prefix +
"_TopHad_W_decay1_p4",
360 getattr(alg, output_var[0]),
362 auxType=
"PtEtaPhiMVector",
365 elif self.
topology ==
"TtbarDiLepton":
368 "TtbarDiLepton_HyPER_Classification_Score_%SYS%",
369 f
"{decorator_prefix}_Classification_Score",
374 "TtbarDiLepton_HyPER_Top1_Indices_%SYS%",
375 f
"{decorator_prefix}_Top1_Indices",
376 auxType=
"vector_int",
380 "TtbarDiLepton_HyPER_Top1_IDs_%SYS%",
381 f
"{decorator_prefix}_Top1_IDs",
382 auxType=
"vector_int",
386 "TtbarDiLepton_HyPER_Top1_Score_%SYS%",
387 f
"{decorator_prefix}_Top1_Score",
392 "TtbarDiLepton_HyPER_Top2_Indices_%SYS%",
393 f
"{decorator_prefix}_Top2_Indices",
394 auxType=
"vector_int",
398 "TtbarDiLepton_HyPER_Top2_Score_%SYS%",
399 f
"{decorator_prefix}_Top2_Score",
404 "TtbarDiLepton_HyPER_Top2_IDs_%SYS%",
405 f
"{decorator_prefix}_Top2_IDs",
406 auxType=
"vector_int",
410 "TtbarDiLepton_HyPER_HE_Score_%SYS%",
411 f
"{decorator_prefix}_HE_Score",
417 (
"top_b_p4", decorator_prefix +
"_Top_b_p4"),
418 (
"topbar_bbar_p4", decorator_prefix +
"_Topbar_bbar_p4"),
421 decorator_prefix +
"_Top_lep_p4",
425 decorator_prefix +
"_Topbar_lepbar_p4",
430 getattr(alg, output_var[0]),
432 auxType=
"PtEtaPhiMVector",
436 raise ValueError(
"Unknown topology: " + self.
topology)