ATLAS Offline Software
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
FlavorTagDiscriminants::IParticlesLoader Class Reference

#include <IParticlesLoader.h>

Inheritance diagram for FlavorTagDiscriminants::IParticlesLoader:
Collaboration diagram for FlavorTagDiscriminants::IParticlesLoader:

Public Member Functions

 IParticlesLoader (ConstituentsInputConfig, const FTagOptions &options)
 
std::tuple< std::string, Inputs, std::vector< const xAOD::IParticle * > > getData (const xAOD::Jet &jet, [[maybe_unused]] const SG::AuxElement &btag) const override
 
FTagDataDependencyNames getDependencies () const override
 
std::set< std::string > getUsedRemap () const override
 
std::string getName () const override
 
ConstituentsType getType () const override
 

Protected Types

typedef xAOD::Jet Jet
 
typedef std::pair< std::string, double > NamedVar
 
typedef std::pair< std::string, std::vector< double > > NamedSeq
 
typedef std::vector< const xAOD::IParticle * > IParticles
 
typedef std::function< double(const xAOD::IParticle *, const Jet &)> IParticleSortVar
 
typedef std::function< NamedSeq(const Jet &, const IParticles &)> SeqFromIParticles
 
using AE = SG::AuxElement
 
using IPC = xAOD::IParticleContainer
 
using PartLinks = std::vector< ElementLink< IPC > >
 
using IPV = std::vector< const xAOD::IParticle * >
 

Protected Member Functions

IParticleSortVar iparticleSortVar (ConstituentsSortOrder)
 
std::vector< const xAOD::IParticle * > getIParticlesFromJet (const xAOD::Jet &jet) const
 

Protected Attributes

IParticleSortVar m_iparticleSortVar
 
getter_utils::SeqGetter< xAOD::IParticlem_seqGetter
 
std::function< IPV(const Jet &)> m_associator
 
bool m_isCharged
 
FTagDataDependencyNames m_deps
 
ConstituentsInputConfig m_config
 
std::set< std::string > m_used_remap
 
std::string m_name
 

Detailed Description

Definition at line 34 of file IParticlesLoader.h.

Member Typedef Documentation

◆ AE

Definition at line 58 of file IParticlesLoader.h.

◆ IParticles

Definition at line 50 of file IParticlesLoader.h.

◆ IParticleSortVar

Definition at line 52 of file IParticlesLoader.h.

◆ IPC

Definition at line 59 of file IParticlesLoader.h.

◆ IPV

Definition at line 61 of file IParticlesLoader.h.

◆ Jet

Definition at line 46 of file IParticlesLoader.h.

◆ NamedSeq

typedef std::pair<std::string, std::vector<double> > FlavorTagDiscriminants::IParticlesLoader::NamedSeq
protected

Definition at line 48 of file IParticlesLoader.h.

◆ NamedVar

typedef std::pair<std::string, double> FlavorTagDiscriminants::IParticlesLoader::NamedVar
protected

Definition at line 47 of file IParticlesLoader.h.

◆ PartLinks

Definition at line 60 of file IParticlesLoader.h.

◆ SeqFromIParticles

Definition at line 55 of file IParticlesLoader.h.

Constructor & Destructor Documentation

◆ IParticlesLoader()

FlavorTagDiscriminants::IParticlesLoader::IParticlesLoader ( ConstituentsInputConfig  cfg,
const FTagOptions options 
)

Definition at line 27 of file IParticlesLoader.cxx.

30  :
33  m_seqGetter(getter_utils::SeqGetter<xAOD::IParticle>(
34  cfg.inputs, options))
35  {
37  m_associator = [acc](const xAOD::Jet& jet) -> IPV {
38  IPV particles;
39  for (const ElementLink<IPC>& link : acc(jet)){
40  if (!link.isValid()) {
41  throw std::logic_error("invalid particle link");
42  }
43  particles.push_back(*link);
44  }
45  return particles;
46  };
47 
48  if (cfg.name.find("charged") != std::string::npos){
49  m_isCharged = true;
50  } else {
51  m_isCharged = false;
52  }
54  m_name = cfg.name;
55  }

Member Function Documentation

◆ getData()

std::tuple< std::string, Inputs, std::vector< const xAOD::IParticle * > > FlavorTagDiscriminants::IParticlesLoader::getData ( const xAOD::Jet jet,
[[maybe_unused] ] const SG::AuxElement btag 
) const
overridevirtual

Implements FlavorTagDiscriminants::IConstituentsLoader.

