ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
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 More...
 
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 {
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;
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 }

◆ 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 }

◆ 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 =
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 }

◆ 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 }

◆ initialize()

StatusCode DerivationFramework::MuonExtrapolationTool::initialize ( )
virtual

Definition at line 26 of file MuonExtrapolationTool.cxx.

27 {
29  ATH_CHECK(m_extrapolator.retrieve());
30  return StatusCode::SUCCESS;
31 }

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.

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ m_extrapolator

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

Definition at line 45 of file MuonExtrapolationTool.h.

◆ m_muonContainerName

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

Definition at line 44 of file MuonExtrapolationTool.h.


The documentation for this class was generated from the following files:
muonContainer
xAOD::MuonContainer * muonContainer
Definition: TrigGlobEffCorrValidation.cxx:188
xAOD::muon
@ muon
Definition: TrackingPrimitives.h:196
DerivationFramework::MuonExtrapolationTool::m_extrapolator
PublicToolHandle< Trk::IExtrapolator > m_extrapolator
Definition: MuonExtrapolationTool.h:45
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:79
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
xAOD::Muon_v1::trackParticle
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:487
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
Trk::ParametersT
Dummy class used to allow special convertors to be called for surfaces owned by a detector element.
Definition: EMErrorDetail.h:25
DerivationFramework::MuonExtrapolationTool::extrapolateToTriggerPivotPlane
const Trk::TrackParameters * extrapolateToTriggerPivotPlane(const xAOD::TrackParticle &track, const EventContext &ctx) const
run the extrapolation - only available in full athena
Definition: MuonExtrapolationTool.cxx:110
Trk::alongMomentum
@ alongMomentum
Definition: PropDirection.h:20
Phi
@ Phi
Definition: RPCdef.h:8
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
DerivationFramework::MuonExtrapolationTool::m_endcapPivotPlaneMinimumRadius
Gaudi::Property< double > m_endcapPivotPlaneMinimumRadius
Definition: MuonExtrapolationTool.h:50
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
DerivationFramework::MuonExtrapolationTool::m_barrelPivotPlaneRadius
Gaudi::Property< double > m_barrelPivotPlaneRadius
Definition: MuonExtrapolationTool.h:52
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:209
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
SG::Decorator
Helper class to provide type-safe access to aux data.
Definition: Decorator.h:59
DerivationFramework::MuonExtrapolationTool::m_barrelPivotPlaneHalfLength
Gaudi::Property< double > m_barrelPivotPlaneHalfLength
Definition: MuonExtrapolationTool.h:53
beamspotman.n
n
Definition: beamspotman.py:727
Trk::CylinderSurface
Definition: CylinderSurface.h:55
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:37
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Trk::ParametersBase
Definition: ParametersBase.h:55
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
jobOptions.pTag
string pTag
Definition: jobOptions.py:28
Trk::muon
@ muon
Definition: ParticleHypothesis.h:31
DerivationFramework::MuonExtrapolationTool::getPreferredTrackParticle
const xAOD::TrackParticle * getPreferredTrackParticle(const xAOD::IParticle *probe) const
Definition: MuonExtrapolationTool.cxx:65
DerivationFramework::MuonExtrapolationTool::m_endcapPivotPlaneMaximumRadius
Gaudi::Property< double > m_endcapPivotPlaneMaximumRadius
Definition: MuonExtrapolationTool.h:51
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
DerivationFramework::MuonExtrapolationTool::m_muonContainerName
SG::ReadHandleKey< xAOD::MuonContainer > m_muonContainerName
Definition: MuonExtrapolationTool.h:44
python.testIfMatch.matrix
matrix
Definition: testIfMatch.py:63
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
xAOD::Muon_v1::primaryTrackParticle
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:401
xAOD::track
@ track
Definition: TrackingPrimitives.h:513
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:44
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:79
Eta
@ Eta
Definition: RPCdef.h:8
DerivationFramework::MuonExtrapolationTool::m_endcapPivotPlaneZ
Gaudi::Property< double > m_endcapPivotPlaneZ
Definition: MuonExtrapolationTool.h:49
DerivationFramework::MuonExtrapolationTool::extrapolateAndDecorateTrackParticle
bool extrapolateAndDecorateTrackParticle(const xAOD::TrackParticle *particle, float &eta, float &phi, const EventContext &ctx) const
Definition: MuonExtrapolationTool.cxx:36