ATLAS Offline Software
Loading...
Searching...
No Matches
MuTagMatchingTool Class Reference

#include <MuTagMatchingTool.h>

Inheritance diagram for MuTagMatchingTool:
Collaboration diagram for MuTagMatchingTool:

Public Member Functions

 MuTagMatchingTool (const std::string &t, const std::string &n, const IInterface *p)
virtual ~MuTagMatchingTool ()=default
virtual StatusCode initialize () override
bool match (const Trk::TrackParameters &atSurface, const Muon::MuonSegment &segment, int surfaceName) const override
bool surfaceMatch (const Muon::MuonSegment &segment, int surfaceName) const override
bool phiMatch (const Trk::TrackParameters &atSurface, const Muon::MuonSegment &segment) const override
bool thetaMatch (const Trk::TrackParameters &atSurface, const Muon::MuonSegment &segment) const override
bool rMatch (const Trk::TrackParameters &atSurface, const Muon::MuonSegment &segment) const override
std::unique_ptr< Trk::TrackParametersExtrapolateTrktoMSEntrance (const EventContext &ctx, const Trk::Track &pTrack, Trk::PropDirection direction) const override
 Get extrapolation at MS entrance level.
std::unique_ptr< Trk::TrackParametersExtrapolateTrktoMSSurface (const EventContext &ctx, const Trk::Surface &surface, const Trk::TrackParameters &pTrack, Trk::PropDirection direction) const override
 Get extrapolation at MSSurface level.
std::shared_ptr< Trk::AtaPlaneExtrapolateTrktoSegmentSurface (const EventContext &ctx, const Muon::MuonSegment &segment, const Trk::TrackParameters &pTrack, Trk::PropDirection direction) const override
 Get extrapolation at Segment Plane Surface level.
bool matchSegmentPosition (const MuonCombined::MuonSegmentInfo &info, bool idHasEtaHits) const override
bool matchSegmentDirection (const MuonCombined::MuonSegmentInfo &info, bool idHasEtaHits) const override
bool matchPtDependentPull (const MuonCombined::MuonSegmentInfo &info, const Trk::Track &trk) const override
bool matchDistance (const MuonCombined::MuonSegmentInfo &info) const override
bool matchCombinedPull (const MuonCombined::MuonSegmentInfo &info) const override
MuonCombined::MuonSegmentInfo muTagSegmentInfo (const EventContext &ctx, const Trk::Track *track, const Muon::MuonSegment &segment, std::shared_ptr< const Trk::AtaPlane > exTrack) const override

Private Member Functions

void testExtrapolation (const Trk::Surface &pSurface, const Trk::Track &pTrack) const
bool isCscSegment (const Muon::MuonSegment &seg) const
unsigned int cscHits (const Muon::MuonSegment &seg) const
void nrTriggerHits (const Muon::MuonSegment &seg, int &nRPC, int &nTGC) const
bool hasPhi (const Muon::MuonSegment &seg) const
double errorProtection (double exTrk_Err, bool isAngle) const
std::unique_ptr< Trk::PerigeeflipDirection (const Trk::Perigee &inputPars) const
double matchingDistanceCorrection (double resPos, double resAngle)
void calculateLocalAngleErrors (const Trk::AtaPlane &expPars, double &exTrkErrXZ, double &exTrkErrYZ, double &covLocYYZ) const
void calculateLocalAngleErrors (const Muon::MuonSegment &segment, double &exTrkErrXZ, double &exTrkErrYZ) const
const Trk::TrackingVolumegetVolume (const EventContext &ctx, const std::string &&vol_name) const

Private Attributes

ToolHandle< Trk::IExtrapolatorm_IExtrapolator
 Pointer on IExtrapolator.
ToolHandle< Trk::IPropagatorm_propagator
 Pointer on propagator for SL propagation.
PublicToolHandle< Muon::MuonEDMPrinterToolm_printer {this,"Printer", ""}
ToolHandle< Muon::IMuonSegmentHitSummaryToolm_hitSummaryTool
ToolHandle< Muon::IMuonSegmentSelectionToolm_selectionTool
ToolHandle< Trk::IResidualPullCalculatorm_pullCalculator
ServiceHandle< Muon::IMuonIdHelperSvcm_idHelperSvc
ServiceHandle< Muon::IMuonEDMHelperSvcm_edmHelperSvc
std::string m_t0Location
StoreGateSvcp_StoreGateSvc {}
 Pointer On StoreGateSvc.
SG::ReadCondHandleKey< MuonGM::MuonDetectorManagerm_DetectorManagerKey
SG::ReadCondHandleKey< Trk::TrackingGeometrym_trackingGeometryReadKey
bool m_assumeLocalErrors
bool m_extrapolatePerigee
double m_GLOBAL_THETA_CUT
double m_GLOBAL_PHI_CUT
double m_GLOBAL_R_CUT
double m_MATCH_THETA
double m_MATCH_PHI
double m_MATCH_THETAANGLE
double m_MATCH_PHIANGLE
double m_ERROR_EX_POS_CUT
double m_ERROR_EX_ANGLE_CUT
bool m_doDistCut
double m_DIST_POS
double m_DIST_ANGLE
double m_SAFE_THETA
double m_SAFE_PHI
double m_SAFE_THETAANGLE
double m_SAFE_PHIANGLE
double m_chamberPullCut
double m_combinedPullCut

Detailed Description

Definition at line 38 of file MuTagMatchingTool.h.

Constructor & Destructor Documentation

◆ MuTagMatchingTool()

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

Definition at line 30 of file MuTagMatchingTool.cxx.

30 : base_class(t, n, p) {
31
32 declareProperty("GlobalThetaCut", m_GLOBAL_THETA_CUT = 0.1);
33 declareProperty("GlobalPhiCut", m_GLOBAL_PHI_CUT = 0.5);
34 declareProperty("GlobalRCut", m_GLOBAL_R_CUT = 1000.);
35
36 declareProperty("ThetaCut", m_MATCH_THETA = 5.); // pull cut in local precision position (bending plane)
37 declareProperty("PhiCut", m_MATCH_PHI = 30.); // pull cut in local NON precision position
38 declareProperty("ThetaAngleCut", m_MATCH_THETAANGLE = 5.); // pull cut in local precision direction
39 declareProperty("PhiAngleCut", m_MATCH_PHIANGLE = 30.); // pull cut in local NON precision direction
40
41 declareProperty("ErrorProtectionPosCut", m_ERROR_EX_POS_CUT = 5000.);
42 declareProperty("ErrorProtectionDirCut", m_ERROR_EX_ANGLE_CUT = 0.35);
43
44 declareProperty("DoDistanceCut", m_doDistCut = true);
45 declareProperty("PositionDistance", m_DIST_POS = 2000.);
46 declareProperty("AngleDistance", m_DIST_ANGLE = 0.7);
47
48 declareProperty("ThetaSafety",
49 m_SAFE_THETA = 25.); // additional uncertainty on precision plane position (bendig plane)
50 declareProperty("PhiSafety", m_SAFE_PHI = 100.); // additional uncertainty on NON precision plane position
51 declareProperty("ThetaAngleSafety",
52 m_SAFE_THETAANGLE = 0.0015); // additional uncertainty on precision plane direction
53 declareProperty("PhiAngleSafety",
54 m_SAFE_PHIANGLE = 0.25); // additional uncertainty on NON precision plane direction
55
56 declareProperty("ChamberPullCut",
57 m_chamberPullCut = 5.); // Inside chamber pull is negative for outside chamber pull > 5 standard
58 // deviations (from edge) in non precision plane
59 declareProperty("CombinedPullCut",
60 m_combinedPullCut = 5.); // Combined pull build from local precision position and angle including the correlation
61
62 declareProperty("AssumeLocalErrors", m_assumeLocalErrors = true);
63 declareProperty("ExtrapolatePerigee", m_extrapolatePerigee = false);
64 declareProperty("MuonChamberT0s", m_t0Location = "MooreMuonChamberT0s");
65}

◆ ~MuTagMatchingTool()

virtual MuTagMatchingTool::~MuTagMatchingTool ( )
virtualdefault

Member Function Documentation

◆ calculateLocalAngleErrors() [1/2]

void MuTagMatchingTool::calculateLocalAngleErrors ( const Muon::MuonSegment & segment,
double & exTrkErrXZ,
double & exTrkErrYZ ) const
private

Definition at line 781 of file MuTagMatchingTool.cxx.

781 {
782 const Amg::MatrixX& segGlobCov = segment.localCovariance();
783 angleXZerror = 999.;
784 angleYZerror = 999.;
785 //
786 // the segment errors are stored in local angles (m_assumeLocalErrors = true);
787 //
788
790 if (segGlobCov(Trk::phi, Trk::phi) >= 0 && segGlobCov(Trk::phi, Trk::phi) <= 999.0)
791 angleXZerror = std::sqrt(segGlobCov(Trk::phi, Trk::phi));
792 if (segGlobCov(Trk::theta, Trk::theta) >= 0 && segGlobCov(Trk::theta, Trk::theta) <= 999.0)
793 angleYZerror = std::sqrt(segGlobCov(Trk::theta, Trk::theta));
794 }
795}
const Amg::MatrixX & localCovariance() const
Interface method to get the localError.
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
@ theta
Definition ParamDefs.h:66
@ phi
Definition ParamDefs.h:75

