ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
Algorithms
TruthParticleLevelAnalysisAlgorithms
Root
ParticleLevelIsolationAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
7
#include "
TruthParticleLevelAnalysisAlgorithms/ParticleLevelIsolationAlg.h
"
8
9
namespace
CP
{
10
11
StatusCode
ParticleLevelIsolationAlg::initialize
() {
12
13
ANA_CHECK
(
m_particlesKey
.initialize());
14
15
// decorators
16
m_dec_isolated
=
17
std::make_unique<SG::Decorator<char>>(
m_isolated
.value());
18
m_dec_notTauOrigin
=
19
std::make_unique<SG::Decorator<char>>(
m_notTauOrigin
.value());
20
21
// accessors
22
if
(
m_isolationVariable
.value() !=
""
) {
23
m_acc_isoVar
= std::make_unique<SG::ConstAccessor<float>>(
24
m_isolationVariable
.value());
25
}
26
27
// set up MCTruthClassifier comparisons
28
MCTruthPartClassifier::ParticleDef
partDef;
29
const
auto
it =
30
std::find(partDef.
sParticleType
.begin(), partDef.
sParticleType
.end(),
31
m_checkTypeName
.value());
32
if
(it == partDef.
sParticleType
.end()) {
33
ANA_MSG_ERROR
(
34
"checkType = "
35
<<
m_checkTypeName
.value()
36
<<
" is not a valid MCTruthPartClassifier::ParticleType string!"
);
37
return
StatusCode::FAILURE;
38
}
else
{
39
m_checkType
=
static_cast<
MCTruthPartClassifier::ParticleType
>
(
40
std::distance(partDef.
sParticleType
.begin(), it));
41
}
42
43
return
StatusCode::SUCCESS;
44
}
45
46
StatusCode
ParticleLevelIsolationAlg::execute
(
const
EventContext &ctx)
const
{
47
48
SG::ReadHandle<xAOD::TruthParticleContainer>
particles(
m_particlesKey
, ctx);
49
50
// accessors
51
static
const
SG::ConstAccessor<unsigned int>
acc_type(
52
"classifierParticleType"
);
53
static
const
SG::ConstAccessor<unsigned int>
acc_orig(
54
"classifierParticleOrigin"
);
55
56
// decorators
57
static
const
SG::Decorator<float>
dec_charge(
"charge"
);
58
59
for
(
const
auto
* particle : *particles) {
60
61
// check the particle is isolated
62
if
(acc_type.
isAvailable
(*particle)) {
63
bool
isolation = acc_type(*particle) ==
m_checkType
;
64
// check further custom isolation cuts
65
if
(
m_acc_isoVar
&& isolation) {
66
if
((*m_acc_isoVar).isAvailable(*particle)) {
67
isolation =
68
isolation && ((*m_acc_isoVar)(*particle) / particle->pt() <
69
m_isolationCut
.value());
70
}
else
{
71
ANA_MSG_ERROR
(
"Truth particle is missing the decoration: "
72
<<
m_isolationVariable
.value() <<
"."
);
73
return
StatusCode::FAILURE;
74
}
75
}
76
(*m_dec_isolated)(*particle) = isolation;
77
}
else
{
78
ANA_MSG_ERROR
(
79
"Truth particle is missing the decoration: classifierParticleType."
);
80
return
StatusCode::FAILURE;
81
}
82
83
// check the particle doesn't come from a tau decay
84
if
(acc_orig.
isAvailable
(*particle)) {
85
(*m_dec_notTauOrigin)(*particle) =
86
acc_orig(*particle) !=
MCTruthPartClassifier::ParticleOrigin::TauLep
;
87
}
else
{
88
ANA_MSG_ERROR
(
89
"Truth particle is missing the decoration: "
90
"classifierParticleOrigin."
);
91
return
StatusCode::FAILURE;
92
}
93
}
94
return
StatusCode::SUCCESS;
95
}
96
97
}
// namespace CP
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:292
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:322
ParticleLevelIsolationAlg.h
CP::ParticleLevelIsolationAlg::m_acc_isoVar
std::unique_ptr< const SG::ConstAccessor< float > > m_acc_isoVar
Definition
ParticleLevelIsolationAlg.h:47
CP::ParticleLevelIsolationAlg::m_particlesKey
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_particlesKey
Definition
ParticleLevelIsolationAlg.h:28
CP::ParticleLevelIsolationAlg::m_checkType
MCTruthPartClassifier::ParticleType m_checkType
Definition
ParticleLevelIsolationAlg.h:44
CP::ParticleLevelIsolationAlg::m_dec_notTauOrigin
std::unique_ptr< const SG::Decorator< char > > m_dec_notTauOrigin
Definition
ParticleLevelIsolationAlg.h:46
CP::ParticleLevelIsolationAlg::m_isolationCut
Gaudi::Property< float > m_isolationCut
Definition
ParticleLevelIsolationAlg.h:41
CP::ParticleLevelIsolationAlg::m_notTauOrigin
Gaudi::Property< std::string > m_notTauOrigin
Definition
ParticleLevelIsolationAlg.h:32
CP::ParticleLevelIsolationAlg::m_dec_isolated
std::unique_ptr< const SG::Decorator< char > > m_dec_isolated
Definition
ParticleLevelIsolationAlg.h:45
CP::ParticleLevelIsolationAlg::initialize
virtual StatusCode initialize() final
Definition
ParticleLevelIsolationAlg.cxx:11
CP::ParticleLevelIsolationAlg::execute
virtual StatusCode execute(const EventContext &ctx) const final
Definition
ParticleLevelIsolationAlg.cxx:46
CP::ParticleLevelIsolationAlg::m_isolated
Gaudi::Property< std::string > m_isolated
Definition
ParticleLevelIsolationAlg.h:30
CP::ParticleLevelIsolationAlg::m_checkTypeName
Gaudi::Property< std::string > m_checkTypeName
Definition
ParticleLevelIsolationAlg.h:35
CP::ParticleLevelIsolationAlg::m_isolationVariable
Gaudi::Property< std::string > m_isolationVariable
Definition
ParticleLevelIsolationAlg.h:38
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition
ConstAccessor.h:55
SG::ConstAccessor::isAvailable
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
CP
Select isolated Photons, Electrons and Muons.
Definition
Control/xAODRootAccess/xAODRootAccess/TEvent.h:27
MCTruthPartClassifier::TauLep
@ TauLep
Definition
TruthClasses.h:65
MCTruthPartClassifier::ParticleType
ParticleType
Definition
TruthClasses.h:10
SG::Decorator
SG::Decorator< T, ALLOC > Decorator
Helper class to provide type-safe access to aux data, specialized for JaggedVecElt.
Definition
AuxElement.h:576
MCTruthPartClassifier::ParticleDef
Definition
TruthClasses.h:124
MCTruthPartClassifier::ParticleDef::sParticleType
std::vector< std::string > sParticleType
the vector of particle types
Definition
TruthClasses.h:126
Generated on
for ATLAS Offline Software by
1.17.0