ATLAS Offline Software
Loading...
Searching...
No Matches
RunHyPERAlg.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef HYPERANALYSISALGORITHMS_RUNHYPERALG_H
6#define HYPERANALYSISALGORITHMS_RUNHYPERALG_H
7
10
11#include <memory>
12#include <string>
13#include <vector>
14
15// Algorithm includes
18#include <AsgTools/ToolHandle.h>
24
25// Framework includes
31
33
34// HyPER includes
38
39namespace EventReco {
40using ROOT::Math::PtEtaPhiMVector;
41
61
77class RunHyPERAlg final : public EL::AnaAlgorithm {
78 public:
80
81 virtual StatusCode initialize() override;
82 virtual StatusCode execute(const EventContext& ctx) override;
83 virtual StatusCode finalize() override;
84
89 StatusCode buildGraph();
90 StatusCode buildTtbarAllHadronicGraph();
91 StatusCode buildTtbarLJetsGraph();
92 StatusCode buildTtbarDiLeptonGraph();
93 bool buildDileptonPartialCandidate(const std::vector<int>& indices,
94 const std::vector<int>& ids,
95 PtEtaPhiMVector& bJetP4,
96 PtEtaPhiMVector& leptonP4,
97 float& analyserCharge) const;
98 void buildTopP4TtbarAllHadronic(const std::vector<int>& topIndices,
99 const std::vector<int>& wIndices,
100 PtEtaPhiMVector& top_b_p4,
101 PtEtaPhiMVector& top_W_decay0_p4,
102 PtEtaPhiMVector& top_W_decay1_p4);
103 void buildTopP4TtbarLJets(const std::vector<int>& topHadIndices,
104 const std::vector<int>& wHadIndices,
105 const std::vector<int>& topLepIndices,
106 const std::vector<int>& topLepIDs,
107 PtEtaPhiMVector& tophad_b_p4,
108 PtEtaPhiMVector& tophad_w_decay0_p4,
109 PtEtaPhiMVector& tophad_w_decay1_p4,
110 PtEtaPhiMVector& toplep_b_p4,
111 PtEtaPhiMVector& toplep_lep_p4);
112
113
114 private:
115 // Configurable properties from python/yml
116 Gaudi::Property<std::string> m_topology{
117 this, "topology", "",
118 "HyPER topology. Choose between: 'TtbarLJets', 'TtbarLJetsNoBTag', "
119 "'TtbarAllHadronic' and 'TtbarDiLepton'."};
120 Gaudi::Property<std::string> m_btagger{
121 this, "btagger", "GN2v01_Continuous",
122 "Name of the b-tagger and working point for jets. The "
123 "'ftag_quantile_' prefix is added internally."};
124
125 // The b-tagging decoration name derived from m_btagger
126 std::string m_btagDecorName;
127
128 // The Athena ONNX inference tools, one per cross-validation fold. The model
129 // files themselves are configured on each tool's session tool.
130 ToolHandle<AthOnnx::IOnnxRuntimeInferenceTool> m_onnxToolTrainedOnEven{
131 this, "onnxToolTrainedOnEven", "",
132 "ONNX inference tool holding the model trained on even-numbered events"};
133 ToolHandle<AthOnnx::IOnnxRuntimeInferenceTool> m_onnxToolTrainedOnOdd{
134 this, "onnxToolTrainedOnOdd", "",
135 "ONNX inference tool holding the model trained on odd-numbered events"};
136
137 // The onnxruntime model
138 std::unique_ptr<HyPERModel> m_hyperModel;
139 // The HyPER Graph object
140 std::unique_ptr<HyPERGraph> m_hyperGraph;
141 // The inputs from xAOD containers
143 // The HyPER parser object
144 std::unique_ptr<HyPERParser> m_hyperParser;
145 // Number for full log event
146 Gaudi::Property<long unsigned int> m_fullLogEventNumber{
147 this, "fullLogEventNumber", 0,
148 "Number of the event to log in full detail"};
149
150 // Cached topology enum (avoid re-parsing from string every event)
152 // Whether the l+jets topology uses b-tagging features
153 bool m_ljetsUseBTag{false};
154
155 // systematics
157
158 // Input objects needed for reconstruction
159 // Electrons
161 this, "electrons", "", "The electron container to use."};
163 this, "electronSelection", "", "The selection on the input electrons."};
164 // Muons
166 this, "muons", "", "The muon container to use."};
168 this, "muonSelection", "", "The selection on the input muons."};
169 // Jets
171 this, "jets", "", "The jet container to use."};
173 "The selection on the input jets."};
174 // MET
176 this, "met", "", "The MET container to use."};
177 // EventInfo
179 this, "eventInfo", "EventInfo",
180 "The EventInfo container to read selection decisions from."};
181 // Event pre-selection
183 this, "eventSelection", "",
184 "Name of the selection on which this HyPER instance is allowed to run."};
185
186 // Output decorations
187
188 // For TtbarAllHadronic
189 // Indices
192 this, "TtbarAllHadronic_HyPER_Top1_Indices",
193 "TtbarAllHadronic_HyPER_Top1_Indices_%SYS%",
194 "Indices of the reconstructed top1 in the ttbar all-hadronic "
195 "topology"};
198 this, "TtbarAllHadronic_HyPER_Top2_Indices",
199 "TtbarAllHadronic_HyPER_Top2_Indices_%SYS%",
200 "Indices of the reconstructed top2 in the ttbar all-hadronic "
201 "topology"};
203 this, "TtbarAllHadronic_HyPER_W1_Indices",
204 "TtbarAllHadronic_HyPER_W1_Indices_%SYS%",
205 "Indices of the reconstructed W1 in the ttbar all-hadronic topology"};
207 this, "TtbarAllHadronic_HyPER_W2_Indices",
208 "TtbarAllHadronic_HyPER_W2_Indices_%SYS%",
209 "Indices of the reconstructed W2 in the ttbar all-hadronic topology"};
210 // Scores
212 this, "TtbarAllHadronic_HyPER_Top1_Score",
213 "TtbarAllHadronic_HyPER_Top1_Score_%SYS%",
214 "Score of the reconstructed top1 in the ttbar all-hadronic topology"};
216 this, "TtbarAllHadronic_HyPER_Top2_Score",
217 "TtbarAllHadronic_HyPER_Top2_Score_%SYS%",
218 "Score of the reconstructed top2 in the ttbar all-hadronic topology"};
220 this, "TtbarAllHadronic_HyPER_W1_Score",
221 "TtbarAllHadronic_HyPER_W1_Score_%SYS%",
222 "Score of the reconstructed W1 in the ttbar all-hadronic topology"};
224 this, "TtbarAllHadronic_HyPER_W2_Score",
225 "TtbarAllHadronic_HyPER_W2_Score_%SYS%",
226 "Score of the reconstructed W2 in the ttbar all-hadronic topology"};
227 // 4-vector publication for TtbarAllHadronic
228 // The b-quark jets definition is in the TtbarDiLepton tology 4-vectors.
230 this, "top_Wplus_decay0_p4", "",
231 "Visible top W+ leading decay product four-vector associated to the top "
232 "quark"};
234 this, "top_Wplus_decay1_p4", "",
235 "Visible top W+ subleading decay product four-vector associated to the "
236 "top quark"};
238 this, "topbar_Wminus_decay0_p4", "",
239 "Visible anti-top W- leading decay product four-vector associated to the "
240 "anti-top quark"};
242 this, "topbar_Wminus_decay1_p4", "",
243 "Visible anti-top W- subleading decay product four-vector associated to "
244 "the anti-top quark"};
245
246 // For TtbarLJets
247 // Classification score
249 this, "TtbarLJets_HyPER_Classification_Score",
250 "TtbarLJets_HyPER_Classification_Score_%SYS%",
251 "Classification score of the ttbar single lepton topology"};
252 // Indices
254 this, "TtbarLJets_HyPER_TopHad_Indices",
255 "TtbarLJets_HyPER_TopHad_Indices_%SYS%",
256 "Indices of the reconstructed hadronic top in the ttbar single "
257 "lepton topology"};
259 this, "TtbarLJets_HyPER_TopLep_Indices",
260 "TtbarLJets_HyPER_TopLep_Indices_%SYS%",
261 "Indices of the reconstructed leptonic top in the ttbar single "
262 "lepton topology"};
264 this, "TtbarLJets_HyPER_WHad_Indices",
265 "TtbarLJets_HyPER_WHad_Indices_%SYS%",
266 "Indices of the reconstructed hadronic W in the ttbar single lepton "
267 "topology"};
269 this, "TtbarLJets_HyPER_WLep_Indices",
270 "TtbarLJets_HyPER_WLep_Indices_%SYS%",
271 "Indices of the reconstructed leptonic W in the ttbar single lepton "
272 "topology"};
273 // Scores
275 this, "TtbarLJets_HyPER_TopHad_Score",
276 "TtbarLJets_HyPER_TopHad_Score_%SYS%",
277 "Score of the reconstructed hadronic top in the ttbar single lepton "
278 "topology"};
280 this, "TtbarLJets_HyPER_TopLep_Score",
281 "TtbarLJets_HyPER_TopLep_Score_%SYS%",
282 "Score of the reconstructed leptonic top in the ttbar single lepton "
283 "topology"};
285 this, "TtbarLJets_HyPER_WHad_Score", "TtbarLJets_HyPER_WHad_Score_%SYS%",
286 "Score of the reconstructed hadronic W in the ttbar single lepton "
287 "topology"};
289 this, "TtbarLJets_HyPER_WLep_Score", "TtbarLJets_HyPER_WLep_Score_%SYS%",
290 "Score of the reconstructed leptonic W in the ttbar single lepton "
291 "topology"};
292 // IDs
294 this, "TtbarLJets_HyPER_TopHad_IDs", "TtbarLJets_HyPER_TopHad_IDs_%SYS%",
295 "IDs of the reconstructed hadronic top in the ttbar single lepton "
296 "topology"};
298 this, "TtbarLJets_HyPER_TopLep_IDs", "TtbarLJets_HyPER_TopLep_IDs_%SYS%",
299 "IDs of the reconstructed leptonic top in the ttbar single lepton "
300 "topology"};
301 // 4-vector publication for TtbarLJets
303 this, "toplep_b_p4", "",
304 "Visible toplep b-jet four-vector associated to the leptonic top quark"};
306 this, "toplep_lep_p4", "",
307 "Lepton four-vector associated to the leptonic top quark"};
309 this, "tophad_b_p4", "",
310 "Visible tophad b-jet four-vector associated to the hadronic top quark"};
312 this, "tophad_w_decay0_p4", "",
313 "Visible hadronic top W leading decay product four-vector"};
315 this, "tophad_w_decay1_p4", "",
316 "Visible hadronic top W subleading decay product four-vector"};
317
318 // For TtbarDiLepton
319 // Classification score
321 this, "TtbarDiLepton_HyPER_Classification_Score",
322 "TtbarDiLepton_HyPER_Classification_Score_%SYS%",
323 "Classification score of the ttbar di-lepton topology"};
324 // Indices
326 this, "TtbarDiLepton_HyPER_Top1_Indices",
327 "TtbarDiLepton_HyPER_Top1_Indices_%SYS%",
328 "Indices of the reconstructed top1 in the ttbar di-lepton "
329 "topology"};
331 this, "TtbarDiLepton_HyPER_Top2_Indices",
332 "TtbarDiLepton_HyPER_Top2_Indices_%SYS%",
333 "Indices of the reconstructed top2 in the ttbar di-lepton "
334 "topology"};
335 // Scores
337 this, "TtbarDiLepton_HyPER_Top1_Score",
338 "TtbarDiLepton_HyPER_Top1_Score_%SYS%",
339 "Score of the reconstructed top1 in the ttbar di-lepton topology"};
341 this, "TtbarDiLepton_HyPER_Top2_Score",
342 "TtbarDiLepton_HyPER_Top2_Score_%SYS%",
343 "Score of the reconstructed top2 in the ttbar di-lepton topology"};
344 // IDs
346 this, "TtbarDiLepton_HyPER_Top1_IDs",
347 "TtbarDiLepton_HyPER_Top1_IDs_%SYS%",
348 "IDs of the reconstructed top1 in the ttbar di-lepton topology"};
350 this, "TtbarDiLepton_HyPER_Top2_IDs",
351 "TtbarDiLepton_HyPER_Top2_IDs_%SYS%",
352 "IDs of the reconstructed top2 in the ttbar di-lepton topology"};
353 // HE score
355 this, "TtbarDiLepton_HyPER_HE_Score",
356 "TtbarDiLepton_HyPER_HE_Score_%SYS%",
357 "HE score of the ttbar di-lepton topology"};
358 // 4-vector publication for TtbarDiLepton
360 this, "top_b_p4", "",
361 "Visible top b-jet four-vector for the positive-charge lepton branch"};
363 this, "topbar_bbar_p4", "",
364 "Visible anti-top bbar-jet four-vector for the negative-charge lepton "
365 "branch"};
367 this, "top_lep_p4", "",
368 "Top lepton four-vector for the positive-charge lepton branch"};
370 this, "topbar_lepbar_p4", "",
371 "Anti-top lepton four-vector for the negative-charge lepton branch"};
372
373 // Tools and functions for btagging
374 std::unique_ptr<SG::ConstAccessor<int>> m_bTagDecoAcc;
375};
376
377} // namespace EventReco
378
379#endif // HYPERANALYSISALGORITHMS_RUNHYPERALG_H
DataVector adapter that acts like it holds const pointers.
std::vector< std::vector< int64_t > > indices
a class managing the property to configure the list of systematics to process
a data handle for reading systematics varied input data
a data handle for reading systematically varied selection properties from objects
a data handle for reading systematics varied input data
DataVector adapter that acts like it holds const pointers.
the (new) base class for EventLoop algorithms
AnaAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
constructor with parameters
virtual::StatusCode execute()
execute this algorithm
This class is in charge of building the HyPER graph and running the HyPER algorithm: The user-inputs ...
Definition RunHyPERAlg.h:77
CP::SysWriteDecorHandle< PtEtaPhiMVector > m_top_b_p4
CP::SysWriteDecorHandle< PtEtaPhiMVector > m_top_lep_p4
CP::SysWriteDecorHandle< float > m_hyper_TtbarLJets_WHad_Score
std::unique_ptr< SG::ConstAccessor< int > > m_bTagDecoAcc
StatusCode buildTtbarLJetsGraph()
StatusCode buildTtbarDiLeptonGraph()
CP::SysWriteDecorHandle< PtEtaPhiMVector > m_topbar_lepbar_p4
CP::SysWriteDecorHandle< std::vector< int > > m_hyper_TtbarAllHadronic_Top2_Indices
CP::SysWriteDecorHandle< float > m_hyper_TtbarLJets_TopLep_Score
StatusCode buildTtbarAllHadronicGraph()
CP::SysWriteDecorHandle< std::vector< int > > m_hyper_TtbarDiLepton_Top1_IDs
void buildTopP4TtbarAllHadronic(const std::vector< int > &topIndices, const std::vector< int > &wIndices, PtEtaPhiMVector &top_b_p4, PtEtaPhiMVector &top_W_decay0_p4, PtEtaPhiMVector &top_W_decay1_p4)
CP::SysWriteDecorHandle< float > m_hyper_TtbarDiLepton_Top2_Score
CP::SysReadSelectionHandle m_jetSelection
CP::SysReadSelectionHandle m_electronSelection
void buildTopP4TtbarLJets(const std::vector< int > &topHadIndices, const std::vector< int > &wHadIndices, const std::vector< int > &topLepIndices, const std::vector< int > &topLepIDs, PtEtaPhiMVector &tophad_b_p4, PtEtaPhiMVector &tophad_w_decay0_p4, PtEtaPhiMVector &tophad_w_decay1_p4, PtEtaPhiMVector &toplep_b_p4, PtEtaPhiMVector &toplep_lep_p4)
CP::SysWriteDecorHandle< std::vector< int > > m_hyper_TtbarLJets_WHad_Indices
CP::SysWriteDecorHandle< PtEtaPhiMVector > m_top_Wplus_decay1_p4
CP::SysReadHandle< xAOD::JetContainer > m_jetsHandle
CP::SysWriteDecorHandle< std::vector< int > > m_hyper_TtbarAllHadronic_Top1_Indices
CP::SysWriteDecorHandle< std::vector< int > > m_hyper_TtbarLJets_TopHad_IDs
CP::SysWriteDecorHandle< std::vector< int > > m_hyper_TtbarLJets_TopHad_Indices
CP::SysWriteDecorHandle< float > m_hyper_TtbarLJets_TopHad_Score
CP::SysWriteDecorHandle< float > m_hyper_TtbarLJets_WLep_Score
CP::SysListHandle m_systematicsList
CP::SysWriteDecorHandle< float > m_hyper_TtbarAllHadronic_W2_Score
CP::SysWriteDecorHandle< std::vector< int > > m_hyper_TtbarLJets_WLep_Indices
CP::SysReadHandle< xAOD::EventInfo > m_eventInfoHandle
CP::SysWriteDecorHandle< PtEtaPhiMVector > m_tophad_w_decay1_p4
CP::SysWriteDecorHandle< std::vector< int > > m_hyper_TtbarDiLepton_Top1_Indices
CP::SysWriteDecorHandle< PtEtaPhiMVector > m_toplep_lep_p4
std::string m_btagDecorName
HyPERTopology m_hyperTopology
CP::SysWriteDecorHandle< std::vector< int > > m_hyper_TtbarDiLepton_Top2_IDs
CP::SysReadHandle< xAOD::MuonContainer > m_muonsHandle
CP::SysWriteDecorHandle< std::vector< int > > m_hyper_TtbarLJets_TopLep_IDs
CP::SysReadHandle< xAOD::ElectronContainer > m_electronsHandle
CP::SysWriteDecorHandle< float > m_hyper_TtbarDiLepton_Top1_Score
std::unique_ptr< HyPERModel > m_hyperModel
CP::SysWriteDecorHandle< std::vector< int > > m_hyper_TtbarDiLepton_Top2_Indices
CP::SysWriteDecorHandle< PtEtaPhiMVector > m_topbar_Wminus_decay0_p4
CP::SysReadHandle< xAOD::MissingETContainer > m_metHandle
CP::SysReadSelectionHandle m_muonSelection
CP::SysWriteDecorHandle< std::vector< int > > m_hyper_TtbarLJets_TopLep_Indices
CP::SysWriteDecorHandle< PtEtaPhiMVector > m_toplep_b_p4
CP::SysWriteDecorHandle< std::vector< int > > m_hyper_TtbarAllHadronic_W2_Indices
CP::SysWriteDecorHandle< std::vector< int > > m_hyper_TtbarAllHadronic_W1_Indices
Gaudi::Property< long unsigned int > m_fullLogEventNumber
ToolHandle< AthOnnx::IOnnxRuntimeInferenceTool > m_onnxToolTrainedOnEven
Gaudi::Property< std::string > m_btagger
CP::SysWriteDecorHandle< PtEtaPhiMVector > m_topbar_bbar_p4
CP::SysWriteDecorHandle< float > m_hyper_TtbarAllHadronic_Top2_Score
CP::SysWriteDecorHandle< float > m_hyper_TtbarAllHadronic_Top1_Score
CP::SysWriteDecorHandle< float > m_hyper_TtbarDiLepton_Classification_Score
CP::SysWriteDecorHandle< PtEtaPhiMVector > m_tophad_w_decay0_p4
CP::SysWriteDecorHandle< float > m_hyper_TtbarDiLepton_HE_Score
Gaudi::Property< std::string > m_topology
CP::SysWriteDecorHandle< float > m_hyper_TtbarLJets_Classification_Score
std::unique_ptr< HyPERGraph > m_hyperGraph
std::unique_ptr< HyPERParser > m_hyperParser
CP::SysWriteDecorHandle< PtEtaPhiMVector > m_tophad_b_p4
CP::SysWriteDecorHandle< PtEtaPhiMVector > m_topbar_Wminus_decay1_p4
virtual StatusCode initialize() override
CP::SysWriteDecorHandle< PtEtaPhiMVector > m_top_Wplus_decay0_p4
ToolHandle< AthOnnx::IOnnxRuntimeInferenceTool > m_onnxToolTrainedOnOdd
CP::SysReadSelectionHandle m_selection
CP::SysWriteDecorHandle< float > m_hyper_TtbarAllHadronic_W1_Score
StatusCode buildGraph()
These methods build the HyPER graph based on the user-input topology.
bool buildDileptonPartialCandidate(const std::vector< int > &indices, const std::vector< int > &ids, PtEtaPhiMVector &bJetP4, PtEtaPhiMVector &leptonP4, float &analyserCharge) const
virtual StatusCode finalize() override
This struct stores the input objects needed to build the graph after reading and filtering the xAOD c...
Definition RunHyPERAlg.h:47
ConstDataVector< xAOD::ElectronContainer > m_electrons
Definition RunHyPERAlg.h:48
ConstDataVector< xAOD::JetContainer > m_jets
Definition RunHyPERAlg.h:50
const xAOD::MissingETContainer * m_met
Definition RunHyPERAlg.h:51
ConstDataVector< xAOD::MuonContainer > m_muons
Definition RunHyPERAlg.h:49