ATLAS Offline Software
Loading...
Searching...
No Matches
TausRUsEvaluator.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 TAURECTOOLS_TAUSRUSEVALUATOR_H
6#define TAURECTOOLS_TAUSRUSEVALUATOR_H
7
10
12
16#include "AsgTools/ToolHandle.h"
17
20
21#include "xAODTau/TauJet.h"
23#include "xAODTau/TauTrack.h"
25#include "xAODTracking/Vertex.h"
27
28#include <cstddef>
29#include <cstdint>
30#include <memory>
31#include <span>
32#include <string>
33#include <vector>
34
61public:
63
64 TausRUsEvaluator(const std::string& name = "TausRUsEvaluator");
65 virtual ~TausRUsEvaluator();
66
67 virtual StatusCode initialize() override;
68 virtual StatusCode execute(xAOD::TauJet& tau) const override;
69
71 static constexpr float DEFAULT_VALUE = -1111.0f;
72 static constexpr int DEFAULT_CLASS = -1;
73
74 struct Output {
75 std::string name;
76 std::string type;
77 std::vector<int64_t> dims;
78 size_t size{0};
79 };
80
82 enum PrimaryClass : size_t { QCD = 0, Tau = 1, Electron = 2 };
83
85 static constexpr int TAU_TRACK_CLASS = 0;
86
89 enum PhiComponent : size_t { PHI_SIN = 0, PHI_COS = 1 };
90
91private:
92
93 using FourMomDecorators = std::vector<SG::Accessor<float>>;
94
97 StatusCode readModel(const std::string& path);
98
99 void setDefaults(xAOD::TauJet& tau) const;
100
103 void decorateFourMomentum(xAOD::TauJet& tau, const FourMomDecorators& decorators,
104 std::span<const float> ptQuantiles,
105 std::span<const float> etaValues,
106 std::span<const float> phiValues,
107 float mass) const;
108
112 std::span<const float> scores,
113 const std::vector<const xAOD::Vertex*>& vertices) const;
114
116 void decorateTracks(xAOD::TauJet& tau, std::span<const float> scores) const;
117
118 std::vector<std::string> tauDecorationNames() const;
119 std::vector<std::string> trackDecorationNames() const;
120
121 ToolHandle<AthInfer::IAthInferenceTool> m_inferenceTool{
122 this, "InferenceTool", "", "ONNX Runtime or Triton inference backend"};
123
125 this, "Key_vertexInputContainer", "PrimaryVertices", "Input vertex container key"};
126
127 Gaudi::Property<std::string> m_modelFile{
128 this, "ModelFile", "",
129 "ONNX model the input and output nodes are read from, also when inference runs on Triton"};
130 Gaudi::Property<std::string> m_tauContainerName{
131 this, "TauContainerName", "",
132 "Name of the TauJetContainer, needed to declare the output data dependencies"};
133 Gaudi::Property<std::string> m_tauTrackContainerName{
134 this, "TauTrackContainerName", "",
135 "Name of the TauTrackContainer, needed to declare the per-track output data dependencies"};
136 Gaudi::Property<float> m_minTauPt{
137 this, "MinTauPt", 15., "Skip taus below this pt to save CPU"};
138
139 std::unique_ptr<TausRUsDataLoader> m_loader;
140
142 std::vector<Output> m_outputs;
143
145 size_t m_nDecayModes{0};
147 size_t m_nQuantiles{0};
153
160 std::vector<SG::Accessor<float>> m_decayModeScores;
164 std::vector<SG::Accessor<float>> m_vertexPosition;
165 // decorators to the tracks
167 std::vector<SG::Decorator<float>> m_trackScores;
168
169 std::vector<SG::WriteDecorHandleKey<xAOD::TauJetContainer>> m_decorKeys;
170 std::vector<SG::WriteDecorHandleKey<xAOD::TauTrackContainer>> m_trackDecorKeys;
171};
172
173#endif // TAURECTOOLS_TAUSRUSEVALUATOR_H
#define ASG_TOOL_CLASS2(CLASSNAME, INT1, INT2)
Property holding a SG store/key/clid from which a ReadHandle is made.
Helper class to provide type-safe access to aux data.
Helper class to provide type-safe access to aux data.
std::vector< std::vector< float > > scores
The base class for all tau tools.
Helper class to provide type-safe access to aux data.
Property holding a SG store/key/clid from which a ReadHandle is made.
TauRecToolBase(const std::string &name)
static constexpr int TAU_TRACK_CLASS
Class for true-tau track from tau_track_class head.
void decorateTracks(xAOD::TauJet &tau, std::span< const float > scores) const
Decorate each track of tau with its slot of the per-track head.
static constexpr float DEFAULT_VALUE
initialized with these default values
virtual StatusCode initialize() override
Tool initializer.
Gaudi::Property< std::string > m_tauContainerName
std::unique_ptr< TausRUsDataLoader > m_loader
std::vector< SG::Accessor< float > > FourMomDecorators
FourMomDecorators m_chargedPionP4
Gaudi::Property< std::string > m_modelFile
std::vector< SG::WriteDecorHandleKey< xAOD::TauTrackContainer > > m_trackDecorKeys
void decorateFourMomentum(xAOD::TauJet &tau, const FourMomDecorators &decorators, std::span< const float > ptQuantiles, std::span< const float > etaValues, std::span< const float > phiValues, float mass) const
Decorate the four floats of decorators from a pt, an eta and a phi head, taking the mass from mass.
size_t m_nDecayModes
Read off the metadata at initialize().
virtual StatusCode execute(xAOD::TauJet &tau) const override
Execute - called for each tau candidate.
FourMomDecorators m_neutralPionP4
Gaudi::Property< std::string > m_tauTrackContainerName
std::vector< SG::WriteDecorHandleKey< xAOD::TauJetContainer > > m_decorKeys
StatusCode readModel(const std::string &path)
Configure the data loader and build m_outputs from the metadata and node shapes of the model.
Gaudi::Property< float > m_minTauPt
SG::Accessor< float > m_decayMode
void decorateVertex(xAOD::TauJet &tau, std::span< const float > scores, const std::vector< const xAOD::Vertex * > &vertices) const
Decorate the position of the vertex that scores picks out of vertices, which must be the list the inp...
SG::Accessor< float > m_eleRejScore
SG::Accessor< float > m_tauIDScore
The decorators.
SG::Accessor< float > m_tauCharge
ToolHandle< AthInfer::IAthInferenceTool > m_inferenceTool
TausRUsEvaluator(const std::string &name="TausRUsEvaluator")
FourMomDecorators m_tauP4
void setDefaults(xAOD::TauJet &tau) const
std::vector< SG::Accessor< float > > m_vertexPosition
std::vector< std::string > trackDecorationNames() const
std::vector< std::string > tauDecorationNames() const
Every decoration written on the tau, and every one written on its tracks, which is what the output da...
std::vector< Output > m_outputs
The model's output nodes, from its metadata.
std::vector< SG::Accessor< float > > m_decayModeScores
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexInputContainer
SG::Decorator< int > m_trackClass
PrimaryClass
Class order of the 'primary' head, which is three raw logits.
PhiComponent
The two components of a phi head, which regresses the angle as a point on the unit circle: phi = atan...
static constexpr int DEFAULT_CLASS
std::vector< SG::Decorator< float > > m_trackScores
size_t m_ptMedianQuantile
The pt heads ('tes', 'charged_pion_pt', 'neutral_pion_pt') regress quantiles of the log response,...
SG::Decorator< T, ALLOC > Decorator
Helper class to provide type-safe access to aux data, specialized for JaggedVecElt.
Definition AuxElement.h:576
TauJet_v3 TauJet
Definition of the current "tau version".
Definition TauJet.h:17
std::string type
head type from the metadata
size_t size
product of dims
std::string name
model output node name
std::vector< int64_t > dims