ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
JetTagging
FlavorTagInference
Root
CaloClusterLoader.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 "
FlavorTagInference/CaloClusterLoader.h
"
6
#include "
xAODBase/IParticle.h
"
7
#include "
xAODPFlow/FlowElement.h
"
8
#include "
xAODCaloEvent/CaloCluster.h
"
9
#include <unordered_set>
10
#include <vector>
11
12
namespace
FlavorTagInference
{
13
14
// factory for functions which return the sort variable we
15
// use to order calo clusters
16
CaloClusterLoader::CaloClusterSortVar
CaloClusterLoader::caloClusterSortVar
(
17
ConstituentsSortOrder
config)
18
{
19
typedef
xAOD::CaloCluster
CC;
20
typedef
xAOD::IParticle
Jet
;
21
switch
(config) {
22
case
ConstituentsSortOrder::PT_DESCENDING
:
23
return
[](
const
CC* p,
const
Jet
&) {
return
p->pt();};
24
default
: {
25
throw
std::logic_error(
"Unknown sort function"
);
26
}
27
}
28
}
// end of CaloCluster sort getter
29
30
CaloClusterLoader::CaloClusterLoader
(
31
const
ConstituentsInputConfig
& cfg,
32
const
FTagOptions
& options
33
):
34
IConstituentsLoader
(cfg),
35
m_caloClusterSortVar
(
CaloClusterLoader
::
caloClusterSortVar
(cfg.order)),
36
m_seqGetter
(
getter_utils
::SeqGetter<
xAOD
::
CaloCluster
>(
37
cfg.inputs, options))
38
{
39
m_used_remap
=
m_seqGetter
.getUsedRemap();
40
m_name
= cfg.name;
41
m_skipInvalidLinks
= options.skip_invalid_links;
42
}
43
44
CaloClusterLoader::CaloClusters
CaloClusterLoader::getCaloClustersFromJet
(
45
const
xAOD::IParticle
&
jet
46
)
const
47
{
48
// Three-hop navigation for UFO jets:
49
// jet -> constituentLinks -> FlowElement (UFO)
50
// -> otherObjects() -> FlowElement (intermediate CSSK PFO)
51
// -> otherObjects() -> CaloCluster
52
// Two-hop navigation for PFlow jets (small-R):
53
// jet -> constituentLinks -> FlowElement (PFO)
54
// -> otherObjects() -> CaloCluster
55
// Dedup via unordered_set because UFO->cluster is many-to-many.
56
static
const
SG::AuxElement::ConstAccessor<PartLinks> acc(
"constituentLinks"
);
57
58
std::vector<std::pair<double, const xAOD::CaloCluster*>> clusters;
59
std::unordered_set<const xAOD::CaloCluster*> seen;
60
61
for
(
const
ElementLink<IPC>
& link : acc(
jet
)) {
62
if
(!link.isValid()) {
63
if
(
m_skipInvalidLinks
) {
continue
; }
64
throw
std::logic_error(
"invalid constituentLink in CaloClusterLoader"
);
65
}
66
const
auto
* flow =
dynamic_cast<
const
xAOD::FlowElement
*
>
(*link);
67
if
(!flow) {
68
continue
;
69
}
70
// Second hop: FlowElement -> otherObjects()
71
for
(
const
auto
* other : flow->otherObjects()) {
72
if
(!other) {
73
continue
;
74
}
75
// PFlow path: `other` is already a CaloCluster.
76
if
(
const
auto
* cluster =
dynamic_cast<
const
xAOD::CaloCluster
*
>
(other)) {
77
if
(seen.insert(cluster).second) {
78
clusters.push_back({
m_caloClusterSortVar
(cluster,
jet
), cluster});
79
}
80
continue
;
81
}
82
// UFO path: `other` is an intermediate FlowElement
83
// (e.g. CSSKGParticleFlowObject). Recurse one more hop.
84
if
(
const
auto
* intermediate =
dynamic_cast<
const
xAOD::FlowElement
*
>
(other)) {
85
for
(
const
auto
* grandOther : intermediate->otherObjects()) {
86
if
(!grandOther) {
continue
; }
87
const
auto
* cluster =
dynamic_cast<
const
xAOD::CaloCluster
*
>
(grandOther);
88
if
(cluster && seen.insert(cluster).second) {
89
clusters.push_back({
m_caloClusterSortVar
(cluster,
jet
), cluster});
90
}
91
}
92
}
93
}
94
}
95
96
// Sort by pt descending
97
std::sort
(clusters.begin(), clusters.end(), std::greater<>());
98
99
CaloClusters
sorted_clusters;
100
sorted_clusters.reserve(clusters.size());
101
for
(
const
auto
& cl : clusters) {
102
sorted_clusters.push_back(cl.second);
103
}
104
return
sorted_clusters;
105
}
106
107
Inputs
CaloClusterLoader::getData
(
const
xAOD::IParticle
&
jet
)
const
{
108
CaloClusters
sorted_clusters =
getCaloClustersFromJet
(
jet
);
109
return
m_seqGetter
.getFeats(
jet
, sorted_clusters);
110
}
111
112
const
FTagDataDependencyNames
&
CaloClusterLoader::getDependencies
()
const
{
113
return
m_deps
;
114
}
115
const
std::set<std::string>&
CaloClusterLoader::getUsedRemap
()
const
{
116
return
m_used_remap
;
117
}
118
const
std::string&
CaloClusterLoader::getName
()
const
{
119
return
m_name
;
120
}
121
const
ConstituentsType
&
CaloClusterLoader::getType
()
const
{
122
return
m_config
.type;
123
}
124
125
}
CaloClusterLoader.h
IParticle.h
CaloCluster.h
FlowElement.h
CaloCluster
Principal data class for CaloCell clusters.
Definition
Calorimeter/CaloEvent/CaloEvent/CaloCluster.h:79
ElementLink
ElementLink implementation for ROOT usage.
Definition
A/AthLinks/ElementLink.h:40
FlavorTagInference::CaloClusterLoader::getCaloClustersFromJet
CaloClusters getCaloClustersFromJet(const xAOD::IParticle &jet) const
Definition
CaloClusterLoader.cxx:44
FlavorTagInference::CaloClusterLoader::getData
Inputs getData(const xAOD::IParticle &jet) const override
Definition
CaloClusterLoader.cxx:107
FlavorTagInference::CaloClusterLoader::m_caloClusterSortVar
CaloClusterSortVar m_caloClusterSortVar
Definition
CaloClusterLoader.h:57
FlavorTagInference::CaloClusterLoader::m_seqGetter
getter_utils::SeqGetter< xAOD::CaloCluster > m_seqGetter
Definition
CaloClusterLoader.h:58
FlavorTagInference::CaloClusterLoader::getName
const std::string & getName() const override
Definition
CaloClusterLoader.cxx:118
FlavorTagInference::CaloClusterLoader::caloClusterSortVar
CaloClusterSortVar caloClusterSortVar(ConstituentsSortOrder)
Definition
CaloClusterLoader.cxx:16
FlavorTagInference::CaloClusterLoader::Jet
xAOD::IParticle Jet
Definition
CaloClusterLoader.h:40
FlavorTagInference::CaloClusterLoader::m_skipInvalidLinks
bool m_skipInvalidLinks
Definition
CaloClusterLoader.h:59
FlavorTagInference::CaloClusterLoader::getDependencies
const FTagDataDependencyNames & getDependencies() const override
Definition
CaloClusterLoader.cxx:112
FlavorTagInference::CaloClusterLoader::CaloClusterSortVar
std::function< double(const xAOD::CaloCluster *, const Jet &)> CaloClusterSortVar
Definition
CaloClusterLoader.h:46
FlavorTagInference::CaloClusterLoader::CaloClusters
std::vector< const xAOD::CaloCluster * > CaloClusters
Definition
CaloClusterLoader.h:44
FlavorTagInference::CaloClusterLoader::CaloClusterLoader
CaloClusterLoader(const ConstituentsInputConfig &cfg, const FTagOptions &options)
Definition
CaloClusterLoader.cxx:30
FlavorTagInference::CaloClusterLoader::getType
const ConstituentsType & getType() const override
Definition
CaloClusterLoader.cxx:121
FlavorTagInference::CaloClusterLoader::getUsedRemap
const std::set< std::string > & getUsedRemap() const override
Definition
CaloClusterLoader.cxx:115
FlavorTagInference::IConstituentsLoader::m_config
ConstituentsInputConfig m_config
Definition
PhysicsAnalysis/JetTagging/FlavorTagInference/FlavorTagInference/ConstituentsLoader.h:100
FlavorTagInference::IConstituentsLoader::m_used_remap
std::set< std::string > m_used_remap
Definition
PhysicsAnalysis/JetTagging/FlavorTagInference/FlavorTagInference/ConstituentsLoader.h:101
FlavorTagInference::IConstituentsLoader::m_name
std::string m_name
Definition
PhysicsAnalysis/JetTagging/FlavorTagInference/FlavorTagInference/ConstituentsLoader.h:102
FlavorTagInference::IConstituentsLoader::IConstituentsLoader
IConstituentsLoader(const ConstituentsInputConfig &cfg)
Definition
PhysicsAnalysis/JetTagging/FlavorTagInference/FlavorTagInference/ConstituentsLoader.h:86
FlavorTagInference::IConstituentsLoader::m_deps
FTagDataDependencyNames m_deps
Definition
PhysicsAnalysis/JetTagging/FlavorTagInference/FlavorTagInference/ConstituentsLoader.h:99
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition
Event/xAOD/xAODBase/xAODBase/IParticle.h:41
FlavorTagInference::getter_utils
Definition
PhysicsAnalysis/JetTagging/FlavorTagInference/FlavorTagInference/CustomGetterUtils.h:39
FlavorTagInference
This file contains "getter" functions used for accessing tagger inputs from the EDM.
Definition
CaloClusterLoader.h:27
FlavorTagInference::ConstituentsType
ConstituentsType
Definition
PhysicsAnalysis/JetTagging/FlavorTagInference/FlavorTagInference/ConstituentsLoader.h:48
FlavorTagInference::ConstituentsSortOrder
ConstituentsSortOrder
Definition
PhysicsAnalysis/JetTagging/FlavorTagInference/FlavorTagInference/ConstituentsLoader.h:29
FlavorTagInference::ConstituentsSortOrder::PT_DESCENDING
@ PT_DESCENDING
Definition
PhysicsAnalysis/JetTagging/FlavorTagInference/FlavorTagInference/ConstituentsLoader.h:32
jet
Definition
JetCalibTools_PlotJESFactors.cxx:23
std::sort
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
Definition
DVL_algorithms.h:554
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition
ICaloAffectedTool.h:24
xAOD::CaloCluster
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Definition
Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloCluster.h:19
xAOD::FlowElement
FlowElement_v1 FlowElement
Definition of the current "pfo version".
Definition
FlowElement.h:16
FlavorTagInference::ConstituentsInputConfig
Definition
PhysicsAnalysis/JetTagging/FlavorTagInference/FlavorTagInference/ConstituentsLoader.h:67
FlavorTagInference::FTagDataDependencyNames
Definition
FTagDataDependencyNames.h:12
FlavorTagInference::FTagOptions
Definition
PhysicsAnalysis/JetTagging/FlavorTagInference/FlavorTagInference/DataPrepUtilities.h:45
Generated on
for ATLAS Offline Software by
1.17.0