ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
IParticleExtractor Class Reference

#include <IParticleExtractor.h>

Inheritance diagram for IParticleExtractor:
Collaboration diagram for IParticleExtractor:

Public Member Functions

 IParticleExtractor (const xAOD::IParticleContainer *, const std::string &label="", bool isGhost=false, bool isTrigger=false)
 
virtual ~IParticleExtractor ()
 
virtual IParticleExtractorclone () const override
 
virtual IParticleExtractorghostClone () const override
 
virtual void addToJet (xAOD::Jet &, const std::vector< int > &indices) const override
 
virtual std::string toString (int level) const override
 
virtual bool checkIntegrity () const override
 

Private Attributes

const xAOD::IParticleContainerm_iParticles
 
std::string m_label
 
bool m_isGhost
 
bool m_debug {false}
 
bool m_isTrigger {false}
 

Detailed Description

Definition at line 18 of file IParticleExtractor.h.

Constructor & Destructor Documentation

◆ IParticleExtractor()

IParticleExtractor::IParticleExtractor ( const xAOD::IParticleContainer ips,
const std::string &  label = "",
bool  isGhost = false,
bool  isTrigger = false 
)

Definition at line 13 of file IParticleExtractor.cxx.

16  :
17  m_iParticles(ips), m_label(label),
18  m_isGhost(isGhost),
19  m_isTrigger(isTrigger)// does not add constits or assoc particles if true
20 {
21 }

◆ ~IParticleExtractor()

IParticleExtractor::~IParticleExtractor ( )
virtualdefault

Member Function Documentation

◆ addToJet()

void IParticleExtractor::addToJet ( xAOD::Jet jet,
const std::vector< int > &  indices 
) const
overridevirtual

Implements IConstituentExtractor.

Definition at line 36 of file IParticleExtractor.cxx.

37  {
38  //Add a template specialisation for muon segments
39 
40  std::vector<const xAOD::IParticle*> constituents;
41  constituents.reserve(indices.size());
42  for(auto i : indices){
43  if(m_debug){
44  constituents.push_back(m_iParticles->at(i));
45  } else {
46  constituents.push_back((*m_iParticles)[i]);
47  }
48  }
49 
50  if(m_isGhost) {
51  // ghosts (in this context) are objects to be stored with the
52  // jet, but with a scaled momentum so they have no kinimatical effect.
53  double ptSum = std::accumulate(constituents.begin(),
54  constituents.end(),
55  0.0,
56  [](double sumPt, const xAOD::IParticle* p){
57  return sumPt + p->pt();});
58 
59  if ( (!m_isTrigger) || (m_label == "GhostTrack") ){jet.setAssociatedObjects(m_label, constituents);}
60  jet.setAttribute<float>(m_label + "Pt", ptSum);
61  jet.setAttribute<int>(m_label+"Count", constituents.size());
62  } else {
63  // these are constituents
64  for(const auto *c: constituents) {
65  jet.addConstituent(c);
66  }
67  }
68 }

◆ checkIntegrity()

bool IParticleExtractor::checkIntegrity ( ) const
overridevirtual

Implements IConstituentExtractor.

Definition at line 104 of file IParticleExtractor.cxx.

104  {
105  for(const auto *const ip: (*m_iParticles)){
106  try{
107  ip->e();
108  } catch(...) {
109  return false;
110  }
111  }
112  return true;
113 }

◆ clone()

IParticleExtractor * IParticleExtractor::clone ( ) const
overridevirtual

Implements IConstituentExtractor.

Definition at line 25 of file IParticleExtractor.cxx.

25  {
26  return new IParticleExtractor(*this);
27 }

◆ ghostClone()

IParticleExtractor * IParticleExtractor::ghostClone ( ) const
overridevirtual

Implements IConstituentExtractor.

Definition at line 29 of file IParticleExtractor.cxx.

29  {
30  // user responsible for deletion.
31  auto *clone = new IParticleExtractor(*this);
32  (*clone).m_isGhost = true;
33  return clone;
34 }