◆ calculateLocalAngleErrors() [2/2]

void MuTagMatchingTool::calculateLocalAngleErrors ( const Trk::AtaPlane & expPars,
double & exTrkErrXZ,
double & exTrkErrYZ,
double & covLocYYZ ) const
private

Definition at line 797 of file MuTagMatchingTool.cxx.

798 {
799
800 if (!exTrack.covariance()) return;
801 // Parameters are described as Trk::LocX, Trk::locY, Trk::phi, Trk::theta
802 // So the errormatrix of the track 'localErrorMatrix' still holds global angle representation!!!!
803 // retrieve Jabcobian to transform the global errors err_phi,err_theta to local errors err_alphaXZ, err_alphaYZ
804 const Amg::RotationMatrix3D glob2loc = exTrack.associatedSurface().transform().rotation().inverse();
805 const AmgVector(5)& exTrkParms = exTrack.parameters();
806 Trk::JacobianPhiThetaLocalAngles jacobianExTrk(exTrkParms[Trk::phi], exTrkParms[Trk::theta], glob2loc);
807
808 // start with global angles error matrix
809 Amg::MatrixX anglesCovGlob(2, 2);
810 anglesCovGlob(0, 0) = (*exTrack.covariance())(Trk::phi, Trk::phi);
811 anglesCovGlob(1, 0) = (*exTrack.covariance())(Trk::theta, Trk::phi);
812 anglesCovGlob(0, 1) = (*exTrack.covariance())(Trk::phi, Trk::theta);
813 anglesCovGlob(1, 1) = (*exTrack.covariance())(Trk::theta, Trk::theta);
814
815 // NEW METHOD
816 const AmgSymMatrix(2)& anglesCovLoc = anglesCovGlob.similarity(jacobianExTrk);
817
818 if (anglesCovLoc(0, 0) >= 0) angleXZerror = std::sqrt(anglesCovLoc(0, 0));
819 if (anglesCovLoc(1, 1) >= 0) angleYZerror = std::sqrt(anglesCovLoc(1, 1));
820
821 covLocYYZ = (*exTrack.covariance())(Trk::locY, Trk::phi) * jacobianExTrk(0, 1) +
822 (*exTrack.covariance())(Trk::locY, Trk::theta) * jacobianExTrk(1, 1);
823 ATH_MSG_DEBUG(" covLocYYZ " << covLocYYZ << " covlocytheta " << (*exTrack.covariance())(Trk::locY, Trk::theta) << " J01 "
824 << jacobianExTrk(0, 1) << " J11 " << jacobianExTrk(0, 1));
825 // some printout
826 ATH_MSG_DEBUG(std::setw(20) << "Angles Jacobian used for TRACK angle errors below: " << jacobianExTrk);
827
828 ATH_MSG_DEBUG(std::setw(20) << "NEW TRACK angleXZ error = " << std::setprecision(6) << std::setw(10) << angleXZerror << std::setw(20)
829 << " and angleYZ error = " << std::setw(10) << angleYZerror);
830}
#define ATH_MSG_DEBUG(x)
#define AmgSymMatrix(dim)
#define AmgVector(rows)
Eigen::Matrix< double, 3, 3 > RotationMatrix3D
@ locY
local cartesian
Definition ParamDefs.h:38

◆ cscHits()

unsigned int MuTagMatchingTool::cscHits ( const Muon::MuonSegment & seg) const
private

Definition at line 864 of file MuTagMatchingTool.cxx.

864 {
865 unsigned int nrHits{0};
866 for (const Trk::MeasurementBase* seg_meas : seg.containedMeasurements()) {
867 const Trk::RIO_OnTrack* rot = dynamic_cast<const Trk::RIO_OnTrack*>(seg_meas);
868 if (!rot) {
869 const Trk::CompetingRIOsOnTrack* crot = dynamic_cast<const Trk::CompetingRIOsOnTrack*>(seg_meas);
870 if (crot) rot = &crot->rioOnTrack(0);
871 }
872 if (!rot) { continue; }
873 if (m_idHelperSvc->isCsc(rot->identify())) ++nrHits;
874 }
875
876 return nrHits;
877}
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
virtual const RIO_OnTrack & rioOnTrack(unsigned int) const =0
returns the RIO_OnTrack (also known as ROT) objects depending on the integer.
Identifier identify() const
return the identifier -extends MeasurementBase
const std::vector< const Trk::MeasurementBase * > & containedMeasurements() const
returns the vector of Trk::MeasurementBase objects

◆ errorProtection()

double MuTagMatchingTool::errorProtection ( double exTrk_Err,
bool isAngle ) const
private

Definition at line 291 of file MuTagMatchingTool.cxx.

291 {
292 double newError = exTrk_Err;
293 if (!isAngle && (exTrk_Err > m_ERROR_EX_POS_CUT)) newError = m_ERROR_EX_POS_CUT;
294 if (isAngle && (exTrk_Err > m_ERROR_EX_ANGLE_CUT)) newError = m_ERROR_EX_ANGLE_CUT;
295
296 return newError;
297}

◆ ExtrapolateTrktoMSEntrance()

std::unique_ptr< Trk::TrackParameters > MuTagMatchingTool::ExtrapolateTrktoMSEntrance ( const EventContext & ctx,
const Trk::Track & pTrack,
Trk::PropDirection direction ) const
override

Get extrapolation at MS entrance level.

Get extrapolation at MS entrance: this will be the starting point to following extrapolations.

Definition at line 143 of file MuTagMatchingTool.cxx.

144 {
145
146
147 const Trk::TrackingVolume* MSEntranceVolume = getVolume(ctx, "MuonSpectrometerEntrance");
148 if (!MSEntranceVolume) { return nullptr; }
149
150 std::unique_ptr<Trk::TrackParameters> exTrk{
151 m_IExtrapolator->extrapolateToVolume(ctx, *(pTrack.perigeeParameters()), *MSEntranceVolume, direction, Trk::muon)};
152
153 if (!exTrk)
154 ATH_MSG_DEBUG("Track could not be extrapolated to MS entrance...");
155 else
156 ATH_MSG_DEBUG("Track extrapolated to MS entrance Radius " << exTrk->position().perp() << " Z " << exTrk->position().z());
157
158 return exTrk;
159}
ToolHandle< Trk::IExtrapolator > m_IExtrapolator
Pointer on IExtrapolator.
const Trk::TrackingVolume * getVolume(const EventContext &ctx, const std::string &&vol_name) const
const Perigee * perigeeParameters() const
return Perigee.

◆ ExtrapolateTrktoMSSurface()

std::unique_ptr< Trk::TrackParameters > MuTagMatchingTool::ExtrapolateTrktoMSSurface ( const EventContext & ctx,
const Trk::Surface & surface,
const Trk::TrackParameters & pTrack,
Trk::PropDirection direction ) const
override

Get extrapolation at MSSurface level.

Definition at line 162 of file MuTagMatchingTool.cxx.

165 {
166 std::unique_ptr<Trk::TrackParameters> exTrk{m_IExtrapolator->extrapolate(ctx, pTrack, pSurface, direction, false, Trk::muon)};
167 if (!exTrk) {
168 ATH_MSG_DEBUG(" didn't manage to extrapolate TrackParameters to abstract surface Radius " << pSurface.center().perp() << " Z "
169 << pSurface.center().z());
170 }
171 return exTrk;
172}

◆ ExtrapolateTrktoSegmentSurface()

std::shared_ptr< Trk::AtaPlane > MuTagMatchingTool::ExtrapolateTrktoSegmentSurface ( const EventContext & ctx,
const Muon::MuonSegment & segment,
const Trk::TrackParameters & pTrack,
Trk::PropDirection direction ) const
override

Get extrapolation at Segment Plane Surface level.

Definition at line 192 of file MuTagMatchingTool.cxx.

