ATLAS Offline Software
Loading...
Searching...
No Matches
DerivationFramework::MuonExtrapolationTool Class Reference

#include <MuonExtrapolationTool.h>

Inheritance diagram for DerivationFramework::MuonExtrapolationTool:
Collaboration diagram for DerivationFramework::MuonExtrapolationTool:

Public Member Functions

 MuonExtrapolationTool (const std::string &t, const std::string &n, const IInterface *p)
virtual StatusCode initialize ()
virtual StatusCode addBranches (const EventContext &ctx) const

Private Member Functions

const Trk::TrackParametersextrapolateToTriggerPivotPlane (const xAOD::TrackParticle &track, const EventContext &ctx) const
 run the extrapolation - only available in full athena
bool extrapolateAndDecorateTrackParticle (const xAOD::TrackParticle *particle, float &eta, float &phi, const EventContext &ctx) const
const xAOD::TrackParticlegetPreferredTrackParticle (const xAOD::IParticle *probe) const

Private Attributes

SG::ReadHandleKey< xAOD::MuonContainerm_muonContainerName {this, "MuonCollection", "Muons"}
PublicToolHandle< Trk::IExtrapolatorm_extrapolator {this, "Extrapolator", "Trk::Extrapolator/AtlasExtrapolator"}
Gaudi::Property< double > m_endcapPivotPlaneZ {this, "EndcapPivotPlaneZ", 15525., "z position of pivot plane in endcap region"}
Gaudi::Property< double > m_endcapPivotPlaneMinimumRadius {this, "EndcapPivotPlaneMinimumRadius", 0., "minimum radius of pivot plane in endcap region"}
Gaudi::Property< double > m_endcapPivotPlaneMaximumRadius {this, "EndcapPivotPlaneMaximumRadius", 11977., "maximum radius of pivot plane in endcap region"}
Gaudi::Property< double > m_barrelPivotPlaneRadius {this, "BarrelPivotPlaneRadius", 8000., "radius of pivot plane in barrel region"}
Gaudi::Property< double > m_barrelPivotPlaneHalfLength {this, "BarrelPivotPlaneHalfLength", 9700., "half length of pivot plane in barrel region"}

Detailed Description

Definition at line 18 of file MuonExtrapolationTool.h.

Constructor & Destructor Documentation

◆ MuonExtrapolationTool()

DerivationFramework::MuonExtrapolationTool::MuonExtrapolationTool ( const std::string & t,
const std::string & n,
const IInterface * p )

Definition at line 17 of file MuonExtrapolationTool.cxx.

18 :
19 base_class(t, n, p)
20{
21}

Member Function Documentation

◆ addBranches()

StatusCode DerivationFramework::MuonExtrapolationTool::addBranches ( const EventContext & ctx) const
virtual

Definition at line 89 of file MuonExtrapolationTool.cxx.

90{
91 SG::ReadHandle<xAOD::MuonContainer> muonContainer{m_muonContainerName, ctx};
92 if (!muonContainer.isValid()) {
93 ATH_MSG_ERROR("Failed to retrieve MuonContainer with name: " << m_muonContainerName.key());
94 return StatusCode::FAILURE;
95 }
96 for (auto muon : *muonContainer) {
98 float eta, phi = 0;
99 if( !extrapolateAndDecorateTrackParticle( track, eta, phi, ctx )){
100 if( muon->pt() > 3500.){
101 //only complain if the muon has sufficient pT to actually reach the pivot plane
102 //extrapolation will often fail for muons with pT < 3500 MeV
103 ATH_MSG_WARNING("Failed to extrapolate+decorate muon with pivot plane coords - Muon params: pt "<<muon->pt()<<", eta "<< muon->eta()<<", phi "<< muon->phi());
104 }
105 }
106 }
107 return StatusCode::SUCCESS;
108}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
xAOD::MuonContainer * muonContainer
const xAOD::TrackParticle * getPreferredTrackParticle(const xAOD::IParticle *probe) const
SG::ReadHandleKey< xAOD::MuonContainer > m_muonContainerName
bool extrapolateAndDecorateTrackParticle(const xAOD::TrackParticle *particle, float &eta, float &phi, const EventContext &ctx) const
TrackParticle_v1 TrackParticle
Reference the current persistent version:

◆ extrapolateAndDecorateTrackParticle()

bool DerivationFramework::MuonExtrapolationTool::extrapolateAndDecorateTrackParticle ( const xAOD::TrackParticle * particle,
float & eta,
float & phi,
const EventContext & ctx ) const
private

Definition at line 36 of file MuonExtrapolationTool.cxx.

