ATLAS Offline Software
Loading...
Searching...
No Matches
SortMuPatHits.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef SORTMUPATHITS_H
6#define SORTMUPATHITS_H
7
12#include "TrkSurfaces/Surface.h"
13
14namespace Muon {
15
17 public:
18 double operator()(const Trk::TrackParameters& pars, const Amg::Vector3D& pos) const {
19 Amg::Vector3D difPos = pos - pars.position();
20 return difPos.dot(pars.momentum().unit());
21 }
22
23 double operator()(const Trk::TrackParameters& pars1, const Trk::TrackParameters& pars2) const {
24 return this->operator()(pars1, pars2.position());
25 }
26
27 double operator()(const Trk::TrackParameters& pars, const Trk::MeasurementBase& meas) const {
28 return this->operator()(pars, meas.globalPosition());
29 }
30 double operator()(const MuPatHitPtr& hit1, const MuPatHitPtr& hit2) const {
31 return operator()(hit1->parameters(), hit2->parameters());
32 }
33 double operator()(const MuPatHit* hit1, const MuPatHit* hit2) const {
34 return operator()(hit1->parameters(), hit2->parameters());
35 }
36
37 };
38
39 //Not used atm (default is SortByDirectionMuPatHits)
41 public:
42
45 bool operator()(const MuPatHitPtr& hit1, const MuPatHitPtr& hit2) const {
46 return operator()(hit1.get(), hit2.get());
47 }
48 bool operator()(const MuPatHit* hit1, const MuPatHit* hit2) const {
49 // first, check if both hits are in the same chamber, and at least one is an RPC
50
51 const MuPatHit::Info& info1 = hit1->info();
52 const MuPatHit::Info& info2 = hit2->info();
53 const Identifier& id1 = info1.id;
54 const Identifier& id2 = info2.id;
55
56 const Trk::Surface& surf1{hit1->measurement().associatedSurface()};
57 const Trk::Surface& surf2{hit2->measurement().associatedSurface()};
58
59 if (info1.isEndcap && info2.isEndcap) {
60 const double absZ1 = std::abs(surf1.center().z());
61 const double absZ2 = std::abs(surf2.center().z());
62 if (std::abs(absZ1 - absZ2) > std::numeric_limits<float>::epsilon()) { return absZ1 < absZ2; }
63 } else if (!info1.isEndcap && !info2.isEndcap) {
64 const double perp1 = surf1.center().perp2();
65 const double perp2 = surf2.center().perp2();
66 if (std::abs(perp1 - perp2) > std::numeric_limits<float>::epsilon()) {return perp1 < perp2; }
67 }
69 else if (info1.isEndcap || info2.isEndcap) {
70 const MuonStationIndex::StIndex& st1 = info1.stIdx;
71 const MuonStationIndex::StIndex& st2 = info2.stIdx;
72 if (st1 != st2) return st1 < st2;
73 }
74 if (info1.type == info2.type) {
75 if (info1.type == MuPatHit::sTGC) {
76 const sTgcIdHelper& id_helper = m_idh->stgcIdHelper();
77 const int type1 =id_helper.channelType(id1);
78 const int type2 =id_helper.channelType(id2);
79 if (type1 != type2) return type1 > type2;
80 }
81 if (info1.status != info2.status) {
82 return info1.status < info2.status;
83 }
84 if (info1.measuresPhi == info2.measuresPhi) {
85 return hit1->pull() < hit2->pull();
86 }
87 }
88 // phi measurements larger than eta measurements
89 return !info1.measuresPhi;
90 }
91
93 const IMuonIdHelperSvc* m_idh{nullptr};
94 };
95
98 public:
100 m_ref(refPars) {}
101
102 bool operator() (const Trk::MeasurementBase* meas1, const Trk::MeasurementBase* meas2) const {
103 return operator()(*meas1,*meas2);
104 }
105 bool operator() (const Trk::MeasurementBase& meas1, const Trk::MeasurementBase& meas2) const {
106 static const DistanceAlongParameters parsSorter{};
107 return parsSorter(m_ref, meas1) < parsSorter(m_ref, meas2);
108 }
109
110 bool operator()(const MuPatHitPtr& hit1, const MuPatHitPtr& hit2) const {
111 return operator()(hit1->parameters(),hit2->parameters());
112 }
113 bool operator()(const MuPatHit* hit1, const MuPatHit* hit2) const {
114 return operator()(hit1->parameters(),hit2->parameters());
115 }
116 bool operator()(const Trk::TrackParameters* pars1, const Trk::TrackParameters* pars2) const {
117 return operator()(*pars1,*pars2);
118 }
119 bool operator()(const Trk::TrackParameters& pars1, const Trk::TrackParameters& pars2) const {
120 static const DistanceAlongParameters parsSorter{};
121 return parsSorter(m_ref, pars1) < parsSorter(m_ref, pars2);
122 }
123
124
125
126 private:
128
129 };
130
131
132} // namespace Muon
133
134#endif
Scalar perp2() const
perp2 method - perpendicular length squared
HWIdentifier id2
double operator()(const Trk::TrackParameters &pars1, const Trk::TrackParameters &pars2) const
double operator()(const Trk::TrackParameters &pars, const Trk::MeasurementBase &meas) const
double operator()(const MuPatHitPtr &hit1, const MuPatHitPtr &hit2) const
double operator()(const MuPatHit *hit1, const MuPatHit *hit2) const
double operator()(const Trk::TrackParameters &pars, const Amg::Vector3D &pos) const
Interface for Helper service that creates muon Identifiers and can be used to print Identifiers.
double pull() const
returns the pull of the measurement
Definition MuPatHit.cxx:54
const Trk::TrackParameters & parameters() const
returns a reference to the TrackParameters
Definition MuPatHit.cxx:43
const Trk::MeasurementBase & measurement() const
returns a reference to the selected measurement
Definition MuPatHit.cxx:45
const Info & info() const
returns a reference to the hit info
Definition MuPatHit.cxx:51
bool operator()(const Trk::MeasurementBase *meas1, const Trk::MeasurementBase *meas2) const
SortByDirectionMuPatHits(const Trk::TrackParameters &refPars)
bool operator()(const MuPatHit *hit1, const MuPatHit *hit2) const
const Trk::TrackParameters & m_ref
bool operator()(const Trk::TrackParameters *pars1, const Trk::TrackParameters *pars2) const
bool operator()(const MuPatHitPtr &hit1, const MuPatHitPtr &hit2) const
bool operator()(const Trk::TrackParameters &pars1, const Trk::TrackParameters &pars2) const
SortByIPMuPatHits(const IMuonIdHelperSvc *idh)
const IMuonIdHelperSvc * m_idh
DistanceAlongParameters distanceCalculator;.
bool operator()(const MuPatHit *hit1, const MuPatHit *hit2) const
bool operator()(const MuPatHitPtr &hit1, const MuPatHitPtr &hit2) const
Sort the mu pat hits using their associated surfaces.
This class is the pure abstract base class for all fittable tracking measurements.
virtual const Surface & associatedSurface() const =0
Interface method to get the associated Surface.
virtual const Amg::Vector3D & globalPosition() const =0
Interface method to get the global Position.
const Amg::Vector3D & position() const
Access method for the position.
Abstract Base Class for tracking surfaces.
const Amg::Vector3D & center() const
Returns the center position of the Surface.
int channelType(const Identifier &id) const
Eigen::Matrix< double, 3, 1 > Vector3D
StIndex
enum to classify the different station layers in the muon spectrometer
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
std::shared_ptr< MuPatHit > MuPatHitPtr
Definition MuPatHit.h:25
ParametersBase< TrackParametersDim, Charged > TrackParameters
Identifier id
Identifier of the measurement. Is invalid in cases of pseudo measurements.
Definition MuPatHit.h:39
bool isEndcap
Hit in the endcap?
Definition MuPatHit.h:54
MuonStationIndex::StIndex stIdx
Station index of the Identifier BI.
Definition MuPatHit.h:48
bool measuresPhi
Does the hit constrain phi?
Definition MuPatHit.h:56
Type type
Measurement type as defined above.
Definition MuPatHit.h:42
Status status
Flag whether the hit is on Tack or not.
Definition MuPatHit.h:46