ATLAS Offline Software
JetsLoader.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 "xAODJet/Jet.h"
8 
10 
11 
12  // factory for functions which return the sort variable we
13  // use to order iparticles
16  {
17  typedef xAOD::Jet Ip;
18  typedef xAOD::Vertex Vertex;
19  switch(config) {
21  return [](const Ip* tp, const Vertex&) {return tp->pt();};
22  default: {
23  throw std::logic_error("Unknown sort function");
24  }
25  }
26  } // end of iparticle sort getter
27 
30  m_iparticleSortVar(JetsLoader::iparticleSortVar(cfg.order)),
31  m_customSequenceGetter(getter_utils::CustomSequenceGetter<xAOD::Jet>(
32  cfg.inputs))
33  {
35  m_associator = [acc](const xAOD::Vertex& vertex) -> IPV {
36  IPV particles;
37  for (const ElementLink<IPC>& link : acc(vertex)){
38  if (!link.isValid()) {
39  throw std::logic_error("invalid particle link");
40  }
41  particles.push_back(*link);
42  }
43  return particles;
44  };
45  m_name = cfg.name;
46  }
47 
48  std::vector<const xAOD::Jet*> JetsLoader::getJetsFromVertex(
49  const xAOD::Vertex& vertex
50  ) const
51  {
52  std::vector<std::pair<double, const xAOD::Jet*>> particles;
53  for (const xAOD::Jet *tp : m_associator(vertex)) {
54  particles.push_back({m_iparticleSortVar(tp, vertex), tp});
55  }
56  std::sort(particles.begin(), particles.end(), std::greater<>());
57  std::vector<const xAOD::Jet*> only_particles;
58  for (const auto& particle: particles) {
59  only_particles.push_back(particle.second);
60  }
61  return only_particles;
62  }
63 
64  std::tuple<std::string, FlavorTagDiscriminants::Inputs, std::vector<const xAOD::IParticle*>> JetsLoader::getData(
65  const xAOD::Vertex& vertex) const {
66  Jets sorted_particles = getJetsFromVertex(vertex);
67  std::vector<const xAOD::IParticle*> sorted_particles_ip;
68  for (const auto& p: sorted_particles) {
69  sorted_particles_ip.push_back(p);
70  }
71  return std::make_tuple(m_config.output_name, m_customSequenceGetter.getFeats(vertex, sorted_particles), sorted_particles_ip);
72  }
73 
74  std::string JetsLoader::getName() const {
75  return m_name;
76  }
78  return m_config.type;
79  }
80 
81 }
InDetGNNHardScatterSelection::ConstituentsInputConfig::output_name
std::string output_name
Definition: InnerDetector/InDetRecTools/InDetGNNHardScatterSelection/InDetGNNHardScatterSelection/ConstituentsLoader.h:47
InDetGNNHardScatterSelection::JetsLoader::getType
ConstituentsType getType() const override
Definition: JetsLoader.cxx:77
Jet.h
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
Jet
Basic data class defines behavior for all Jet objects The Jet class is the principal data class for...
Definition: Reconstruction/Jet/JetEvent/JetEvent/Jet.h:47
InDetGNNHardScatterSelection::JetsLoader::getData
std::tuple< std::string, FlavorTagDiscriminants::Inputs, std::vector< const xAOD::IParticle * > > getData(const xAOD::Vertex &vertex) const override
Definition: JetsLoader.cxx:64
Jets
Definition: Jets.py:1
InDetGNNHardScatterSelection::JetsLoader::Vertex
xAOD::Vertex Vertex
Definition: JetsLoader.h:41
InDetGNNHardScatterSelection::JetsLoader::m_associator
std::function< IPV(const Vertex &)> m_associator
Definition: JetsLoader.h:62
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
InDetGNNHardScatterSelection::JetsLoader::JetSortVar
std::function< double(const xAOD::Jet *, const Vertex &)> JetSortVar
Definition: JetsLoader.h:48
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::JetsLoader::IPV
std::vector< const xAOD::Jet * > IPV
Definition: JetsLoader.h:54
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
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
InDetGNNHardScatterSelection::JetsLoader::m_iparticleSortVar
JetSortVar m_iparticleSortVar
Definition: JetsLoader.h:60
InDetGNNHardScatterSelection::ConstituentsSortOrder
ConstituentsSortOrder
Definition: InnerDetector/InDetRecTools/InDetGNNHardScatterSelection/InDetGNNHardScatterSelection/ConstituentsLoader.h:25
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
mc.order
order
Configure Herwig7.
Definition: mc.Herwig7_Dijet.py:12
AthenaPoolTestRead.acc
acc
Definition: AthenaPoolTestRead.py:16
JetsLoader.h
InDetGNNHardScatterSelection::JetsLoader
Definition: JetsLoader.h:32
InDetGNNHardScatterSelection::JetsLoader::getName
std::string getName() const override
Definition: JetsLoader.cxx:74
InDetGNNHardScatterSelection::IConstituentsLoader::m_config
ConstituentsInputConfig m_config
Definition: InnerDetector/InDetRecTools/InDetGNNHardScatterSelection/InDetGNNHardScatterSelection/ConstituentsLoader.h:71
WriteCaloSwCorrections.cfg
cfg
Definition: WriteCaloSwCorrections.py:23
InDetGNNHardScatterSelection::ConstituentsSortOrder::PT_DESCENDING
@ PT_DESCENDING
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
InDetGNNHardScatterSelection::JetsLoader::getJetsFromVertex
std::vector< const xAOD::Jet * > getJetsFromVertex(const xAOD::Vertex &vertex) const
Definition: JetsLoader.cxx:48
Trk::vertex
@ vertex
Definition: MeasurementType.h:21
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
InDetGNNHardScatterSelection
Definition: InnerDetector/InDetRecTools/InDetGNNHardScatterSelection/InDetGNNHardScatterSelection/ConstituentsLoader.h:22
InDetGNNHardScatterSelection::JetsLoader::m_customSequenceGetter
getter_utils::CustomSequenceGetter< xAOD::Jet > m_customSequenceGetter
Definition: JetsLoader.h:61
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::JetsLoader::iparticleSortVar
JetSortVar iparticleSortVar(ConstituentsSortOrder)
Definition: JetsLoader.cxx:14
InDetGNNHardScatterSelection::JetsLoader::JetsLoader
JetsLoader(const ConstituentsInputConfig &)
Definition: JetsLoader.cxx:28