ATLAS Offline Software
Loading...
Searching...
No Matches
GNN.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
4 This class is used in conjunction with SaltModel to run inference on a GNN model.
5 Whereas SaltModel handles the interfacing with the ONNX runtime, this class handles
6 the interfacing with the ATLAS EDM. It is responsible for collecting all the inputs
7 needed for inference, running inference (via SaltModel), and decorating the results
8 back to ATLAS EDM.
9*/
10
11#ifndef FLAVORTAGINFERENCE_GNN_H
12#define FLAVORTAGINFERENCE_GNN_H
13
14// Tool includes
21
22// EDM includes
23#include "xAODBase/IParticle.h"
24
25#include <string>
26#include <map>
27
28namespace FlavorTagInference {
29
30 struct GNNOptions;
31
32 //
33 // Tool to to flavor tag jet/btagging object
34 // using GNN based taggers
35 class GNN
36 {
37 public:
38 // recommended constructor, file path + options
39 GNN(const std::string& nnFile, const GNNOptions& opts);
40 // Formerly private constructor, promoted to public to contain
41 // preprocessor macros within a single class in the package: NNSharingSvc
42 GNN(ISaltModelPtr, const GNNOptions& opts);
43 // redefined options constructor, will share underlying network
44 GNN(const GNN&, const GNNOptions& opts);
45 // legacy constructor
46 GNN(const std::string& nnFile,
47 const FlipTagConfig& flip_config = FlipTagConfig::STANDARD,
48 const std::map<std::string, std::string>& variableRemapping = {},
49 float defaultOutputValue = NAN);
50 GNN(GNN&&);
51 GNN(const GNN&);
52 virtual ~GNN();
53
54 virtual void decorate(const xAOD::IParticle& i_jet) const;
55 virtual void decorateWithDefaults(const xAOD::IParticle& jet) const;
56
57 // cppcheck-suppress returnByReference
59
60 private:
61 template<typename T>
63
64 template<typename T>
65 using Decs = std::vector<std::pair<std::string, Dec<T>>>;
66
76
77 /* create all decorators */
78 std::tuple<FTagDataDependencyNames, std::set<std::string>>
79 createDecorators(const OutputConfig& outConfig, const FTagOptions& options);
80
82 std::string m_input_node_name;
84
86 std::vector<float> m_truncFloatScales; // per-entry scale for jetVecTruncFloat
87 std::vector<std::pair<int,int>> m_truncFloatBits; // (exp_bits, man_bits) per VECTRUNCFLOAT output
88 std::vector<std::pair<Dec<float>, float>> m_defaultValues;
90 };
91} // end namespace FlavorTagInference
92#endif //GNN_H
std::tuple< FTagDataDependencyNames, std::set< std::string > > createDecorators(const OutputConfig &outConfig, const FTagOptions &options)
Definition GNN.cxx:192
bool m_defaultZeroTracks
Definition GNN.h:89
std::vector< std::pair< int, int > > m_truncFloatBits
Definition GNN.h:87
std::vector< std::pair< std::string, Dec< T > > > Decs
Definition GNN.h:65
std::vector< float > m_truncFloatScales
Definition GNN.h:86
ISaltModelPtr m_saltModel
Definition GNN.h:81
GNNDataLoader m_dataLoader
Definition GNN.h:83
Decorators m_decorators
Definition GNN.h:85
std::string m_input_node_name
Definition GNN.h:82
virtual void decorateWithDefaults(const xAOD::IParticle &jet) const
Definition GNN.cxx:97
SG::Decorator< T > Dec
Definition GNN.h:62
virtual void decorate(const xAOD::IParticle &i_jet) const
Definition GNN.cxx:123
GNN(const std::string &nnFile, const GNNOptions &opts)
Definition GNN.cxx:38
FTagDataDependencyNames getDependencies() const
Definition GNN.cxx:187
std::vector< std::pair< Dec< float >, float > > m_defaultValues
Definition GNN.h:88
Class providing the definition of the 4-vector interface.
This file contains "getter" functions used for accessing tagger inputs from the EDM.
std::vector< SaltModelOutput > OutputConfig
Definition ISaltModel.h:38
std::shared_ptr< const ISaltModel > ISaltModelPtr
Definition ISaltModel.h:56
SG::Decorator< T, ALLOC > Decorator
Helper class to provide type-safe access to aux data, specialized for JaggedVecElt.
Definition AuxElement.h:576
Decs< std::vector< float > > jetVecFloat
Definition GNN.h:70
Decs< std::vector< char > > jetVecChar
Definition GNN.h:69
Decs< std::vector< int > > jetVecInt
Definition GNN.h:71
Decs< std::vector< float > > jetVecTruncFloat
Definition GNN.h:72