195 {
196
197 unsigned int hits{cscHits(segment)};
198 bool isCsc{hits>0};
199 if (isCsc) {
200 ATH_MSG_DEBUG("CSC segment has " << hits << " hits");
201 if (hits < 5) {
202 ATH_MSG_DEBUG("CSC segment is identified to be 2D. Not extrapolating.");
203 return nullptr;
204 }
205 }
206
207 std::shared_ptr<Trk::TrackParameters> atap{
208 m_IExtrapolator->extrapolate(ctx, pTrack, segment.associatedSurface(), direction, false, Trk::muon)};
209 if (!atap) {
210 ATH_MSG_DEBUG(" didn't manage to extrapolate TrackParameters to segment surface Radius"
211 << segment.associatedSurface().center().perp() << " Z " << segment.associatedSurface().center().z());
212 return nullptr;
213 }
214
215 std::shared_ptr<Trk::AtaPlane> matap = std::dynamic_pointer_cast<Trk::AtaPlane>(atap);
216
217 if (!matap) {
218 ATH_MSG_DEBUG(" didn't manage to extrapolate MeasuredTrackParameters to segment surface atap Radius "
219 << atap->position().perp() << " Z" << atap->position().z());
220 return nullptr;
221 } else {
222 ATH_MSG_DEBUG(" Succesfull extrapolation segment surface matap Radius " << matap->position().perp() << " Z"
223 << matap->position().z());
224 }
225 return matap;
226}
unsigned int cscHits(const Muon::MuonSegment &seg) const
virtual const Trk::PlaneSurface & associatedSurface() const override final
returns the surface for the local to global transformation
const Amg::Vector3D & center() const
Returns the center position of the Surface.

◆ flipDirection()

std::unique_ptr< Trk::Perigee > MuTagMatchingTool::flipDirection ( const Trk::Perigee & inputPars) const
private

Definition at line 174 of file MuTagMatchingTool.cxx.

174 {
175 const AmgVector(5)& pars = inputPars.parameters();
176
177 double flippedPhi = pars[2] + M_PI;
178 if (flippedPhi > M_PI) flippedPhi -= 2 * M_PI;
179 double flippedTheta = M_PI - pars[3];
180 if (flippedTheta < 0.) flippedTheta += M_PI;
181 if (inputPars.covariance()) {
182 AmgSymMatrix(5) covMat = AmgSymMatrix(5)(*inputPars.covariance());
183 const Trk::PerigeeSurface perSurf;
184 return std::make_unique<Trk::Perigee>(-pars[0], pars[1], flippedPhi, flippedTheta, pars[4], perSurf, covMat);
185 } else {
186 ATH_MSG_DEBUG("flipDirection: no covariance associated to input parameters " << inputPars);
187 return nullptr;
188 }
189}
#define M_PI

◆ getVolume()

const Trk::TrackingVolume * MuTagMatchingTool::getVolume ( const EventContext & ctx,
const std::string && vol_name ) const
inlineprivate

Definition at line 192 of file MuTagMatchingTool.h.

192 {
193 SG::ReadCondHandle<Trk::TrackingGeometry> handle(m_trackingGeometryReadKey, ctx);
194 if (!handle.isValid()) {
195 ATH_MSG_WARNING("Could not retrieve a valid tracking geometry");
196 return nullptr;
197 }
198 return handle.cptr()->trackingVolume(vol_name);
199 }
#define ATH_MSG_WARNING(x)
SG::ReadCondHandleKey< Trk::TrackingGeometry > m_trackingGeometryReadKey

◆ hasPhi()

bool MuTagMatchingTool::hasPhi ( const Muon::MuonSegment & seg) const
private

Definition at line 258 of file MuTagMatchingTool.cxx.

258 {
259 Muon::IMuonSegmentHitSummaryTool::HitCounts hitCounts = m_hitSummaryTool->getHitCounts(seg);
260 return hitCounts.nexpectedTrigHitLayers > 1;
261}
ToolHandle< Muon::IMuonSegmentHitSummaryTool > m_hitSummaryTool

◆ initialize()

StatusCode MuTagMatchingTool::initialize ( )
overridevirtual

Definition at line 67 of file MuTagMatchingTool.cxx.

67 {
68 ATH_MSG_DEBUG("================================");
69 ATH_MSG_DEBUG("=Proprieties are ");
70 ATH_MSG_DEBUG("GlobalThetaCut" << std::setw(10) << m_GLOBAL_THETA_CUT);
71 ATH_MSG_DEBUG("GlobaPhiCut" << std::setw(10) << m_GLOBAL_PHI_CUT);
72 ATH_MSG_DEBUG("GlobalRCut" << std::setw(10) << m_GLOBAL_R_CUT);
73 ATH_MSG_DEBUG("ThetaCut" << std::setw(10) << m_MATCH_THETA);
74 ATH_MSG_DEBUG("PhiCut" << std::setw(10) << m_MATCH_PHI);
75 ATH_MSG_DEBUG("ThetaAngleCut" << std::setw(10) << m_MATCH_THETAANGLE);
76 ATH_MSG_DEBUG("PhiAngleCut" << std::setw(10) << m_MATCH_PHIANGLE);
77 ATH_MSG_DEBUG("DoDistanceCut" << std::setw(10) << m_doDistCut);
78 ATH_MSG_DEBUG("ThetaDistance" << std::setw(10) << m_DIST_POS);
79 ATH_MSG_DEBUG("ThetaAngleDistance" << std::setw(10) << m_DIST_ANGLE);
80 ATH_MSG_DEBUG("ThetaSafety" << std::setw(10) << m_SAFE_THETA);
81 ATH_MSG_DEBUG("PhiSafety" << std::setw(10) << m_SAFE_PHI);
82 ATH_MSG_DEBUG("ThetaAngleSafety" << std::setw(10) << m_SAFE_THETAANGLE);
83 ATH_MSG_DEBUG("PhiAngleSafety" << std::setw(10) << m_SAFE_PHIANGLE);
84
85 ATH_MSG_DEBUG("AssumeLocalErrors " << std::setw(10) << m_assumeLocalErrors);
86 ATH_MSG_DEBUG("ExtrapolatePerigee " << std::setw(10) << m_extrapolatePerigee);
87 ATH_MSG_DEBUG("================================");
88
89 // Retrieve m_IExtrapolator
90 ATH_CHECK(m_IExtrapolator.retrieve());
91 ATH_MSG_DEBUG("Retrieved tool " << m_IExtrapolator);
92
93 ATH_CHECK(m_propagator.retrieve());
94
95 ATH_CHECK(m_hitSummaryTool.retrieve());
96 ATH_CHECK(m_selectionTool.retrieve());
97
98 // MuonDetectorManager from the conditions store
99 ATH_CHECK(m_DetectorManagerKey.initialize());
100
101 ATH_CHECK(m_idHelperSvc.retrieve());
102 ATH_CHECK(m_edmHelperSvc.retrieve());
103 ATH_CHECK(m_printer.retrieve());
104 ATH_CHECK(m_pullCalculator.retrieve());
105
106 if (!m_trackingGeometryReadKey.empty()) {
108 } else {
109 ATH_MSG_ERROR("Could not retrieve a valid tracking geometry");
110 }
111
112 return StatusCode::SUCCESS;
113}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
PublicToolHandle< Muon::MuonEDMPrinterTool > m_printer
ToolHandle< Trk::IPropagator > m_propagator
Pointer on propagator for SL propagation.
ServiceHandle< Muon::IMuonEDMHelperSvc > m_edmHelperSvc
ToolHandle< Trk::IResidualPullCalculator > m_pullCalculator
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_DetectorManagerKey
ToolHandle< Muon::IMuonSegmentSelectionTool > m_selectionTool

◆ isCscSegment()

bool MuTagMatchingTool::isCscSegment ( const Muon::MuonSegment & seg) const
private

Definition at line 850 of file MuTagMatchingTool.cxx.

850 {
851 for (const Trk::MeasurementBase* seg_meas : seg.containedMeasurements()) {
852 const Trk::RIO_OnTrack* rot = dynamic_cast<const Trk::RIO_OnTrack*>(seg_meas);
853 if (!rot) {
854 const Trk::CompetingRIOsOnTrack* crot = dynamic_cast<const Trk::CompetingRIOsOnTrack*>(seg_meas);
855 if (crot) rot = &crot->rioOnTrack(0);
856 }
857 if (!rot) { continue; }
858 if (m_idHelperSvc->isCsc(rot->identify())) return true;
859 }
860
861 return false;
862}

◆ match()

bool MuTagMatchingTool::match ( const Trk::TrackParameters & atSurface,
const Muon::MuonSegment & segment,
int surfaceName ) const
override

We need a barrel function here

Definition at line 115 of file MuTagMatchingTool.cxx.

116 {
118 // performs a rough match to an abstract MS surface (disc or cylinder)
119 // by matching on station name (I M O, S L, B E) and a crude phi-position
120 // match, followed by either a match in theta-position or r-position
122 if (!surfaceMatch(segment, surfaceName)) return false;
123
124 if (!phiMatch(atSurface, segment)) return false;
125
126 const Identifier id = m_edmHelperSvc->chamberId(segment);
127
129 if (m_idHelperSvc->regionIndex(id) == DetectorRegionIndex::Barrel)
130 return thetaMatch(atSurface, segment);
131 else
132 return rMatch(atSurface, segment);
133}
bool rMatch(const Trk::TrackParameters &atSurface, const Muon::MuonSegment &segment) const override
bool surfaceMatch(const Muon::MuonSegment &segment, int surfaceName) const override
bool phiMatch(const Trk::TrackParameters &atSurface, const Muon::MuonSegment &segment) const override
bool thetaMatch(const Trk::TrackParameters &atSurface, const Muon::MuonSegment &segment) const override

