ATLAS Offline Software
Loading...
Searching...
No Matches
LundJetOnnxAlg.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4#ifndef XAOD_ANALYSIS
5#ifndef LUNDJETONNXALG_H
6#define LUNDJETONNXALG_H
7
8// Framework
10
11// xAOD
12#include "xAODJet/Jet.h"
13
14// ONNX Runtime
15#include <onnxruntime_cxx_api.h>
16
18
19// STL
20#include <string>
21#include <vector>
22#include <memory>
23
25public:
26 using AthReentrantAlgorithm::AthReentrantAlgorithm;
27 virtual StatusCode initialize() override;
28 virtual StatusCode execute(const EventContext& ctx) const override;
29
30private:
31 // Job properties
32 Gaudi::Property<std::string> m_inputJetContainer{
33 this, "InputJetContainer", "AntiKt10UFO",
34 "Name of input jet container"
35 };
36 Gaudi::Property<std::string> m_prefix{
37 this, "Prefix", "",
38 "Prefix used by LundVariablesTool decorations"
39 };
40 Gaudi::Property<float> m_kTSelection{
41 this, "kTSelection", -1000.f,
42 "kT cut to apply (same meaning as kT_Cut in python loader)"
43 };
44
45 Gaudi::Property<std::string> m_scoreName{
46 this, "ScoreDecoration", "LundNetScore",
47 "Name of the decoration (without container prefix). Final decoration will be <container>.<prefix><ScoreDecoration>"
48 };
49
50 Gaudi::Property<int> m_expectedBatchSize{
51 this,
52 "ExpectedBatchSize",
53 1,
54 "Batch size expected by the ONNX model (from training/export)"
55 };
57 this, "ValidDecor", "", "Valid LundNet inference"
58 };
59 //SG::WriteDecorHandleKey<float> m_scoreDecorKey{ this, "ScoreDecorKey", "", "WriteDecorHandleKey for the LundNet score" };
61 this, "ScoreDecorKey", "", "Score decoration key"
62 };
63 // Means and stds used for normalization (defaults from your python snippet)
64 Gaudi::Property<float> m_mean_z{ this, "MeanZ", 2.0568479032747313f, "mean z (for normalization)" };
65 Gaudi::Property<float> m_std_z{ this, "StdZ", 1.4450598054504056f, "std z (for normalization)" };
66 Gaudi::Property<float> m_mean_dr{ this, "MeanDR", 3.8597358364389427f, "mean dr (for normalization)" };
67 Gaudi::Property<float> m_std_dr{ this, "StdDR", 2.2748462855901073f, "std dr (for normalization)" };
68 Gaudi::Property<float> m_mean_kt{ this, "MeanKT", -2.379904791478249f, "mean kt (for normalization)" };
69 Gaudi::Property<float> m_std_kt{ this, "StdKT", 2.940813577366582f, "std kt (for normalization)" };
70 Gaudi::Property<float> m_mean_ntrk{ this, "MeanNtrk", 57.588158609500134f, "mean Ntrk" };
71 Gaudi::Property<float> m_std_ntrk{ this, "StdNtrk", 23.900100132781983f, "std Ntrk" };
73 Gaudi::Property<std::string> m_modelPath{
74 this,
75 "ModelPath",
76 "",
77 "Path to the ONNX model"
78 };
79 std::unique_ptr<Ort::Env> m_env;
80 std::unique_ptr<Ort::Session> m_session;
81 // The IAthInferenceTool that wraps ONNX runtime (provided via CA)
82
84 bool buildOnnxInputs(const xAOD::Jet& jet,
85 std::vector<float>& out_x_float, // flattened [num_nodes * feat_dim]
86 std::vector<int64_t>& out_edge_index_int64, // flattened [2 * num_edges]
87 std::vector<int64_t>& out_batch_int64, // [num_nodes]
88 std::vector<int64_t>& out_counts_int64, // [1]
89 std::vector<float>& out_Ntrk_float) const; // [1]
90};
91
92#endif // LUNDJETONNXALG_H
93#endif // ATHENA-ONLY
Property holding a SG store/key/clid/attr name from which a WriteDecorHandle is made.
An algorithm that can be simultaneously executed in multiple threads.
Gaudi::Property< float > m_mean_ntrk
Gaudi::Property< std::string > m_modelPath
Gaudi::Property< float > m_mean_dr
Gaudi::Property< std::string > m_inputJetContainer
Gaudi::Property< float > m_std_ntrk
virtual StatusCode execute(const EventContext &ctx) const override
Gaudi::Property< float > m_std_kt
Gaudi::Property< std::string > m_scoreName
Gaudi::Property< float > m_mean_z
Gaudi::Property< float > m_std_z
Gaudi::Property< float > m_std_dr
std::unique_ptr< Ort::Env > m_env
Gaudi::Property< float > m_kTSelection
SG::WriteDecorHandleKey< xAOD::JetContainer > m_validDecorKey
bool buildOnnxInputs(const xAOD::Jet &jet, std::vector< float > &out_x_float, std::vector< int64_t > &out_edge_index_int64, std::vector< int64_t > &out_batch_int64, std::vector< int64_t > &out_counts_int64, std::vector< float > &out_Ntrk_float) const
Helper to build ONNX inputs (batch_size=1)
std::unique_ptr< Ort::Session > m_session
Gaudi::Property< int > m_expectedBatchSize
Gaudi::Property< float > m_mean_kt
SG::WriteDecorHandleKey< xAOD::JetContainer > m_scoreDecorKey
std::string m_resolvedModelPath
Gaudi::Property< std::string > m_prefix
virtual StatusCode initialize() override
Property holding a SG store/key/clid/attr name from which a WriteDecorHandle is made.
Jet_v1 Jet
Definition of the current "jet version".