ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetRecTools
InDetGNNHardScatterSelection
Root
PhotonsLoader.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
InDetGNNHardScatterSelection/PhotonsLoader.h
"
6
7
#include "
xAODEgamma/Photon.h
"
8
9
namespace
InDetGNNHardScatterSelection
{
10
11
// factory for functions which return the sort variable we
12
// use to order iparticles
13
PhotonsLoader::PhotonSortVar
PhotonsLoader::iparticleSortVar
(
14
ConstituentsSortOrder
config)
15
{
16
using
Ip =
xAOD::Photon
;
17
using
Vertex
=
xAOD::Vertex
;
18
switch
(config) {
19
case
ConstituentsSortOrder::PT_DESCENDING
:
20
return
[](
const
Ip* tp,
const
Vertex
&) {
return
tp->pt();};
21
default
: {
22
throw
std::logic_error(
"Unknown sort function"
);
23
}
24
}
25
}
// end of iparticle sort getter
26
27
PhotonsLoader::PhotonsLoader
(
28
const
ConstituentsInputConfig
& cfg
29
):
30
IConstituentsLoader
(cfg),
31
m_iparticleSortVar
(
PhotonsLoader
::
iparticleSortVar
(cfg.order)),
32
m_customSequenceGetter
(
getter_utils
::CustomSequenceGetter<
xAOD
::
Photon
>(
33
cfg.inputs))
34
{
35
const
SG::AuxElement::ConstAccessor<PartLinks> acc(
"photonLinks"
);
36
m_associator
= [acc](
const
xAOD::Vertex
& vertex) ->
IPV
{
37
IPV
particles;
38
for
(
const
ElementLink<IPC>
& link : acc(vertex)){
39
if
(!link.isValid()) {
40
throw
std::logic_error(
"invalid particle link"
);
41
}
42
particles.push_back(*link);
43
}
44
return
particles;
45
};
46
m_name
= cfg.name;
47
}
48
49
std::vector<const xAOD::Photon*>
PhotonsLoader::getPhotonsFromVertex
(
50
const
xAOD::Vertex
& vertex
51
)
const
52
{
53
std::vector<std::pair<double, const xAOD::Photon*>> particles;
54
for
(
const
xAOD::Photon
*tp :
m_associator
(vertex)) {
55
particles.emplace_back(
m_iparticleSortVar
(tp, vertex), tp);
56
}
57
std::sort
(particles.begin(), particles.end(), std::greater<>());
58
std::vector<const xAOD::Photon*> only_particles;
59
only_particles.reserve(particles.size());
60
for
(
const
auto
& particle: particles) {
61
only_particles.push_back(particle.second);
62
}
63
return
only_particles;
64
}
65
66
std::tuple<std::string, FlavorTagInference::Inputs, std::vector<const xAOD::IParticle*>>
PhotonsLoader::getData
(
67
const
xAOD::Vertex
& vertex)
const
{
68
Photons
sorted_particles =
getPhotonsFromVertex
(vertex);
69
std::vector<const xAOD::IParticle*> sorted_particles_ip;
70
for
(
const
auto
& p: sorted_particles) {
71
sorted_particles_ip.push_back(p);
72
}
73
return
std::make_tuple(
m_config
.output_name,
m_customSequenceGetter
.getFeats(vertex, sorted_particles), sorted_particles_ip);
74
}
75
76
std::string
PhotonsLoader::getName
()
const
{
77
return
m_name
;
78
}
79
ConstituentsType
PhotonsLoader::getType
()
const
{
80
return
m_config
.type;
81
}
82
83
}
Photon.h
PhotonsLoader.h
ElementLink
ElementLink implementation for ROOT usage.
Definition
A/AthLinks/ElementLink.h:40
InDetGNNHardScatterSelection::IConstituentsLoader::m_name
std::string m_name
Definition
InnerDetector/InDetRecTools/InDetGNNHardScatterSelection/InDetGNNHardScatterSelection/ConstituentsLoader.h:72
InDetGNNHardScatterSelection::IConstituentsLoader::IConstituentsLoader
IConstituentsLoader(const ConstituentsInputConfig &cfg)
Definition
InnerDetector/InDetRecTools/InDetGNNHardScatterSelection/InDetGNNHardScatterSelection/ConstituentsLoader.h:63
InDetGNNHardScatterSelection::IConstituentsLoader::m_config
ConstituentsInputConfig m_config
Definition
InnerDetector/InDetRecTools/InDetGNNHardScatterSelection/InDetGNNHardScatterSelection/ConstituentsLoader.h:71
InDetGNNHardScatterSelection::PhotonsLoader::m_iparticleSortVar
PhotonSortVar m_iparticleSortVar
Definition
PhotonsLoader.h:60
InDetGNNHardScatterSelection::PhotonsLoader::Photons
std::vector< const xAOD::Photon * > Photons
Definition
PhotonsLoader.h:45
InDetGNNHardScatterSelection::PhotonsLoader::Vertex
xAOD::Vertex Vertex
Definition
PhotonsLoader.h:41
InDetGNNHardScatterSelection::PhotonsLoader::getName
std::string getName() const override
Definition
PhotonsLoader.cxx:76
InDetGNNHardScatterSelection::PhotonsLoader::getPhotonsFromVertex
std::vector< const xAOD::Photon * > getPhotonsFromVertex(const xAOD::Vertex &vertex) const
Definition
PhotonsLoader.cxx:49
InDetGNNHardScatterSelection::PhotonsLoader::m_customSequenceGetter
getter_utils::CustomSequenceGetter< xAOD::Photon > m_customSequenceGetter
Definition
PhotonsLoader.h:61
InDetGNNHardScatterSelection::PhotonsLoader::IPV
std::vector< const xAOD::Photon * > IPV
Definition
PhotonsLoader.h:54
InDetGNNHardScatterSelection::PhotonsLoader::m_associator
std::function< IPV(const Vertex &)> m_associator
Definition
PhotonsLoader.h:62
InDetGNNHardScatterSelection::PhotonsLoader::getType
ConstituentsType getType() const override
Definition
PhotonsLoader.cxx:79
InDetGNNHardScatterSelection::PhotonsLoader::PhotonsLoader
PhotonsLoader(const ConstituentsInputConfig &cfg)
Definition
PhotonsLoader.cxx:27
InDetGNNHardScatterSelection::PhotonsLoader::getData
std::tuple< std::string, FlavorTagInference::Inputs, std::vector< const xAOD::IParticle * > > getData(const xAOD::Vertex &vertex) const override
Definition
PhotonsLoader.cxx:66
InDetGNNHardScatterSelection::PhotonsLoader::iparticleSortVar
static PhotonSortVar iparticleSortVar(ConstituentsSortOrder)
Definition
PhotonsLoader.cxx:13
InDetGNNHardScatterSelection::PhotonsLoader::PhotonSortVar
std::function< double(const xAOD::Photon *, const Vertex &)> PhotonSortVar
Definition
PhotonsLoader.h:48
Photon
Class describing an photon.
InDetGNNHardScatterSelection::getter_utils
Utils to produce Constituent -> vector<double> functions.
Definition
InnerDetector/InDetRecTools/InDetGNNHardScatterSelection/InDetGNNHardScatterSelection/CustomGetterUtils.h:46
InDetGNNHardScatterSelection
Definition
InnerDetector/InDetRecTools/InDetGNNHardScatterSelection/InDetGNNHardScatterSelection/ConstituentsLoader.h:22
InDetGNNHardScatterSelection::ConstituentsType
ConstituentsType
Definition
InnerDetector/InDetRecTools/InDetGNNHardScatterSelection/InDetGNNHardScatterSelection/ConstituentsLoader.h:31
InDetGNNHardScatterSelection::ConstituentsSortOrder
ConstituentsSortOrder
Definition
InnerDetector/InDetRecTools/InDetGNNHardScatterSelection/InDetGNNHardScatterSelection/ConstituentsLoader.h:25
InDetGNNHardScatterSelection::ConstituentsSortOrder::PT_DESCENDING
@ PT_DESCENDING
Definition
InnerDetector/InDetRecTools/InDetGNNHardScatterSelection/InDetGNNHardScatterSelection/ConstituentsLoader.h:26
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::Vertex
Vertex_v1 Vertex
Define the latest version of the vertex class.
Definition
Event/xAOD/xAODTracking/xAODTracking/Vertex.h:16
xAOD::Photon
Photon_v1 Photon
Definition of the current "egamma version".
Definition
Event/xAOD/xAODEgamma/xAODEgamma/Photon.h:17
InDetGNNHardScatterSelection::ConstituentsInputConfig
Definition
InnerDetector/InDetRecTools/InDetGNNHardScatterSelection/InDetGNNHardScatterSelection/ConstituentsLoader.h:45
Generated on
for ATLAS Offline Software by
1.17.0