◆ matchCombinedPull()

bool MuTagMatchingTool::matchCombinedPull ( const MuonCombined::MuonSegmentInfo & info) const
override

Definition at line 326 of file MuTagMatchingTool.cxx.

326 {
327 bool pass(true);
328 if (!info.segment || !info.trackAtSegment) {
329 ATH_MSG_DEBUG(" No segment and or trackAtSegment pointer matchCombinedPull ");
330 return false;
331 }
332 if (info.pullChamber > m_chamberPullCut) pass = false;
333 if (std::abs(info.pullCY) > m_combinedPullCut) pass = false;
334
335 ATH_MSG_DEBUG(" matchCombinedPull MuTagSegmentInfo hasPhi "
336 << info.hasPhi << " minimumPullPhi " << info.minimumPullPhi << " pullChamber " << info.pullChamber << " cut "
337 << m_chamberPullCut << " pullCY " << info.pullCY << " cut m_combinedPullCut " << m_combinedPullCut << " pass " << pass);
338
339 return pass;
340}

◆ matchDistance()

bool MuTagMatchingTool::matchDistance ( const MuonCombined::MuonSegmentInfo & info) const
override

Definition at line 831 of file MuTagMatchingTool.cxx.

831 {
832 bool pass(true);
833 if (!info.segment || !info.trackAtSegment) {
834 ATH_MSG_DEBUG(" No segment and or trackAtSegment pointer matchDistance ");
835 return false;
836 }
837 if (!m_doDistCut) return pass;
838
839 if (info.hasPhi) {
840 if (std::abs(info.resX) > m_DIST_POS) pass = false;
841 if (std::abs(info.dangleXZ) > m_DIST_ANGLE) pass = false;
842 }
843 if (info.maximumResidualAlongTube > m_DIST_POS) pass = false;
844 if (std::abs(info.resY) > m_DIST_POS) pass = false;
845 if (std::abs(info.dangleYZ) > m_DIST_ANGLE) pass = false;
846
847 return pass;
848}

◆ matchingDistanceCorrection()

double MuTagMatchingTool::matchingDistanceCorrection ( double resPos,
double resAngle )
private

◆ matchPtDependentPull()

bool MuTagMatchingTool::matchPtDependentPull ( const MuonCombined::MuonSegmentInfo & info,
const Trk::Track & trk ) const
override

Definition at line 342 of file MuTagMatchingTool.cxx.

342 {
343 bool pass(true);
344 if (!info.segment || !info.trackAtSegment) {
345 ATH_MSG_DEBUG(" No segment and or trackAtSegment pointermatchPtDependentPull ");
346 return false;
347 }
348 double pT(100.);
349 const Trk::Perigee* aMeasPer = trk.perigeeParameters();
350 if (aMeasPer) {
351 pT = aMeasPer->pT();
352 }
353 double Pullcut = 2.0;
354
355 if (pT > 2.) { Pullcut = 5.0 - 6.0 / pT; }
356 if (Pullcut > m_combinedPullCut) Pullcut = m_combinedPullCut;
357
358 if (std::abs(info.pullCY) > Pullcut) pass = false;
359
360 return pass;
361}
double pT() const
Access method for transverse momentum.
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee

◆ matchSegmentDirection()

bool MuTagMatchingTool::matchSegmentDirection ( const MuonCombined::MuonSegmentInfo & info,
bool idHasEtaHits ) const
override

Definition at line 315 of file MuTagMatchingTool.cxx.

315 {
316 if (!info.segment || !info.trackAtSegment) {
317 ATH_MSG_DEBUG(" No segment and or trackAtSegment pointer matchSegmentDirection ");
318 return false;
319 }
320 if (idHasEtaHits) {
321 return std::abs(info.pullYZ) < m_MATCH_THETAANGLE || std::abs(info.pullCY) < m_combinedPullCut;
322 }
323 return true;
324}

◆ matchSegmentPosition()

bool MuTagMatchingTool::matchSegmentPosition ( const MuonCombined::MuonSegmentInfo & info,
bool idHasEtaHits ) const
override

Definition at line 299 of file MuTagMatchingTool.cxx.

299 {
300 if (!info.segment || !info.trackAtSegment) {
301 ATH_MSG_DEBUG(" No segment and or trackAtSegment pointer matchSegmentPosition ");
302 return false;
303 }
304
305 bool pass(false);
306
307 if (idHasEtaHits) {
308 if (std::abs(info.pullY) < m_MATCH_THETA || std::abs(info.pullCY) < m_combinedPullCut) pass = true;
309 } else {
310 if (std::abs(info.pullX) < m_MATCH_PHI) pass = true;
311 }
312
313 return pass;
314}

◆ muTagSegmentInfo()

MuonCombined::MuonSegmentInfo MuTagMatchingTool::muTagSegmentInfo ( const EventContext & ctx,
const Trk::Track * track,
const Muon::MuonSegment & segment,
std::shared_ptr< const Trk::AtaPlane > exTrack ) const
override

The cut off variable is used to avoid FPEs risen where one of the matrix enties exceeds a large number and hence the determinant becomes tremendously larger

What do these magic numbers represent?

Definition at line 467 of file MuTagMatchingTool.cxx.