37{
38
39 // decorators used to access or store the information
40 static const SG::AuxElement::Decorator< char > Decorated ("DecoratedPivotEtaPhi");
41 static const SG::AuxElement::Decorator< float > Eta ("EtaTriggerPivot");
42 static const SG::AuxElement::Decorator< float > Phi ("PhiTriggerPivot");
43
44 if (! Decorated.isAvailable(*particle) || !Decorated(*particle)){
45 // in the athena release, we can run the extrapolation if needed
47 if(!pTag) {
48 Decorated(*particle) = false;
49 return false;
50 }
51 Eta(*particle) = pTag->position().eta();
52 Phi(*particle) = pTag->position().phi();
53 Decorated(*particle) = true;
54 delete pTag;
55 }
56 // if we get here, the decoration was either already present or just added by us
57 // so we can finally read the values
58 eta = Eta(*particle);
59 phi = Phi(*particle);
60 return true;
61}
@ Phi
Definition RPCdef.h:8
@ Eta
Definition RPCdef.h:8
const Trk::TrackParameters * extrapolateToTriggerPivotPlane(const xAOD::TrackParticle &track, const EventContext &ctx) const
run the extrapolation - only available in full athena
ParametersBase< TrackParametersDim, Charged > TrackParameters

◆ extrapolateToTriggerPivotPlane()

const Trk::TrackParameters * DerivationFramework::MuonExtrapolationTool::extrapolateToTriggerPivotPlane ( const xAOD::TrackParticle & track,
const EventContext & ctx ) const
private

run the extrapolation - only available in full athena

Definition at line 110 of file MuonExtrapolationTool.cxx.

