ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
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) {}

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  }

◆ 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 
102  if (tsos1->type(Trk::TrackStateOnSurface::TrackStateOnSurfaceType::CaloDeposit) ||
103  tsos2->type(Trk::TrackStateOnSurface::TrackStateOnSurfaceType::CaloDeposit)) {
104  if (okId1 && tsos2->type(Trk::TrackStateOnSurface::TrackStateOnSurfaceType::CaloDeposit)) return false;
105  if (tsos1->type(Trk::TrackStateOnSurface::TrackStateOnSurfaceType::CaloDeposit) && okId2) return true;
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  }

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:
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
Trk::TrackStateOnSurface::trackParameters
const TrackParameters * trackParameters() const
return ptr to trackparameters const overload
Muon::IMuonIdHelperSvc::isMuon
virtual bool isMuon(const Identifier &id) const =0
returns whether this is a Muon Identifier or not
Muon::IMuonEDMHelperSvc::getIdentifier
virtual Identifier getIdentifier(const Trk::MeasurementBase &meas) const =0
tries to get Identifier for measurement, if not possible it will return Identifier()
Muon::SortTSOSs::operator()
bool operator()(const Trk::TrackStateOnSurface *tsos1, const Trk::TrackStateOnSurface *tsos2) const
Definition: SortMeasurementsByPosition.h:82
Muon::SortTSOSs::m_idHelperSvc
const IMuonIdHelperSvc * m_idHelperSvc
Definition: SortMeasurementsByPosition.h:149
Trk::ParametersBase::position
const Amg::Vector3D & position() const
Access method for the position.
Trk::TrackStateOnSurface::measurementOnTrack
const MeasurementBase * measurementOnTrack() const
returns MeasurementBase const overload
Muon::IMuonIdHelperSvc::measuresPhi
virtual bool measuresPhi(const Identifier &id) const =0
returns whether channel measures phi or not
Identifier::is_valid
bool is_valid() const
Check if id is in a valid state.
Muon::SortTSOSs::m_helperSvc
const IMuonEDMHelperSvc * m_helperSvc
Definition: SortMeasurementsByPosition.h:148
Trk::TrackStateOnSurface::type
bool type(const TrackStateOnSurfaceType type) const
Use this method to find out if the TSoS is of a certain type: i.e.
id2
HWIdentifier id2
Definition: LArRodBlockPhysicsV0.cxx:562
dot.dot
def dot(G, fn, nodesToHighlight=[])
Definition: dot.py:5
Trk::MeasurementBase
Definition: MeasurementBase.h:58
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Trk::ParametersBase::momentum
const Amg::Vector3D & momentum() const
Access method for the momentum.
h
Identifier
Definition: IdentifierFieldParser.cxx:14