ATLAS Offline Software
Loading...
Searching...
No Matches
Rec::MuidTrackIsolation Class Reference

#include <MuidTrackIsolation.h>

Inheritance diagram for Rec::MuidTrackIsolation:
Collaboration diagram for Rec::MuidTrackIsolation:

Public Member Functions

virtual ~MuidTrackIsolation ()=default
StatusCode initialize () override
std::pair< int, double > trackIsolation (const EventContext &ctx, double eta, double phi) const override
 IMuidTrackIsolation interface: get the number of tracks and summed momentum in a cone at the production vertex or around the muon calo intersect.

Private Member Functions

std::pair< int, double > trackVertex (const xAOD::TrackParticleContainer *indetTracks, double eta, double phi) const
std::pair< int, double > trackExtrapolated (const xAOD::TrackParticleContainer *indetTracks, double eta, double phi) const

Private Attributes

double m_barrelCotTheta {}
std::unique_ptr< const Trk::Surfacem_caloBackwardDisc
std::unique_ptr< const Trk::Surfacem_caloCylinder
std::unique_ptr< const Trk::Surfacem_caloForwardDisc
double m_etaSafetyFactor {0.1}
SG::ReadHandleKey< xAOD::TrackParticleContainerm_inDetTracksLocation {this, "InDetTracksLocation", "InDetTrackParticles", "ID tracks"}
SG::ReadDecorHandleKey< xAOD::TrackParticleContainerm_trackLinkKey {this, "TrackLinkKey", m_inDetTracksLocation, "trackLink"}
ToolHandle< Trk::IIntersectorm_intersector {this, "RungeKuttaIntersector", "Trk::RungeKuttaIntersector/RungeKuttaIntersector"}
Gaudi::Property< double > m_minPt {this, "MinPt", 1.0 * Gaudi::Units::GeV}
Gaudi::Property< double > m_trackCone {this, "TrackCone", 0.2}
double m_trackCone2 {0.}
Gaudi::Property< bool > m_trackExtrapolation {this, "TrackExtrapolation", false}

Detailed Description

Definition at line 34 of file MuidTrackIsolation.h.

Constructor & Destructor Documentation

◆ ~MuidTrackIsolation()

virtual Rec::MuidTrackIsolation::~MuidTrackIsolation ( )
virtualdefault

Member Function Documentation

◆ initialize()

StatusCode MuidTrackIsolation::initialize ( )
override

Definition at line 28 of file MuidTrackIsolation.cxx.

28 {
29 ATH_MSG_INFO("MuidTrackIsolation::initialize()");
30
31 // get the Tools
32 ATH_CHECK(m_intersector.retrieve());
34 // create the calo barrel surfaces (cylinder) and 2 endcap discs)
35 double radius = 2.0 * Gaudi::Units::meter;
36 double halfLength = 4.0 * Gaudi::Units::meter;
37 Amg::Transform3D transform{Amg::Transform3D::Identity()};
38 m_caloCylinder = std::make_unique<Trk::CylinderSurface>(transform, radius, halfLength);
39
40 // the corresponding max barrel cotTheta
41 m_barrelCotTheta = halfLength / radius;
42
43 // and the forward/backward endcap disks
44 Amg::Transform3D discRotation{Amg::Transform3D::Identity()};
45 Amg::Vector3D forwardDiscPosition(0., 0., halfLength);
46 auto transform1 = std::make_unique<Amg::Transform3D>(discRotation * forwardDiscPosition);
47 m_caloForwardDisc = std::make_unique<Trk::DiscSurface>(*transform1, 0., radius);
48 Amg::Vector3D backwardDiscPosition(0., 0., -halfLength);
49 auto transform2 = std::make_unique<Amg::Transform3D>(discRotation * backwardDiscPosition);
50 m_caloBackwardDisc = std::make_unique<Trk::DiscSurface>(*transform2, 0., radius);
51
52 ATH_CHECK(m_inDetTracksLocation.initialize());
53 ATH_CHECK(m_trackLinkKey.initialize());
54 return StatusCode::SUCCESS;
55 }
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
std::unique_ptr< const Trk::Surface > m_caloForwardDisc
std::unique_ptr< const Trk::Surface > m_caloBackwardDisc
Gaudi::Property< double > m_trackCone
ToolHandle< Trk::IIntersector > m_intersector
SG::ReadDecorHandleKey< xAOD::TrackParticleContainer > m_trackLinkKey
std::unique_ptr< const Trk::Surface > m_caloCylinder
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_inDetTracksLocation
Eigen::Affine3d Transform3D
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
Eigen::Matrix< double, 3, 1 > Vector3D