111{
112 // BARREL
113 const Trk::Perigee& perigee = track.perigeeParameters();
114
115 // create the barrel as a cylinder surface centered at 0,0,0
116 Amg::Vector3D barrelCentre(0., 0., 0.);
117 Amg::Transform3D matrix = Amg::Transform3D(Amg::RotationMatrix3D::Identity(), barrelCentre);
118
119 Trk::CylinderSurface* cylinder =
120 new Trk::CylinderSurface(matrix,
123 if (!cylinder) {
124 ATH_MSG_WARNING("extrapolateToTriggerPivotPlane :: new Trk::CylinderSurface failed.");
125 return nullptr;
126 }
127 // and then attempt to extrapolate our track to this surface, checking for the boundaries of the barrel
128 bool boundaryCheck = true;
129 const Trk::Surface* surface = cylinder;
130 const Trk::TrackParameters* p = m_extrapolator->extrapolate(
131 ctx, perigee, *surface, Trk::alongMomentum, boundaryCheck, Trk::muon).release();
132 delete cylinder;
133 // if the extrapolation worked out (so we are in the barrel) we are done and can return the
134 // track parameters at this surface.
135 if (p) return p;
136
137 // if we get here, the muon did not cross the barrel surface
138 // so we assume it is going into the endcap.
139 // ENDCAP
140
141 // After 2 years of using this code, we realised that ATLAS actually has endcaps on both sides ;-)
142 // So better make sure we place our endcap at the correct side of the detector!
143 // Hopefully no-one will ever read this comment...
144 float SignOfEta = track.eta() > 0 ? 1. : -1.;
145
146 Amg::Vector3D endcapCentre(0., 0., m_endcapPivotPlaneZ);
147 // much better!
148 matrix = Amg::Transform3D(Amg::RotationMatrix3D::Identity(), SignOfEta * endcapCentre);
149
150 std::unique_ptr<Trk::DiscSurface> disc =
151 std::make_unique<Trk::DiscSurface>(matrix,
154 if (!disc) {
155 ATH_MSG_WARNING("extrapolateToTriggerPivotPlane :: new Trk::DiscSurface failed.");
156 return nullptr;
157 }
158
159 // for the endcap, we turn off the boundary check, extending the EC infinitely to catch stuff heading for the transition region
160 boundaryCheck = false;
161 surface = disc.get();
162 p = m_extrapolator->extrapolate(
163 ctx, perigee, *surface, Trk::alongMomentum, boundaryCheck, Trk::muon).release();
164 return p;
165}
Gaudi::Property< double > m_endcapPivotPlaneMaximumRadius
Gaudi::Property< double > m_endcapPivotPlaneMinimumRadius
PublicToolHandle< Trk::IExtrapolator > m_extrapolator
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
@ alongMomentum
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee

◆ getPreferredTrackParticle()

const xAOD::TrackParticle * DerivationFramework::MuonExtrapolationTool::getPreferredTrackParticle ( const xAOD::IParticle * probe) const
private

Definition at line 65 of file MuonExtrapolationTool.cxx.

66{
67 if (dynamic_cast<const xAOD::TruthParticle*>(muon)){
68 ATH_MSG_WARNING("Pivot plane extrapolation not supported for Truth muons!");
69 return 0;
70 }
71 const xAOD::TrackParticle* muonTrack = dynamic_cast<const xAOD::TrackParticle*>(muon);
72 if(!muonTrack && dynamic_cast<const xAOD::Muon*>(muon)) {
73 const xAOD::Muon* theMuon = dynamic_cast<const xAOD::Muon*>(muon);
74 muonTrack = theMuon->trackParticle( xAOD::Muon::MuonSpectrometerTrackParticle );
75 if(!muonTrack) {
76 muonTrack = theMuon->primaryTrackParticle();
77 if(!muonTrack) {
78 muonTrack = theMuon->trackParticle( xAOD::Muon::InnerDetectorTrackParticle );
79 }
80 }
81 }
82 if(!muonTrack){
83 ATH_MSG_WARNING("no valid track found for extrapolating the muon to the pivot plane!");
84 }
85 return muonTrack;
86
87}
const TrackParticle * primaryTrackParticle() const
Returns a pointer (which should not usually be NULL, but might be if the muon has been stripped of in...
Definition Muon_v1.cxx:396
const TrackParticle * trackParticle(TrackParticleType type) const
Returns a pointer (which can be NULL) to the TrackParticle used in identification of this muon.
Definition Muon_v1.cxx:482
TruthParticle_v1 TruthParticle
Typedef to implementation.
Muon_v1 Muon
Reference the current persistent version:

◆ initialize()

StatusCode DerivationFramework::MuonExtrapolationTool::initialize ( )
virtual

Definition at line 26 of file MuonExtrapolationTool.cxx.

27{
28 ATH_CHECK(m_muonContainerName.initialize());
29 ATH_CHECK(m_extrapolator.retrieve());
30 return StatusCode::SUCCESS;
31}
#define ATH_CHECK
Evaluate an expression and check for errors.

Member Data Documentation

◆ m_barrelPivotPlaneHalfLength

Gaudi::Property<double> DerivationFramework::MuonExtrapolationTool::m_barrelPivotPlaneHalfLength {this, "BarrelPivotPlaneHalfLength", 9700., "half length of pivot plane in barrel region"}
private

Definition at line 53 of file MuonExtrapolationTool.h.

53{this, "BarrelPivotPlaneHalfLength", 9700., "half length of pivot plane in barrel region"};

◆ m_barrelPivotPlaneRadius

Gaudi::Property<double> DerivationFramework::MuonExtrapolationTool::m_barrelPivotPlaneRadius {this, "BarrelPivotPlaneRadius", 8000., "radius of pivot plane in barrel region"}
private

Definition at line 52 of file MuonExtrapolationTool.h.

52{this, "BarrelPivotPlaneRadius", 8000., "radius of pivot plane in barrel region"};

◆ m_endcapPivotPlaneMaximumRadius

Gaudi::Property<double> DerivationFramework::MuonExtrapolationTool::m_endcapPivotPlaneMaximumRadius {this, "EndcapPivotPlaneMaximumRadius", 11977., "maximum radius of pivot plane in endcap region"}
private

Definition at line 51 of file MuonExtrapolationTool.h.

51{this, "EndcapPivotPlaneMaximumRadius", 11977., "maximum radius of pivot plane in endcap region"};

◆ m_endcapPivotPlaneMinimumRadius

Gaudi::Property<double> DerivationFramework::MuonExtrapolationTool::m_endcapPivotPlaneMinimumRadius {this, "EndcapPivotPlaneMinimumRadius", 0., "minimum radius of pivot plane in endcap region"}
private

Definition at line 50 of file MuonExtrapolationTool.h.

50{this, "EndcapPivotPlaneMinimumRadius", 0., "minimum radius of pivot plane in endcap region"};

◆ m_endcapPivotPlaneZ

Gaudi::Property<double> DerivationFramework::MuonExtrapolationTool::m_endcapPivotPlaneZ {this, "EndcapPivotPlaneZ", 15525., "z position of pivot plane in endcap region"}
private

Definition at line 49 of file MuonExtrapolationTool.h.

49{this, "EndcapPivotPlaneZ", 15525., "z position of pivot plane in endcap region"};

◆ m_extrapolator

PublicToolHandle<Trk::IExtrapolator> DerivationFramework::MuonExtrapolationTool::m_extrapolator {this, "Extrapolator", "Trk::Extrapolator/AtlasExtrapolator"}
private

Definition at line 45 of file MuonExtrapolationTool.h.

45{this, "Extrapolator", "Trk::Extrapolator/AtlasExtrapolator"};

◆ m_muonContainerName

SG::ReadHandleKey<xAOD::MuonContainer> DerivationFramework::MuonExtrapolationTool::m_muonContainerName {this, "MuonCollection", "Muons"}
private

Definition at line 44 of file MuonExtrapolationTool.h.

44{this, "MuonCollection", "Muons"};

The documentation for this class was generated from the following files: