ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
Algorithms
AsgAnalysisAlgorithms
Root
AsgLeptonTrackDecorationAlg.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
6
#include <
AsgAnalysisAlgorithms/AsgLeptonTrackDecorationAlg.h
>
7
#include "
AsgDataHandles/ReadHandle.h
"
8
9
#include <
xAODEgamma/Electron.h
>
10
#include <
xAODMuon/Muon.h
>
11
#include <
xAODTracking/TrackParticlexAODHelpers.h
>
12
13
#include <optional>
14
15
16
namespace
CP
17
{
18
19
StatusCode AsgLeptonTrackDecorationAlg ::
20
initialize ()
21
{
22
if
(!
m_biasingTool
.empty())
23
ANA_CHECK
(
m_biasingTool
.retrieve());
24
if
(!
m_smearingTool
.empty())
25
ANA_CHECK
(
m_smearingTool
.retrieve());
26
27
ANA_CHECK
(
m_particlesHandle
.initialize (
m_systematicsList
));
28
29
ANA_CHECK
(
m_d0sigHandle
.initialize(
m_systematicsList
,
m_particlesHandle
));
30
ANA_CHECK
(
m_z0sinthetaHandle
.initialize(
m_systematicsList
,
m_particlesHandle
));
31
32
ANA_CHECK
(
m_d0Handle
.initialize(
m_systematicsList
,
m_particlesHandle
));
33
ANA_CHECK
(
m_z0Handle
.initialize(
m_systematicsList
,
m_particlesHandle
));
34
ANA_CHECK
(
m_z0sinthetasigHandle
.initialize(
m_systematicsList
,
m_particlesHandle
));
35
36
if
(!
m_biasingTool
.empty())
37
ANA_CHECK
(
m_systematicsList
.addSystematics (*
m_biasingTool
));
38
if
(!
m_smearingTool
.empty())
39
ANA_CHECK
(
m_systematicsList
.addSystematics (*
m_smearingTool
));
40
ANA_CHECK
(
m_systematicsList
.initialize());
41
42
ANA_CHECK
(
m_eventInfoKey
.initialize());
43
ANA_CHECK
(
m_primaryVerticesKey
.initialize());
44
ANA_CHECK
(
m_outOfValidity
.initialize());
45
46
return
StatusCode::SUCCESS;
47
}
48
49
StatusCode AsgLeptonTrackDecorationAlg ::
50
execute (
const
EventContext& ctx)
51
{
52
SG::ReadHandle<xAOD::EventInfo>
eventInfo(
m_eventInfoKey
, ctx);
53
SG::ReadHandle<xAOD::VertexContainer>
vertices(
m_primaryVerticesKey
, ctx);
54
if
(!vertices.
isValid
())
55
{
56
ANA_MSG_ERROR
(
"Cannot retrieve primary vertex container "
<<
m_primaryVerticesKey
.key());
57
return
StatusCode::FAILURE;
58
}
59
const
xAOD::Vertex
*primaryVertex {
nullptr
};
60
61
for
(
const
xAOD::Vertex
*vertex : *vertices)
62
{
63
if
(vertex->vertexType() ==
xAOD::VxType::PriVtx
)
64
{
65
primaryVertex = vertex;
66
break
;
67
}
68
}
69
70
for
(
const
auto
& sys :
m_systematicsList
.systematicsVector())
71
{
72
if
(!
m_biasingTool
.empty())
73
ANA_CHECK
(
m_biasingTool
->applySystematicVariation (sys));
74
if
(!
m_smearingTool
.empty())
75
ANA_CHECK
(
m_smearingTool
->applySystematicVariation (sys));
76
const
xAOD::IParticleContainer
*particles =
nullptr
;
77
ANA_CHECK
(
m_particlesHandle
.retrieve (particles, sys, ctx));
78
for
(
const
xAOD::IParticle
*particle : *particles)
79
{
80
float
d0sig = -999;
81
float
d0 = -999;
82
float
z0 = -999;
83
float
deltaZ0SinTheta = -999;
84
float
deltaZ0SinThetasig = -999;
85
86
const
xAOD::TrackParticle
*
track
{
nullptr
};
87
if
(
const
xAOD::Muon
*
muon
=
dynamic_cast<
const
xAOD::Muon
*
>
(particle)){
88
track
=
muon
->trackParticle(xAOD::Muon::TrackParticleType::Primary);
89
}
else
if
(
const
xAOD::Electron
*
electron
=
dynamic_cast<
const
xAOD::Electron
*
>
(particle)){
90
track
=
electron
->trackParticle();
91
}
else
{
92
ANA_MSG_ERROR
(
"failed to cast input to electron or muon"
);
93
return
StatusCode::FAILURE;
94
}
95
96
// This deep-copy is not optimal and it would be more efficient to work with shallow-copies of the track container(s)
97
std::optional<xAOD::TrackParticle> correctedTrack;
98
if
(!
m_biasingTool
.empty() || !
m_smearingTool
.empty())
99
correctedTrack.emplace (*
track
);
100
if
(!
m_biasingTool
.empty())
101
ANA_CHECK_CORRECTION
(
m_outOfValidity
, *correctedTrack,
m_biasingTool
->applyCorrection (*correctedTrack));
102
if
(!
m_smearingTool
.empty())
103
ANA_CHECK_CORRECTION
(
m_outOfValidity
, *correctedTrack,
m_smearingTool
->applyCorrection (*correctedTrack));
104
const
xAOD::TrackParticle
©Track = correctedTrack ? *correctedTrack : *
track
;
105
d0 = copyTrack.
d0
();
106
try
{
107
d0sig =
xAOD::TrackingHelpers::d0significance
(©Track,
108
eventInfo->beamPosSigmaX(),
109
eventInfo->beamPosSigmaY(),
110
eventInfo->beamPosSigmaXY());
111
}
catch
(
const
std::runtime_error &) {
112
d0sig = -999;
113
}
114
z0 = copyTrack.
z0
();
115
const
double
vertex_z = primaryVertex ? primaryVertex->
z
() : 0;
116
deltaZ0SinTheta = (z0 + copyTrack.
vz
() - vertex_z) * sin (particle->p4().Theta());
117
try
{
118
deltaZ0SinThetasig =
xAOD::TrackingHelpers::z0sinthetasignificance
(©Track,primaryVertex);
119
}
catch
(
const
std::runtime_error &) {
120
deltaZ0SinThetasig = -999;
121
}
122
123
m_d0Handle
.set(*particle,d0,sys);
124
m_d0sigHandle
.set(*particle, d0sig, sys);
125
m_z0Handle
.set(*particle,z0,sys);
126
m_z0sinthetaHandle
.set(*particle, deltaZ0SinTheta, sys);
127
m_z0sinthetasigHandle
.set(*particle,deltaZ0SinThetasig,sys);
128
}
129
}
130
131
return
StatusCode::SUCCESS;
132
}
133
134
}
// namespace
AsgLeptonTrackDecorationAlg.h
ReadHandle.h
Handle class for reading from StoreGate.
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg,...)
Macro printing error messages.
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:295
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:325
Electron.h
Muon.h
ANA_CHECK_CORRECTION
#define ANA_CHECK_CORRECTION(helper, object, expr)
a helper check macro to work with OutOfValidityHelper
Definition
OutOfValidityHelper.h:131
TrackParticlexAODHelpers.h
CP::AsgLeptonTrackDecorationAlg::m_smearingTool
ToolHandle< InDet::IInDetTrackSmearingTool > m_smearingTool
the smearing tool
Definition
AsgLeptonTrackDecorationAlg.h:41
CP::AsgLeptonTrackDecorationAlg::m_d0sigHandle
SysWriteDecorHandle< float > m_d0sigHandle
Definition
AsgLeptonTrackDecorationAlg.h:63
CP::AsgLeptonTrackDecorationAlg::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
the EventInfo key
Definition
AsgLeptonTrackDecorationAlg.h:48
CP::AsgLeptonTrackDecorationAlg::m_particlesHandle
SysReadHandle< xAOD::IParticleContainer > m_particlesHandle
the particle container we run on
Definition
AsgLeptonTrackDecorationAlg.h:57
CP::AsgLeptonTrackDecorationAlg::m_z0Handle
SysWriteDecorHandle< float > m_z0Handle
Definition
AsgLeptonTrackDecorationAlg.h:66
CP::AsgLeptonTrackDecorationAlg::m_d0Handle
SysWriteDecorHandle< float > m_d0Handle
Definition
AsgLeptonTrackDecorationAlg.h:60
CP::AsgLeptonTrackDecorationAlg::m_biasingTool
ToolHandle< InDet::IInDetTrackBiasingTool > m_biasingTool
the biasing tool
Definition
AsgLeptonTrackDecorationAlg.h:37
CP::AsgLeptonTrackDecorationAlg::m_z0sinthetasigHandle
SysWriteDecorHandle< float > m_z0sinthetasigHandle
Definition
AsgLeptonTrackDecorationAlg.h:72
CP::AsgLeptonTrackDecorationAlg::m_z0sinthetaHandle
SysWriteDecorHandle< float > m_z0sinthetaHandle
Definition
AsgLeptonTrackDecorationAlg.h:69
CP::AsgLeptonTrackDecorationAlg::m_systematicsList
SysListHandle m_systematicsList
the systematics list we run
Definition
AsgLeptonTrackDecorationAlg.h:45
CP::AsgLeptonTrackDecorationAlg::m_outOfValidity
OutOfValidityHelper m_outOfValidity
the helper for OutOfValidity results
Definition
AsgLeptonTrackDecorationAlg.h:76
CP::AsgLeptonTrackDecorationAlg::m_primaryVerticesKey
SG::ReadHandleKey< xAOD::VertexContainer > m_primaryVerticesKey
the PrimaryVertex key
Definition
AsgLeptonTrackDecorationAlg.h:52
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:66
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition
Event/xAOD/xAODBase/xAODBase/IParticle.h:41
xAOD::TrackParticle_v1::z0
float z0() const
Returns the parameter.
xAOD::TrackParticle_v1::vz
float vz() const
The z origin for the parameters.
xAOD::TrackParticle_v1::d0
float d0() const
Returns the parameter.
xAOD::Vertex_v1::z
float z() const
Returns the z position.
CP
Select isolated Photons, Electrons and Muons.
Definition
Control/xAODRootAccess/xAODRootAccess/TEvent.h:27
xAOD::TrackingHelpers::z0sinthetasignificance
double z0sinthetasignificance(const xAOD::TrackParticle *tp, const xAOD::Vertex *vx=NULL)
Get the impact parameter significance of a track particle in the z direction, including the sin(theta...
Definition
TrackParticlexAODHelpers.cxx:82
xAOD::TrackingHelpers::d0significance
double d0significance(const xAOD::TrackParticle *tp, double d0_uncert_beam_spot_2)
Definition
TrackParticlexAODHelpers.cxx:42
xAOD::VxType::PriVtx
@ PriVtx
Primary vertex.
Definition
TrackingPrimitives.h:590
xAOD::TrackParticle
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Definition
Event/xAOD/xAODTracking/xAODTracking/TrackParticle.h:13
xAOD::Vertex
Vertex_v1 Vertex
Define the latest version of the vertex class.
Definition
Event/xAOD/xAODTracking/xAODTracking/Vertex.h:16
xAOD::track
@ track
Definition
TrackingPrimitives.h:531
xAOD::Muon
Muon_v1 Muon
Reference the current persistent version:
Definition
Event/xAOD/xAODMuon/xAODMuon/Muon.h:13
xAOD::muon
@ muon
Definition
TrackingPrimitives.h:196
xAOD::electron
@ electron
Definition
TrackingPrimitives.h:195
xAOD::Electron
Electron_v1 Electron
Definition of the current "egamma version".
Definition
Event/xAOD/xAODEgamma/xAODEgamma/Electron.h:17
xAOD::IParticleContainer
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.
Definition
xAOD/xAODBase/xAODBase/IParticleContainer.h:32
Generated on
for ATLAS Offline Software by
1.17.0