468 {
469 MuonCombined::MuonSegmentInfo info;
470
471 // segment and track pointers
472
473 info.track = track;
474 info.segment = &segment;
475 info.trackAtSegment = exTrack;
476
477 Muon::IMuonSegmentHitSummaryTool::HitCounts hitCounts = m_hitSummaryTool->getHitCounts(segment);
478
479 // quality
480
481 info.quality = m_selectionTool->quality(segment);
482
483 // Global angular differences
484
485 info.dtheta = exTrack->momentum().theta() - segment.globalDirection().theta();
486 info.dphi = exTrack->momentum().deltaPhi(segment.globalDirection());
487
488 // Global angular differences for position
489
490 info.dthetaPos = exTrack->position().theta() - segment.globalPosition().theta();
491 info.dphiPos = exTrack->position().deltaPhi (segment.globalPosition());
492
493 // Local positions
494
495 info.resY = exTrack->parameters()[Trk::locY] - segment.localParameters()[Trk::locY]; // delta_theta
496 info.resX = exTrack->parameters()[Trk::locX] - segment.localParameters()[Trk::locX]; // delta_phi
497
498 // Local errors and covariance Matrix
499
500 info.exCovYTheta = 0.;
501 if (exTrack->covariance()) {
502 ATH_MSG_DEBUG("Measured Parameters: error x " << (*exTrack->covariance())(Trk::locX, Trk::locX) << " y "
503 << (*exTrack->covariance())(Trk::locY, Trk::locY) << " pull x "
504 << info.resX / std::sqrt((*exTrack->covariance())(Trk::locX, Trk::locX)) << " pull y "
505 << info.resY / std::sqrt((*exTrack->covariance())(Trk::locY, Trk::locY)));
506 info.exErrorX = std::sqrt((*exTrack->covariance())(Trk::locX, Trk::locX));
507 info.exErrorY = std::sqrt((*exTrack->covariance())(Trk::locY, Trk::locY));
508 if ((*exTrack->covariance())(Trk::theta, Trk::locY) != 0) { info.exCovYTheta = (*exTrack->covariance())(Trk::theta, Trk::locY); }
509 } else {
510 info.exErrorX = -999.;
511 info.exErrorY = -999.;
512 }
513
514 // Segment local errors
515 info.segErrorX = std::sqrt((segment.localCovariance())(Trk::locX, Trk::locX));
516 info.segErrorY = std::sqrt((segment.localCovariance())(Trk::locY, Trk::locY));
517
518 // Pull local X and Y
519 double erexX = errorProtection(info.exErrorX, false);
520 double erexY = errorProtection(info.exErrorY, false);
521 info.pullX = info.resX / std::hypot(erexX, info.segErrorX, m_SAFE_PHI);
522 info.pullY = info.resY / std::hypot(erexY, info.segErrorY, m_SAFE_THETA);
523
524 // Local angles
525
526 Trk::LocalDirection segLocDir = segment.localDirection();
527 Trk::LocalDirection exTrkLocDir;
528 exTrack->associatedSurface().globalToLocalDirection(exTrack->momentum(), exTrkLocDir);
529 info.dangleYZ = exTrkLocDir.angleYZ() - segLocDir.angleYZ(); // deltaYZ
530 info.dangleXZ = exTrkLocDir.angleXZ() - segLocDir.angleXZ(); // deltaXZ
531 // delete exTrkLocDir;
532
533 // Errors on local angles
534 double exTrkErrXZ(0.), exTrkErrYZ(0.), segErrXZ(0.), segErrYZ(0.), covLocYYZ(0.);
535
536 calculateLocalAngleErrors(*exTrack, exTrkErrXZ, exTrkErrYZ, covLocYYZ);
537 info.exErrorXZ = exTrkErrXZ;
538 info.exErrorYZ = exTrkErrYZ;
539 info.exCovYZY = covLocYYZ;
540 calculateLocalAngleErrors(segment, segErrXZ, segErrYZ);
541 info.segErrorXZ = segErrXZ;
542 info.segErrorYZ = segErrYZ;
543 double erexXZ = errorProtection(info.exErrorXZ, true);
544 double erexYZ = errorProtection(info.exErrorYZ, true);
545
546 ATH_MSG_DEBUG(" exTrkLocDir.angleYZ() " << exTrkLocDir.angleYZ() << " segLocDir.angleYZ() " << segLocDir.angleYZ());
547 ATH_MSG_DEBUG(" exTrkLocDir.angleXZ() " << exTrkLocDir.angleXZ() << " segLocDir.angleXZ() " << segLocDir.angleXZ());
548
549 ATH_MSG_DEBUG(" info.exErrorYZ " << info.exErrorYZ << " info.segErrorYZ " << info.segErrorYZ << " info.exCovYZY " << info.exCovYZY);
550 ATH_MSG_DEBUG(" info.exErrorXZ " << info.exErrorXZ << " info.segErrorXZ " << info.segErrorXZ);
551
552 info.pullXZ = info.dangleXZ / std::hypot(erexXZ, info.segErrorXZ, m_SAFE_PHIANGLE);
553 info.pullYZ = info.dangleYZ / std::hypot(erexYZ, info.segErrorYZ, m_SAFE_THETAANGLE);
554
555 ATH_MSG_DEBUG(" info.pullXZ " << info.pullXZ);
556
557 Identifier chId = m_edmHelperSvc->chamberId(segment);
558 StIndex stIndex = m_idHelperSvc->stationIndex(chId);
559 //
560 // residuals and pulls in X coordinate (along tube)
561 //
562
563 // MuonDetectorManager from the conditions store
564 SG::ReadCondHandle<MuonGM::MuonDetectorManager> DetectorManagerHandle{m_DetectorManagerKey, ctx};
565 const MuonGM::MuonDetectorManager* MuonDetMgr = DetectorManagerHandle.cptr();
566 if (!MuonDetMgr) {
567 ATH_MSG_ERROR("Null pointer to the read MuonDetectorManager conditions object");
568 return info;
569 }
570 double maxResXMdt{-1e9}, maxResPhi{-1e9}, maxPullPhi{-1e9}, minResPhi{1e9}, minPullPhi{1e9};
571 // loop over hits
572 for (const Trk::MeasurementBase* seg_it : segment.containedMeasurements()) {
573 const Muon::MdtDriftCircleOnTrack* mdt = dynamic_cast<const Muon::MdtDriftCircleOnTrack*>(seg_it);
574 if (mdt) {
575 // get id and check that it is a muon hit id
576 Identifier id = mdt->identify();
577
578 // get layer index
579 int lay = m_idHelperSvc->mdtIdHelper().tubeLayer(id);
580 int tube = m_idHelperSvc->mdtIdHelper().tube(id);
581
582 const MuonGM::MdtReadoutElement* detEl =
583 mdt->prepRawData() ? mdt->prepRawData()->detectorElement() : MuonDetMgr->getMdtReadoutElement(id);
584 if (!detEl) {
585 ATH_MSG_WARNING(" could not get MdtReadoutElement for tube " << m_idHelperSvc->toString(id));
586 continue;
587 }
588 double tubeLen = detEl->getActiveTubeLength(lay, tube);
589
590 // use SL within station to speed up extrapolation
591 // lifetime only in this scope
592 std::unique_ptr<Trk::TrackParameters> exP = m_propagator->propagate(ctx, *exTrack, mdt->associatedSurface(), Trk::anyDirection, false, Trk::NoField);
593 if (!exP) {
594 ATH_MSG_WARNING("Failed to extrapolate to " << m_idHelperSvc->toString(id));
595 continue;
596 }
597 ATH_MSG_DEBUG(m_idHelperSvc->toString(id)
598 << " exPos " << exP->parameters()[Trk::locR] << " y " << exP->parameters()[Trk::locZ] << " tubeL " << tubeLen);
599 double exResidual = std::abs(exP->parameters()[Trk::locZ]) - 0.5 * tubeLen;
600 if (maxResXMdt < exResidual) maxResXMdt = exResidual;
601 if (exResidual > 0.) ATH_MSG_DEBUG("Extrapolated position outside tube, " << exResidual);
602 } else {
603 // get id and check that it is a muon hit id
604 Identifier id = m_edmHelperSvc->getIdentifier(*seg_it);
605 if (!id.is_valid() || !m_idHelperSvc->isMuon(id)) continue;
606 if (!m_idHelperSvc->measuresPhi(id)) continue;
607 // lifetime only in this scope
608 std::unique_ptr<Trk::TrackParameters> exP{
609 m_propagator->propagate(ctx, *exTrack, seg_it->associatedSurface(), Trk::anyDirection, false, Trk::NoField)};
610 if (!exP) {
611 ATH_MSG_WARNING("Failed to extrapolate to " << m_idHelperSvc->toString(id));
612 continue;
613 }
614 std::optional<Trk::ResidualPull> resPull{
615 m_pullCalculator->residualPull(seg_it, exP.get(), Trk::ResidualPull::Unbiased)};
616 if (!resPull) {
617 ATH_MSG_WARNING(" calculation of residual/pull failed !!!!! ");
618 // delete exP;
619 continue;
620 }
621 const double residual = resPull->residual().front();
622 const double pull = resPull->pull().front();
623
624 maxResPhi = std::max(residual, maxResPhi);
625 minResPhi = std::min(residual, minResPhi);
626 maxPullPhi = std::max(pull, maxPullPhi);
627 minPullPhi = std::min(pull, minPullPhi);
628
629 ATH_MSG_DEBUG(m_idHelperSvc->toString(id) << " residual " << residual << " pull " << pull);
630 }
631 }
632 ATH_MSG_DEBUG("Residual phi min " << minResPhi << " max " << maxResPhi << " pull min " << minPullPhi << " max " << maxPullPhi
633 << " dist from tube end " << maxResXMdt);
634
635 //
636 // Store the local X variables
637 //
638 info.maximumResidualAlongTube = maxResXMdt;
639 info.maximumResidualPhi = maxResPhi;
640 info.maximumPullPhi = maxPullPhi;
641
642 info.minimumResidualPhi = minResPhi;
643 info.minimumPullPhi = minPullPhi;
644
645 info.pullChamber = maxResXMdt / info.exErrorX;
646
647 // Scale covariance Matrix (if needed)
651 constexpr double matrix_cutoff = 1.e20;
652 double a = std::pow(std::min(matrix_cutoff, info.exErrorY), 2);
653 double b = std::abs(info.exCovYZY) < matrix_cutoff ? info.exCovYZY : (info.exCovYZY < 0 ? -1. : 1) * matrix_cutoff;
654 double d = std::pow(std::min(matrix_cutoff, info.exErrorYZ), 2);
655 double det = a * d - b * b;
656
657 double scale = 1.;
658 if (det < 0.1 * a * d) {
659 scale = std::sqrt(0.9 * a * d) / std::abs(b);
660 det = a * d - scale * b * scale * b;
661 }
662 if (det ==0.) {
663 ATH_MSG_DEBUG("Found singular determinant");
664 return info;
665 }
666 double dydyz = scale * info.exCovYZY;
667 double correction = dydyz / std::max(info.exErrorYZ * info.exErrorYZ, DBL_EPSILON);
668
669 //
670 // residual after taking into account the correlation with the angle YZ
671 //
672
673 info.resCY = info.resY - correction * info.dangleYZ;
674
675 ATH_MSG_DEBUG(" segment direction theta " << segment.globalDirection().theta() << " position theta "
676 << segment.globalPosition().theta() << " correction " << correction);
677 ATH_MSG_DEBUG(" resY " << info.resY << " dangleYZ " << info.dangleYZ << " resCY " << info.resCY);
678 double error_rescy = info.exErrorY * info.exErrorY - correction * correction * info.exErrorYZ * info.exErrorYZ;
679 double error_segcy = info.segErrorY * info.segErrorY + correction * correction * info.segErrorYZ * info.segErrorYZ;
680 if (error_rescy > 0) {
681 error_rescy = std::sqrt(error_rescy + error_segcy);
682 } else {
683 error_rescy = std::sqrt(info.exErrorY * info.exErrorY + error_segcy);
684 }
685
686 // pull after taking into account the correlation with the angle YZ
687
688 info.pullCY = info.resCY / std::hypot(error_rescy, m_SAFE_THETA, correction * m_SAFE_THETAANGLE);
689
690 // chi2 with full covariance matrix in Y and YZ plane
691
692 double chi2Y = d * info.resY * info.resY - 2 * b * scale * info.resY * info.dangleYZ + a * info.dangleYZ * info.dangleYZ;
693 info.chi2Y = 0.5*( chi2Y / det);
694 if (info.chi2Y < 0) ATH_MSG_DEBUG(" NEGATIVE chi2Y " << chi2Y << " dydyz " << dydyz << " determinant " << det);
695
696 bool hasPhi = hitCounts.nexpectedTrigHitLayers > 1;
697
698 //
699 // Store hasphi
700 //
701 info.hasPhi = hasPhi;
702 info.t0 = 0.;
703
704 // station layer
705 info.stationLayer = 0;
706 switch (stIndex) {
707 case StIndex::BI:
708 info.stationLayer = 1;
709 break;
710 case StIndex::BM:
711 info.stationLayer = 2;
712 break;
713 case StIndex::BO:
714 info.stationLayer = 3;
715 break;
716 case StIndex::BE:
717 info.stationLayer = 4;
718 break;
719 case StIndex::EI:
720 info.stationLayer = m_idHelperSvc->isMdt(chId) ? 11 : 21;
721 break;
722 case StIndex::EM:
723 info.stationLayer = 12;
724 break;
725 case StIndex::EO:
726 info.stationLayer = 13;
727 break;
728 case StIndex::EE:
729 info.stationLayer = 14;
730 break;
731 case StIndex::StUnknown:
732 case StIndex::StIndexMax:
733 ATH_MSG_WARNING(__func__<<"(): "<<__LINE__<<"Invalid station index passed");
734 break;
735 }
736
737 ATH_MSG_DEBUG("stationLayer " << info.stationLayer);
738 // number of holes
739 info.nholes = 0;
740 const Muon::MuonSegmentQuality* q = dynamic_cast<const Muon::MuonSegmentQuality*>(segment.fitQuality());
741 if (q) info.nholes = q->numberOfHoles();
742
743 // number of segments
744 info.nsegments = 1;
745
746 // single ML
747 info.singleML = 1;
748 if (hitCounts.nmdtHitsMl1 > 0 && hitCounts.nmdtHitsMl2 > 0) info.singleML = 0;
749
750 // RLocY parametrized rejection as a function of locY
751 // RAYZ parametrized rejection as a function of Angle YZ
752
753 // parameters are used for selecting best segment in ambiguity solver
754
756 constexpr double a_locY{13.8269}, b_locY{1.23548}, c_locY{2.73400}, a_AYZ{12.0655}, b_AYZ{1.87578}, c_AYZ{1.88660}, width_locY{20.},
757 width_AYZ{0.004};
758
759 double dlocY = info.resY;
760 double dAYZ = info.dangleYZ;
761
762 double logLocY = std::log(1 + std::abs(dlocY / width_locY));
763 double logAYZ = std::log(1 + std::abs(dAYZ / width_AYZ));
764
765 info.RLocY = a_locY / (1. + b_locY * (logLocY) * (logLocY) + c_locY * (logLocY) * (logLocY) * (logLocY));
766 info.RAYZ = a_AYZ / (1. + b_AYZ * (logAYZ) * (logAYZ) + c_AYZ * (logAYZ) * (logAYZ) * (logAYZ));
767
768 int selected = 0;
769 scale = 1.;
770
771 if (std::abs(info.pullY) < m_MATCH_THETA && std::abs(info.pullYZ) < m_MATCH_THETAANGLE &&
772 std::abs(info.pullCY) < scale * m_combinedPullCut && info.pullChamber < m_chamberPullCut) {
773 bool pass = true;
774 if (pass) selected = 1;
775 }
776
777 info.selected = selected;
778
779 return info;
780}
static Double_t a
void calculateLocalAngleErrors(const Trk::AtaPlane &expPars, double &exTrkErrXZ, double &exTrkErrYZ, double &covLocYYZ) const
bool hasPhi(const Muon::MuonSegment &seg) const
double errorProtection(double exTrk_Err, bool isAngle) const
double getActiveTubeLength(const int tubeLayer, const int tube) const
const MdtReadoutElement * getMdtReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
virtual const Trk::StraightLineSurface & associatedSurface() const override final
Returns the surface on which this measurement was taken.
virtual const MdtPrepData * prepRawData() const override final
Returns the PrepRawData used to create this corrected measurement.
virtual const MuonGM::MdtReadoutElement * detectorElement() const override
Returns the detector element corresponding to this PRD.
virtual const Amg::Vector3D & globalPosition() const override final
global position
const_pointer_type cptr()
double angleXZ() const
access method for angle of local XZ projection
double angleYZ() const
access method for angle of local YZ projection
const LocalParameters & localParameters() const
Interface method to get the LocalParameters.
@ Unbiased
RP with track state that has measurement not included.
const FitQuality * fitQuality() const
return the FitQuality object, returns NULL if no FitQuality is defined
StIndex
enum to classify the different station layers in the muon spectrometer
@ anyDirection
@ NoField
Field is set to 0., 0., 0.,.
@ locX
Definition ParamDefs.h:37
@ locR
Definition ParamDefs.h:44
@ locZ
local cylindrical
Definition ParamDefs.h:42
correction(mu, runmode, campaign, run=None)
Definition zlumi_mc_cf.py:4

