ATLAS Offline Software
MuonsLoader.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 "xAODMuon/Muon.h"
8 
10 
11  // factory for functions which return the sort variable we
12  // use to order iparticles
15  {
16  using Ip = xAOD::Muon;
17  using Vertex = xAOD::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(MuonsLoader::iparticleSortVar(cfg.order)),
32  m_customSequenceGetter(getter_utils::CustomSequenceGetter<xAOD::Muon>(
33  cfg.inputs))
34  {
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::Muon*> MuonsLoader::getMuonsFromVertex(
50  const xAOD::Vertex& vertex
51  ) const
52  {
53  std::vector<std::pair<double, const xAOD::Muon*>> particles;
54  for (const xAOD::Muon *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::Muon*> 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*>> MuonsLoader::getData(
67  const xAOD::Vertex& vertex) const {
68  Muons sorted_particles = getMuonsFromVertex(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 MuonsLoader::getName() const {
77  return m_name;
78  }
80  return m_config.type;
81  }
82 
83 }
InDetGNNHardScatterSelection::ConstituentsInputConfig::output_name
std::string output_name
Definition: InnerDetector/InDetRecTools/InDetGNNHardScatterSelection/InDetGNNHardScatterSelection/ConstituentsLoader.h:47
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:79
InDetGNNHardScatterSelection::MuonsLoader::getMuonsFromVertex
std::vector< const xAOD::Muon * > getMuonsFromVertex(const xAOD::Vertex &vertex) const
Definition: MuonsLoader.cxx:49
xAOD::Vertex
Vertex_v1 Vertex
Define the latest version of the vertex class.
Definition: Event/xAOD/xAODTracking/xAODTracking/Vertex.h:16
Muon.h
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
Muon
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
Definition: TrackSystemController.h:45
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
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
InDetGNNHardScatterSelection::ConstituentsSortOrder
ConstituentsSortOrder
Definition: InnerDetector/InDetRecTools/InDetGNNHardScatterSelection/InDetGNNHardScatterSelection/ConstituentsLoader.h:25
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:209
InDetGNNHardScatterSelection::MuonsLoader::getType
ConstituentsType getType() const override
Definition: MuonsLoader.cxx:79
InDetGNNHardScatterSelection::MuonsLoader::m_associator
std::function< IPV(const Vertex &)> m_associator
Definition: MuonsLoader.h:62
MuonsLoader.h
mc.order
order
Configure Herwig7.
Definition: mc.Herwig7_Dijet.py:12
InDetGNNHardScatterSelection::MuonsLoader::IPV
std::vector< const xAOD::Muon * > IPV
Definition: MuonsLoader.h:54
AthenaPoolTestRead.acc
acc
Definition: AthenaPoolTestRead.py:16
InDetGNNHardScatterSelection::MuonsLoader
Definition: MuonsLoader.h:32
InDetGNNHardScatterSelection::MuonsLoader::m_iparticleSortVar
MuonSortVar m_iparticleSortVar
Definition: MuonsLoader.h:60
InDetGNNHardScatterSelection::IConstituentsLoader::m_config
ConstituentsInputConfig m_config
Definition: InnerDetector/InDetRecTools/InDetGNNHardScatterSelection/InDetGNNHardScatterSelection/ConstituentsLoader.h:71
InDetGNNHardScatterSelection::MuonsLoader::iparticleSortVar
static MuonSortVar iparticleSortVar(ConstituentsSortOrder)
Definition: MuonsLoader.cxx:13
xAOD::Muon
Muon_v1 Muon
Reference the current persistent version:
Definition: Event/xAOD/xAODMuon/xAODMuon/Muon.h:13
InDetGNNHardScatterSelection::MuonsLoader::m_customSequenceGetter
getter_utils::CustomSequenceGetter< xAOD::Muon > m_customSequenceGetter
Definition: MuonsLoader.h:61
InDetGNNHardScatterSelection::MuonsLoader::getName
std::string getName() const override
Definition: MuonsLoader.cxx:76
WriteCaloSwCorrections.cfg
cfg
Definition: WriteCaloSwCorrections.py:23
InDetGNNHardScatterSelection::MuonsLoader::getData
std::tuple< std::string, FlavorTagInference::Inputs, std::vector< const xAOD::IParticle * > > getData(const xAOD::Vertex &vertex) const override
Definition: MuonsLoader.cxx:66
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
Muons
Definition: Muons.py:1
InDetGNNHardScatterSelection
Definition: InnerDetector/InDetRecTools/InDetGNNHardScatterSelection/InDetGNNHardScatterSelection/ConstituentsLoader.h:22
InDetGNNHardScatterSelection::IConstituentsLoader::m_name
std::string m_name
Definition: InnerDetector/InDetRecTools/InDetGNNHardScatterSelection/InDetGNNHardScatterSelection/ConstituentsLoader.h:72
LArG4FSStartPointFilter.particles
list particles
Definition: LArG4FSStartPointFilter.py:84
InDetGNNHardScatterSelection::MuonsLoader::MuonSortVar
std::function< double(const xAOD::Muon *, const Vertex &)> MuonSortVar
Definition: MuonsLoader.h:48
InDetGNNHardScatterSelection::MuonsLoader::MuonsLoader
MuonsLoader(const ConstituentsInputConfig &cfg)
Definition: MuonsLoader.cxx:27