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-2025 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
14
namespace
CP
15
{
16
17
StatusCode AsgLeptonTrackDecorationAlg ::
18
initialize ()
19
{
20
if
(!
m_biasingTool
.empty())
21
ANA_CHECK
(
m_biasingTool
.retrieve());
22
if
(!
m_smearingTool
.empty())
23
ANA_CHECK
(
m_smearingTool
.retrieve());
24
25
ANA_CHECK
(
m_particlesHandle
.initialize (
m_systematicsList
));
26
27
ANA_CHECK
(
m_d0sigHandle
.initialize(
m_systematicsList
,
m_particlesHandle
));
28
ANA_CHECK
(
m_z0sinthetaHandle
.initialize(
m_systematicsList
,
m_particlesHandle
));
29
30
ANA_CHECK
(
m_d0Handle
.initialize(
m_systematicsList
,
m_particlesHandle
));
31
ANA_CHECK
(
m_z0Handle
.initialize(
m_systematicsList
,
m_particlesHandle
));
32
ANA_CHECK
(
m_z0sinthetasigHandle
.initialize(
m_systematicsList
,
m_particlesHandle
));
33
34
if
(!
m_biasingTool
.empty())
35
ANA_CHECK
(
m_systematicsList
.addSystematics (*
m_biasingTool
));
36
if
(!
m_smearingTool
.empty())
37
ANA_CHECK
(
m_systematicsList
.addSystematics (*
m_smearingTool
));
38
ANA_CHECK
(
m_systematicsList
.initialize());
39
40
ANA_CHECK
(
m_eventInfoKey
.initialize());
41
ANA_CHECK
(
m_primaryVerticesKey
.initialize());
42
ANA_CHECK
(
m_outOfValidity
.initialize());
43
44
return
StatusCode::SUCCESS;
45
}
46
47
StatusCode AsgLeptonTrackDecorationAlg ::
48
execute (
const
EventContext& ctx)
49
{
50
SG::ReadHandle<xAOD::EventInfo>
eventInfo(
m_eventInfoKey
, ctx);
51
SG::ReadHandle<xAOD::VertexContainer>
vertices(
m_primaryVerticesKey
, ctx);
52
const
xAOD::Vertex
*primaryVertex {
nullptr
};
53
54
for
(
const
xAOD::Vertex
*vertex : *vertices)
55
{
56
if
(vertex->vertexType() ==
xAOD::VxType::PriVtx
)
57
{
58
if
(primaryVertex ==
nullptr
)
59
{
60
primaryVertex = vertex;
61
break
;
62
}
63
}
64
}
65
66
for
(
const
auto
& sys :
m_systematicsList
.systematicsVector())
67
{
68
if
(!
m_biasingTool
.empty())
69
ANA_CHECK
(
m_biasingTool
->applySystematicVariation (sys));
70
if
(!
m_smearingTool
.empty())
71
ANA_CHECK
(
m_smearingTool
->applySystematicVariation (sys));
72
const
xAOD::IParticleContainer
*particles =
nullptr
;
73
ANA_CHECK
(
m_particlesHandle
.retrieve (particles, sys, ctx));
74
for
(
const
xAOD::IParticle
*particle : *particles)
75
{
76
float
d0sig = -999;
77
float
d0 = -999;
78
float
z0 = -999;
79
float
deltaZ0SinTheta = -999;
80
float
deltaZ0SinThetasig = -999;
81
82
const
xAOD::TrackParticle
*
track
{
nullptr
};
83
if
(
const
xAOD::Muon
*
muon
=
dynamic_cast<
const
xAOD::Muon
*
>
(particle)){
84
track
=
muon
->trackParticle(xAOD::Muon::TrackParticleType::Primary);
85
}
else
if
(
const
xAOD::Electron
*
electron
=
dynamic_cast<
const
xAOD::Electron
*
>
(particle)){
86
track
=
electron
->trackParticle();
87
}
else
{
88
ANA_MSG_ERROR
(
"failed to cast input to electron or muon"
);
89
return
StatusCode::FAILURE;
90
}
91
92
if
(
track
!=
nullptr
) {
93
// This deep-copy is not optimal and it would be more efficient to work with shallow-copies of the track container(s)
94
xAOD::TrackParticle
copyTrack {*
track
};
95
if
(!
m_biasingTool
.empty())
96
ANA_CHECK_CORRECTION
(
m_outOfValidity
, copyTrack,
m_biasingTool
->applyCorrection (copyTrack));
97
if
(!
m_smearingTool
.empty())
98
ANA_CHECK_CORRECTION
(
m_outOfValidity
, copyTrack,
m_smearingTool
->applyCorrection (copyTrack));
99
d0 = copyTrack.
d0
();
100
d0sig =
xAOD::TrackingHelpers::d0significance
(©Track,
101
eventInfo->beamPosSigmaX(),
102
eventInfo->beamPosSigmaY(),
103
eventInfo->beamPosSigmaXY());
104
105
z0 = copyTrack.
z0
();
106
const
double
vertex_z = primaryVertex ? primaryVertex->
z
() : 0;
107
deltaZ0SinTheta = (z0 + copyTrack.
vz
() - vertex_z) * sin (particle->p4().Theta());
108
deltaZ0SinThetasig =
xAOD::TrackingHelpers::z0sinthetasignificance
(©Track,primaryVertex);
109
}
110
111
m_d0Handle
.set(*particle,d0,sys);
112
m_d0sigHandle
.set(*particle, d0sig, sys);
113
m_z0Handle
.set(*particle,z0,sys);
114
m_z0sinthetaHandle
.set(*particle, deltaZ0SinTheta, sys);
115
m_z0sinthetasigHandle
.set(*particle,deltaZ0SinThetasig,sys);
116
}
117
}
118
119
return
StatusCode::SUCCESS;
120
}
121
122
}
// 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:294
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
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:132
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:67
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