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 
10  HadronOriginDecorator::HadronOriginDecorator(const std::string& t, const std::string& n, const IInterface* p):
11  base_class(t,n,p)
12  {
13  }
14 
16 
18  ATH_MSG_VERBOSE( "Initialize" );
21  ATH_CHECK(m_Tool.retrieve());
22  return StatusCode::SUCCESS;
23  }
24 
25  StatusCode HadronOriginDecorator::addBranches(const EventContext& ctx) const{
26  // Retrieve truth collections
28  if (!truthParticles.isValid()) {
29  ATH_MSG_ERROR("Couldn't retrieve TruthParticle collection with name " << m_particlesKey);
30  return StatusCode::FAILURE;
31  }
32 
33  std::map<const xAOD::TruthParticle*, DerivationFramework::HadronOriginClassifier::HF_id> hadronMap=m_Tool->GetOriginMap();
35  for (auto* truthParticle : *truthParticles) {
36  originDecorator(*truthParticle) = (hadronMap.find(truthParticle)!=hadronMap.end()) ? static_cast<int>(hadronMap[truthParticle]) : 6;
37  }
38 
39  return StatusCode::SUCCESS;
40  }
41 
42 }
DerivationFramework::HadronOriginDecorator::m_particlesKey
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_particlesKey
Definition: HadronOriginDecorator.h:36
DerivationFramework::HadronOriginDecorator::~HadronOriginDecorator
~HadronOriginDecorator()
Definition: HadronOriginDecorator.cxx:15
SG::ReadHandle< xAOD::TruthParticleContainer >
DerivationFramework::HadronOriginDecorator::m_originDecoratorKey
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_originDecoratorKey
Definition: HadronOriginDecorator.h:39
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
DerivationFramework::HadronOriginDecorator::addBranches
virtual StatusCode addBranches(const EventContext &ctx) const
Definition: HadronOriginDecorator.cxx:25
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:209
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
DerivationFramework::HadronOriginDecorator::HadronOriginDecorator
HadronOriginDecorator(const std::string &t, const std::string &n, const IInterface *p)
Definition: HadronOriginDecorator.cxx:10
beamspotman.n
n
Definition: beamspotman.py:727
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:40
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
DerivationFramework::HadronOriginDecorator::initialize
StatusCode initialize()
Definition: HadronOriginDecorator.cxx:17