◆ nrTriggerHits()

void MuTagMatchingTool::nrTriggerHits ( const Muon::MuonSegment & seg,
int & nRPC,
int & nTGC ) const
private

Definition at line 452 of file MuTagMatchingTool.cxx.

452 {
453 nRPC = 0;
454 nTGC = 0;
455 for (const Trk::MeasurementBase* seg_meas : seg.containedMeasurements()) {
456 const Trk::RIO_OnTrack* rot = dynamic_cast<const Trk::RIO_OnTrack*>(seg_meas);
457 if (!rot) {
458 const Trk::CompetingRIOsOnTrack* crot = dynamic_cast<const Trk::CompetingRIOsOnTrack*>(seg_meas);
459 if (crot) rot = &crot->rioOnTrack(0);
460 }
461 if (!rot) { continue; }
462 if (m_idHelperSvc->isRpc(rot->identify())) ++nRPC;
463 if (m_idHelperSvc->isTgc(rot->identify())) ++nTGC;
464 }
465}

◆ phiMatch()

bool MuTagMatchingTool::phiMatch ( const Trk::TrackParameters & atSurface,
const Muon::MuonSegment & segment ) const
override

Definition at line 228 of file MuTagMatchingTool.cxx.

228 {
229 double PHI_CUT = m_GLOBAL_PHI_CUT;
230 if (hasPhi(segment)) PHI_CUT = m_GLOBAL_PHI_CUT / 2.;
231
232 const Amg::Vector3D exTrkPos = atSurface.position();
233 const Amg::Vector3D& segPos = segment.globalPosition();
234
235 const double deltaPhi = exTrkPos.deltaPhi(segPos);
236
237 double sigma_phi = 0.;
239 const AmgSymMatrix(5)& covAtCyl = *atSurface.covariance();
240 double r = atSurface.associatedSurface().bounds().r();
241 if ( r > 0 && covAtCyl(Trk::locRPhi, Trk::locRPhi) >= 0.) sigma_phi = Amg::error(covAtCyl, Trk::locRPhi) / r;
242 } else if (atSurface.associatedSurface().type() == Trk::SurfaceType::Plane) {
243 const AmgSymMatrix(5)& covAtPlane = *atSurface.covariance();
244 sigma_phi = Amg::error(covAtPlane, Trk::phi0);
245 } else if (atSurface.associatedSurface().type() == Trk::SurfaceType::Disc) { // error in endcap
246 const AmgSymMatrix(5)& covAtDisc = *atSurface.covariance();
247 if (covAtDisc(Trk::locPhi, Trk::locPhi) >= 0.) sigma_phi = Amg::error(covAtDisc, Trk::locPhi);
248 }
249 double errPhi = std::hypot(PHI_CUT, sigma_phi);
250 // if the difference between exTrk and Segment phi position falls within the errPhi, accept as rough match
251 if (std::abs(deltaPhi) < errPhi)
252 return true; // BRes: TEMPORARY - segment direction not sure, so I'm making this match symmetric wrt Pi/2
253 ATH_MSG_DEBUG(std::setw(30) << "roughPhi failed: d_phi = " << std::setw(10) << std::abs(deltaPhi) // BRes: TEMPORARY - same
254 << " while the cut is set on " << std::setw(10) << errPhi);
255 return false;
256}
Scalar deltaPhi(const MatrixBase< Derived > &vec) const
const Amg::Vector3D & position() const
Access method for the position.
virtual const Surface & associatedSurface() const override=0
Access to the Surface associated to the Parameters.
virtual double r() const =0
Interface method for the maximal extension or the radius.
virtual constexpr SurfaceType type() const =0
Returns the Surface type to avoid dynamic casts.
virtual const SurfaceBounds & bounds() const =0
Surface Bounds method.
int r
Definition globals.cxx:22
double error(const Amg::MatrixX &mat, int index)
return diagonal error of the matrix caller should ensure the matrix is symmetric and the index is in ...
Eigen::Matrix< double, 3, 1 > Vector3D
@ locRPhi
Definition ParamDefs.h:40
@ phi0
Definition ParamDefs.h:65
@ locPhi
local polar
Definition ParamDefs.h:45

◆ rMatch()

