ATLAS Offline Software
TruthParticleChildAssociationTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
13 #include "xAODTruth/TruthVertex.h"
16 
17 namespace D3PD {
18 
19 
27  (const std::string& type,
28  const std::string& name,
29  const IInterface* parent)
30  : Base (type, name, parent),
31  m_i (0)
32 {}
33 
34 
39 {
40  return Base::initialize();
41 }
42 
43 
50 {
51  m_i = 0;
52  m_xaod_children.clear();
53 
54  const xAOD::TruthVertex* vx = p.decayVtx();
55  if (!vx) {
56  return StatusCode::SUCCESS;
57  }
58 
59  size_t sz = vx->nOutgoingParticles();
60  m_xaod_children.reserve (sz);
61  for (unsigned int i = 0; i < sz; i++) {
63  if (p2)
64  m_xaod_children.push_back(p2);
65  }
66  std::sort (m_xaod_children.begin(), m_xaod_children.end(), [](const auto & a, const auto & b) -> bool{ return HepMC::uniqueID(a) < HepMC::uniqueID(b); }); // FIXME barcode-based - NB ordering may change when this function switches to return id rather than barcode
67  return StatusCode::SUCCESS;
68 }
69 
70 
77 {
78  if (m_i < m_xaod_children.size())
79  return m_xaod_children[m_i++];
80  return 0;
81 }
82 
83 
84 } // namespace D3PD
xAOD::TruthVertex_v1::nOutgoingParticles
size_t nOutgoingParticles() const
Get the number of outgoing particles.
D3PD::TruthParticleChildAssociationTool::initialize
virtual StatusCode initialize() override
Standard Gaudi initialize method.
Definition: TruthParticleChildAssociationTool.cxx:38
fitman.sz
sz
Definition: fitman.py:527
initialize
void initialize()
Definition: run_EoverP.cxx:894
D3PD::TruthParticleChildAssociationTool::m_i
unsigned int m_i
Current index.
Definition: TruthParticleChildAssociationTool.h:77
D3PD::MultiAssociationTool< xAOD::TruthParticle >
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
TRTCalib_cfilter.p2
p2
Definition: TRTCalib_cfilter.py:131
D3PD
Block filler tool for noisy FEB information.
Definition: CaloCellDetailsFillerTool.cxx:29
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:209
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
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
D3PD::TruthParticleChildAssociationTool::TruthParticleChildAssociationTool
TruthParticleChildAssociationTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard Gaudi tool constructor.
Definition: TruthParticleChildAssociationTool.cxx:27
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:240
MagicNumbers.h
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:76
errorcheck.h
Helpers for checking error return status codes and reporting errors.
TruthParticleChildAssociationTool.h
Associate children of TruthParticles.
a
TList * a
Definition: liststreamerinfos.cxx:10
D3PD::TruthParticleChildAssociationTool::m_xaod_children
std::vector< const xAOD::TruthParticle * > m_xaod_children
Vector of xAOD pointers.
Definition: TruthParticleChildAssociationTool.h:74
D3PD::TruthParticleChildAssociationTool::next
virtual const xAOD::TruthParticle * next() override
Return a pointer to the next element in the association.
Definition: TruthParticleChildAssociationTool.cxx:76
D3PD::TruthParticleChildAssociationTool::reset
virtual StatusCode reset(const xAOD::TruthParticle &p) override
Start the iteration for a new association.
Definition: TruthParticleChildAssociationTool.cxx:49
xAOD::TruthVertex_v1::outgoingParticle
const TruthParticle_v1 * outgoingParticle(size_t index) const
Get one of the outgoing particles.
Definition: TruthVertex_v1.cxx:120