ATLAS Offline Software
Loading...
Searching...
No Matches
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
8namespace DerivationFramework {
9
11 ATH_MSG_VERBOSE( "Initialize" );
12 ATH_CHECK( m_particlesKey.initialize() );
13 ATH_CHECK(m_originDecoratorKey.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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
Handle class for adding a decoration to an object.
PublicToolHandle< DerivationFramework::HadronOriginClassifier > m_Tool
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_particlesKey
virtual StatusCode initialize() override final
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_originDecoratorKey
virtual StatusCode addBranches(const EventContext &ctx) const override final
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Handle class for adding a decoration to an object.
THE reconstruction tool.