ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
DerivationFramework
DerivationFrameworkMuons
src
MuonTPExtrapolationAlg.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 "
MuonTPExtrapolationAlg.h
"
6
#include "
FourMomUtils/xAODP4Helpers.h
"
7
#include "
TrkSurfaces/CylinderSurface.h
"
8
#include "
TrkSurfaces/DiscSurface.h
"
9
#include "
xAODEventInfo/EventInfo.h
"
10
#include "
xAODMuonViews/ContainerDecorator.h
"
11
namespace
{
12
constexpr
float
min_warn_pt = 3500;
13
constexpr
float
dummy_result = 5.;
14
15
enum
ExtStatus {
16
Success = 1,
17
Failed = 2,
18
NotPresent = 0,
19
};
20
}
// namespace
21
22
namespace
DerivationFramework
{
23
24
StatusCode
MuonTPExtrapolationAlg::initialize
() {
25
ATH_CHECK
(
m_extrapolator
.retrieve());
26
ATH_CHECK
(
m_partKey
.initialize());
27
28
for
(
const
std::string& selDecor :
m_trkSelDecors
) {
29
m_trkSelKeys
.emplace_back(
m_partKey
, selDecor);
30
}
31
ATH_CHECK
(
m_trkSelKeys
.initialize());
32
ATH_CHECK
(
m_extEtaKey
.initialize());
33
ATH_CHECK
(
m_extPhiKey
.initialize());
34
ATH_CHECK
(
m_extStatKey
.initialize());
35
return
StatusCode::SUCCESS;
36
}
37
38
StatusCode
MuonTPExtrapolationAlg::execute
(
const
EventContext& ctx)
const
{
39
const
xAOD::IParticleContainer
* muons{
nullptr
};
40
ATH_CHECK
(
SG::get
(muons,
m_partKey
, ctx));
41
42
43
xAOD::ContainerDecorator<xAOD::IParticleContainer, float>
dec_Eta{
m_extEtaKey
, ctx, dummy_result};
44
xAOD::ContainerDecorator<xAOD::IParticleContainer, float>
dec_Phi{
m_extPhiKey
, ctx, dummy_result};
45
xAOD::ContainerDecorator<xAOD::IParticleContainer, char>
dec_Decorated{
m_extStatKey
, ctx, ExtStatus::NotPresent};
46
47
using
SelDecorator =
SG::ReadDecorHandle<xAOD::IParticleContainer, std::uint8_t>
;
48
49
std::vector<SelDecorator> selDecors;
50
for
(
const
SG::ReadDecorHandleKey<xAOD::IParticleContainer>
& key :
m_trkSelKeys
) {
51
selDecors.emplace_back(key, ctx);
52
}
53
54
for
(
const
xAOD::IParticle
* muon : *muons) {
56
const
xAOD::TrackParticle
* track{
nullptr
};
57
if
(muon->type() ==
xAOD::Type::ObjectType::TruthParticle
) {
58
ATH_MSG_FATAL
(
"Truth is not supported"
);
59
return
StatusCode::FAILURE;
60
}
else
if
(muon->type() ==
xAOD::Type::ObjectType::TrackParticle
) {
61
track =
static_cast<
const
xAOD::TrackParticle
*
>
(muon);
62
}
else
if
(muon->type() ==
xAOD::Type::ObjectType::Muon
) {
63
const
xAOD::Muon
* probeMuon =
static_cast<
const
xAOD::Muon
*
>
(muon);
64
track = probeMuon->
trackParticle
(xAOD::Muon::TrackParticleType::MuonSpectrometerTrackParticle);
65
if
(!track) { track = probeMuon->
trackParticle
(xAOD::Muon::TrackParticleType::Primary); }
66
}
67
bool
passSelection = muon->pt() >
m_ptMin
&& (selDecors.empty () ||
68
std::find_if(selDecors.begin(),selDecors.end(),
69
[&muon](
const
SelDecorator& dec){
70
return dec(*muon);
71
}) != selDecors.end());
72
std::unique_ptr<Trk::TrackParameters> pTag = passSelection && track ?
extrapolateToTriggerPivotPlane
(ctx, *track) :
nullptr
;
73
int
extr_code = ExtStatus::NotPresent;
74
float
eta
{dummy_result},
phi
{dummy_result};
75
if
(!pTag) {
76
// complain only if the particle has sufficient pt to actually make it to the MS...
77
if
(passSelection && muon->pt() > min_warn_pt)
78
ATH_MSG_WARNING
(
"Warning - Pivot plane extrapolation failed for a track particle with IP pt "
79
<< muon->pt() <<
", eta "
<< muon->eta() <<
", phi "
<< muon->phi());
80
extr_code = ExtStatus::Failed;
81
}
else
{
82
eta
= pTag->position().eta();
83
phi
= pTag->position().phi();
84
extr_code = ExtStatus::Success;
85
}
86
dec_Eta(*muon) =
eta
;
87
dec_Phi(*muon) =
phi
;
88
dec_Decorated(*muon) = extr_code;
89
}
90
return
StatusCode::SUCCESS;
91
}
92
93
std::unique_ptr<Trk::TrackParameters>
MuonTPExtrapolationAlg::extrapolateToTriggerPivotPlane
(
const
EventContext& ctx,
94
const
xAOD::TrackParticle
& track)
const
{
95
// BARREL
96
const
Trk::Perigee
& perigee = track.perigeeParameters();
97
98
// create the barrel as a cylinder surface centered at 0,0,0
99
Amg::Transform3D
matrix =
Amg::Transform3D
(Amg::RotationMatrix3D::Identity(), Amg::Vector3D::Zero());
100
101
std::unique_ptr<Trk::CylinderSurface> cylinder =
102
std::make_unique<Trk::CylinderSurface>(matrix,
m_barrelPivotPlaneRadius
,
m_barrelPivotPlaneHalfLength
);
103
104
// and then attempt to extrapolate our track to this surface, checking for the boundaries of the barrel
105
bool
boundaryCheck =
true
;
106
107
std::unique_ptr<Trk::TrackParameters> p{
108
m_extrapolator
->extrapolate(ctx, perigee, *cylinder,
Trk::alongMomentum
, boundaryCheck,
Trk::muon
)};
109
110
// if the extrapolation worked out (so we are in the barrel) we are done and can return the
111
// track parameters at this surface.
112
if
(p)
return
p;
113
114
// if we get here, the muon did not cross the barrel surface
115
// so we assume it is going into the endcap.
116
// ENDCAP
117
118
// After 2 years of using this code, we realised that ATLAS actually has endcaps on both sides ;-)
119
// So better make sure we place our endcap at the correct side of the detector!
120
// Hopefully no-one will ever read this comment...
121
const
int
SignOfEta = track.eta() > 0 ? 1. : -1.;
122
// much better!
123
matrix =
Amg::Transform3D
(Amg::RotationMatrix3D::Identity(), SignOfEta *
m_endcapPivotPlaneZ
* Amg::Vector3D::UnitZ());
124
std::unique_ptr<Trk::DiscSurface> disc = std::make_unique<Trk::DiscSurface>(matrix,
m_endcapPivotPlaneMinimumRadius
,
125
m_endcapPivotPlaneMaximumRadius
);
126
127
boundaryCheck =
false
;
128
return
m_extrapolator
->extrapolate(ctx, perigee, *disc,
Trk::alongMomentum
, boundaryCheck,
Trk::muon
);
129
}
130
131
}
eta
Scalar eta() const
pseudorapidity method
Definition
AmgMatrixBasePlugin.h:83
phi
Scalar phi() const
phi method
Definition
AmgMatrixBasePlugin.h:67
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition
AthMsgStreamMacros.h:34
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ContainerDecorator.h
CylinderSurface.h
DiscSurface.h
MuonTPExtrapolationAlg.h
DerivationFramework::MuonTPExtrapolationAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
MuonTPExtrapolationAlg.cxx:38
DerivationFramework::MuonTPExtrapolationAlg::initialize
virtual StatusCode initialize() override
Definition
MuonTPExtrapolationAlg.cxx:24
DerivationFramework::MuonTPExtrapolationAlg::m_extrapolator
ToolHandle< Trk::IExtrapolator > m_extrapolator
Definition
MuonTPExtrapolationAlg.h:30
DerivationFramework::MuonTPExtrapolationAlg::m_extPhiKey
SG::WriteDecorHandleKey< xAOD::IParticleContainer > m_extPhiKey
Definition
MuonTPExtrapolationAlg.h:45
DerivationFramework::MuonTPExtrapolationAlg::m_trkSelDecors
Gaudi::Property< std::vector< std::string > > m_trkSelDecors
Definition
MuonTPExtrapolationAlg.h:52
DerivationFramework::MuonTPExtrapolationAlg::m_endcapPivotPlaneZ
Gaudi::Property< float > m_endcapPivotPlaneZ
Definition
MuonTPExtrapolationAlg.h:32
DerivationFramework::MuonTPExtrapolationAlg::m_ptMin
Gaudi::Property< float > m_ptMin
Optional list of decorators to select only the good tracks for the isolation decoration.
Definition
MuonTPExtrapolationAlg.h:50
DerivationFramework::MuonTPExtrapolationAlg::m_partKey
SG::ReadHandleKey< xAOD::IParticleContainer > m_partKey
Particle container to decorate the Pivot plane coordinates to.
Definition
MuonTPExtrapolationAlg.h:42
DerivationFramework::MuonTPExtrapolationAlg::m_extEtaKey
SG::WriteDecorHandleKey< xAOD::IParticleContainer > m_extEtaKey
Definition
MuonTPExtrapolationAlg.h:44
DerivationFramework::MuonTPExtrapolationAlg::m_trkSelKeys
SG::ReadDecorHandleKeyArray< xAOD::IParticleContainer > m_trkSelKeys
Definition
MuonTPExtrapolationAlg.h:55
DerivationFramework::MuonTPExtrapolationAlg::m_barrelPivotPlaneRadius
Gaudi::Property< float > m_barrelPivotPlaneRadius
Definition
MuonTPExtrapolationAlg.h:37
DerivationFramework::MuonTPExtrapolationAlg::m_extStatKey
SG::WriteDecorHandleKey< xAOD::IParticleContainer > m_extStatKey
Definition
MuonTPExtrapolationAlg.h:46
DerivationFramework::MuonTPExtrapolationAlg::extrapolateToTriggerPivotPlane
std::unique_ptr< Trk::TrackParameters > extrapolateToTriggerPivotPlane(const EventContext &ctx, const xAOD::TrackParticle &track) const
run the extrapolation - only available in full athena
Definition
MuonTPExtrapolationAlg.cxx:93
DerivationFramework::MuonTPExtrapolationAlg::m_barrelPivotPlaneHalfLength
Gaudi::Property< float > m_barrelPivotPlaneHalfLength
Definition
MuonTPExtrapolationAlg.h:38
DerivationFramework::MuonTPExtrapolationAlg::m_endcapPivotPlaneMinimumRadius
Gaudi::Property< float > m_endcapPivotPlaneMinimumRadius
Definition
MuonTPExtrapolationAlg.h:33
DerivationFramework::MuonTPExtrapolationAlg::m_endcapPivotPlaneMaximumRadius
Gaudi::Property< float > m_endcapPivotPlaneMaximumRadius
Definition
MuonTPExtrapolationAlg.h:35
SG::ReadDecorHandleKey
Property holding a SG store/key/clid/attr name from which a ReadDecorHandle is made.
Definition
StoreGate/StoreGate/ReadDecorHandleKey.h:86
SG::ReadDecorHandle
Handle class for reading a decoration on an object.
Definition
StoreGate/StoreGate/ReadDecorHandle.h:94
xAOD::ContainerDecorator
Auxiliary class to instantiate WriteDecorHandles.The handles can be created in an empty state.
Definition
ContainerDecorator.h:18
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition
Event/xAOD/xAODBase/xAODBase/IParticle.h:41
xAOD::Muon_v1::trackParticle
const TrackParticle * trackParticle(TrackParticleType type) const
Returns a pointer (which can be a nullptr) to the TrackParticle used in identification of this muon.
Definition
Muon_v1.cxx:422
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition
GeoPrimitives.h:46
DerivationFramework
THE reconstruction tool.
Definition
CascadeTools.h:16
SG::get
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
Definition
ReadCondHandle.h:282
Trk::alongMomentum
@ alongMomentum
Definition
PropDirection.h:20
Trk::Perigee
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
Definition
Tracking/TrkEvent/TrkParameters/TrkParameters/TrackParameters.h:33
Trk::muon
@ muon
Definition
ParticleHypothesis.h:31
xAODType::TrackParticle
@ TrackParticle
The object is a charged track particle.
Definition
ObjectType.h:43
xAODType::Muon
@ Muon
The object is a muon.
Definition
ObjectType.h:48
xAODType::TruthParticle
@ TruthParticle
The object is a truth particle.
Definition
ObjectType.h:67
xAOD::TrackParticle
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Definition
Event/xAOD/xAODTracking/xAODTracking/TrackParticle.h:13
xAOD::Muon
Muon_v1 Muon
Reference the current persistent version:
Definition
Event/xAOD/xAODMuon/xAODMuon/Muon.h:13
xAOD::IParticleContainer
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.
Definition
xAOD/xAODBase/xAODBase/IParticleContainer.h:32
xAODP4Helpers.h
EventInfo.h
Generated on
for ATLAS Offline Software by
1.17.0