ATLAS Offline Software
Loading...
Searching...
No Matches
Muon::SortTSOSs Class Reference

#include <SortMeasurementsByPosition.h>

Collaboration diagram for Muon::SortTSOSs:

Public Member Functions

bool operator() (const Trk::TrackStateOnSurface *tsos1, const Trk::TrackStateOnSurface *tsos2) const
bool operator() (const std::unique_ptr< const Trk::TrackStateOnSurface > &tsos1, const std::unique_ptr< const Trk::TrackStateOnSurface > &tsos2) const
 SortTSOSs (const IMuonEDMHelperSvc *h, const IMuonIdHelperSvc *idh)

Public Attributes

const IMuonEDMHelperSvcm_helperSvc
const IMuonIdHelperSvcm_idHelperSvc

Detailed Description

Definition at line 80 of file SortMeasurementsByPosition.h.

Constructor & Destructor Documentation

◆ SortTSOSs()

Muon::SortTSOSs::SortTSOSs ( const IMuonEDMHelperSvc * h,
const IMuonIdHelperSvc * idh )
inline

Definition at line 146 of file SortMeasurementsByPosition.h.

146: m_helperSvc(h), m_idHelperSvc(idh) {}
const IMuonIdHelperSvc * m_idHelperSvc
const IMuonEDMHelperSvc * m_helperSvc

Member Function Documentation

◆ operator()() [1/2]

bool Muon::SortTSOSs::operator() ( const std::unique_ptr< const Trk::TrackStateOnSurface > & tsos1,
const std::unique_ptr< const Trk::TrackStateOnSurface > & tsos2 ) const
inline

Definition at line 141 of file SortMeasurementsByPosition.h.

142 {
143 return this->operator()(tsos1.get(), tsos2.get());
144 }
bool operator()(const Trk::TrackStateOnSurface *tsos1, const Trk::TrackStateOnSurface *tsos2) const

◆ operator()() [2/2]

bool Muon::SortTSOSs::operator() ( const Trk::TrackStateOnSurface * tsos1,
const Trk::TrackStateOnSurface * tsos2 ) const
inline

Definition at line 82 of file SortMeasurementsByPosition.h.

82 {
83 if (!tsos1->trackParameters()) {
84 std::cout << "Muon::SortTSOSs: state 1 without parameters " << std::endl;
85 return false;
86 }
87 if (!tsos2->trackParameters()) {
88 std::cout << "Muon::SortTSOSs: state 2 without parameters " << std::endl;
89 return true;
90 }
91 // first, address rare problems with funky track directions leading to strange orderings by checking for comparisons of calo
92 // deposits and MS hits
93 const Trk::MeasurementBase* meas1 = tsos1->measurementOnTrack();
94 Identifier id1 = meas1 ? m_helperSvc->getIdentifier(*meas1) : Identifier();
95
96 const Trk::MeasurementBase* meas2 = tsos2->measurementOnTrack();
97 Identifier id2 = meas2 ? m_helperSvc->getIdentifier(*meas2) : Identifier();
98
99 bool okId1 = id1.is_valid() && m_idHelperSvc->isMuon(id1) ? true : false;
100 bool okId2 = id2.is_valid() && m_idHelperSvc->isMuon(id2) ? true : false;
101
106 }
107
108 // get average direction of the 2 TSOSs
109 Amg::Vector3D trackDir = tsos1->trackParameters()->momentum().unit();
110 trackDir += tsos2->trackParameters()->momentum().unit();
111 const Amg::Vector3D& pos1 = tsos1->trackParameters()->position();
112 const Amg::Vector3D& pos2 = tsos2->trackParameters()->position();
113 double dist = (pos2 - pos1).dot(trackDir);
114
115 if (std::abs(dist) < 1e-5) {
116 // one is a good muon hit and one is not: good muon hit comes after
117 if (okId1 && !okId2) return true;
118 if (!okId1 && okId2) return false;
119 // both invalid or non-muon: consider them equal
120 if (!okId1 && !okId2) return false;
121 // now we have 2 valid muon Ids
122 bool measPhi1 = m_idHelperSvc->measuresPhi(id1);
123 bool measPhi2 = m_idHelperSvc->measuresPhi(id2);
124 // put phi measurement in front of eta measurements
125 if (measPhi1 && !measPhi2) return true;
126 if (!measPhi1 && measPhi2) return false;
127 // now both are phi or both are eta
128 // decide on identifier (increasing away from IP within same technology)
129 double inOrOut = (pos1 + pos2).dot(trackDir);
130 if (inOrOut >= 0.0) {
131 return id1 < id2;
132 } else {
133 return id1 > id2;
134 }
135
136 // if we get here, there was no decision
137 return false; // consider them equal
138 }
139 return dist > 0.;
140 }
HWIdentifier id2
bool is_valid() const
Check if id is in a valid state.
const Amg::Vector3D & momentum() const
Access method for the momentum.
const Amg::Vector3D & position() const
Access method for the position.
const MeasurementBase * measurementOnTrack() const
returns MeasurementBase const overload
const TrackParameters * trackParameters() const
return ptr to trackparameters const overload
bool type(const TrackStateOnSurfaceType type) const
Use this method to find out if the TSoS is of a certain type: i.e.
@ CaloDeposit
This TSOS contains a CaloEnergy object.
Eigen::Matrix< double, 3, 1 > Vector3D
dot(G, fn, nodesToHighlight=[])
Definition dot.py:5

Member Data Documentation

◆ m_helperSvc

const IMuonEDMHelperSvc* Muon::SortTSOSs::m_helperSvc

Definition at line 148 of file SortMeasurementsByPosition.h.

◆ m_idHelperSvc

const IMuonIdHelperSvc* Muon::SortTSOSs::m_idHelperSvc

Definition at line 149 of file SortMeasurementsByPosition.h.


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