ATLAS Offline Software
Loading...
Searching...
No Matches
FlowElementsLoader.cxx
Go to the documentation of this file.
1/*
2Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
8#include <vector>
9
10namespace FlavorTagInference {
11
12 // factory for functions which return the sort variable we
13 // use to order flow elements
16 {
17 typedef xAOD::FlowElement FE;
18 typedef xAOD::IParticle Jet;
19 switch(config) {
21 return [](const FE* p, const Jet&) {return p->pt();};
22 default: {
23 throw std::logic_error("Unknown sort function");
24 }
25 }
26 } // end of FlowElements sort getter
27
29 const ConstituentsInputConfig& cfg,
30 const FTagOptions& options
31 ):
34 m_seqGetter(getter_utils::SeqGetter<xAOD::FlowElement>(
35 cfg.inputs, options))
36 {
37 static const SG::AuxElement::ConstAccessor<PartLinks> acc("constituentLinks");
38 m_associator = [](const xAOD::IParticle& jet) -> FEV {
39 FEV particles;
40 for (const ElementLink<IPC>& link : acc(jet)){
41 if (!link.isValid()) {
42 throw std::logic_error("invalid particle link");
43 }
44 const auto* flow = dynamic_cast<const xAOD::FlowElement*>(*link);
45 if (!flow){
46 throw std::runtime_error("FlowsLoader: Dynamic cast to FlowElement failed");
47 }
48 particles.push_back(flow);
49 }
50 return particles;
51 };
52
53 m_used_remap = m_seqGetter.getUsedRemap();
54 m_name = cfg.name;
55 }
56
57 std::vector<const xAOD::FlowElement*> FlowElementsLoader::getFlowElementsFromJet(
58 const xAOD::IParticle& jet
59 ) const
60 {
61 std::vector<std::pair<double, const xAOD::FlowElement*>> particles;
62 for (const xAOD::FlowElement *p : m_associator(jet)) {
63 particles.push_back({m_flowElementSortVar(p, jet), p});
64 }
65 std::sort(particles.begin(), particles.end(), std::greater<>());
66 std::vector<const xAOD::FlowElement*> only_particles;
67 for (const auto& particle: particles) {
68 only_particles.push_back(particle.second);
69 }
70 return only_particles;
71 }
72
73 std::tuple<Inputs, std::vector<const xAOD::IParticle*>> FlowElementsLoader::getData(
74 const xAOD::IParticle& jet) const {
76
77 // We return a dummy vector of IParticles as we don't decorate flow elements
78 return std::make_tuple(m_seqGetter.getFeats(jet, sorted_flows), std::vector<const xAOD::IParticle *>{});
79 }
80
84 const std::set<std::string>& FlowElementsLoader::getUsedRemap() const {
85 return m_used_remap;
86 }
87 const std::string& FlowElementsLoader::getName() const {
88 return m_name;
89 }
91 return m_config.type;
92 }
93
94}
const ConstituentsType & getType() const override
std::function< FEV(const Jet &)> m_associator
const FTagDataDependencyNames & getDependencies() const override
FlowElementsLoader(const ConstituentsInputConfig &cfg, const FTagOptions &options)
std::function< double(const xAOD::FlowElement *, const Jet &)> FlowElementSortVar
getter_utils::SeqGetter< xAOD::FlowElement > m_seqGetter
const std::set< std::string > & getUsedRemap() const override
const std::string & getName() const override
std::vector< const xAOD::FlowElement * > getFlowElementsFromJet(const xAOD::IParticle &jet) const
std::vector< const xAOD::FlowElement * > FEV
std::tuple< Inputs, std::vector< const xAOD::IParticle * > > getData(const xAOD::IParticle &jet) const override
std::vector< const xAOD::FlowElement * > FlowElements
FlowElementSortVar flowElementSortVar(ConstituentsSortOrder)
SG::ConstAccessor< T, ALLOC > ConstAccessor
Definition AuxElement.h:569
Class providing the definition of the 4-vector interface.
This file contains "getter" functions used for accessing tagger inputs from the EDM.
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.
FlowElement_v1 FlowElement
Definition of the current "pfo version".
Definition FlowElement.h:16