ATLAS Offline Software
Loading...
Searching...
No Matches
TruthParticleIndexDecoratorAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
7
8TruthParticleIndexDecoratorAlg::TruthParticleIndexDecoratorAlg(const std::string& name, ISvcLocator* pSvcLocator) :
9 AthReentrantAlgorithm(name, pSvcLocator)
10{
11}
12
13StatusCode
15
16 ATH_CHECK( m_truthParticleName.initialize());
17 if (m_indexDecor.key().empty()) {
18 ATH_MSG_FATAL("Empty truth index name.");
19 return StatusCode::FAILURE;
20 }
22 ATH_CHECK( m_indexDecor.initialize() );
23 return StatusCode::SUCCESS;
24}
25
26StatusCode
27TruthParticleIndexDecoratorAlg::execute(const EventContext &ctx) const {
29 if ((not ptruth.isValid())) {
30 return StatusCode::FAILURE;
31 }
33
34 for (const xAOD::TruthParticle *truth_particle : *ptruth) {
35 index_decorator(*truth_particle) = truth_particle->index();
36 }
37 return StatusCode::SUCCESS;
38}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
Handle class for adding a decoration to an object.
An algorithm that can be simultaneously executed in multiple threads.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Handle class for adding a decoration to an object.
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthParticleName
TruthParticle container's name needed to create decorators.
TruthParticleIndexDecoratorAlg(const std::string &name, ISvcLocator *pSvcLocator)
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_indexDecor
virtual StatusCode execute(const EventContext &ctx) const
TruthParticle_v1 TruthParticle
Typedef to implementation.