ATLAS Offline Software
Loading...
Searching...
No Matches
JetsLoader.cxx
Go to the documentation of this file.
1/*
2Copyright (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 using Ip = xAOD::Jet;
18 using Vertex = xAOD::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
31 m_customSequenceGetter(getter_utils::CustomSequenceGetter<xAOD::Jet>(
32 cfg.inputs))
33 {
34 const SG::AuxElement::ConstAccessor<PartLinks> acc("jetLinks");
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.emplace_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 only_particles.reserve(particles.size());
59for (const auto& particle: particles) {
60 only_particles.push_back(particle.second);
61 }
62 return only_particles;
63 }
64
65 std::tuple<std::string, FlavorTagInference::Inputs, std::vector<const xAOD::IParticle*>> JetsLoader::getData(
66 const xAOD::Vertex& vertex) const {
67 Jets sorted_particles = getJetsFromVertex(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 JetsLoader::getName() const {
76 return m_name;
77 }
79 return m_config.type;
80 }
81
82}
std::vector< const xAOD::Jet * > IPV
Definition JetsLoader.h:54
std::function< double(const xAOD::Jet *, const Vertex &)> JetSortVar
Definition JetsLoader.h:48
std::tuple< std::string, FlavorTagInference::Inputs, std::vector< const xAOD::IParticle * > > getData(const xAOD::Vertex &vertex) const override
getter_utils::CustomSequenceGetter< xAOD::Jet > m_customSequenceGetter
Definition JetsLoader.h:61
std::function< IPV(const Vertex &)> m_associator
Definition JetsLoader.h:62
std::vector< const xAOD::Jet * > getJetsFromVertex(const xAOD::Vertex &vertex) const
static JetSortVar iparticleSortVar(ConstituentsSortOrder)
JetsLoader(const ConstituentsInputConfig &)
std::string getName() const override
ConstituentsType getType() const override
SG::ConstAccessor< T, ALLOC > ConstAccessor
Definition AuxElement.h:569
Definition Jets.py:1
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Jet_v1 Jet
Definition of the current "jet version".
Vertex_v1 Vertex
Define the latest version of the vertex class.