ATLAS Offline Software
TruthParticleParentAssociationTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // $Id$
15 #include "xAODTruth/TruthVertex.h"
18 
19 namespace D3PD {
20 
21 
29  (const std::string& type,
30  const std::string& name,
31  const IInterface* parent)
32  : Base (type, name, parent),
33  m_i (0)
34 {}
35 
36 
41 {
42  return Base::initialize();
43 }
44 
45 
52 {
53  const xAOD::TruthVertex* vx = p.prodVtx();
54  if (!vx)
55  m_parents.clear();
56  else {
57  size_t sz = vx->nIncomingParticles();
58  m_parents.resize (sz);
59  for (unsigned int i = 0; i < sz; i++)
60  m_parents[i] = vx->incomingParticle(i);
61  std::sort (m_parents.begin(), m_parents.end(), [](const auto & a, const auto & b) -> bool{ return HepMC::uniqueID(a) < HepMC::uniqueID(b); }); // FIXME barcode-based - ordering may change when this function switches to returning id rather than barcode
62  m_i = 0;
63  }
64  return StatusCode::SUCCESS;
65 }
66 
67 
74 {
75  if (m_i < m_parents.size())
76  return m_parents[m_i++];
77  return 0;
78 }
79 
80 
81 } // namespace D3PD
fitman.sz
sz
Definition: fitman.py:527
initialize
void initialize()
Definition: run_EoverP.cxx:894
D3PD::MultiAssociationTool< xAOD::TruthParticle >
D3PD::TruthParticleParentAssociationTool::initialize
virtual StatusCode initialize()
Standard Gaudi initialize method.
Definition: TruthParticleParentAssociationTool.cxx:40
D3PD::TruthParticleParentAssociationTool::next
virtual const xAOD::TruthParticle * next()
Return a pointer to the next element in the association.
Definition: TruthParticleParentAssociationTool.cxx:73
D3PD
Block filler tool for noisy FEB information.
Definition: CaloCellDetailsFillerTool.cxx:29
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
lumiFormat.i
int i
Definition: lumiFormat.py:85
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
D3PD::TruthParticleParentAssociationTool::TruthParticleParentAssociationTool
TruthParticleParentAssociationTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard Gaudi tool constructor.
Definition: TruthParticleParentAssociationTool.cxx:29
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:37
test_pyathena.parent
parent
Definition: test_pyathena.py:15
TruthParticleParentAssociationTool.h
Associate parents of TruthParticles.
xAOD::TruthVertex_v1::incomingParticle
const TruthParticle_v1 * incomingParticle(size_t index) const
Get one of the incoming particles.
Definition: TruthVertex_v1.cxx:69
TruthVertex.h
xAOD::TruthVertex_v1
Class describing a truth vertex in the MC record.
Definition: TruthVertex_v1.h:37
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
MagicNumbers.h
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
errorcheck.h
Helpers for checking error return status codes and reporting errors.
a
TList * a
Definition: liststreamerinfos.cxx:10
D3PD::TruthParticleParentAssociationTool::reset
virtual StatusCode reset(const xAOD::TruthParticle &p)
Start the iteration for a new association.
Definition: TruthParticleParentAssociationTool.cxx:51
xAOD::TruthVertex_v1::nIncomingParticles
size_t nIncomingParticles() const
Get the number of incoming particles.
Definition: TruthVertex_v1.cxx:47
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
D3PD::TruthParticleParentAssociationTool::m_i
unsigned int m_i
Current index.
Definition: TruthParticleParentAssociationTool.h:77
D3PD::TruthParticleParentAssociationTool::m_parents
std::vector< const xAOD::TruthParticle * > m_parents
Vector of parent pointers.
Definition: TruthParticleParentAssociationTool.h:74