ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
Algorithms
AsgAnalysisAlgorithms
Root
AsgLeptonTrackSelectionAlg.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
8
9
//
10
// includes
11
//
12
13
#include <
AsgAnalysisAlgorithms/AsgLeptonTrackSelectionAlg.h
>
14
15
#include <
xAODEgamma/Electron.h
>
16
#include <
xAODMuon/Muon.h
>
17
#include <
xAODTracking/TrackParticlexAODHelpers.h
>
18
19
//
20
// method implementations
21
//
22
23
namespace
CP
24
{
25
26
StatusCode AsgLeptonTrackSelectionAlg ::
27
initialize ()
28
{
29
30
if
(
m_maxD0Significance
< 0 || !std::isfinite (
m_maxD0Significance
))
31
{
32
ATH_MSG_ERROR
(
"invalid value of maxD0Significance: "
<<
m_maxD0Significance
);
33
return
StatusCode::FAILURE;
34
}
35
if
(
m_maxDeltaZ0SinTheta
< 0 || !std::isfinite (
m_maxDeltaZ0SinTheta
))
36
{
37
ATH_MSG_ERROR
(
"invalid value of maxDeltaZ0SinTheta: "
<<
m_maxDeltaZ0SinTheta
);
38
return
StatusCode::FAILURE;
39
}
40
41
m_accept
.addCut (
"trackRetrieval"
,
"whether the track retrieval failed"
);
42
if
(
m_maxD0Significance
> 0)
43
m_accept
.addCut (
"maxD0Significance"
,
"maximum D0 significance cut"
);
44
if
(
m_maxDeltaZ0SinTheta
> 0)
45
m_accept
.addCut (
"maxDeltaZ0SinTheta"
,
"maximum Delta z0 sin theta cut"
);
46
if
(
m_nMinPixelHits
!= -1 ||
m_nMaxPixelHits
!= -1)
47
m_accept
.addCut (
"numPixelHits"
,
"Minimum and/or maxiumum Pixel hits"
);
48
if
(
m_nMinSCTHits
!= -1 ||
m_nMaxSCTHits
!= -1)
49
m_accept
.addCut (
"numSCTHits"
,
"Minimum and/or maxiumum SCT hits"
);
50
51
ANA_CHECK
(
m_particlesHandle
.initialize (
m_systematicsList
));
52
ANA_CHECK
(
m_preselection
.initialize (
m_systematicsList
,
m_particlesHandle
,
SG::AllowEmpty
));
53
ANA_CHECK
(
m_selectionHandle
.initialize (
m_systematicsList
,
m_particlesHandle
));
54
ANA_CHECK
(
m_systematicsList
.initialize());
55
56
ANA_CHECK
(
m_eventInfoKey
.initialize());
57
ANA_CHECK
(
m_primaryVerticesKey
.initialize());
58
59
if
(!
m_nameSvc
.empty())
60
{
61
ANA_CHECK
(
m_nameSvc
.retrieve());
62
ANA_CHECK
(
m_nameSvc
->addAcceptInfo (
m_particlesHandle
.getNamePattern(),
m_selectionHandle
.getLabel(),
63
m_accept
));
64
}
65
66
return
StatusCode::SUCCESS;
67
}
68
69
70
71
StatusCode AsgLeptonTrackSelectionAlg ::
72
execute (
const
EventContext &ctx)
const
73
{
74
SG::ReadHandle<xAOD::EventInfo>
eventInfo(
m_eventInfoKey
, ctx);
75
SG::ReadHandle<xAOD::VertexContainer>
vertices(
m_primaryVerticesKey
, ctx);
76
const
xAOD::Vertex
*primaryVertex {
nullptr
};
77
78
for
(
const
xAOD::Vertex
*vertex : *vertices)
79
{
80
if
(vertex->vertexType() ==
xAOD::VxType::PriVtx
)
81
{
82
// The default "PrimaryVertex" container is ordered in
83
// sum-pt, and the tracking group recommends to pick the one
84
// with the maximum sum-pt, so this will do the right thing.
85
// If the user needs a different primary vertex, they need to
86
// provide a reordered primary vertex container and point
87
// this algorithm to it. Currently there is no central
88
// algorithm to do that, so users will have to write their
89
// own (15 Aug 18).
90
if
(primaryVertex ==
nullptr
)
91
{
92
primaryVertex = vertex;
93
break
;
94
}
95
}
96
}
97
98
for
(
const
auto
& sys :
m_systematicsList
.systematicsVector())
99
{
100
const
xAOD::IParticleContainer
*particles =
nullptr
;
101
ANA_CHECK
(
m_particlesHandle
.retrieve (particles, sys, ctx));
102
for
(
const
xAOD::IParticle
*particle : *particles)
103
{
104
asg::AcceptData
acceptData (&
m_accept
);
105
float
d0sig = -999;
106
float
deltaZ0SinTheta = -999;
107
108
if
(
m_preselection
.getBool (*particle, sys))
109
{
110
std::size_t cutIndex {0};
111
112
const
xAOD::TrackParticle
*
track
{
nullptr
};
113
if
(
const
xAOD::Muon
*
muon
=
dynamic_cast<
const
xAOD::Muon
*
>
(particle)){
114
track
=
muon
->trackParticle(xAOD::Muon::TrackParticleType::Primary);
115
}
else
if
(
const
xAOD::Electron
*
electron
=
dynamic_cast<
const
xAOD::Electron
*
>
(particle)){
116
track
=
electron
->trackParticle();
117
}
else
{
118
ANA_MSG_ERROR
(
"failed to cast input to electron or muon"
);
119
return
StatusCode::FAILURE;
120
}
121
122
acceptData.
setCutResult
(cutIndex ++,
track
!=
nullptr
);
123
124
if
(
track
!=
nullptr
) {
125
try
{
126
d0sig =
xAOD::TrackingHelpers::d0significance
(
track
, eventInfo->beamPosSigmaX(), eventInfo->beamPosSigmaY(), eventInfo->beamPosSigmaXY());
127
if
(
m_maxD0Significance
> 0) acceptData.
setCutResult
(cutIndex ++, fabs( d0sig ) <
m_maxD0Significance
);
128
129
}
catch
(
const
std::runtime_error &) {
130
acceptData.
setCutResult
(cutIndex ++,
false
);
131
}
132
133
const
double
vertex_z = primaryVertex ? primaryVertex->
z
() : 0;
134
deltaZ0SinTheta = (
track
->z0() +
track
->vz() - vertex_z) * sin (particle->p4().Theta());
135
if
(
m_maxDeltaZ0SinTheta
> 0) acceptData.
setCutResult
(cutIndex ++, fabs (deltaZ0SinTheta) <
m_maxDeltaZ0SinTheta
);
136
137
if
(
m_nMinPixelHits
!= -1 ||
m_nMaxPixelHits
!= -1) {
138
uint8_t
nPixelHits;
139
track
->summaryValue(nPixelHits,
xAOD::numberOfPixelHits
);
140
bool
accept =
true
;
141
if
(
m_nMinPixelHits
!= -1) {
142
accept &= nPixelHits >=
m_nMinPixelHits
;
143
}
144
if
(
m_nMaxPixelHits
!= -1) {
145
accept &= nPixelHits <=
m_nMaxPixelHits
;
146
}
147
acceptData.
setCutResult
(cutIndex++, accept);
148
}
149
if
(
m_nMinSCTHits
!= -1 ||
m_nMaxSCTHits
!= -1) {
150
uint8_t
nSCTHits;
151
track
->summaryValue(nSCTHits,
xAOD::numberOfSCTHits
);
152
bool
accept =
true
;
153
if
(
m_nMinSCTHits
!= -1) {
154
accept &= nSCTHits >=
m_nMinSCTHits
;
155
}
156
if
(
m_nMaxSCTHits
!= -1) {
157
accept &= nSCTHits <=
m_nMaxSCTHits
;
158
}
159
acceptData.
setCutResult
(cutIndex++, accept);
160
}
161
}
162
}
163
164
m_selectionHandle
.setBits(*particle,
selectionFromAccept
(acceptData), sys);
165
}
166
}
167
168
return
StatusCode::SUCCESS;
169
}
170
}
AsgLeptonTrackSelectionAlg.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
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
TrackParticlexAODHelpers.h
CP::AsgLeptonTrackSelectionAlg::m_systematicsList
SysListHandle m_systematicsList
the systematics list we run
Definition
AsgLeptonTrackSelectionAlg.h:66
CP::AsgLeptonTrackSelectionAlg::m_nameSvc
ServiceHandle< ISelectionNameSvc > m_nameSvc
the ISelectionNameSvc
Definition
AsgLeptonTrackSelectionAlg.h:91
CP::AsgLeptonTrackSelectionAlg::m_nMinPixelHits
Gaudi::Property< int > m_nMinPixelHits
Definition
AsgLeptonTrackSelectionAlg.h:56
CP::AsgLeptonTrackSelectionAlg::m_maxDeltaZ0SinTheta
Gaudi::Property< float > m_maxDeltaZ0SinTheta
Definition
AsgLeptonTrackSelectionAlg.h:55
CP::AsgLeptonTrackSelectionAlg::m_selectionHandle
SysWriteSelectionHandle m_selectionHandle
the accessor for m_selectionDecoration
Definition
AsgLeptonTrackSelectionAlg.h:86
CP::AsgLeptonTrackSelectionAlg::m_nMaxPixelHits
Gaudi::Property< int > m_nMaxPixelHits
Definition
AsgLeptonTrackSelectionAlg.h:57
CP::AsgLeptonTrackSelectionAlg::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
the EventInfo key
Definition
AsgLeptonTrackSelectionAlg.h:69
CP::AsgLeptonTrackSelectionAlg::m_primaryVerticesKey
SG::ReadHandleKey< xAOD::VertexContainer > m_primaryVerticesKey
the PrimaryVertex key
Definition
AsgLeptonTrackSelectionAlg.h:72
CP::AsgLeptonTrackSelectionAlg::m_nMaxSCTHits
Gaudi::Property< int > m_nMaxSCTHits
Definition
AsgLeptonTrackSelectionAlg.h:59
CP::AsgLeptonTrackSelectionAlg::m_nMinSCTHits
Gaudi::Property< int > m_nMinSCTHits
Definition
AsgLeptonTrackSelectionAlg.h:58
CP::AsgLeptonTrackSelectionAlg::m_particlesHandle
SysReadHandle< xAOD::IParticleContainer > m_particlesHandle
the particle container we run on
Definition
AsgLeptonTrackSelectionAlg.h:76
CP::AsgLeptonTrackSelectionAlg::m_maxD0Significance
Gaudi::Property< float > m_maxD0Significance
algorithm properties
Definition
AsgLeptonTrackSelectionAlg.h:54
CP::AsgLeptonTrackSelectionAlg::m_preselection
SysReadSelectionHandle m_preselection
the preselection we apply to our input
Definition
AsgLeptonTrackSelectionAlg.h:81
CP::AsgLeptonTrackSelectionAlg::m_accept
asg::AcceptInfo m_accept
the asg::AcceptInfo we are using
Definition
AsgLeptonTrackSelectionAlg.h:95
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
asg::AcceptData
Definition
AcceptData.h:31
asg::AcceptData::setCutResult
void setCutResult(const std::string &cutName, bool cutResult)
Set the result of a cut, based on the cut name (safer).
Definition
AcceptData.h:135
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition
Event/xAOD/xAODBase/xAODBase/IParticle.h:41
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
CP::selectionFromAccept
SelectionType selectionFromAccept(const asg::AcceptData &accept)
the selection decoration made from the given AcceptData object
Definition
SelectionHelpers.cxx:32
SG::AllowEmpty
@ AllowEmpty
Definition
StoreGate/StoreGate/VarHandleKey.h:27
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::uint8_t
uint8_t
Definition
Muon_v1.cxx:500
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::numberOfSCTHits
@ numberOfSCTHits
number of hits in SCT [unit8_t].
Definition
TrackingPrimitives.h:269
xAOD::numberOfPixelHits
@ numberOfPixelHits
these are the pixel hits, including the b-layer [unit8_t].
Definition
TrackingPrimitives.h:260
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