ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
DerivationFramework
DerivationFrameworkMCTruth
src
HadronOriginDecorator.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
DerivationFrameworkMCTruth/HadronOriginDecorator.h
"
6
#include "
StoreGate/WriteDecorHandle.h
"
7
8
namespace
DerivationFramework
{
9
10
StatusCode
HadronOriginDecorator::initialize
(){
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
20
SG::ReadHandle<xAOD::TruthParticleContainer>
truthParticles(
m_particlesKey
,ctx);
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(ctx);
27
SG::WriteDecorHandle<xAOD::TruthParticleContainer, int>
originDecorator(
m_originDecoratorKey
, ctx);
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
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
HadronOriginDecorator.h
WriteDecorHandle.h
Handle class for adding a decoration to an object.
DerivationFramework::HadronOriginDecorator::m_Tool
PublicToolHandle< DerivationFramework::HadronOriginClassifier > m_Tool
Definition
HadronOriginDecorator.h:41
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
DerivationFramework::HadronOriginDecorator::m_originDecoratorKey
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_originDecoratorKey
Definition
HadronOriginDecorator.h:40
DerivationFramework::HadronOriginDecorator::addBranches
virtual StatusCode addBranches(const EventContext &ctx) const override final
Definition
HadronOriginDecorator.cxx:18
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition
StoreGate/StoreGate/WriteDecorHandle.h:100
DerivationFramework
THE reconstruction tool.
Definition
CascadeTools.h:16
Generated on
for ATLAS Offline Software by
1.17.0