bool MuTagMatchingTool::rMatch ( const Trk::TrackParameters & atSurface,
const Muon::MuonSegment & segment ) const
override

Definition at line 276 of file MuTagMatchingTool.cxx.

276 {
277 const Amg::Vector3D exTrkPos = atSurface.position();
278 double L = exTrkPos.mag();
279 double R_CUT = m_GLOBAL_R_CUT * (L / 7500.); // mm
280
281 const Amg::Vector3D& segPos = segment.globalPosition();
282 const double dPerp = std::abs(exTrkPos.perp() - segPos.perp());
283 if (dPerp < R_CUT)
284 return true;
285
286 ATH_MSG_DEBUG(std::setw(30) << "rough R failed: d_R = " << std::setw(10) << dPerp << " while the cut is set on "
287 << std::setw(10) << R_CUT);
288 return false;
289}

◆ surfaceMatch()

bool MuTagMatchingTool::surfaceMatch ( const Muon::MuonSegment & segment,
int surfaceName ) const
override

Definition at line 137 of file MuTagMatchingTool.cxx.

137 {
138 const Identifier id = m_edmHelperSvc->chamberId(segment);
139 return surfaceName == MuonCombined::MuonSegmentTagSurfaces::stIdxToSurfDef(m_idHelperSvc->stationIndex(id), m_idHelperSvc->stationEta(id)>0);
140}
static int stIdxToSurfDef(Muon::MuonStationIndex::StIndex st_idx, bool pos_eta)
Transforms the Muon Station index to a SurfDef index.

◆ testExtrapolation()

void MuTagMatchingTool::testExtrapolation ( const Trk::Surface & pSurface,
const Trk::Track & pTrack ) const
private

Definition at line 363 of file MuTagMatchingTool.cxx.

363 {
364 const Trk::Perigee* oriPerigee = pTrack.perigeeParameters();
365 if (!oriPerigee) {
366 ATH_MSG_DEBUG("Couldn't get the measured Perigee from TP");
367 return;
368 }
369 const EventContext& ctx = Gaudi::Hive::currentContext();
370 const AmgVector(5)& oripars = oriPerigee->parameters();
371 const Trk::PerigeeSurface periSurf;
372 std::unique_ptr<Trk::Perigee> pPerigee = std::make_unique<Trk::Perigee>(oripars[0], oripars[1], oripars[2], oripars[3], 0., periSurf, std::nullopt);
373 const Amg::Vector3D startPos = pPerigee->position();
374 const Amg::Vector3D startMom = pPerigee->momentum();
375 const AmgVector(5)& pars = pPerigee->parameters();
376
377 ATH_MSG_DEBUG("==============================================================================");
378 ATH_MSG_DEBUG("======= INITIAL TRACK PARAMETERS (PERIGEE)");
379 ATH_MSG_DEBUG("=== parameters are " << pars[0] << " " << pars[1] << " " << pars[2] << " " << pars[3] << " " << pars[4]);
380 ATH_MSG_DEBUG("=== global position " << startPos.x() << " " << startPos.y() << " " << startPos.z());
381 ATH_MSG_DEBUG("=== global directn " << startMom.phi() << " " << startMom.theta());
382
383 std::unique_ptr<Trk::TrackParameters> alongPars{
384 m_IExtrapolator->extrapolate(ctx, *pPerigee, pSurface, Trk::alongMomentum, false, Trk::muon)};
385
386 ATH_MSG_DEBUG("======= EXTRAPOLATED ALONG MOMENTUM ORIGINAL PERIGEE");
387 if (alongPars) {
388 const Amg::Vector3D alongPos = alongPars->position();
389 const Amg::Vector3D alongMom = alongPars->momentum();
390
391 ATH_MSG_DEBUG("=== global position " << alongPos.x() << " " << alongPos.y() << " " << alongPos.z());
392 ATH_MSG_DEBUG("=== global position phi theta " << alongPos.phi() << " " << alongPos.theta());
393 ATH_MSG_DEBUG("=== global directn " << alongMom.phi() << " " << alongMom.theta());
394 } else
395 ATH_MSG_DEBUG("======= NOT EXTRAPOLATED");
396
397 ATH_MSG_DEBUG("======= EXTRAPOLATED OPPOSITE MOMENTUM ORIGINAL PERIGEE");
398 std::unique_ptr<const Trk::TrackParameters> oppositePars{
399 m_IExtrapolator->extrapolate(ctx, *pPerigee, pSurface, Trk::oppositeMomentum, false, Trk::muon)};
400 if (oppositePars) {
401 const Amg::Vector3D oppositePos = oppositePars->position();
402 const Amg::Vector3D oppositeMom = oppositePars->momentum();
403 ATH_MSG_DEBUG("=== global position " << oppositePos.x() << " " << oppositePos.y() << " " << oppositePos.z());
404 ATH_MSG_DEBUG("=== global position phi theta " << oppositePos.phi() << " " << oppositePos.theta());
405 ATH_MSG_DEBUG("=== global directn " << oppositeMom.phi() << " " << oppositeMom.theta());
406 } else
407 ATH_MSG_DEBUG("======= NOT EXTRAPOLATED");
408
409 ;
410 std::unique_ptr<const Trk::Perigee> flippedPerigee = flipDirection(*pPerigee);
411 const AmgVector(5)& flipPars = flippedPerigee->parameters();
412 const Amg::Vector3D flipPos = flippedPerigee->position();
413 const Amg::Vector3D flipMom = flippedPerigee->momentum();
414
415 ATH_MSG_DEBUG("======= FLIPPED TRACK PARAMETERS (PERIGEE)");
416 ATH_MSG_DEBUG("=== phi and theta were " << pars[2] << " " << pars[3] << " and are flipped to ");
417 ATH_MSG_DEBUG("=== parameters are " << flipPars[0] << " " << flipPars[1] << " " << flipPars[2] << " " << flipPars[3] << " "
418 << flipPars[4]);
419 ATH_MSG_DEBUG("=== global position " << flipPos.x() << " " << flipPos.y() << " " << flipPos.z());
420 ATH_MSG_DEBUG("=== global directn " << flipMom.phi() << " " << flipMom.theta());
421
422 std::unique_ptr<const Trk::TrackParameters> alongFlipPars{
423 m_IExtrapolator->extrapolate(ctx,*flippedPerigee, pSurface, Trk::alongMomentum, false, Trk::muon)};
424
425 ATH_MSG_DEBUG("======= EXTRAPOLATED ALONGFLIP MOMENTUM ORIGINAL PERIGEE");
426 if (alongFlipPars) {
427 const Amg::Vector3D alongFlipPos = alongFlipPars->position();
428 const Amg::Vector3D alongFlipMom = alongFlipPars->momentum();
429 ATH_MSG_DEBUG("=== global position " << alongFlipPos.x() << " " << alongFlipPos.y() << " " << alongFlipPos.z());
430 ATH_MSG_DEBUG("=== global position phi theta " << alongFlipPos.phi() << " " << alongFlipPos.theta());
431 ATH_MSG_DEBUG("=== global directn " << alongFlipMom.phi() << " " << alongFlipMom.theta());
432 } else
433 ATH_MSG_DEBUG("======= NOT EXTRAPOLATED");
434
435 ATH_MSG_DEBUG("======= EXTRAPOLATED OPPOSITEFLIP MOMENTUM ORIGINAL PERIGEE");
436 std::unique_ptr<const Trk::TrackParameters> oppositeFlipPars{
437 m_IExtrapolator->extrapolate(ctx, *flippedPerigee, pSurface, Trk::oppositeMomentum, false, Trk::muon)};
438 if (oppositeFlipPars) {
439 const Amg::Vector3D oppositeFlipPos = oppositeFlipPars->position();
440 const Amg::Vector3D oppositeFlipMom = oppositeFlipPars->momentum();
441 ATH_MSG_DEBUG("=== global position " << oppositeFlipPos.x() << " " << oppositeFlipPos.y() << " " << oppositeFlipPos.z());
442 ATH_MSG_DEBUG("=== global position phi theta " << oppositeFlipPos.phi() << " " << oppositeFlipPos.theta());
443 ATH_MSG_DEBUG("=== global directn " << oppositeFlipMom.phi() << " " << oppositeFlipMom.theta());
444 } else
445 ATH_MSG_DEBUG("======= NOT EXTRAPOLATED");
446
447 ATH_MSG_DEBUG("==============================================================================");
448
449}
std::unique_ptr< Trk::Perigee > flipDirection(const Trk::Perigee &inputPars) const
@ oppositeMomentum
@ alongMomentum

◆ thetaMatch()

bool MuTagMatchingTool::thetaMatch ( const Trk::TrackParameters & atSurface,
const Muon::MuonSegment & segment ) const
override

Definition at line 263 of file MuTagMatchingTool.cxx.

