ATLAS Offline Software
HadronOriginDecorator.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
8 namespace DerivationFramework {
9 
11  ATH_MSG_VERBOSE( "Initialize" );
14  ATH_CHECK(m_Tool.retrieve());
15  return StatusCode::SUCCESS;
16  }
17 
18  StatusCode HadronOriginDecorator::addBranches(const EventContext& ctx) const{
19  // Retrieve truth collections
21  if (!truthParticles.isValid()) {
22  ATH_MSG_ERROR("Couldn't retrieve TruthParticle collection with name " << m_particlesKey);
23  return StatusCode::FAILURE;
24  }
25 
26  std::map<const xAOD::TruthParticle*, DerivationFramework::HadronOriginClassifier::HF_id> hadronMap=m_Tool->GetOriginMap();
28  for (auto* truthParticle : *truthParticles) {
29  originDecorator(*truthParticle) = (hadronMap.find(truthParticle)!=hadronMap.end()) ? static_cast<int>(hadronMap[truthParticle]) : 6;
30  }
31 
32  return StatusCode::SUCCESS;
33  }
34 
35 }
DerivationFramework::HadronOriginDecorator::m_particlesKey
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_particlesKey
Definition: HadronOriginDecorator.h:37
DerivationFramework::HadronOriginDecorator::initialize
virtual StatusCode initialize() override final
Definition: HadronOriginDecorator.cxx:10
SG::ReadHandle< xAOD::TruthParticleContainer >
DerivationFramework::HadronOriginDecorator::m_originDecoratorKey
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_originDecoratorKey
Definition: HadronOriginDecorator.h:40
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
DerivationFramework::HadronOriginDecorator::addBranches
virtual StatusCode addBranches(const EventContext &ctx) const override final
Definition: HadronOriginDecorator.cxx:18
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
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
DerivationFramework
THE reconstruction tool.
Definition: ParticleSortingAlg.h:24
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
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
DerivationFramework::HadronOriginDecorator::m_Tool
PublicToolHandle< DerivationFramework::HadronOriginClassifier > m_Tool
Definition: HadronOriginDecorator.h:41
SG::WriteDecorHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
HadronOriginDecorator.h