Definition at line 90 of file IParticlesLoader.cxx.

92  {
93  IParticles sorted_particles = getIParticlesFromJet(jet);
94 
95  return std::make_tuple(m_config.output_name, m_seqGetter.getFeats(jet, sorted_particles), sorted_particles);
96  }

◆ getDependencies()

FTagDataDependencyNames FlavorTagDiscriminants::IParticlesLoader::getDependencies ( ) const
overridevirtual

Implements FlavorTagDiscriminants::IConstituentsLoader.

Definition at line 98 of file IParticlesLoader.cxx.

98  {
99  return m_deps;
100  }

◆ getIParticlesFromJet()

std::vector< const xAOD::IParticle * > FlavorTagDiscriminants::IParticlesLoader::getIParticlesFromJet ( const xAOD::Jet jet) const
protected

Definition at line 57 of file IParticlesLoader.cxx.

60  {
61  std::vector<std::pair<double, const xAOD::IParticle*>> particles;
62  for (const xAOD::IParticle *tp : m_associator(jet)) {
63  particles.push_back({m_iparticleSortVar(tp, jet), tp});
64  }
65  std::sort(particles.begin(), particles.end(), std::greater<>());
66  std::vector<const xAOD::IParticle*> only_particles;
67  for (const auto& particle: particles) {
68  auto* flow = dynamic_cast<const xAOD::FlowElement*>(particle.second);
69  const xAOD::IParticle* obj = nullptr;
70  if (!flow){
71  throw std::runtime_error("IParticlesLoader: Dynamic cast to FlowElement failed");
72  }
73  if ((flow->isCharged() != m_isCharged)) continue;
74  else {
75  if (m_isCharged){
76  obj = flow->chargedObject(0);
77  }
78  else{
79  obj = flow;
80  }
81  }
82  if (!obj){
83  continue;
84  }
85  only_particles.push_back(obj);
86  }
87  return only_particles;
88  }

◆ getName()

std::string FlavorTagDiscriminants::IParticlesLoader::getName ( ) const
overridevirtual

Implements FlavorTagDiscriminants::IConstituentsLoader.

Definition at line 104 of file IParticlesLoader.cxx.

104  {
105  return m_name;
106  }

◆ getType()

ConstituentsType FlavorTagDiscriminants::IParticlesLoader::getType ( ) const
overridevirtual

Implements FlavorTagDiscriminants::IConstituentsLoader.

Definition at line 107 of file IParticlesLoader.cxx.

107  {
108  return m_config.type;
109  }

◆ getUsedRemap()

std::set< std::string > FlavorTagDiscriminants::IParticlesLoader::getUsedRemap ( ) const
overridevirtual

Implements FlavorTagDiscriminants::IConstituentsLoader.

Definition at line 101 of file IParticlesLoader.cxx.

101  {
102  return m_used_remap;
103  }

◆ iparticleSortVar()

IParticlesLoader::IParticleSortVar FlavorTagDiscriminants::IParticlesLoader::iparticleSortVar ( ConstituentsSortOrder  config)
protected

Definition at line 13 of file IParticlesLoader.cxx.

15  {
16  typedef xAOD::IParticle Ip;
17  typedef xAOD::Jet Jet;
18  switch(config) {
20  return [](const Ip* tp, const Jet&) {return tp->pt();};
21  default: {
22  throw std::logic_error("Unknown sort function");
23  }
24  }
25  } // end of iparticle sort getter

Member Data Documentation

◆ m_associator

std::function<IPV(const Jet&)> FlavorTagDiscriminants::IParticlesLoader::m_associator
protected

Definition at line 69 of file IParticlesLoader.h.

◆ m_config

ConstituentsInputConfig FlavorTagDiscriminants::IConstituentsLoader::m_config
protectedinherited

Definition at line 91 of file ConstituentsLoader.h.

◆ m_deps

FTagDataDependencyNames FlavorTagDiscriminants::IConstituentsLoader::m_deps
protectedinherited

Definition at line 90 of file ConstituentsLoader.h.

◆ m_iparticleSortVar

IParticleSortVar FlavorTagDiscriminants::IParticlesLoader::m_iparticleSortVar
protected

Definition at line 67 of file IParticlesLoader.h.

◆ m_isCharged

bool FlavorTagDiscriminants::IParticlesLoader::m_isCharged
protected

Definition at line 70 of file IParticlesLoader.h.

◆ m_name

std::string FlavorTagDiscriminants::IConstituentsLoader::m_name
protectedinherited

