ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
tauRecTools
Root
ConstituentLoaderTauHit.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
tauRecTools/ConstituentsLoaderTauHit.h
"
6
7
namespace
FlavorTagInference
{
8
ConstituentLoaderTauHit::ConstituentLoaderTauHit
(
const
ConstituentsInputConfig
& cfg,
const
std::string& hits_key) :
9
IConstituentsLoader
(cfg),
10
m_hits_key
{hits_key}
11
{
12
for
(
const
InputVariableConfig
& input_var : cfg.inputs) {
13
m_feature_extractors.push_back(getFeatureExtractor(input_var.name));
14
}
15
}
16
17
18
Inputs
ConstituentLoaderTauHit::getData
(
const
xAOD::IParticle
& p)
const
19
{
20
const
std::vector<const xAOD::TrackMeasurementValidation*> hits =
getParticleHits
(p);
21
return
getFeatures
(p, hits);
22
}
23
24
25
const
std::vector<const xAOD::TrackMeasurementValidation*>
ConstituentLoaderTauHit::getParticleHits
(
const
xAOD::IParticle
& p)
const
26
{
27
static
const
SG::AuxElement::ConstAccessor<std::vector<ElementLink<xAOD::TrackMeasurementValidationContainer>>> hitsHandle(
m_hits_key
);
28
29
std::vector<const xAOD::TrackMeasurementValidation*> hits;
30
for
(
const
ElementLink<xAOD::TrackMeasurementValidationContainer>
& el : hitsHandle(p)) {
31
if
(el.isValid()) hits.push_back(*el);
32
33
// Truncate hits input (already sorted by the upstream JetHitAssociationAlg)
34
if
(hits.size() ==
m_config
.max_n_constituents)
break
;
35
}
36
37
return
hits;
38
}
39
40
41
const
Eigen::Matrix3d
ConstituentLoaderTauHit::getJABInvMatrix
(
const
xAOD::IParticle
& p)
const
42
{
43
// We often work with hits associated to a particle in the following coordinates:
44
// - jet (particle axis) projection,
45
// - adjacent projection (orthogonal to the jet axis and the beam),
46
// - beamline projection.
47
// Since the jet and the beam aren't perpendicular for eta != 0, this isn't a fully-orthogonal basis.
48
//
49
// We also approximate the eta-phi coordinates of the jet to be approximately constant w.r.t. the event vertex,
50
// considering the very-small displacements of the beamspot in the x-y plane, and the relatively small difference
51
// in eta with small (+/- 50mm) changes in z. We might need to revisit this approximation, but we'll use it for now.
52
53
// Use zhat as the beamline
54
Eigen::Vector3d bhat(0, 0, 1);
55
56
const
TLorentzVector p4 = p.p4();
57
Eigen::Vector3d jhat = Eigen::Vector3d(p4.X(), p4.Y(), p4.Z()).normalized();
58
59
Eigen::Vector3d ahat = bhat.cross(jhat).normalized();
60
61
// Build the matrix m that maps the jab displacement such that m*jab = detector
62
Eigen::Matrix3d m;
63
m << jhat, ahat, bhat;
64
65
return
m.inverse();
66
}
67
68
69
const
Inputs
ConstituentLoaderTauHit::getFeatures
(
const
xAOD::IParticle
& p,
const
std::vector<const xAOD::TrackMeasurementValidation*>& hits)
const
70
{
71
std::vector<int64_t> features_dim = {
static_cast<
int64_t
>
(hits.size()),
static_cast<
int64_t
>
(
m_feature_extractors
.size())};
72
73
const
Eigen::Matrix3d jav_inv =
getJABInvMatrix
(p);
74
75
std::vector<float> features;
76
features.reserve(hits.size() *
m_feature_extractors
.size());
77
for
(
const
xAOD::TrackMeasurementValidation
*
hit
: hits) {
78
for
(
const
FeatureFunc_t
& extractor :
m_feature_extractors
) {
79
features.push_back(extractor(p, *
hit
, jav_inv));
80
}
81
}
82
83
return
Inputs{std::move(features), std::move(features_dim)};
84
}
85
86
87
ConstituentLoaderTauHit::FeatureFunc_t
ConstituentLoaderTauHit::getFeatureExtractor
(
const
std::string& var_name)
const
88
{
89
try
{
90
return
m_func_map
.at(var_name);
91
}
catch
(
const
std::out_of_range &e) {
92
throw
std::runtime_error(
"Variable '"
+ var_name +
"' not defined"
);
93
}
94
}
95
96
}
// namespace FlavorTagInference
97
98
99
100
namespace
TauHitVars
{
101
102
float
j
(
const
xAOD::IParticle
&
/*p*/
,
const
xAOD::TrackMeasurementValidation
&
hit
,
const
Eigen::Matrix3d& jab_inv) {
103
static
const
SG::ConstAccessor<float>
acc_localX(
"HitsXRelToBeamspot"
);
104
static
const
SG::ConstAccessor<float>
acc_localY(
"HitsYRelToBeamspot"
);
105
static
const
SG::ConstAccessor<float>
acc_localZ(
"HitsZRelToBeamspot"
);
106
107
return
jab_inv(0, 0)*acc_localX(
hit
) + jab_inv(0, 1)*acc_localY(
hit
) + jab_inv(0, 2)*acc_localZ(
hit
);
108
}
109
110
111
float
a
(
const
xAOD::IParticle
&
/*p*/
,
const
xAOD::TrackMeasurementValidation
&
hit
,
const
Eigen::Matrix3d& jab_inv) {
112
static
const
SG::ConstAccessor<float>
acc_localX(
"HitsXRelToBeamspot"
);
113
static
const
SG::ConstAccessor<float>
acc_localY(
"HitsYRelToBeamspot"
);
114
static
const
SG::ConstAccessor<float>
acc_localZ(
"HitsZRelToBeamspot"
);
115
116
return
jab_inv(1, 0)*acc_localX(
hit
) + jab_inv(1, 1)*acc_localY(
hit
) + jab_inv(1, 2)*acc_localZ(
hit
);
117
}
118
119
120
float
b
(
const
xAOD::IParticle
&
/*p*/
,
const
xAOD::TrackMeasurementValidation
&
hit
,
const
Eigen::Matrix3d& jab_inv) {
121
static
const
SG::ConstAccessor<float>
acc_localX(
"HitsXRelToBeamspot"
);
122
static
const
SG::ConstAccessor<float>
acc_localY(
"HitsYRelToBeamspot"
);
123
static
const
SG::ConstAccessor<float>
acc_localZ(
"HitsZRelToBeamspot"
);
124
125
return
jab_inv(2, 0)*acc_localX(
hit
) + jab_inv(2, 1)*acc_localY(
hit
) + jab_inv(2, 2)*acc_localZ(
hit
);
126
}
127
128
129
float
layer
(
const
xAOD::IParticle
&
/*p*/
,
const
xAOD::TrackMeasurementValidation
&
hit
,
const
Eigen::Matrix3d&
/*jab_inv*/
) {
130
static
const
SG::AuxElement::ConstAccessor<int> acc_layer(
"layer"
);
131
return
acc_layer(
hit
);
132
}
133
134
}
// namespace TauHitVars
ConstituentsLoaderTauHit.h
hit
bool hit(const Container &ids, int pdgId)
Definition
JetIRCSafeLabelTool.cxx:64
a
static Double_t a
Definition
LArPhysWaveHECTool.cxx:38
ElementLink
ElementLink implementation for ROOT usage.
Definition
A/AthLinks/ElementLink.h:40
FlavorTagInference::ConstituentLoaderTauHit::m_feature_extractors
std::vector< FeatureFunc_t > m_feature_extractors
Definition
ConstituentsLoaderTauHit.h:62
FlavorTagInference::ConstituentLoaderTauHit::FeatureFunc_t
std::function< float(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &, const Eigen::Matrix3d &)> FeatureFunc_t
Definition
ConstituentsLoaderTauHit.h:53
FlavorTagInference::ConstituentLoaderTauHit::getFeatureExtractor
FeatureFunc_t getFeatureExtractor(const std::string &var_name) const
Definition
ConstituentLoaderTauHit.cxx:87
FlavorTagInference::ConstituentLoaderTauHit::getFeatures
const Inputs getFeatures(const xAOD::IParticle &p, const std::vector< const xAOD::TrackMeasurementValidation * > &hits) const
Definition
ConstituentLoaderTauHit.cxx:69
FlavorTagInference::ConstituentLoaderTauHit::ConstituentLoaderTauHit
ConstituentLoaderTauHit(const ConstituentsInputConfig &cfg, const std::string &hits_key)
Definition
ConstituentLoaderTauHit.cxx:8
FlavorTagInference::ConstituentLoaderTauHit::m_func_map
static const std::unordered_map< std::string, FeatureFunc_t > m_func_map
Definition
ConstituentsLoaderTauHit.h:64
FlavorTagInference::ConstituentLoaderTauHit::getParticleHits
const std::vector< const xAOD::TrackMeasurementValidation * > getParticleHits(const xAOD::IParticle &p) const
Definition
ConstituentLoaderTauHit.cxx:25
FlavorTagInference::ConstituentLoaderTauHit::getData
Inputs getData(const xAOD::IParticle &p) const override
Definition
ConstituentLoaderTauHit.cxx:18
FlavorTagInference::ConstituentLoaderTauHit::m_hits_key
const std::string m_hits_key
Definition
ConstituentsLoaderTauHit.h:55
FlavorTagInference::ConstituentLoaderTauHit::getJABInvMatrix
const Eigen::Matrix3d getJABInvMatrix(const xAOD::IParticle &p) const
Definition
ConstituentLoaderTauHit.cxx:41
FlavorTagInference::IConstituentsLoader::m_config
ConstituentsInputConfig m_config
Definition
PhysicsAnalysis/JetTagging/FlavorTagInference/FlavorTagInference/ConstituentsLoader.h:100
FlavorTagInference::IConstituentsLoader::IConstituentsLoader
IConstituentsLoader(const ConstituentsInputConfig &cfg)
Definition
PhysicsAnalysis/JetTagging/FlavorTagInference/FlavorTagInference/ConstituentsLoader.h:86
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition
ConstAccessor.h:55
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition
Event/xAOD/xAODBase/xAODBase/IParticle.h:41
FlavorTagInference
This file contains "getter" functions used for accessing tagger inputs from the EDM.
Definition
CaloClusterLoader.h:27
TauHitVars
Definition
ConstituentLoaderTauHit.cxx:100
TauHitVars::j
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)
Definition
ConstituentLoaderTauHit.cxx:102
TauHitVars::layer
float layer(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &)
Definition
ConstituentLoaderTauHit.cxx:129
TauHitVars::b
float b(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)
Definition
ConstituentLoaderTauHit.cxx:120
xAOD::TrackMeasurementValidation
TrackMeasurementValidation_v1 TrackMeasurementValidation
Reference the current persistent version:
Definition
TrackMeasurementValidation.h:13
FlavorTagInference::ConstituentsInputConfig
Definition
PhysicsAnalysis/JetTagging/FlavorTagInference/FlavorTagInference/ConstituentsLoader.h:67
FlavorTagInference::InputVariableConfig
Definition
PhysicsAnalysis/JetTagging/FlavorTagInference/FlavorTagInference/ConstituentsLoader.h:61
Generated on
for ATLAS Offline Software by
1.17.0