ATLAS Offline Software
TruthParticleChildAssociationTool.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  m_i = 0;
54 
55  const xAOD::TruthVertex* vx = p.decayVtx();
56  if (!vx) {
57  m_xaod_children.clear();
58  return StatusCode::SUCCESS;
59  }
60 
61  size_t sz = vx->nOutgoingParticles();
62  m_xaod_children.reserve (sz);
63  for (unsigned int i = 0; i < sz; i++) {
64  const xAOD::TruthParticle* p2 = vx->outgoingParticle (i);
65  if (p2)
66  m_xaod_children[i] = p2;
67  }
68  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
69  return StatusCode::SUCCESS;
70 }
71 
72 
79 {
80  if (m_i < m_xaod_children.size())
81  return m_xaod_children[m_i++];
82  return 0;
83 }
84 
85 
86 } // 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:40
fitman.sz
sz
Definition: fitman.py:527
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
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 >
D3PD
Block filler tool for noisy FEB information.
Definition: InnerDetector/InDetMonitoring/InDetGlobalMonitoring/macros/EnhancedPrimaryVertexMonitoring/TrigD3PD/ChainGroup.h:21
lumiFormat.i
int i
Definition: lumiFormat.py:92
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:41
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:29
TruthVertex.h
xAOD::TruthVertex_v1
Class describing a truth vertex in the MC record.
Definition: TruthVertex_v1.h:41
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
MagicNumbers.h
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
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
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
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:78
D3PD::TruthParticleChildAssociationTool::reset
virtual StatusCode reset(const xAOD::TruthParticle &p) override
Start the iteration for a new association.
Definition: TruthParticleChildAssociationTool.cxx:51
xAOD::TruthVertex_v1::outgoingParticle
const TruthParticle_v1 * outgoingParticle(size_t index) const
Get one of the outgoing particles.
Definition: TruthVertex_v1.cxx:121