◆ toString()

std::string IParticleExtractor::toString ( int  level) const
overridevirtual

Implements IConstituentExtractor.

Definition at line 72 of file IParticleExtractor.cxx.

72  {
73  std::ostringstream oss{"", std::ios::ate};
74  oss << "IParticleExtractor dump level (" << level << ")"
75  << " label " << m_label
76  << " isGhost: " << std::boolalpha << m_isGhost
77  << " isTrigger: " << std::boolalpha << m_isTrigger
78  << " No of IParticles: " << m_iParticles->size();
79 
80  if (level > 0){
81 
82  oss << "\n IParticle energies\n";
83  std::vector<float> energies;
84  energies.reserve(m_iParticles->size());
86  m_iParticles->end(),
87  std::back_inserter(energies),
88  [](const xAOD::IParticle* p){return p->e();});
89 
90  LineFormatter formatter(10); // 10 numbers/line
91  oss << formatter(energies) << '\n';
92 
93  std::vector<const xAOD::IParticle*> adds(m_iParticles->begin(),
94  m_iParticles->end());
95  oss << "\n IParticle addresses\n"
96  << formatter(adds)
97  << '\n';
98  }
99  return oss.str();
100 }

Member Data Documentation

◆ m_debug

bool IParticleExtractor::m_debug {false}
private

Definition at line 39 of file IParticleExtractor.h.

◆ m_iParticles

const xAOD::IParticleContainer* IParticleExtractor::m_iParticles
private

Definition at line 36 of file IParticleExtractor.h.

◆ m_isGhost

bool IParticleExtractor::m_isGhost
private

Definition at line 38 of file IParticleExtractor.h.

◆ m_isTrigger

bool IParticleExtractor::m_isTrigger {false}
private

Definition at line 40 of file IParticleExtractor.h.

◆ m_label

std::string IParticleExtractor::m_label
private

Definition at line 37 of file IParticleExtractor.h.


The documentation for this class was generated from the following files:
IParticleExtractor::m_debug
bool m_debug
Definition: IParticleExtractor.h:39
PlotCalibFromCool.label
label
Definition: PlotCalibFromCool.py:78
Trk::indices
std::pair< long int, long int > indices
Definition: AlSymMatBase.h:24
accumulate
bool accumulate(AccumulateMap &map, std::vector< module_t > const &modules, FPGATrackSimMatrixAccumulator const &acc)
Accumulates an accumulator (e.g.
Definition: FPGATrackSimMatrixAccumulator.cxx:22
IParticleExtractor::m_isTrigger
bool m_isTrigger
Definition: IParticleExtractor.h:40
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:41
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
IParticleExtractor::m_label
std::string m_label
Definition: IParticleExtractor.h:37
IParticleExtractor::IParticleExtractor
IParticleExtractor(const xAOD::IParticleContainer *, const std::string &label="", bool isGhost=false, bool isTrigger=false)
Definition: IParticleExtractor.cxx:13
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
IParticleExtractor::clone
virtual IParticleExtractor * clone() const override
Definition: IParticleExtractor.cxx:25
lumiFormat.i
int i
Definition: lumiFormat.py:85
IParticleExtractor::m_isGhost
bool m_isGhost
Definition: IParticleExtractor.h:38
Amg::transform
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
Definition: GeoPrimitivesHelpers.h:156
find_tgc_unfilled_channelids.ip
ip
Definition: find_tgc_unfilled_channelids.py:3
vtune_athena.formatter
formatter
Definition: vtune_athena.py:19
LineFormatter
Definition: LineFormatter.h:14
IParticleExtractor::m_iParticles
const xAOD::IParticleContainer * m_iParticles
Definition: IParticleExtractor.h:36
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
DataVector::at
const T * at(size_type n) const
Access an element, as an rvalue.
python.compressB64.c
def c
Definition: compressB64.py:93
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.