◆ trackExtrapolated()

std::pair< int, double > MuidTrackIsolation::trackExtrapolated ( const xAOD::TrackParticleContainer * indetTracks,
double eta,
double phi ) const
private

Use identiy of cot (x) = tan( pi/2 - x)

Definition at line 121 of file MuidTrackIsolation.cxx.

121 {
122 // set initial state
123 double sumP = 0.;
124 int numberTracks = 0;
125
126 // extrapolate close in eta tracks to calorimeter surface
127 for (const xAOD::TrackParticle* idTrack : *inDetTracks) {
128
129 const Trk::Track* id = idTrack->track();
130 const Trk::Perigee& perigee = *id->perigeeParameters();
131 if (id->info().trackProperties(Trk::TrackInfo::StraightTrack) || perigee.pT() < m_minPt) continue;
132
133 double inDetEta = perigee.eta();
134 if (std::abs(eta - inDetEta) > m_trackCone + m_etaSafetyFactor) continue;
135
136 // track has sufficient momentum and is close in eta:
137 // find intersection at calo surface
138 double qOverP = perigee.parameters()[Trk::qOverP];
140 double cotTheta = std::tan(M_PI_2 - perigee.parameters()[Trk::theta]);
141 Amg::Vector3D direction(std::cos(perigee.parameters()[Trk::phi]), std::sin(perigee.parameters()[Trk::phi]), cotTheta);
142 direction /= direction.mag();
143
144 const Trk::TrackSurfaceIntersection idIntersection(perigee.position(), direction, 0.);
145 const Trk::Surface* surface = m_caloCylinder.get();
146 if (cotTheta > m_barrelCotTheta) {
147 surface = m_caloForwardDisc.get();
148 } else if (cotTheta < -m_barrelCotTheta) {
149 surface = m_caloBackwardDisc.get();
150 }
151 std::optional<Trk::TrackSurfaceIntersection> caloIntersection(
152 m_intersector->intersectSurface(*surface, idIntersection, qOverP));
153
154 // no intersection - should never happen !
155 if (!caloIntersection) {
156 ATH_MSG_DEBUG(" track didn't find intersection !!! "
157 << std::setiosflags(std::ios::fixed) << " Id track: momentum " << std::setw(8) << std::setprecision(1)
158 << perigee.momentum().mag() / Gaudi::Units::GeV << " with initial eta " << std::setw(8)
159 << std::setprecision(3) << perigee.eta() << " and phi " << std::setw(8) << std::setprecision(3)
160 << perigee.parameters()[Trk::phi]);
161
162 continue;
163 }
164
165 double diffEta = eta - caloIntersection->position().eta();
166 double diffPhi = xAOD::P4Helpers::deltaPhi(phi, caloIntersection->position().phi());
167 ATH_MSG_VERBOSE(std::endl
168 << std::setiosflags(std::ios::fixed) << " Id track: momentum " << std::setw(8) << std::setprecision(1)
169 << perigee.momentum().mag() / Gaudi::Units::GeV << " with initial,extrapolated and calo difference for eta "
170 << std::setw(8) << std::setprecision(3) << perigee.eta() << std::setw(8) << std::setprecision(3)
171 << caloIntersection->position().eta() << std::setw(8) << std::setprecision(3) << diffEta << " and phi "
172 << std::setw(8) << std::setprecision(3) << perigee.parameters()[Trk::phi] << std::setw(8)
173 << std::setprecision(3) << caloIntersection->position().phi() << std::setw(8) << std::setprecision(3)
174 << diffPhi);
175
176 // check if inside cone
177 if ((diffPhi * diffPhi + diffEta * diffEta) < m_trackCone2) {
178 ++numberTracks;
179 const double p = perigee.momentum().mag();
180 sumP += p;
181
182 ATH_MSG_VERBOSE(" inside cone, track#" << std::setw(3) << numberTracks);
183 }
184 }
185
186 return std::make_pair(numberTracks, sumP);
187 }
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
Gaudi::Property< double > m_minPt
double eta() const
Access method for pseudorapidity - from momentum.
const Amg::Vector3D & momentum() const
Access method for the momentum.
const Amg::Vector3D & position() const
Access method for the position.
double pT() const
Access method for transverse momentum.
@ qOverP
perigee
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
const Amg::Vector3D & direction() const
Method to retrieve the direction at the Intersection.
@ theta
Definition ParamDefs.h:66
@ qOverP
perigee
Definition ParamDefs.h:67
@ phi
Definition ParamDefs.h:75
TrackSurfaceIntersection()=default
double deltaPhi(double phiA, double phiB)
delta Phi in range [-pi,pi[
TrackParticle_v1 TrackParticle
Reference the current persistent version:

◆ trackIsolation()

std::pair< int, double > MuidTrackIsolation::trackIsolation ( const EventContext & ctx,
double eta,
double phi ) const
override

IMuidTrackIsolation interface: get the number of tracks and summed momentum in a cone at the production vertex or around the muon calo intersect.

Definition at line 56 of file MuidTrackIsolation.cxx.

56 {
57 // debug input quantities
58 ATH_MSG_DEBUG(" MuidTrackIsolation:: " << std::setiosflags(std::ios::fixed)
59 << (m_trackExtrapolation ? "applied after extrapolation to calo, " : "applied at perigee, ")
60 << " for muon at calo with eta,phi " << std::setw(8) << std::setprecision(3) << eta
61 << std::setw(8) << std::setprecision(3) << phi);
62
63 // set initial state
64 std::pair<int, double> isolation{0, 0.};
65
66 // retrieve track collection
67 const xAOD::TrackParticleContainer* inDetTracks{};
68 if (!SG::get(inDetTracks, m_inDetTracksLocation, ctx).isSuccess()) {
69 return std::make_pair(0, 0.);
70 }
71
72 // evaluate isolation according to configuration
74 isolation = trackExtrapolated(inDetTracks, eta, phi);
75 } else {
76 isolation = trackVertex(inDetTracks, eta, phi);
77 }
78
79 // debug result
80 ATH_MSG_DEBUG("Found " << isolation.first << std::setiosflags(std::ios::fixed) << " InDet tracks with total momentum "
81 << std::setw(8) << std::setprecision(1) << isolation.second / Gaudi::Units::GeV << " GeV");
82
83 return isolation;
84 }
Gaudi::Property< bool > m_trackExtrapolation
std::pair< int, double > trackVertex(const xAOD::TrackParticleContainer *indetTracks, double eta, double phi) const
std::pair< int, double > trackExtrapolated(const xAOD::TrackParticleContainer *indetTracks, double eta, double phi) const
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".

◆ trackVertex()

std::pair< int, double > MuidTrackIsolation::trackVertex ( const xAOD::TrackParticleContainer * indetTracks,
double eta,
double phi ) const
private

Definition at line 86 of file MuidTrackIsolation.cxx.

86 {
87 // set initial state
88 double sumP = 0.;
89 int numberTracks = 0;
90
91 // choose tracks in cone
92 for (const xAOD::TrackParticle* idTrack : *inDetTracks) {
93 const Trk::Track* id = idTrack->track();
94 const Trk::Perigee& perigee = *id->perigeeParameters();
95 if (id->info().trackProperties(Trk::TrackInfo::StraightTrack) || perigee.pT() < m_minPt) continue;
96
97 double inDetPhi = perigee.parameters()[Trk::phi];
98 double inDetEta = perigee.eta();
99
100 double diffEta = std::abs(eta - inDetEta);
101 double diffPhi = xAOD::P4Helpers::deltaPhi(phi, inDetPhi);
102
103 ATH_MSG_DEBUG(std::endl
104 << std::setiosflags(std::ios::fixed) << " Id track: momentum " << std::setw(8) << std::setprecision(1)
105 << perigee.momentum().mag() / Gaudi::Units::GeV << " with perigee eta and difference " << std::setw(8)
106 << std::setprecision(3) << perigee.eta() << std::setw(8) << std::setprecision(3) << diffEta
107 << " and same for phi " << std::setw(8) << std::setprecision(3) << perigee.parameters()[Trk::phi] << std::setw(8)
108 << std::setprecision(3) << diffPhi);
109
110 if ((diffPhi * diffPhi + diffEta * diffEta) > m_trackCone2) continue;
111 ++numberTracks;
112 const double p = perigee.momentum().mag();
113 sumP += p;
114
115 ATH_MSG_VERBOSE("inside cone, track#" << std::setw(3) << numberTracks);
116 }
117
118 return std::make_pair(numberTracks, sumP);
119 }

Member Data Documentation

◆ m_barrelCotTheta

double Rec::MuidTrackIsolation::m_barrelCotTheta {}
private

Definition at line 53 of file MuidTrackIsolation.h.

53{};

◆ m_caloBackwardDisc

std::unique_ptr<const Trk::Surface> Rec::MuidTrackIsolation::m_caloBackwardDisc
private

Definition at line 54 of file MuidTrackIsolation.h.

◆ m_caloCylinder

std::unique_ptr<const Trk::Surface> Rec::MuidTrackIsolation::m_caloCylinder
private

Definition at line 55 of file MuidTrackIsolation.h.

◆ m_caloForwardDisc

std::unique_ptr<const Trk::Surface> Rec::MuidTrackIsolation::m_caloForwardDisc
private

Definition at line 56 of file MuidTrackIsolation.h.

◆ m_etaSafetyFactor

double Rec::MuidTrackIsolation::m_etaSafetyFactor {0.1}
private

Definition at line 57 of file MuidTrackIsolation.h.

57{0.1};

◆ m_inDetTracksLocation

SG::ReadHandleKey<xAOD::TrackParticleContainer> Rec::MuidTrackIsolation::m_inDetTracksLocation {this, "InDetTracksLocation", "InDetTrackParticles", "ID tracks"}
private

Definition at line 58 of file MuidTrackIsolation.h.

58{this, "InDetTracksLocation", "InDetTrackParticles", "ID tracks"};

◆ m_intersector

ToolHandle<Trk::IIntersector> Rec::MuidTrackIsolation::m_intersector {this, "RungeKuttaIntersector", "Trk::RungeKuttaIntersector/RungeKuttaIntersector"}
private

Definition at line 62 of file MuidTrackIsolation.h.

62{this, "RungeKuttaIntersector", "Trk::RungeKuttaIntersector/RungeKuttaIntersector"};

◆ m_minPt

Gaudi::Property<double> Rec::MuidTrackIsolation::m_minPt {this, "MinPt", 1.0 * Gaudi::Units::GeV}
private

Definition at line 63 of file MuidTrackIsolation.h.

63{this, "MinPt", 1.0 * Gaudi::Units::GeV};

◆ m_trackCone

Gaudi::Property<double> Rec::MuidTrackIsolation::m_trackCone {this, "TrackCone", 0.2}
private

Definition at line 64 of file MuidTrackIsolation.h.

64{this, "TrackCone", 0.2};

◆ m_trackCone2

double Rec::MuidTrackIsolation::m_trackCone2 {0.}
private

Definition at line 65 of file MuidTrackIsolation.h.

65{0.};

◆ m_trackExtrapolation

Gaudi::Property<bool> Rec::MuidTrackIsolation::m_trackExtrapolation {this, "TrackExtrapolation", false}
private

Definition at line 66 of file MuidTrackIsolation.h.

66{this, "TrackExtrapolation", false};

◆ m_trackLinkKey

SG::ReadDecorHandleKey<xAOD::TrackParticleContainer> Rec::MuidTrackIsolation::m_trackLinkKey {this, "TrackLinkKey", m_inDetTracksLocation, "trackLink"}
private

Definition at line 60 of file MuidTrackIsolation.h.

60{this, "TrackLinkKey", m_inDetTracksLocation, "trackLink"};

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