ATLAS Offline Software
Loading...
Searching...
No Matches
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$
12
13
18
19namespace 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
50StatusCode
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
Helpers for checking error return status codes and reporting errors.
static Double_t sz
static Double_t a
Associate parents of TruthParticles.
virtual StatusCode reset(const xAOD::TruthParticle &p)
Start the iteration for a new association.
virtual const xAOD::TruthParticle * next()
Return a pointer to the next element in the association.
std::vector< const xAOD::TruthParticle * > m_parents
Vector of parent pointers.
MultiAssociationTool< xAOD::TruthParticle > Base
virtual StatusCode initialize()
Standard Gaudi initialize method.
TruthParticleParentAssociationTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard Gaudi tool constructor.
const TruthParticle_v1 * incomingParticle(size_t index) const
Get one of the incoming particles.
size_t nIncomingParticles() const
Get the number of incoming 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.