ATLAS Offline Software
Loading...
Searching...
No Matches
TruthParticleChildAssociationTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
10
11
16
17namespace 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
48StatusCode
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++) {
62 const xAOD::TruthParticle* p2 = vx->outgoingParticle (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
Helpers for checking error return status codes and reporting errors.
static Double_t sz
static Double_t a
Associate children of TruthParticles.
MultiAssociationTool< xAOD::TruthParticle > Base
virtual StatusCode initialize() override
Standard Gaudi initialize method.
std::vector< const xAOD::TruthParticle * > m_xaod_children
Vector of xAOD pointers.
virtual StatusCode reset(const xAOD::TruthParticle &p) override
Start the iteration for a new association.
virtual const xAOD::TruthParticle * next() override
Return a pointer to the next element in the association.
TruthParticleChildAssociationTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard Gaudi tool constructor.
const TruthParticle_v1 * outgoingParticle(size_t index) const
Get one of the outgoing particles.
size_t nOutgoingParticles() const
Get the number of outgoing particles.
Block filler tool for noisy FEB information.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
TruthVertex_v1 TruthVertex
Typedef to implementation.
Definition TruthVertex.h:15
TruthParticle_v1 TruthParticle
Typedef to implementation.