ATLAS Offline Software
MuTagMatchingTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "MuTagMatchingTool.h"
6 
7 #include <cmath>
8 
10 #include "GaudiKernel/IDataProviderSvc.h"
11 #include "GaudiKernel/SmartDataPtr.h"
25 #include "TrkSurfaces/Surface.h"
26 #include "TrkTrack/Track.h"
27 
28 MuTagMatchingTool::MuTagMatchingTool(const std::string& t, const std::string& n, const IInterface* p) : AthAlgTool(t, n, p) {
29  declareInterface<IMuTagMatchingTool>(this);
30 
31  declareProperty("GlobalThetaCut", m_GLOBAL_THETA_CUT = 0.1);
32  declareProperty("GlobalPhiCut", m_GLOBAL_PHI_CUT = 0.5);
33  declareProperty("GlobalRCut", m_GLOBAL_R_CUT = 1000.);
34 
35  declareProperty("ThetaCut", m_MATCH_THETA = 5.); // pull cut in local precision position (bending plane)
36  declareProperty("PhiCut", m_MATCH_PHI = 30.); // pull cut in local NON precision position
37  declareProperty("ThetaAngleCut", m_MATCH_THETAANGLE = 5.); // pull cut in local precision direction
38  declareProperty("PhiAngleCut", m_MATCH_PHIANGLE = 30.); // pull cut in local NON precision direction
39 
40  declareProperty("ErrorProtectionPosCut", m_ERROR_EX_POS_CUT = 5000.);
41  declareProperty("ErrorProtectionDirCut", m_ERROR_EX_ANGLE_CUT = 0.35);
42 
43  declareProperty("DoDistanceCut", m_doDistCut = true);
44  declareProperty("PositionDistance", m_DIST_POS = 2000.);
45  declareProperty("AngleDistance", m_DIST_ANGLE = 0.7);
46 
47  declareProperty("ThetaSafety",
48  m_SAFE_THETA = 25.); // additional uncertainty on precision plane position (bendig plane)
49  declareProperty("PhiSafety", m_SAFE_PHI = 100.); // additional uncertainty on NON precision plane position
50  declareProperty("ThetaAngleSafety",
51  m_SAFE_THETAANGLE = 0.0015); // additional uncertainty on precision plane direction
52  declareProperty("PhiAngleSafety",
53  m_SAFE_PHIANGLE = 0.25); // additional uncertainty on NON precision plane direction
54 
55  declareProperty("ChamberPullCut",
56  m_chamberPullCut = 5.); // Inside chamber pull is negative for outside chamber pull > 5 standard
57  // deviations (from edge) in non precision plane
58  declareProperty("CombinedPullCut",
59  m_combinedPullCut = 5.); // Combined pull build from local precision position and angle including the correlation
60 
61  declareProperty("AssumeLocalErrors", m_assumeLocalErrors = true);
62  declareProperty("ExtrapolatePerigee", m_extrapolatePerigee = false);
63  declareProperty("MuonChamberT0s", m_t0Location = "MooreMuonChamberT0s");
64 }
65 
67  ATH_MSG_DEBUG("================================");
68  ATH_MSG_DEBUG("=Proprieties are ");
69  ATH_MSG_DEBUG("GlobalThetaCut" << std::setw(10) << m_GLOBAL_THETA_CUT);
70  ATH_MSG_DEBUG("GlobaPhiCut" << std::setw(10) << m_GLOBAL_PHI_CUT);
71  ATH_MSG_DEBUG("GlobalRCut" << std::setw(10) << m_GLOBAL_R_CUT);
72  ATH_MSG_DEBUG("ThetaCut" << std::setw(10) << m_MATCH_THETA);
73  ATH_MSG_DEBUG("PhiCut" << std::setw(10) << m_MATCH_PHI);
74  ATH_MSG_DEBUG("ThetaAngleCut" << std::setw(10) << m_MATCH_THETAANGLE);
75  ATH_MSG_DEBUG("PhiAngleCut" << std::setw(10) << m_MATCH_PHIANGLE);
76  ATH_MSG_DEBUG("DoDistanceCut" << std::setw(10) << m_doDistCut);
77  ATH_MSG_DEBUG("ThetaDistance" << std::setw(10) << m_DIST_POS);
78  ATH_MSG_DEBUG("ThetaAngleDistance" << std::setw(10) << m_DIST_ANGLE);
79  ATH_MSG_DEBUG("ThetaSafety" << std::setw(10) << m_SAFE_THETA);
80  ATH_MSG_DEBUG("PhiSafety" << std::setw(10) << m_SAFE_PHI);
81  ATH_MSG_DEBUG("ThetaAngleSafety" << std::setw(10) << m_SAFE_THETAANGLE);
82  ATH_MSG_DEBUG("PhiAngleSafety" << std::setw(10) << m_SAFE_PHIANGLE);
83 
84  ATH_MSG_DEBUG("AssumeLocalErrors " << std::setw(10) << m_assumeLocalErrors);
85  ATH_MSG_DEBUG("ExtrapolatePerigee " << std::setw(10) << m_extrapolatePerigee);
86  ATH_MSG_DEBUG("================================");
87 
88  // Retrieve m_IExtrapolator
89  ATH_CHECK(m_IExtrapolator.retrieve());
90  ATH_MSG_DEBUG("Retrieved tool " << m_IExtrapolator);
91 
92  ATH_CHECK(m_propagator.retrieve());
93 
94  ATH_CHECK(m_hitSummaryTool.retrieve());
95  ATH_CHECK(m_selectionTool.retrieve());
96 
97  // MuonDetectorManager from the conditions store
99 
100  ATH_CHECK(m_idHelperSvc.retrieve());
101  ATH_CHECK(m_edmHelperSvc.retrieve());
102  ATH_CHECK(m_printer.retrieve());
103  ATH_CHECK(m_pullCalculator.retrieve());
104 
107  } else {
108  ATH_MSG_ERROR("Could not retrieve a valid tracking geometry");
109  }
110 
111  return StatusCode::SUCCESS;
112 }
113 
115  int surfaceName) const {
117  // performs a rough match to an abstract MS surface (disc or cylinder)
118  // by matching on station name (I M O, S L, B E) and a crude phi-position
119  // match, followed by either a match in theta-position or r-position
121  if (!surfaceMatch(segment, surfaceName)) return false;
122 
123  if (!phiMatch(atSurface, segment)) return false;
124 
125  const Identifier id = m_edmHelperSvc->chamberId(segment);
126 
128  if (m_idHelperSvc->regionIndex(id) == Muon::MuonStationIndex::Barrel)
129  return thetaMatch(atSurface, segment);
130  else
131  return rMatch(atSurface, segment);
132 }
133 
134 
135 
136 bool MuTagMatchingTool::surfaceMatch(const Muon::MuonSegment& segment, int surfaceName) const {
137  const Identifier id = m_edmHelperSvc->chamberId(segment);
138  return surfaceName == MuonCombined::MuonSegmentTagSurfaces::stIdxToSurfDef(m_idHelperSvc->stationIndex(id), m_idHelperSvc->stationEta(id)>0);
139 }
140 
142 std::unique_ptr<Trk::TrackParameters> MuTagMatchingTool::ExtrapolateTrktoMSEntrance(const EventContext& ctx, const Trk::Track& pTrack,
143  Trk::PropDirection direction) const {
144 
145 
146  const Trk::TrackingVolume* MSEntranceVolume = getVolume(ctx, "MuonSpectrometerEntrance");
147  if (!MSEntranceVolume) { return nullptr; }
148 
149  std::unique_ptr<Trk::TrackParameters> exTrk{
150  m_IExtrapolator->extrapolateToVolume(ctx, *(pTrack.perigeeParameters()), *MSEntranceVolume, direction, Trk::muon)};
151 
152  if (!exTrk)
153  ATH_MSG_DEBUG("Track could not be extrapolated to MS entrance...");
154  else
155  ATH_MSG_DEBUG("Track extrapolated to MS entrance Radius " << exTrk->position().perp() << " Z " << exTrk->position().z());
156 
157  return exTrk;
158 }
159 
161 std::unique_ptr<Trk::TrackParameters> MuTagMatchingTool::ExtrapolateTrktoMSSurface(const EventContext& ctx,
162  const Trk::Surface& pSurface,
163  const Trk::TrackParameters& pTrack,
164  Trk::PropDirection direction) const {
165  std::unique_ptr<Trk::TrackParameters> exTrk{m_IExtrapolator->extrapolate(ctx, pTrack, pSurface, direction, false, Trk::muon)};
166  if (!exTrk) {
167  ATH_MSG_DEBUG(" didn't manage to extrapolate TrackParameters to abstract surface Radius " << pSurface.center().perp() << " Z "
168  << pSurface.center().z());
169  }
170  return exTrk;
171 }
172 
173 std::unique_ptr<Trk::Perigee> MuTagMatchingTool::flipDirection(const Trk::Perigee& inputPars) const {
174  const AmgVector(5)& pars = inputPars.parameters();
175 
176  double flippedPhi = pars[2] + M_PI;
177  if (flippedPhi > M_PI) flippedPhi -= 2 * M_PI;
178  double flippedTheta = M_PI - pars[3];
179  if (flippedTheta < 0.) flippedTheta += M_PI;
180  if (inputPars.covariance()) {
181  AmgSymMatrix(5) covMat = AmgSymMatrix(5)(*inputPars.covariance());
182  const Trk::PerigeeSurface perSurf;
183  return std::make_unique<Trk::Perigee>(-pars[0], pars[1], flippedPhi, flippedTheta, pars[4], perSurf, covMat);
184  } else {
185  ATH_MSG_DEBUG("flipDirection: no covariance associated to input parameters " << inputPars);
186  return nullptr;
187  }
188 }
189 
191 std::shared_ptr<Trk::AtaPlane> MuTagMatchingTool::ExtrapolateTrktoSegmentSurface(const EventContext& ctx,
192  const Muon::MuonSegment& segment,
193  const Trk::TrackParameters& pTrack,
194  Trk::PropDirection direction) const {
195 
196  unsigned int hits{cscHits(segment)};
197  bool isCsc{hits>0};
198  if (isCsc) {
199  ATH_MSG_DEBUG("CSC segment has " << hits << " hits");
200  if (hits < 5) {
201  ATH_MSG_DEBUG("CSC segment is identified to be 2D. Not extrapolating.");
202  return nullptr;
203  }
204  }
205 
206  std::shared_ptr<Trk::TrackParameters> atap{
207  m_IExtrapolator->extrapolate(ctx, pTrack, segment.associatedSurface(), direction, false, Trk::muon)};
208  if (!atap) {
209  ATH_MSG_DEBUG(" didn't manage to extrapolate TrackParameters to segment surface Radius"
210  << segment.associatedSurface().center().perp() << " Z " << segment.associatedSurface().center().z());
211  return nullptr;
212  }
213 
214  std::shared_ptr<Trk::AtaPlane> matap = std::dynamic_pointer_cast<Trk::AtaPlane>(atap);
215 
216  if (!matap) {
217  ATH_MSG_DEBUG(" didn't manage to extrapolate MeasuredTrackParameters to segment surface atap Radius "
218  << atap->position().perp() << " Z" << atap->position().z());
219  return nullptr;
220  } else {
221  ATH_MSG_DEBUG(" Succesfull extrapolation segment surface matap Radius " << matap->position().perp() << " Z"
222  << matap->position().z());
223  }
224  return matap;
225 }
226 
228  double PHI_CUT = m_GLOBAL_PHI_CUT;
229  if (hasPhi(segment)) PHI_CUT = m_GLOBAL_PHI_CUT / 2.;
230 
231  const Amg::Vector3D exTrkPos = atSurface.position();
232  const Amg::Vector3D& segPos = segment.globalPosition();
233 
234  const double deltaPhi = exTrkPos.deltaPhi(segPos);
235 
236  double sigma_phi = 0.;
237  if (atSurface.associatedSurface().type() == Trk::SurfaceType::Cylinder) {
238  const AmgSymMatrix(5)& covAtCyl = *atSurface.covariance();
239  double r = atSurface.associatedSurface().bounds().r();
240  if ( r > 0 && covAtCyl(Trk::locRPhi, Trk::locRPhi) >= 0.) sigma_phi = Amg::error(covAtCyl, Trk::locRPhi) / r;
241  } else if (atSurface.associatedSurface().type() == Trk::SurfaceType::Plane) {
242  const AmgSymMatrix(5)& covAtPlane = *atSurface.covariance();
243  sigma_phi = Amg::error(covAtPlane, Trk::phi0);
244  } else if (atSurface.associatedSurface().type() == Trk::SurfaceType::Disc) { // error in endcap
245  const AmgSymMatrix(5)& covAtDisc = *atSurface.covariance();
246  if (covAtDisc(Trk::locPhi, Trk::locPhi) >= 0.) sigma_phi = Amg::error(covAtDisc, Trk::locPhi);
247  }
248  double errPhi = std::hypot(PHI_CUT, sigma_phi);
249  // if the difference between exTrk and Segment phi position falls within the errPhi, accept as rough match
250  if (std::abs(deltaPhi) < errPhi)
251  return true; // BRes: TEMPORARY - segment direction not sure, so I'm making this match symmetric wrt Pi/2
252  ATH_MSG_DEBUG(std::setw(30) << "roughPhi failed: d_phi = " << std::setw(10) << std::abs(deltaPhi) // BRes: TEMPORARY - same
253  << " while the cut is set on " << std::setw(10) << errPhi);
254  return false;
255 }
256 
258  Muon::IMuonSegmentHitSummaryTool::HitCounts hitCounts = m_hitSummaryTool->getHitCounts(seg);
259  return hitCounts.nexpectedTrigHitLayers > 1;
260 }
261 
263  double THETA_CUT = m_GLOBAL_THETA_CUT;
264  const Amg::Vector3D exTrkPos = atSurface.position();
265  const Amg::Vector3D& segPos = segment.globalPosition();
266  const double dTheta = std::abs(exTrkPos.theta() - segPos.theta());
267  if (dTheta < THETA_CUT)
268  return true;
269 
270  ATH_MSG_DEBUG(std::setw(30) << "roughTheta failed: d_theta = " << std::setw(10) << dTheta << " while the cut is set on "
271  << std::setw(10) << THETA_CUT);
272  return false;
273 }
274 
276  const Amg::Vector3D exTrkPos = atSurface.position();
277  double L = exTrkPos.mag();
278  double R_CUT = m_GLOBAL_R_CUT * (L / 7500.); // mm
279 
280  const Amg::Vector3D& segPos = segment.globalPosition();
281  const double dPerp = std::abs(exTrkPos.perp() - segPos.perp());
282  if (dPerp < R_CUT)
283  return true;
284 
285  ATH_MSG_DEBUG(std::setw(30) << "rough R failed: d_R = " << std::setw(10) << dPerp << " while the cut is set on "
286  << std::setw(10) << R_CUT);
287  return false;
288 }
289 
290 double MuTagMatchingTool::errorProtection(double exTrk_Err, bool isAngle) const {
291  double newError = exTrk_Err;
292  if (!isAngle && (exTrk_Err > m_ERROR_EX_POS_CUT)) newError = m_ERROR_EX_POS_CUT;
293  if (isAngle && (exTrk_Err > m_ERROR_EX_ANGLE_CUT)) newError = m_ERROR_EX_ANGLE_CUT;
294 
295  return newError;
296 }
297 
299  if (!info.segment || !info.trackAtSegment) {
300  ATH_MSG_DEBUG(" No segment and or trackAtSegment pointer matchSegmentPosition ");
301  return false;
302  }
303 
304  bool pass(false);
305 
306  if (idHasEtaHits) {
307  if (std::abs(info.pullY) < m_MATCH_THETA || std::abs(info.pullCY) < m_combinedPullCut) pass = true;
308  } else {
309  if (std::abs(info.pullX) < m_MATCH_PHI) pass = true;
310  }
311 
312  return pass;
313 }
315  if (!info.segment || !info.trackAtSegment) {
316  ATH_MSG_DEBUG(" No segment and or trackAtSegment pointer matchSegmentDirection ");
317  return false;
318  }
319  if (idHasEtaHits) {
320  return std::abs(info.pullYZ) < m_MATCH_THETAANGLE || std::abs(info.pullCY) < m_combinedPullCut;
321  }
322  return true;
323 }
324 
326  bool pass(true);
327  if (!info.segment || !info.trackAtSegment) {
328  ATH_MSG_DEBUG(" No segment and or trackAtSegment pointer matchCombinedPull ");
329  return false;
330  }
331  if (info.pullChamber > m_chamberPullCut) pass = false;
332  if (std::abs(info.pullCY) > m_combinedPullCut) pass = false;
333 
334  ATH_MSG_DEBUG(" matchCombinedPull MuTagSegmentInfo hasPhi "
335  << info.hasPhi << " minimumPullPhi " << info.minimumPullPhi << " pullChamber " << info.pullChamber << " cut "
336  << m_chamberPullCut << " pullCY " << info.pullCY << " cut m_combinedPullCut " << m_combinedPullCut << " pass " << pass);
337 
338  return pass;
339 }
340 
342  bool pass(true);
343  if (!info.segment || !info.trackAtSegment) {
344  ATH_MSG_DEBUG(" No segment and or trackAtSegment pointermatchPtDependentPull ");
345  return false;
346  }
347  double pT(100.);
348  const Trk::Perigee* aMeasPer = trk.perigeeParameters();
349  if (aMeasPer) {
350  pT = aMeasPer->pT();
351  }
352  double Pullcut = 2.0;
353 
354  if (pT > 2.) { Pullcut = 5.0 - 6.0 / pT; }
355  if (Pullcut > m_combinedPullCut) Pullcut = m_combinedPullCut;
356 
357  if (std::abs(info.pullCY) > Pullcut) pass = false;
358 
359  return pass;
360 }
361 
362 void MuTagMatchingTool::testExtrapolation(const Trk::Surface& pSurface, const Trk::Track& pTrack) const {
363  const Trk::Perigee* oriPerigee = pTrack.perigeeParameters();
364  if (!oriPerigee) {
365  ATH_MSG_DEBUG("Couldn't get the measured Perigee from TP");
366  return;
367  }
368  const EventContext& ctx = Gaudi::Hive::currentContext();
369  const AmgVector(5)& oripars = oriPerigee->parameters();
370  const Trk::PerigeeSurface periSurf;
371  std::unique_ptr<Trk::Perigee> pPerigee = std::make_unique<Trk::Perigee>(oripars[0], oripars[1], oripars[2], oripars[3], 0., periSurf, std::nullopt);
372  const Amg::Vector3D startPos = pPerigee->position();
373  const Amg::Vector3D startMom = pPerigee->momentum();
374  const AmgVector(5)& pars = pPerigee->parameters();
375 
376  ATH_MSG_DEBUG("==============================================================================");
377  ATH_MSG_DEBUG("======= INITIAL TRACK PARAMETERS (PERIGEE)");
378  ATH_MSG_DEBUG("=== parameters are " << pars[0] << " " << pars[1] << " " << pars[2] << " " << pars[3] << " " << pars[4]);
379  ATH_MSG_DEBUG("=== global position " << startPos.x() << " " << startPos.y() << " " << startPos.z());
380  ATH_MSG_DEBUG("=== global directn " << startMom.phi() << " " << startMom.theta());
381 
382  std::unique_ptr<Trk::TrackParameters> alongPars{
383  m_IExtrapolator->extrapolate(ctx, *pPerigee, pSurface, Trk::alongMomentum, false, Trk::muon)};
384 
385  ATH_MSG_DEBUG("======= EXTRAPOLATED ALONG MOMENTUM ORIGINAL PERIGEE");
386  if (alongPars) {
387  const Amg::Vector3D alongPos = alongPars->position();
388  const Amg::Vector3D alongMom = alongPars->momentum();
389 
390  ATH_MSG_DEBUG("=== global position " << alongPos.x() << " " << alongPos.y() << " " << alongPos.z());
391  ATH_MSG_DEBUG("=== global position phi theta " << alongPos.phi() << " " << alongPos.theta());
392  ATH_MSG_DEBUG("=== global directn " << alongMom.phi() << " " << alongMom.theta());
393  } else
394  ATH_MSG_DEBUG("======= NOT EXTRAPOLATED");
395 
396  ATH_MSG_DEBUG("======= EXTRAPOLATED OPPOSITE MOMENTUM ORIGINAL PERIGEE");
397  std::unique_ptr<const Trk::TrackParameters> oppositePars{
398  m_IExtrapolator->extrapolate(ctx, *pPerigee, pSurface, Trk::oppositeMomentum, false, Trk::muon)};
399  if (oppositePars) {
400  const Amg::Vector3D oppositePos = oppositePars->position();
401  const Amg::Vector3D oppositeMom = oppositePars->momentum();
402  ATH_MSG_DEBUG("=== global position " << oppositePos.x() << " " << oppositePos.y() << " " << oppositePos.z());
403  ATH_MSG_DEBUG("=== global position phi theta " << oppositePos.phi() << " " << oppositePos.theta());
404  ATH_MSG_DEBUG("=== global directn " << oppositeMom.phi() << " " << oppositeMom.theta());
405  } else
406  ATH_MSG_DEBUG("======= NOT EXTRAPOLATED");
407 
408  ;
409  std::unique_ptr<const Trk::Perigee> flippedPerigee = flipDirection(*pPerigee);
410  const AmgVector(5)& flipPars = flippedPerigee->parameters();
411  const Amg::Vector3D flipPos = flippedPerigee->position();
412  const Amg::Vector3D flipMom = flippedPerigee->momentum();
413 
414  ATH_MSG_DEBUG("======= FLIPPED TRACK PARAMETERS (PERIGEE)");
415  ATH_MSG_DEBUG("=== phi and theta were " << pars[2] << " " << pars[3] << " and are flipped to ");
416  ATH_MSG_DEBUG("=== parameters are " << flipPars[0] << " " << flipPars[1] << " " << flipPars[2] << " " << flipPars[3] << " "
417  << flipPars[4]);
418  ATH_MSG_DEBUG("=== global position " << flipPos.x() << " " << flipPos.y() << " " << flipPos.z());
419  ATH_MSG_DEBUG("=== global directn " << flipMom.phi() << " " << flipMom.theta());
420 
421  std::unique_ptr<const Trk::TrackParameters> alongFlipPars{
422  m_IExtrapolator->extrapolate(ctx,*flippedPerigee, pSurface, Trk::alongMomentum, false, Trk::muon)};
423 
424  ATH_MSG_DEBUG("======= EXTRAPOLATED ALONGFLIP MOMENTUM ORIGINAL PERIGEE");
425  if (alongFlipPars) {
426  const Amg::Vector3D alongFlipPos = alongFlipPars->position();
427  const Amg::Vector3D alongFlipMom = alongFlipPars->momentum();
428  ATH_MSG_DEBUG("=== global position " << alongFlipPos.x() << " " << alongFlipPos.y() << " " << alongFlipPos.z());
429  ATH_MSG_DEBUG("=== global position phi theta " << alongFlipPos.phi() << " " << alongFlipPos.theta());
430  ATH_MSG_DEBUG("=== global directn " << alongFlipMom.phi() << " " << alongFlipMom.theta());
431  } else
432  ATH_MSG_DEBUG("======= NOT EXTRAPOLATED");
433 
434  ATH_MSG_DEBUG("======= EXTRAPOLATED OPPOSITEFLIP MOMENTUM ORIGINAL PERIGEE");
435  std::unique_ptr<const Trk::TrackParameters> oppositeFlipPars{
436  m_IExtrapolator->extrapolate(ctx, *flippedPerigee, pSurface, Trk::oppositeMomentum, false, Trk::muon)};
437  if (oppositeFlipPars) {
438  const Amg::Vector3D oppositeFlipPos = oppositeFlipPars->position();
439  const Amg::Vector3D oppositeFlipMom = oppositeFlipPars->momentum();
440  ATH_MSG_DEBUG("=== global position " << oppositeFlipPos.x() << " " << oppositeFlipPos.y() << " " << oppositeFlipPos.z());
441  ATH_MSG_DEBUG("=== global position phi theta " << oppositeFlipPos.phi() << " " << oppositeFlipPos.theta());
442  ATH_MSG_DEBUG("=== global directn " << oppositeFlipMom.phi() << " " << oppositeFlipMom.theta());
443  } else
444  ATH_MSG_DEBUG("======= NOT EXTRAPOLATED");
445 
446  ATH_MSG_DEBUG("==============================================================================");
447 
448 }
449 
450 //==========Counts ROTs and CompetingROTs on segment.
451 void MuTagMatchingTool::nrTriggerHits(const Muon::MuonSegment& seg, int& nRPC, int& nTGC) const {
452  nRPC = 0;
453  nTGC = 0;
454  for (const Trk::MeasurementBase* seg_meas : seg.containedMeasurements()) {
455  const Trk::RIO_OnTrack* rot = dynamic_cast<const Trk::RIO_OnTrack*>(seg_meas);
456  if (!rot) {
457  const Trk::CompetingRIOsOnTrack* crot = dynamic_cast<const Trk::CompetingRIOsOnTrack*>(seg_meas);
458  if (crot) rot = &crot->rioOnTrack(0);
459  }
460  if (!rot) { continue; }
461  if (m_idHelperSvc->isRpc(rot->identify())) ++nRPC;
462  if (m_idHelperSvc->isTgc(rot->identify())) ++nTGC;
463  }
464 }
465 
467  std::shared_ptr<const Trk::AtaPlane> exTrack) const {
469 
470  // segment and track pointers
471 
472  info.track = track;
473  info.segment = &segment;
474  info.trackAtSegment = exTrack;
475 
477 
478  // quality
479 
480  info.quality = m_selectionTool->quality(segment);
481 
482  // Global angular differences
483 
484  info.dtheta = exTrack->momentum().theta() - segment.globalDirection().theta();
485  info.dphi = exTrack->momentum().deltaPhi(segment.globalDirection());
486 
487  // Global angular differences for position
488 
489  info.dthetaPos = exTrack->position().theta() - segment.globalPosition().theta();
490  info.dphiPos = exTrack->position().deltaPhi (segment.globalPosition());
491 
492  // Local positions
493 
494  info.resY = exTrack->parameters()[Trk::locY] - segment.localParameters()[Trk::locY]; // delta_theta
495  info.resX = exTrack->parameters()[Trk::locX] - segment.localParameters()[Trk::locX]; // delta_phi
496 
497  // Local errors and covariance Matrix
498 
499  info.exCovYTheta = 0.;
500  if (exTrack->covariance()) {
501  ATH_MSG_DEBUG("Measured Parameters: error x " << (*exTrack->covariance())(Trk::locX, Trk::locX) << " y "
502  << (*exTrack->covariance())(Trk::locY, Trk::locY) << " pull x "
503  << info.resX / std::sqrt((*exTrack->covariance())(Trk::locX, Trk::locX)) << " pull y "
504  << info.resY / std::sqrt((*exTrack->covariance())(Trk::locY, Trk::locY)));
505  info.exErrorX = std::sqrt((*exTrack->covariance())(Trk::locX, Trk::locX));
506  info.exErrorY = std::sqrt((*exTrack->covariance())(Trk::locY, Trk::locY));
507  if ((*exTrack->covariance())(Trk::theta, Trk::locY) != 0) { info.exCovYTheta = (*exTrack->covariance())(Trk::theta, Trk::locY); }
508  } else {
509  info.exErrorX = -999.;
510  info.exErrorY = -999.;
511  }
512 
513  // Segment local errors
514  info.segErrorX = std::sqrt((segment.localCovariance())(Trk::locX, Trk::locX));
515  info.segErrorY = std::sqrt((segment.localCovariance())(Trk::locY, Trk::locY));
516 
517  // Pull local X and Y
518  double erexX = errorProtection(info.exErrorX, false);
519  double erexY = errorProtection(info.exErrorY, false);
520  info.pullX = info.resX / std::hypot(erexX, info.segErrorX, m_SAFE_PHI);
521  info.pullY = info.resY / std::hypot(erexY, info.segErrorY, m_SAFE_THETA);
522 
523  // Local angles
524 
525  Trk::LocalDirection segLocDir = segment.localDirection();
526  Trk::LocalDirection exTrkLocDir;
527  exTrack->associatedSurface().globalToLocalDirection(exTrack->momentum(), exTrkLocDir);
528  info.dangleYZ = exTrkLocDir.angleYZ() - segLocDir.angleYZ(); // deltaYZ
529  info.dangleXZ = exTrkLocDir.angleXZ() - segLocDir.angleXZ(); // deltaXZ
530  // delete exTrkLocDir;
531 
532  // Errors on local angles
533  double exTrkErrXZ(0.), exTrkErrYZ(0.), segErrXZ(0.), segErrYZ(0.), covLocYYZ(0.);
534 
535  calculateLocalAngleErrors(*exTrack, exTrkErrXZ, exTrkErrYZ, covLocYYZ);
536  info.exErrorXZ = exTrkErrXZ;
537  info.exErrorYZ = exTrkErrYZ;
538  info.exCovYZY = covLocYYZ;
539  calculateLocalAngleErrors(segment, segErrXZ, segErrYZ);
540  info.segErrorXZ = segErrXZ;
541  info.segErrorYZ = segErrYZ;
542  double erexXZ = errorProtection(info.exErrorXZ, true);
543  double erexYZ = errorProtection(info.exErrorYZ, true);
544 
545  ATH_MSG_DEBUG(" exTrkLocDir.angleYZ() " << exTrkLocDir.angleYZ() << " segLocDir.angleYZ() " << segLocDir.angleYZ());
546  ATH_MSG_DEBUG(" exTrkLocDir.angleXZ() " << exTrkLocDir.angleXZ() << " segLocDir.angleXZ() " << segLocDir.angleXZ());
547 
548  ATH_MSG_DEBUG(" info.exErrorYZ " << info.exErrorYZ << " info.segErrorYZ " << info.segErrorYZ << " info.exCovYZY " << info.exCovYZY);
549  ATH_MSG_DEBUG(" info.exErrorXZ " << info.exErrorXZ << " info.segErrorXZ " << info.segErrorXZ);
550 
551  info.pullXZ = info.dangleXZ / std::hypot(erexXZ, info.segErrorXZ, m_SAFE_PHIANGLE);
552  info.pullYZ = info.dangleYZ / std::hypot(erexYZ, info.segErrorYZ, m_SAFE_THETAANGLE);
553 
554  ATH_MSG_DEBUG(" info.pullXZ " << info.pullXZ);
555 
556  Identifier chId = m_edmHelperSvc->chamberId(segment);
557  Muon::MuonStationIndex::StIndex stIndex = m_idHelperSvc->stationIndex(chId);
558  //
559  // residuals and pulls in X coordinate (along tube)
560  //
561 
562  // MuonDetectorManager from the conditions store
564  const MuonGM::MuonDetectorManager* MuonDetMgr = DetectorManagerHandle.cptr();
565  if (!MuonDetMgr) {
566  ATH_MSG_ERROR("Null pointer to the read MuonDetectorManager conditions object");
567  return info;
568  }
569  double maxResXMdt{-1e9}, maxResPhi{-1e9}, maxPullPhi{-1e9}, minResPhi{1e9}, minPullPhi{1e9};
570  // loop over hits
571  for (const Trk::MeasurementBase* seg_it : segment.containedMeasurements()) {
572  const Muon::MdtDriftCircleOnTrack* mdt = dynamic_cast<const Muon::MdtDriftCircleOnTrack*>(seg_it);
573  if (mdt) {
574  // get id and check that it is a muon hit id
575  Identifier id = mdt->identify();
576 
577  // get layer index
578  int lay = m_idHelperSvc->mdtIdHelper().tubeLayer(id);
579  int tube = m_idHelperSvc->mdtIdHelper().tube(id);
580 
581  const MuonGM::MdtReadoutElement* detEl =
582  mdt->prepRawData() ? mdt->prepRawData()->detectorElement() : MuonDetMgr->getMdtReadoutElement(id);
583  if (!detEl) {
584  ATH_MSG_WARNING(" could not get MdtReadoutElement for tube " << m_idHelperSvc->toString(id));
585  continue;
586  }
587  double tubeLen = detEl->getActiveTubeLength(lay, tube);
588 
589  // use SL within station to speed up extrapolation
590  // lifetime only in this scope
591  std::unique_ptr<Trk::TrackParameters> exP = m_propagator->propagate(ctx, *exTrack, mdt->associatedSurface(), Trk::anyDirection, false, Trk::NoField);
592  if (!exP) {
593  ATH_MSG_WARNING("Failed to extrapolate to " << m_idHelperSvc->toString(id));
594  continue;
595  }
596  ATH_MSG_DEBUG(m_idHelperSvc->toString(id)
597  << " exPos " << exP->parameters()[Trk::locR] << " y " << exP->parameters()[Trk::locZ] << " tubeL " << tubeLen);
598  double exResidual = std::abs(exP->parameters()[Trk::locZ]) - 0.5 * tubeLen;
599  if (maxResXMdt < exResidual) maxResXMdt = exResidual;
600  if (exResidual > 0.) ATH_MSG_DEBUG("Extrapolated position outside tube, " << exResidual);
601  } else {
602  // get id and check that it is a muon hit id
603  Identifier id = m_edmHelperSvc->getIdentifier(*seg_it);
604  if (!id.is_valid() || !m_idHelperSvc->isMuon(id)) continue;
605  if (!m_idHelperSvc->measuresPhi(id)) continue;
606  // lifetime only in this scope
607  std::unique_ptr<Trk::TrackParameters> exP{
608  m_propagator->propagate(ctx, *exTrack, seg_it->associatedSurface(), Trk::anyDirection, false, Trk::NoField)};
609  if (!exP) {
610  ATH_MSG_WARNING("Failed to extrapolate to " << m_idHelperSvc->toString(id));
611  continue;
612  }
613  std::optional<Trk::ResidualPull> resPull{
614  m_pullCalculator->residualPull(seg_it, exP.get(), Trk::ResidualPull::Unbiased)};
615  if (!resPull) {
616  ATH_MSG_WARNING(" calculation of residual/pull failed !!!!! ");
617  // delete exP;
618  continue;
619  }
620  const double residual = resPull->residual().front();
621  const double pull = resPull->pull().front();
622 
623  maxResPhi = std::max(residual, maxResPhi);
624  minResPhi = std::min(residual, minResPhi);
625  maxPullPhi = std::max(pull, maxPullPhi);
626  minPullPhi = std::min(pull, minPullPhi);
627 
628  ATH_MSG_DEBUG(m_idHelperSvc->toString(id) << " residual " << residual << " pull " << pull);
629  }
630  }
631  ATH_MSG_DEBUG("Residual phi min " << minResPhi << " max " << maxResPhi << " pull min " << minPullPhi << " max " << maxPullPhi
632  << " dist from tube end " << maxResXMdt);
633 
634  //
635  // Store the local X variables
636  //
637  info.maximumResidualAlongTube = maxResXMdt;
638  info.maximumResidualPhi = maxResPhi;
639  info.maximumPullPhi = maxPullPhi;
640 
641  info.minimumResidualPhi = minResPhi;
642  info.minimumPullPhi = minPullPhi;
643 
644  info.pullChamber = maxResXMdt / info.exErrorX;
645 
646  // Scale covariance Matrix (if needed)
650  constexpr double matrix_cutoff = 1.e20;
651  double a = std::pow(std::min(matrix_cutoff, info.exErrorY), 2);
652  double b = std::abs(info.exCovYZY) < matrix_cutoff ? info.exCovYZY : (info.exCovYZY < 0 ? -1. : 1) * matrix_cutoff;
653  double d = std::pow(std::min(matrix_cutoff, info.exErrorYZ), 2);
654  double det = a * d - b * b;
655 
656  double scale = 1.;
657  if (det < 0.1 * a * d) {
658  scale = std::sqrt(0.9 * a * d) / std::abs(b);
659  det = a * d - scale * b * scale * b;
660  }
661  if (det ==0.) {
662  ATH_MSG_DEBUG("Found singular determinant");
663  return info;
664  }
665  double dydyz = scale * info.exCovYZY;
666  double correction = dydyz / std::max(info.exErrorYZ * info.exErrorYZ, DBL_EPSILON);
667 
668  //
669  // residual after taking into account the correlation with the angle YZ
670  //
671 
672  info.resCY = info.resY - correction * info.dangleYZ;
673 
674  ATH_MSG_DEBUG(" segment direction theta " << segment.globalDirection().theta() << " position theta "
675  << segment.globalPosition().theta() << " correction " << correction);
676  ATH_MSG_DEBUG(" resY " << info.resY << " dangleYZ " << info.dangleYZ << " resCY " << info.resCY);
677  double error_rescy = info.exErrorY * info.exErrorY - correction * correction * info.exErrorYZ * info.exErrorYZ;
678  double error_segcy = info.segErrorY * info.segErrorY + correction * correction * info.segErrorYZ * info.segErrorYZ;
679  if (error_rescy > 0) {
680  error_rescy = std::sqrt(error_rescy + error_segcy);
681  } else {
682  error_rescy = std::sqrt(info.exErrorY * info.exErrorY + error_segcy);
683  }
684 
685  // pull after taking into account the correlation with the angle YZ
686 
687  info.pullCY = info.resCY / std::hypot(error_rescy, m_SAFE_THETA, correction * m_SAFE_THETAANGLE);
688 
689  // chi2 with full covariance matrix in Y and YZ plane
690 
691  double chi2Y = d * info.resY * info.resY - 2 * b * scale * info.resY * info.dangleYZ + a * info.dangleYZ * info.dangleYZ;
692  info.chi2Y = 0.5*( chi2Y / det);
693  if (info.chi2Y < 0) ATH_MSG_DEBUG(" NEGATIVE chi2Y " << chi2Y << " dydyz " << dydyz << " determinant " << det);
694 
695  bool hasPhi = hitCounts.nexpectedTrigHitLayers > 1;
696 
697  //
698  // Store hasphi
699  //
700  info.hasPhi = hasPhi;
701  info.t0 = 0.;
702 
703  // station layer
704  info.stationLayer = 0;
705  if (stIndex == Muon::MuonStationIndex::BI) info.stationLayer = 1;
706  if (stIndex == Muon::MuonStationIndex::BM) info.stationLayer = 2;
707  if (stIndex == Muon::MuonStationIndex::BO) info.stationLayer = 3;
708  if (stIndex == Muon::MuonStationIndex::BE) info.stationLayer = 4;
709  if (stIndex == Muon::MuonStationIndex::EI) info.stationLayer = m_idHelperSvc->isMdt(chId) ? 11 : 21;
710  if (stIndex == Muon::MuonStationIndex::EM) info.stationLayer = 12;
711  if (stIndex == Muon::MuonStationIndex::EO) info.stationLayer = 13;
712  if (stIndex == Muon::MuonStationIndex::EE) info.stationLayer = 14;
713 
714  ATH_MSG_DEBUG("stationLayer " << info.stationLayer);
715  // number of holes
716  info.nholes = 0;
717  const Muon::MuonSegmentQuality* q = dynamic_cast<const Muon::MuonSegmentQuality*>(segment.fitQuality());
718  if (q) info.nholes = q->numberOfHoles();
719 
720  // number of segments
721  info.nsegments = 1;
722 
723  // single ML
724  info.singleML = 1;
725  if (hitCounts.nmdtHitsMl1 > 0 && hitCounts.nmdtHitsMl2 > 0) info.singleML = 0;
726 
727  // RLocY parametrized rejection as a function of locY
728  // RAYZ parametrized rejection as a function of Angle YZ
729 
730  // parameters are used for selecting best segment in ambiguity solver
731 
733  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.},
734  width_AYZ{0.004};
735 
736  double dlocY = info.resY;
737  double dAYZ = info.dangleYZ;
738 
739  double logLocY = std::log(1 + std::abs(dlocY / width_locY));
740  double logAYZ = std::log(1 + std::abs(dAYZ / width_AYZ));
741 
742  info.RLocY = a_locY / (1. + b_locY * (logLocY) * (logLocY) + c_locY * (logLocY) * (logLocY) * (logLocY));
743  info.RAYZ = a_AYZ / (1. + b_AYZ * (logAYZ) * (logAYZ) + c_AYZ * (logAYZ) * (logAYZ) * (logAYZ));
744 
745  int selected = 0;
746  scale = 1.;
747 
748  if (std::abs(info.pullY) < m_MATCH_THETA && std::abs(info.pullYZ) < m_MATCH_THETAANGLE &&
749  std::abs(info.pullCY) < scale * m_combinedPullCut && info.pullChamber < m_chamberPullCut) {
750  bool pass = true;
751  if (pass) selected = 1;
752  }
753 
754  info.selected = selected;
755 
756  return info;
757 }
758 void MuTagMatchingTool::calculateLocalAngleErrors(const Muon::MuonSegment& segment, double& angleXZerror, double& angleYZerror) const {
759  const Amg::MatrixX& segGlobCov = segment.localCovariance();
760  angleXZerror = 999.;
761  angleYZerror = 999.;
762  //
763  // the segment errors are stored in local angles (m_assumeLocalErrors = true);
764  //
765 
766  if (m_assumeLocalErrors) {
767  if (segGlobCov(Trk::phi, Trk::phi) >= 0 && segGlobCov(Trk::phi, Trk::phi) <= 999.0)
768  angleXZerror = std::sqrt(segGlobCov(Trk::phi, Trk::phi));
769  if (segGlobCov(Trk::theta, Trk::theta) >= 0 && segGlobCov(Trk::theta, Trk::theta) <= 999.0)
770  angleYZerror = std::sqrt(segGlobCov(Trk::theta, Trk::theta));
771  }
772 }
773 
774 void MuTagMatchingTool::calculateLocalAngleErrors(const Trk::AtaPlane& exTrack, double& angleXZerror, double& angleYZerror,
775  double& covLocYYZ) const {
776 
777  if (!exTrack.covariance()) return;
778  // Parameters are described as Trk::LocX, Trk::locY, Trk::phi, Trk::theta
779  // So the errormatrix of the track 'localErrorMatrix' still holds global angle representation!!!!
780  // retrieve Jabcobian to transform the global errors err_phi,err_theta to local errors err_alphaXZ, err_alphaYZ
781  const Amg::RotationMatrix3D glob2loc = exTrack.associatedSurface().transform().rotation().inverse();
782  const AmgVector(5)& exTrkParms = exTrack.parameters();
783  Trk::JacobianPhiThetaLocalAngles jacobianExTrk(exTrkParms[Trk::phi], exTrkParms[Trk::theta], glob2loc);
784 
785  // start with global angles error matrix
786  Amg::MatrixX anglesCovGlob(2, 2);
787  anglesCovGlob(0, 0) = (*exTrack.covariance())(Trk::phi, Trk::phi);
788  anglesCovGlob(1, 0) = (*exTrack.covariance())(Trk::theta, Trk::phi);
789  anglesCovGlob(0, 1) = (*exTrack.covariance())(Trk::phi, Trk::theta);
790  anglesCovGlob(1, 1) = (*exTrack.covariance())(Trk::theta, Trk::theta);
791 
792  // NEW METHOD
793  const AmgSymMatrix(2)& anglesCovLoc = anglesCovGlob.similarity(jacobianExTrk);
794 
795  if (anglesCovLoc(0, 0) >= 0) angleXZerror = std::sqrt(anglesCovLoc(0, 0));
796  if (anglesCovLoc(1, 1) >= 0) angleYZerror = std::sqrt(anglesCovLoc(1, 1));
797 
798  covLocYYZ = (*exTrack.covariance())(Trk::locY, Trk::phi) * jacobianExTrk(0, 1) +
799  (*exTrack.covariance())(Trk::locY, Trk::theta) * jacobianExTrk(1, 1);
800  ATH_MSG_DEBUG(" covLocYYZ " << covLocYYZ << " covlocytheta " << (*exTrack.covariance())(Trk::locY, Trk::theta) << " J01 "
801  << jacobianExTrk(0, 1) << " J11 " << jacobianExTrk(0, 1));
802  // some printout
803  ATH_MSG_DEBUG(std::setw(20) << "Angles Jacobian used for TRACK angle errors below: " << jacobianExTrk);
804 
805  ATH_MSG_DEBUG(std::setw(20) << "NEW TRACK angleXZ error = " << std::setprecision(6) << std::setw(10) << angleXZerror << std::setw(20)
806  << " and angleYZ error = " << std::setw(10) << angleYZerror);
807 }
809  bool pass(true);
810  if (!info.segment || !info.trackAtSegment) {
811  ATH_MSG_DEBUG(" No segment and or trackAtSegment pointer matchDistance ");
812  return false;
813  }
814  if (!m_doDistCut) return pass;
815 
816  if (info.hasPhi) {
817  if (std::abs(info.resX) > m_DIST_POS) pass = false;
818  if (std::abs(info.dangleXZ) > m_DIST_ANGLE) pass = false;
819  }
820  if (info.maximumResidualAlongTube > m_DIST_POS) pass = false;
821  if (std::abs(info.resY) > m_DIST_POS) pass = false;
822  if (std::abs(info.dangleYZ) > m_DIST_ANGLE) pass = false;
823 
824  return pass;
825 }
826 
828  for (const Trk::MeasurementBase* seg_meas : seg.containedMeasurements()) {
829  const Trk::RIO_OnTrack* rot = dynamic_cast<const Trk::RIO_OnTrack*>(seg_meas);
830  if (!rot) {
831  const Trk::CompetingRIOsOnTrack* crot = dynamic_cast<const Trk::CompetingRIOsOnTrack*>(seg_meas);
832  if (crot) rot = &crot->rioOnTrack(0);
833  }
834  if (!rot) { continue; }
835  if (m_idHelperSvc->isCsc(rot->identify())) return true;
836  }
837 
838  return false;
839 }
840 
841 unsigned int MuTagMatchingTool::cscHits(const Muon::MuonSegment& seg) const {
842  unsigned int nrHits{0};
843  for (const Trk::MeasurementBase* seg_meas : seg.containedMeasurements()) {
844  const Trk::RIO_OnTrack* rot = dynamic_cast<const Trk::RIO_OnTrack*>(seg_meas);
845  if (!rot) {
846  const Trk::CompetingRIOsOnTrack* crot = dynamic_cast<const Trk::CompetingRIOsOnTrack*>(seg_meas);
847  if (crot) rot = &crot->rioOnTrack(0);
848  }
849  if (!rot) { continue; }
850  if (m_idHelperSvc->isCsc(rot->identify())) ++nrHits;
851  }
852 
853  return nrHits;
854 }
grepfile.info
info
Definition: grepfile.py:38
MuTagMatchingTool::m_GLOBAL_PHI_CUT
double m_GLOBAL_PHI_CUT
Definition: MuTagMatchingTool.h:173
Muon::MuonSegmentQuality
Definition: MuonSegmentQuality.h:34
Trk::anyDirection
@ anyDirection
Definition: PropDirection.h:22
make_hlt_rep.pars
pars
Definition: make_hlt_rep.py:90
beamspotman.r
def r
Definition: beamspotman.py:676
Muon::MuonStationIndex::BE
@ BE
Definition: MuonStationIndex.h:25
MuonCombined::MuonSegmentInfo
Definition: MuonSegmentInfo.h:23
CalculateHighPtTerm.pT
pT
Definition: ICHEP2016/CalculateHighPtTerm.py:57
MuTagMatchingTool::m_DIST_POS
double m_DIST_POS
Definition: MuTagMatchingTool.h:185
MuTagMatchingTool::m_MATCH_PHI
double m_MATCH_PHI
Definition: MuTagMatchingTool.h:177
MuTagMatchingTool::m_MATCH_THETA
double m_MATCH_THETA
Definition: MuTagMatchingTool.h:176
MuTagMatchingTool::phiMatch
bool phiMatch(const Trk::TrackParameters &atSurface, const Muon::MuonSegment &segment) const override
Definition: MuTagMatchingTool.cxx:227
Amg::MatrixX
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Definition: EventPrimitives.h:29
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
MuTagMatchingTool::m_hitSummaryTool
ToolHandle< Muon::IMuonSegmentHitSummaryTool > m_hitSummaryTool
Definition: MuTagMatchingTool.h:127
max
#define max(a, b)
Definition: cfImp.cxx:41
TrackParameters.h
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
Muon::MdtDriftCircleOnTrack::prepRawData
virtual const MdtPrepData * prepRawData() const override final
Returns the PrepRawData used to create this corrected measurement.
Definition: MdtDriftCircleOnTrack.h:257
Trk::locX
@ locX
Definition: ParamDefs.h:43
CompetingRIOsOnTrack.h
Trk::locY
@ locY
local cartesian
Definition: ParamDefs.h:44
Surface.h
Trk::Track
The ATLAS Track class.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h:73
MuTagMatchingTool::m_t0Location
std::string m_t0Location
Definition: MuTagMatchingTool.h:155
MuTagMatchingTool::testExtrapolation
void testExtrapolation(const Trk::Surface &pSurface, const Trk::Track &pTrack) const
Definition: MuTagMatchingTool.cxx:362
MuTagMatchingTool::m_extrapolatePerigee
bool m_extrapolatePerigee
Definition: MuTagMatchingTool.h:170
ClusterSeg::residual
@ residual
Definition: ClusterNtuple.h:20
Trk::PerigeeSurface
Definition: PerigeeSurface.h:43
MuTagMatchingTool::m_ERROR_EX_ANGLE_CUT
double m_ERROR_EX_ANGLE_CUT
Definition: MuTagMatchingTool.h:182
Muon::IMuonSegmentHitSummaryTool::HitCounts::nmdtHitsMl1
uint8_t nmdtHitsMl1
Definition: IMuonSegmentHitSummaryTool.h:40
Trk::ParametersBase::position
const Amg::Vector3D & position() const
Access method for the position.
Muon::MuonStationIndex::EO
@ EO
Definition: MuonStationIndex.h:26
Trk::oppositeMomentum
@ oppositeMomentum
Definition: PropDirection.h:21
Trk::ParametersBase::associatedSurface
virtual const Surface & associatedSurface() const override=0
Access to the Surface associated to the Parameters.
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
hist_file_dump.d
d
Definition: hist_file_dump.py:137
Trk::ParametersT
Dummy class used to allow special convertors to be called for surfaces owned by a detector element.
Definition: EMErrorDetail.h:25
xAOD::deltaPhi
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap setEtaBin setIsTgcFailure setDeltaPt deltaPhi
Definition: L2StandAloneMuon_v1.cxx:160
MuTagMatchingTool::initialize
virtual StatusCode initialize() override
Definition: MuTagMatchingTool.cxx:66
MuTagMatchingTool::m_MATCH_PHIANGLE
double m_MATCH_PHIANGLE
Definition: MuTagMatchingTool.h:179
MuTagMatchingTool::m_edmHelperSvc
ServiceHandle< Muon::IMuonEDMHelperSvc > m_edmHelperSvc
Definition: MuTagMatchingTool.h:148
EventPrimitivesHelpers.h
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
Trk::locRPhi
@ locRPhi
Definition: ParamDefs.h:46
MuTagMatchingTool::m_IExtrapolator
ToolHandle< Trk::IExtrapolator > m_IExtrapolator
Pointer on IExtrapolator.
Definition: MuTagMatchingTool.h:112
MuTagMatchingTool::m_selectionTool
ToolHandle< Muon::IMuonSegmentSelectionTool > m_selectionTool
Definition: MuTagMatchingTool.h:132
Trk::ResidualPull::Unbiased
@ Unbiased
RP with track state that has measurement not included.
Definition: ResidualPull.h:57
MuonCombined::MuonSegmentTagSurfaces::stIdxToSurfDef
static int stIdxToSurfDef(Muon::MuonStationIndex::StIndex st_idx, bool pos_eta)
Transforms the Muon Station index to a SurfDef index.
Definition: MuonSegmentTagSurfaces.cxx:21
M_PI
#define M_PI
Definition: ActiveFraction.h:11
MuTagMatchingTool::matchPtDependentPull
bool matchPtDependentPull(const MuonCombined::MuonSegmentInfo &info, const Trk::Track &trk) const override
Definition: MuTagMatchingTool.cxx:341
MuTagMatchingTool::matchSegmentDirection
bool matchSegmentDirection(const MuonCombined::MuonSegmentInfo &info, bool idHasEtaHits) const override
Definition: MuTagMatchingTool.cxx:314
PropDirection.h
MuTagMatchingTool::m_printer
ToolHandle< Muon::MuonEDMPrinterTool > m_printer
Definition: MuTagMatchingTool.h:122
IExtrapolator.h
Muon::MuonStationIndex::BI
@ BI
Definition: MuonStationIndex.h:25
IPropagator.h
Trk::RIO_OnTrack
Definition: RIO_OnTrack.h:70
Trk::alongMomentum
@ alongMomentum
Definition: PropDirection.h:20
MuonSegmentQuality.h
MuTagMatchingTool::ExtrapolateTrktoMSEntrance
std::unique_ptr< Trk::TrackParameters > ExtrapolateTrktoMSEntrance(const EventContext &ctx, const Trk::Track &pTrack, Trk::PropDirection direction) const override
Get extrapolation at MS entrance level.
Definition: MuTagMatchingTool.cxx:142
Trk::locR
@ locR
Definition: ParamDefs.h:50
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
MuTagMatchingTool::matchCombinedPull
bool matchCombinedPull(const MuonCombined::MuonSegmentInfo &info) const override
Definition: MuTagMatchingTool.cxx:325
MdtDriftCircleOnTrack.h
Trk::Surface::center
const Amg::Vector3D & center() const
Returns the center position of the Surface.
SG::VarHandleKey::empty
bool empty() const
Test if the key is blank.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:150
yodamerge_tmp.scale
scale
Definition: yodamerge_tmp.py:138
MuonSegmentInfo.h
AmgSymMatrix
#define AmgSymMatrix(dim)
Definition: EventPrimitives.h:52
MuTagMatchingTool::matchSegmentPosition
bool matchSegmentPosition(const MuonCombined::MuonSegmentInfo &info, bool idHasEtaHits) const override
Definition: MuTagMatchingTool.cxx:298
Trk::LocalDirection::angleYZ
double angleYZ() const
access method for angle of local YZ projection
Definition: LocalDirection.h:106
Track.h
MuTagMatchingTool::m_DIST_ANGLE
double m_DIST_ANGLE
Definition: MuTagMatchingTool.h:186
MagneticFieldProperties.h
tools.zlumi_mc_cf.correction
def correction(mu, runmode, campaign, run=None)
Definition: zlumi_mc_cf.py:4
Trk::ParametersT::associatedSurface
virtual const S & associatedSurface() const override final
Access to the Surface method.
MuTagMatchingTool::m_chamberPullCut
double m_chamberPullCut
Definition: MuTagMatchingTool.h:193
MuTagMatchingTool::m_assumeLocalErrors
bool m_assumeLocalErrors
Definition: MuTagMatchingTool.h:169
MuTagMatchingTool::m_GLOBAL_R_CUT
double m_GLOBAL_R_CUT
Definition: MuTagMatchingTool.h:174
Trk::CompetingRIOsOnTrack::rioOnTrack
virtual const RIO_OnTrack & rioOnTrack(unsigned int) const =0
returns the RIO_OnTrack (also known as ROT) objects depending on the integer.
Trk::PropDirection
PropDirection
Definition: PropDirection.h:19
Muon::IMuonSegmentHitSummaryTool::HitCounts::nexpectedTrigHitLayers
uint8_t nexpectedTrigHitLayers
Definition: IMuonSegmentHitSummaryTool.h:54
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
MuonGM::MuonDetectorManager::getMdtReadoutElement
const MdtReadoutElement * getMdtReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonDetectorManager.cxx:204
Trk::locZ
@ locZ
local cylindrical
Definition: ParamDefs.h:48
MuTagMatchingTool::matchDistance
bool matchDistance(const MuonCombined::MuonSegmentInfo &info) const override
Definition: MuTagMatchingTool.cxx:808
ResidualPull.h
MuonGM::MdtReadoutElement
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MdtReadoutElement.h:50
MuTagMatchingTool::m_DetectorManagerKey
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_DetectorManagerKey
Definition: MuTagMatchingTool.h:159
Muon::MuonStationIndex::BM
@ BM
Definition: MuonStationIndex.h:25
MuTagMatchingTool.h
MuTagMatchingTool::hasPhi
bool hasPhi(const Muon::MuonSegment &seg) const
Definition: MuTagMatchingTool.cxx:257
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
beamspotman.n
n
Definition: beamspotman.py:731
Trk::theta
@ theta
Definition: ParamDefs.h:72
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
Muon::MuonStationIndex::EI
@ EI
Definition: MuonStationIndex.h:26
AmgVector
AmgVector(4) T2BSTrackFilterTool
Definition: T2BSTrackFilterTool.cxx:114
LArG4ShowerLibProcessing.hits
hits
Definition: LArG4ShowerLibProcessing.py:136
Muon::MuonStationIndex::Barrel
@ Barrel
Definition: MuonStationIndex.h:49
MuTagMatchingTool::surfaceMatch
bool surfaceMatch(const Muon::MuonSegment &segment, int surfaceName) const override
Definition: MuTagMatchingTool.cxx:136
MuonGM::MdtReadoutElement::getActiveTubeLength
double getActiveTubeLength(const int tubeLayer, const int tube) const
WritePulseShapeToCool.det
det
Definition: WritePulseShapeToCool.py:204
Trk::Segment::containedMeasurements
const std::vector< const Trk::MeasurementBase * > & containedMeasurements() const
returns the vector of Trk::MeasurementBase objects
Definition: TrkEvent/TrkSegment/TrkSegment/Segment.h:166
Trk::CompetingRIOsOnTrack
Base class for all CompetingRIOsOnTack implementations, extends the common MeasurementBase.
Definition: CompetingRIOsOnTrack.h:64
MuTagMatchingTool::ExtrapolateTrktoSegmentSurface
std::shared_ptr< Trk::AtaPlane > 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: MuTagMatchingTool.cxx:191
python.StandardJetMods.pull
pull
Definition: StandardJetMods.py:264
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
MuTagMatchingTool::match
bool match(const Trk::TrackParameters &atSurface, const Muon::MuonSegment &segment, int surfaceName) const override
Definition: MuTagMatchingTool.cxx:114
Trk::ParametersBase
Definition: ParametersBase.h:55
Trk::muon
@ muon
Definition: ParticleHypothesis.h:28
Trk::LocalDirection
represents the three-dimensional global direction with respect to a planar surface frame.
Definition: LocalDirection.h:81
MuTagMatchingTool::m_SAFE_THETAANGLE
double m_SAFE_THETAANGLE
Definition: MuTagMatchingTool.h:190
MuTagMatchingTool::m_GLOBAL_THETA_CUT
double m_GLOBAL_THETA_CUT
Definition: MuTagMatchingTool.h:172
min
#define min(a, b)
Definition: cfImp.cxx:40
Trk::MeasurementBase
Definition: MeasurementBase.h:58
Trk::NoField
@ NoField
Field is set to 0., 0., 0.,.
Definition: MagneticFieldMode.h:18
Trk::Track::perigeeParameters
const Perigee * perigeeParameters() const
return Perigee.
Definition: Tracking/TrkEvent/TrkTrack/src/Track.cxx:163
MuTagMatchingTool::errorProtection
double errorProtection(double exTrk_Err, bool isAngle) const
Definition: MuTagMatchingTool.cxx:290
MuTagMatchingTool::m_SAFE_PHI
double m_SAFE_PHI
Definition: MuTagMatchingTool.h:189
MuTagMatchingTool::m_doDistCut
bool m_doDistCut
Definition: MuTagMatchingTool.h:184
MuTagMatchingTool::getVolume
const Trk::TrackingVolume * getVolume(const EventContext &ctx, const std::string &&vol_name) const
Definition: MuTagMatchingTool.h:196
MuTagMatchingTool::calculateLocalAngleErrors
void calculateLocalAngleErrors(const Trk::AtaPlane &expPars, double &exTrkErrXZ, double &exTrkErrYZ, double &covLocYYZ) const
Definition: MuTagMatchingTool.cxx:774
Trk::Surface::bounds
virtual const SurfaceBounds & bounds() const =0
Surface Bounds method.
JacobianPhiThetaLocalAngles.h
MuTagMatchingTool::nrTriggerHits
void nrTriggerHits(const Muon::MuonSegment &seg, int &nRPC, int &nTGC) const
Definition: MuTagMatchingTool.cxx:451
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
Amg::error
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 ...
Definition: EventPrimitivesHelpers.h:40
Trk::locPhi
@ locPhi
local polar
Definition: ParamDefs.h:51
Muon::MdtDriftCircleOnTrack
This class represents the corrected MDT measurements, where the corrections include the effects of wi...
Definition: MdtDriftCircleOnTrack.h:37
MuTagMatchingTool::m_trackingGeometryReadKey
SG::ReadCondHandleKey< Trk::TrackingGeometry > m_trackingGeometryReadKey
Definition: MuTagMatchingTool.h:166
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
MuTagMatchingTool::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: MuTagMatchingTool.h:143
Muon::IMuonSegmentHitSummaryTool::HitCounts
Definition: IMuonSegmentHitSummaryTool.h:37
MuTagMatchingTool::cscHits
unsigned int cscHits(const Muon::MuonSegment &seg) const
Definition: MuTagMatchingTool.cxx:841
a
TList * a
Definition: liststreamerinfos.cxx:10
Muon::MuonStationIndex::BO
@ BO
Definition: MuonStationIndex.h:25
Trk::JacobianPhiThetaLocalAngles
Definition: JacobianPhiThetaLocalAngles.h:32
MuonGM::MuonDetectorManager
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonDetectorManager.h:49
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Muon::MdtDriftCircleOnTrack::associatedSurface
virtual const Trk::StraightLineSurface & associatedSurface() const override final
Returns the surface on which this measurement was taken.
Definition: MdtDriftCircleOnTrack.h:271
Amg::RotationMatrix3D
Eigen::Matrix< double, 3, 3 > RotationMatrix3D
Definition: GeoPrimitives.h:49
Trk::SurfaceType::Disc
@ Disc
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
MuTagMatchingTool::m_pullCalculator
ToolHandle< Trk::IResidualPullCalculator > m_pullCalculator
Definition: MuTagMatchingTool.h:137
Trk::RIO_OnTrack::identify
virtual Identifier identify() const final
return the identifier -extends MeasurementBase
Definition: RIO_OnTrack.h:155
Trk::SurfaceType::Cylinder
@ Cylinder
MuTagMatchingTool::flipDirection
std::unique_ptr< Trk::Perigee > flipDirection(const Trk::Perigee &inputPars) const
Definition: MuTagMatchingTool.cxx:173
extractSporadic.q
list q
Definition: extractSporadic.py:98
MuTagMatchingTool::MuTagMatchingTool
MuTagMatchingTool(const std::string &t, const std::string &n, const IInterface *p)
Definition: MuTagMatchingTool.cxx:28
MuTagMatchingTool::m_ERROR_EX_POS_CUT
double m_ERROR_EX_POS_CUT
Definition: MuTagMatchingTool.h:181
MuonSegment.h
MuTagMatchingTool::m_SAFE_PHIANGLE
double m_SAFE_PHIANGLE
Definition: MuTagMatchingTool.h:191
Muon::MuonStationIndex::StIndex
StIndex
enum to classify the different station layers in the muon spectrometer
Definition: MuonStationIndex.h:23
Trk::SurfaceType::Plane
@ Plane
Trk::phi
@ phi
Definition: ParamDefs.h:81
LocalDirection.h
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
Muon::MuonSegment
Definition: MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonSegment/MuonSegment/MuonSegment.h:45
AthAlgTool
Definition: AthAlgTool.h:26
Trk::LocalDirection::angleXZ
double angleXZ() const
access method for angle of local XZ projection
Definition: LocalDirection.h:103
MuTagMatchingTool::muTagSegmentInfo
MuonCombined::MuonSegmentInfo muTagSegmentInfo(const EventContext &ctx, const Trk::Track *track, const Muon::MuonSegment &segment, std::shared_ptr< const Trk::AtaPlane > exTrack) const override
Definition: MuTagMatchingTool.cxx:466
MuTagMatchingTool::m_propagator
ToolHandle< Trk::IPropagator > m_propagator
Pointer on propagator for SL propagation.
Definition: MuTagMatchingTool.h:117
Muon::MuonStationIndex::EE
@ EE
Definition: MuonStationIndex.h:26
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:75
Trk::TrackingVolume
Definition: TrackingVolume.h:121
MuTagMatchingTool::ExtrapolateTrktoMSSurface
std::unique_ptr< Trk::TrackParameters > ExtrapolateTrktoMSSurface(const EventContext &ctx, const Trk::Surface &surface, const Trk::TrackParameters &pTrack, Trk::PropDirection direction) const override
Get extrapolation at MSSurface level.
Definition: MuTagMatchingTool.cxx:161
MuTagMatchingTool::thetaMatch
bool thetaMatch(const Trk::TrackParameters &atSurface, const Muon::MuonSegment &segment) const override
Definition: MuTagMatchingTool.cxx:262
Muon::MdtPrepData::detectorElement
virtual const MuonGM::MdtReadoutElement * detectorElement() const override
Returns the detector element corresponding to this PRD.
Definition: MdtPrepData.h:156
Trk::Surface::type
constexpr virtual SurfaceType type() const =0
Returns the Surface type to avoid dynamic casts.
MuTagMatchingTool::rMatch
bool rMatch(const Trk::TrackParameters &atSurface, const Muon::MuonSegment &segment) const override
Definition: MuTagMatchingTool.cxx:275
calibdata.tube
tube
Definition: calibdata.py:31
Trk::phi0
@ phi0
Definition: ParamDefs.h:71
MuTagMatchingTool::m_combinedPullCut
double m_combinedPullCut
Definition: MuTagMatchingTool.h:194
Muon::MuonStationIndex::EM
@ EM
Definition: MuonStationIndex.h:26
MuTagMatchingTool::m_MATCH_THETAANGLE
double m_MATCH_THETAANGLE
Definition: MuTagMatchingTool.h:178
NSWL1::PadTriggerAdapter::segment
Muon::NSW_PadTriggerSegment segment(const NSWL1::PadTrigger &data)
Definition: PadTriggerAdapter.cxx:5
MuTagMatchingTool::isCscSegment
bool isCscSegment(const Muon::MuonSegment &seg) const
Definition: MuTagMatchingTool.cxx:827
MuTagMatchingTool::m_SAFE_THETA
double m_SAFE_THETA
Definition: MuTagMatchingTool.h:188
Trk::SurfaceBounds::r
virtual double r() const =0
Interface method for the maximal extension or the radius.
Muon::IMuonSegmentHitSummaryTool::HitCounts::nmdtHitsMl2
uint8_t nmdtHitsMl2
Definition: IMuonSegmentHitSummaryTool.h:41