ATLAS Offline Software
ElectronsLoader.cxx
Go to the documentation of this file.
1 /*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include "xAODEgamma/Electron.h"
8 
10 
11  // factory for functions which return the sort variable we
12  // use to order iparticles
15  {
16  typedef xAOD::Electron Ip;
17  typedef xAOD::Vertex Vertex;
18  switch(config) {
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 
29  ):
31  m_iparticleSortVar(ElectronsLoader::iparticleSortVar(cfg.order)),
32  m_customSequenceGetter(getter_utils::CustomSequenceGetter<xAOD::Electron>(
33  cfg.inputs))
34  {
35  const SG::AuxElement::ConstAccessor<PartLinks> acc("electronLinks");
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::Electron*> ElectronsLoader::getElectronsFromVertex(
50  const xAOD::Vertex& vertex
51  ) const
52  {
53  std::vector<std::pair<double, const xAOD::Electron*>> particles;
54  for (const xAOD::Electron *tp : m_associator(vertex)) {
55  particles.push_back({m_iparticleSortVar(tp, vertex), tp});
56  }
57  std::sort(particles.begin(), particles.end(), std::greater<>());
58  std::vector<const xAOD::Electron*> only_particles;
59  for (const auto& particle: particles) {
60  only_particles.push_back(particle.second);
61  }
62  return only_particles;
63  }
64 
65  std::tuple<std::string, FlavorTagDiscriminants::Inputs, std::vector<const xAOD::IParticle*>> ElectronsLoader::getData(
66  const xAOD::Vertex& vertex) const {
67  Electrons sorted_particles = getElectronsFromVertex(vertex);
68  std::vector<const xAOD::IParticle*> sorted_particles_ip;
69  for (const auto& p: sorted_particles) {
70  sorted_particles_ip.push_back(p);
71  }
72  return std::make_tuple(m_config.output_name, m_customSequenceGetter.getFeats(vertex, sorted_particles), sorted_particles_ip);
73  }
74 
75  std::string ElectronsLoader::getName() const {
76  return m_name;
77  }
79  return m_config.type;
80  }
81 
82 }
InDetGNNHardScatterSelection::ConstituentsInputConfig::output_name
std::string output_name
Definition: InnerDetector/InDetRecTools/InDetGNNHardScatterSelection/InDetGNNHardScatterSelection/ConstituentsLoader.h:47
InDetGNNHardScatterSelection::ElectronsLoader::Vertex
xAOD::Vertex Vertex
Definition: ElectronsLoader.h:41
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
ParticleTest.tp
tp
Definition: ParticleTest.py:25
InDetGNNHardScatterSelection::ConstituentsInputConfig
Definition: InnerDetector/InDetRecTools/InDetGNNHardScatterSelection/InDetGNNHardScatterSelection/ConstituentsLoader.h:45
InDetGNNHardScatterSelection::ConstituentsType
ConstituentsType
Definition: InnerDetector/InDetRecTools/InDetGNNHardScatterSelection/InDetGNNHardScatterSelection/ConstituentsLoader.h:31
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:55
InDetGNNHardScatterSelection::ElectronsLoader::IPV
std::vector< const xAOD::Electron * > IPV
Definition: ElectronsLoader.h:57
InDetGNNHardScatterSelection::ElectronsLoader::m_customSequenceGetter
getter_utils::CustomSequenceGetter< xAOD::Electron > m_customSequenceGetter
Definition: ElectronsLoader.h:64
InDetGNNHardScatterSelection::IConstituentsLoader
Definition: InnerDetector/InDetRecTools/InDetGNNHardScatterSelection/InDetGNNHardScatterSelection/ConstituentsLoader.h:61
postInclude.inputs
inputs
Definition: postInclude.SortInput.py:15
InDetGNNHardScatterSelection::ConstituentsInputConfig::type
ConstituentsType type
Definition: InnerDetector/InDetRecTools/InDetGNNHardScatterSelection/InDetGNNHardScatterSelection/ConstituentsLoader.h:49
InDetGNNHardScatterSelection::ElectronsLoader::m_iparticleSortVar
ElectronSortVar m_iparticleSortVar
Definition: ElectronsLoader.h:63
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
InDetGNNHardScatterSelection::ConstituentsSortOrder
ConstituentsSortOrder
Definition: InnerDetector/InDetRecTools/InDetGNNHardScatterSelection/InDetGNNHardScatterSelection/ConstituentsLoader.h:25
InDetGNNHardScatterSelection::ElectronsLoader::getData
std::tuple< std::string, FlavorTagDiscriminants::Inputs, std::vector< const xAOD::IParticle * > > getData(const xAOD::Vertex &vertex) const override
Definition: ElectronsLoader.cxx:65
mc.order
order
Configure Herwig7.
Definition: mc.Herwig7_Dijet.py:12
AthenaPoolTestRead.acc
acc
Definition: AthenaPoolTestRead.py:16
InDetGNNHardScatterSelection::ElectronsLoader::getElectronsFromVertex
std::vector< const xAOD::Electron * > getElectronsFromVertex(const xAOD::Vertex &vertex) const
Definition: ElectronsLoader.cxx:49
InDetGNNHardScatterSelection::ElectronsLoader::ElectronsLoader
ElectronsLoader(ConstituentsInputConfig)
Definition: ElectronsLoader.cxx:27
InDetGNNHardScatterSelection::IConstituentsLoader::m_config
ConstituentsInputConfig m_config
Definition: InnerDetector/InDetRecTools/InDetGNNHardScatterSelection/InDetGNNHardScatterSelection/ConstituentsLoader.h:73
InDetGNNHardScatterSelection::ElectronsLoader::getType
ConstituentsType getType() const override
Definition: ElectronsLoader.cxx:78
InDetGNNHardScatterSelection::ElectronsLoader
Definition: ElectronsLoader.h:32
ElectronsLoader.h
InDetGNNHardScatterSelection::ElectronsLoader::m_associator
std::function< IPV(const Vertex &)> m_associator
Definition: ElectronsLoader.h:65
WriteCaloSwCorrections.cfg
cfg
Definition: WriteCaloSwCorrections.py:23
xAOD::Electron_v1
Definition: Electron_v1.h:34
InDetGNNHardScatterSelection::ConstituentsSortOrder::PT_DESCENDING
@ PT_DESCENDING
Trk::vertex
@ vertex
Definition: MeasurementType.h:21
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
InDetGNNHardScatterSelection::ElectronsLoader::getName
std::string getName() const override
Definition: ElectronsLoader.cxx:75
InDetGNNHardScatterSelection
Definition: InnerDetector/InDetRecTools/InDetGNNHardScatterSelection/InDetGNNHardScatterSelection/ConstituentsLoader.h:22
Electron
Class describing an electron.
InDetGNNHardScatterSelection::IConstituentsLoader::m_name
std::string m_name
Definition: InnerDetector/InDetRecTools/InDetGNNHardScatterSelection/InDetGNNHardScatterSelection/ConstituentsLoader.h:74
LArG4FSStartPointFilter.particles
list particles
Definition: LArG4FSStartPointFilter.py:84
InDetGNNHardScatterSelection::ElectronsLoader::ElectronSortVar
std::function< double(const xAOD::Electron *, const Vertex &)> ElectronSortVar
Definition: ElectronsLoader.h:48
Electron.h
InDetGNNHardScatterSelection::ElectronsLoader::iparticleSortVar
ElectronSortVar iparticleSortVar(ConstituentsSortOrder)
Definition: ElectronsLoader.cxx:13
InDetGNNHardScatterSelection::ElectronsLoader::Electrons
std::vector< const xAOD::Electron * > Electrons
Definition: ElectronsLoader.h:45