Definition at line 93 of file ConstituentsLoader.h.

◆ m_seqGetter

getter_utils::SeqGetter<xAOD::IParticle> FlavorTagDiscriminants::IParticlesLoader::m_seqGetter
protected

Definition at line 68 of file IParticlesLoader.h.

◆ m_used_remap

std::set<std::string> FlavorTagDiscriminants::IConstituentsLoader::m_used_remap
protectedinherited

Definition at line 92 of file ConstituentsLoader.h.


The documentation for this class was generated from the following files:
FlavorTagDiscriminants::getter_utils::SeqGetter::getFeats
std::pair< std::vector< float >, std::vector< int64_t > > getFeats(const xAOD::Jet &jet, const Const &constituents) const
Definition: CustomGetterUtils.cxx:414
FlavorTagDiscriminants::IParticlesLoader::getIParticlesFromJet
std::vector< const xAOD::IParticle * > getIParticlesFromJet(const xAOD::Jet &jet) const
Definition: IParticlesLoader.cxx:57
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
FlavorTagDiscriminants::ConstituentsInputConfig::type
ConstituentsType type
Definition: ConstituentsLoader.h:62
FlavorTagDiscriminants::IParticlesLoader::Jet
xAOD::Jet Jet
Definition: IParticlesLoader.h:46
FlavorTagDiscriminants::IParticlesLoader::IParticles
std::vector< const xAOD::IParticle * > IParticles
Definition: IParticlesLoader.h:50
FlavorTagDiscriminants::IParticlesLoader::m_isCharged
bool m_isCharged
Definition: IParticlesLoader.h:70
ParticleTest.tp
tp
Definition: ParticleTest.py:25
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:54
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:40
FlavorTagDiscriminants::IParticlesLoader::iparticleSortVar
IParticleSortVar iparticleSortVar(ConstituentsSortOrder)
Definition: IParticlesLoader.cxx:13
FlavorTagDiscriminants::IConstituentsLoader::m_name
std::string m_name
Definition: ConstituentsLoader.h:93
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
FlavorTagDiscriminants::IConstituentsLoader::m_used_remap
std::set< std::string > m_used_remap
Definition: ConstituentsLoader.h:92
FlavorTagDiscriminants::IConstituentsLoader::IConstituentsLoader
IConstituentsLoader(ConstituentsInputConfig cfg)
Definition: ConstituentsLoader.h:77
FlavorTagDiscriminants::IParticlesLoader::m_iparticleSortVar
IParticleSortVar m_iparticleSortVar
Definition: IParticlesLoader.h:67
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
HepMC::flow
int flow(const T &a, int i)
Definition: Flow.h:51
AthenaPoolTestRead.acc
acc
Definition: AthenaPoolTestRead.py:16
python.AtlRunQueryLib.options
options
Definition: AtlRunQueryLib.py:379
FlavorTagDiscriminants::IParticlesLoader::m_seqGetter
getter_utils::SeqGetter< xAOD::IParticle > m_seqGetter
Definition: IParticlesLoader.h:68
FlavorTagDiscriminants::IConstituentsLoader::m_deps
FTagDataDependencyNames m_deps
Definition: ConstituentsLoader.h:90
FlavorTagDiscriminants::ConstituentsInputConfig::output_name
std::string output_name
Definition: ConstituentsLoader.h:61
FlavorTagDiscriminants::ConstituentsSortOrder::PT_DESCENDING
@ PT_DESCENDING
WriteCaloSwCorrections.cfg
cfg
Definition: WriteCaloSwCorrections.py:23
FlavorTagDiscriminants::IConstituentsLoader::m_config
ConstituentsInputConfig m_config
Definition: ConstituentsLoader.h:91
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
std::sort
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:623
LArG4FSStartPointFilter.particles
list particles
Definition: LArG4FSStartPointFilter.py:84
FlavorTagDiscriminants::getter_utils::SeqGetter::getUsedRemap
std::set< std::string > getUsedRemap() const
Definition: CustomGetterUtils.cxx:456
python.PyAthena.obj
obj
Definition: PyAthena.py:135
FlavorTagDiscriminants::IParticlesLoader::IPV
std::vector< const xAOD::IParticle * > IPV
Definition: IParticlesLoader.h:61
FlavorTagDiscriminants::IParticlesLoader::m_associator
std::function< IPV(const Jet &)> m_associator
Definition: IParticlesLoader.h:69
xAOD::FlowElement_v1
A detector object made of other lower level object(s)
Definition: FlowElement_v1.h:25