ATLAS Offline Software
Loading...
Searching...
No Matches
JSSMLTool.h
Go to the documentation of this file.
1// Dear emacs, this is -*- c++ -*-
2// Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3#ifndef BOOSTEDJETTAGGERS_JSSMLTOOL_H
4#define BOOSTEDJETTAGGERS_JSSMLTOOL_H
5
6#include "IJSSMLTool.h"
7#include "AsgTools/AsgTool.h"
8
9// ONNX Runtime include(s).
10#include <onnxruntime_cxx_api.h>
11
12// xAOD
15// System include(s).
16#include <memory> //unique_ptr
17#include <string>
18#include <map>
19#include <vector>
20#include <cstdint>
21
22class TH2D;
23
24
25namespace AthONNX {
26
41
45
47 : public asg::AsgTool,
48 virtual public IJSSMLTool {
50
51 public:
52 JSSMLTool (const std::string& name);
53
55 virtual StatusCode initialize() override;
57 virtual double retrieveConstituentsScore(std::vector<TH2D> Images) const override;
58 virtual double retrieveConstituentsScore(std::vector<std::vector<float>> constituents) const override;
59 virtual double retrieveConstituentsScore(std::vector<std::vector<float>> constituents, std::vector<std::vector<std::vector<float>>> interactions) const override;
60 virtual double retrieveConstituentsScore(std::vector<std::vector<float>> constituents, std::vector<std::vector<std::vector<float>>> interactions, std::vector<std::vector<float>> mask) const override;
61 virtual double retrieveHighLevelScore(std::map<std::string, double> JSSVars) const override;
62
63 // basic tool functions
64 std::vector<float> ReadJetImagePixels( std::vector<TH2D> Images ) const;
65 std::vector<float> ReadJSSInputs(std::map<std::string, double> JSSVars) const;
66 std::vector<int> ReadOutputLabels() const;
67
68 // extra methods
69 StatusCode SetScaler(std::map<std::string, std::vector<double>> scaler) override;
70
72 std::unique_ptr< Ort::Session > m_session;
73 std::unique_ptr< Ort::Env > m_env;
74
75 std::map<std::string, std::vector<double>> m_scaler;
76 std::map<int, std::string> m_JSSInputMap;
77
78 private:
79
81 std::string m_modelFileName;
82 std::string m_pixelFileName;
83 std::string m_labelFileName;
84
85 // input node info
86 std::vector<int64_t> m_input_node_dims;
88 std::vector<const char*> m_input_node_names;
89
90 // output node info
91 std::vector<int64_t> m_output_node_dims;
93 std::vector<const char*> m_output_node_names;
94
95 // some configs
97
98 int m_nvars{};
99
100 }; // class JSSMLTool
101
102} // namespace AthONNX
103
104#endif // BOOSTEDJETTAGGERS_JSSMLTOOL_H
#define ASG_TOOL_CLASS(CLASSNAME, INT1)
std::string m_modelFileName
Name of the model file to load.
Definition JSSMLTool.h:81
std::map< std::string, std::vector< double > > m_scaler
Definition JSSMLTool.h:75
StatusCode SetScaler(std::map< std::string, std::vector< double > > scaler) override
virtual double retrieveHighLevelScore(std::map< std::string, double > JSSVars) const override
virtual StatusCode initialize() override
Function initialising the tool.
Definition JSSMLTool.cxx:83
std::vector< float > ReadJetImagePixels(std::vector< TH2D > Images) const
Definition JSSMLTool.cxx:17
std::string m_pixelFileName
Definition JSSMLTool.h:82
JSSMLTool(const std::string &name)
Definition JSSMLTool.cxx:73
std::vector< int > ReadOutputLabels() const
Definition JSSMLTool.cxx:63
std::unique_ptr< Ort::Env > m_env
Definition JSSMLTool.h:73
std::vector< int64_t > m_output_node_dims
Definition JSSMLTool.h:91
virtual double retrieveConstituentsScore(std::vector< TH2D > Images) const override
Function executing the tool for a single event.
size_t m_num_output_nodes
Definition JSSMLTool.h:92
size_t m_num_input_nodes
Definition JSSMLTool.h:87
std::string m_labelFileName
Definition JSSMLTool.h:83
std::vector< float > ReadJSSInputs(std::map< std::string, double > JSSVars) const
Definition JSSMLTool.cxx:39
std::vector< const char * > m_output_node_names
Definition JSSMLTool.h:93
std::vector< int64_t > m_input_node_dims
Definition JSSMLTool.h:86
std::map< int, std::string > m_JSSInputMap
Definition JSSMLTool.h:76
std::vector< const char * > m_input_node_names
Definition JSSMLTool.h:88
std::unique_ptr< Ort::Session > m_session
Definition JSSMLTool.h:72
Base class for the dual-use tool implementation classes.
Definition AsgTool.h:47