ATLAS Offline Software
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 
8 TruthParticleIndexDecoratorAlg::TruthParticleIndexDecoratorAlg(const std::string& name, ISvcLocator* pSvcLocator) :
9  AthReentrantAlgorithm(name, pSvcLocator)
10 {
11 }
12 
15 
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 
27 TruthParticleIndexDecoratorAlg::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 }
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
TruthParticleIndexDecoratorAlg::execute
virtual StatusCode execute(const EventContext &ctx) const
Definition: TruthParticleIndexDecoratorAlg.cxx:27
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
TruthParticleIndexDecoratorAlg::m_truthParticleName
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthParticleName
TruthParticle container's name needed to create decorators.
Definition: TruthParticleIndexDecoratorAlg.h:26
TruthParticleIndexDecoratorAlg::TruthParticleIndexDecoratorAlg
TruthParticleIndexDecoratorAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TruthParticleIndexDecoratorAlg.cxx:8
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
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:100
WriteDecorHandle.h
Handle class for adding a decoration to an object.
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
TruthParticleIndexDecoratorAlg.h
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
TruthParticleIndexDecoratorAlg::m_indexDecor
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_indexDecor
Definition: TruthParticleIndexDecoratorAlg.h:29
TruthParticleIndexDecoratorAlg::initialize
virtual StatusCode initialize()
Definition: TruthParticleIndexDecoratorAlg.cxx:14