263 {
264 double THETA_CUT = m_GLOBAL_THETA_CUT;
265 const Amg::Vector3D exTrkPos = atSurface.position();
266 const Amg::Vector3D& segPos = segment.globalPosition();
267 const double dTheta = std::abs(exTrkPos.theta() - segPos.theta());
268 if (dTheta < THETA_CUT)
269 return true;
270
271 ATH_MSG_DEBUG(std::setw(30) << "roughTheta failed: d_theta = " << std::setw(10) << dTheta << " while the cut is set on "
272 << std::setw(10) << THETA_CUT);
273 return false;
274}

Member Data Documentation

◆ m_assumeLocalErrors

bool MuTagMatchingTool::m_assumeLocalErrors
private

Definition at line 165 of file MuTagMatchingTool.h.

◆ m_chamberPullCut

double MuTagMatchingTool::m_chamberPullCut
private

Definition at line 189 of file MuTagMatchingTool.h.

◆ m_combinedPullCut

double MuTagMatchingTool::m_combinedPullCut
private

Definition at line 190 of file MuTagMatchingTool.h.

◆ m_DetectorManagerKey

SG::ReadCondHandleKey<MuonGM::MuonDetectorManager> MuTagMatchingTool::m_DetectorManagerKey
private
Initial value:
{
this,
"DetectorManagerKey",
"MuonDetectorManager",
"Key of input MuonDetectorManager condition data",
}

Definition at line 155 of file MuTagMatchingTool.h.

155 {
156 this,
157 "DetectorManagerKey",
158 "MuonDetectorManager",
159 "Key of input MuonDetectorManager condition data",
160 };

◆ m_DIST_ANGLE

double MuTagMatchingTool::m_DIST_ANGLE
private

Definition at line 182 of file MuTagMatchingTool.h.

◆ m_DIST_POS

double MuTagMatchingTool::m_DIST_POS
private

Definition at line 181 of file MuTagMatchingTool.h.

◆ m_doDistCut

bool MuTagMatchingTool::m_doDistCut
private

Definition at line 180 of file MuTagMatchingTool.h.

◆ m_edmHelperSvc

ServiceHandle<Muon::IMuonEDMHelperSvc> MuTagMatchingTool::m_edmHelperSvc
private
Initial value:
{
this,
"edmHelper",
"Muon::MuonEDMHelperSvc/MuonEDMHelperSvc",
"Handle to the service providing the IMuonEDMHelperSvc interface",
}

Definition at line 144 of file MuTagMatchingTool.h.

144 {
145 this,
146 "edmHelper",
147 "Muon::MuonEDMHelperSvc/MuonEDMHelperSvc",
148 "Handle to the service providing the IMuonEDMHelperSvc interface",
149 };

◆ m_ERROR_EX_ANGLE_CUT

double MuTagMatchingTool::m_ERROR_EX_ANGLE_CUT
private

Definition at line 178 of file MuTagMatchingTool.h.

◆ m_ERROR_EX_POS_CUT

double MuTagMatchingTool::m_ERROR_EX_POS_CUT
private

Definition at line 177 of file MuTagMatchingTool.h.

◆ m_extrapolatePerigee

bool MuTagMatchingTool::m_extrapolatePerigee
private

Definition at line 166 of file MuTagMatchingTool.h.

◆ m_GLOBAL_PHI_CUT

double MuTagMatchingTool::m_GLOBAL_PHI_CUT
private

Definition at line 169 of file MuTagMatchingTool.h.

◆ m_GLOBAL_R_CUT

double MuTagMatchingTool::m_GLOBAL_R_CUT
private

Definition at line 170 of file MuTagMatchingTool.h.

◆ m_GLOBAL_THETA_CUT

double MuTagMatchingTool::m_GLOBAL_THETA_CUT
private

Definition at line 168 of file MuTagMatchingTool.h.

◆ m_hitSummaryTool

ToolHandle<Muon::IMuonSegmentHitSummaryTool> MuTagMatchingTool::m_hitSummaryTool
private
Initial value:
{
this,
"MuonSegmentHitSummary",
"Muon::MuonSegmentHitSummaryTool/MuonSegmentHitSummaryTool",
}

Definition at line 123 of file MuTagMatchingTool.h.

123 {
124 this,
125 "MuonSegmentHitSummary",
126 "Muon::MuonSegmentHitSummaryTool/MuonSegmentHitSummaryTool",
127 };

◆ m_idHelperSvc

ServiceHandle<Muon::IMuonIdHelperSvc> MuTagMatchingTool::m_idHelperSvc
private
Initial value:
{
this,
"MuonIdHelperSvc",
"Muon::MuonIdHelperSvc/MuonIdHelperSvc",
}

Definition at line 139 of file MuTagMatchingTool.h.

139 {
140 this,
141 "MuonIdHelperSvc",
142 "Muon::MuonIdHelperSvc/MuonIdHelperSvc",
143 };

◆ m_IExtrapolator

ToolHandle<Trk::IExtrapolator> MuTagMatchingTool::m_IExtrapolator
private
Initial value:
{
this,
"IExtrapolator",
"Trk::Extrapolator/AtlasExtrapolator",
}

Pointer on IExtrapolator.

Definition at line 112 of file MuTagMatchingTool.h.

112 {
113 this,
114 "IExtrapolator",
115 "Trk::Extrapolator/AtlasExtrapolator",
116 };

◆ m_MATCH_PHI

double MuTagMatchingTool::m_MATCH_PHI
private

Definition at line 173 of file MuTagMatchingTool.h.

◆ m_MATCH_PHIANGLE

double MuTagMatchingTool::m_MATCH_PHIANGLE
private

Definition at line 175 of file MuTagMatchingTool.h.

◆ m_MATCH_THETA

double MuTagMatchingTool::m_MATCH_THETA
private

Definition at line 172 of file MuTagMatchingTool.h.

◆ m_MATCH_THETAANGLE

double MuTagMatchingTool::m_MATCH_THETAANGLE
private

Definition at line 174 of file MuTagMatchingTool.h.

◆ m_printer

PublicToolHandle<Muon::MuonEDMPrinterTool> MuTagMatchingTool::m_printer {this,"Printer", ""}
private

Definition at line 122 of file MuTagMatchingTool.h.

122{this,"Printer", ""};

◆ m_propagator

ToolHandle<Trk::IPropagator> MuTagMatchingTool::m_propagator
private
Initial value:
{
this,
"Propagator",
"Trk::RungeKuttaPropagator/AtlasRungeKuttaPropagator",
}

Pointer on propagator for SL propagation.

Definition at line 117 of file MuTagMatchingTool.h.

117 {
118 this,
119 "Propagator",
120 "Trk::RungeKuttaPropagator/AtlasRungeKuttaPropagator",
121 };

◆ m_pullCalculator

ToolHandle<Trk::IResidualPullCalculator> MuTagMatchingTool::m_pullCalculator
private
Initial value:
{
this,
"ResidualPullCalculator",
"Trk::ResidualPullCalculator/ResidualPullCalculator",
}

Definition at line 133 of file MuTagMatchingTool.h.

133 {
134 this,
135 "ResidualPullCalculator",
136 "Trk::ResidualPullCalculator/ResidualPullCalculator",
137 };

◆ m_SAFE_PHI

double MuTagMatchingTool::m_SAFE_PHI
private

Definition at line 185 of file MuTagMatchingTool.h.

◆ m_SAFE_PHIANGLE

double MuTagMatchingTool::m_SAFE_PHIANGLE
private

Definition at line 187 of file MuTagMatchingTool.h.

◆ m_SAFE_THETA

double MuTagMatchingTool::m_SAFE_THETA
private

Definition at line 184 of file MuTagMatchingTool.h.

◆ m_SAFE_THETAANGLE

double MuTagMatchingTool::m_SAFE_THETAANGLE
private

Definition at line 186 of file MuTagMatchingTool.h.

◆ m_selectionTool

ToolHandle<Muon::IMuonSegmentSelectionTool> MuTagMatchingTool::m_selectionTool
private
Initial value:
{
this,
"MuonSegmentSelection",
"Muon::MuonSegmentSelectionTool/MuonSegmentSelectionTool",
}

Definition at line 128 of file MuTagMatchingTool.h.

128 {
129 this,
130 "MuonSegmentSelection",
131 "Muon::MuonSegmentSelectionTool/MuonSegmentSelectionTool",
132 };

◆ m_t0Location

std::string MuTagMatchingTool::m_t0Location
private

Definition at line 151 of file MuTagMatchingTool.h.

◆ m_trackingGeometryReadKey

SG::ReadCondHandleKey<Trk::TrackingGeometry> MuTagMatchingTool::m_trackingGeometryReadKey
private
Initial value:
{this, "TrackingGeometryReadKey", "",
"Key of input TrackingGeometry"}

Definition at line 162 of file MuTagMatchingTool.h.

162 {this, "TrackingGeometryReadKey", "",
163 "Key of input TrackingGeometry"};

◆ p_StoreGateSvc

StoreGateSvc* MuTagMatchingTool::p_StoreGateSvc {}
private

Pointer On StoreGateSvc.

Definition at line 152 of file MuTagMatchingTool.h.

152{};

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