ATLAS Offline Software
MdtDriftCircleOnTrack.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
9 #include "GaudiKernel/GaudiException.h"
10 #include "GaudiKernel/StatusCode.h"
11 #include <cmath>
12 
13 
14 // Full Constructor :
15 namespace Muon{
17  Trk::LocalParameters&& locPos,
18  Amg::MatrixX&& errDriftRadius,
19  const double driftTime,
21  const Amg::Vector3D& predictedTrackDirection,
22  const double positionAlongWire,
23  const MuonDriftCircleErrorStrategy& errorStrategy) :
24  Trk::RIO_OnTrack{std::move(locPos), std::move(errDriftRadius), RIO->identify()},
25  m_status{status},
26  m_positionAlongWire{positionAlongWire},
27  m_driftTime{driftTime},
28  m_errorStrategy{errorStrategy} {
29 
30  assert(m_status!=Trk::UNDECIDED); // use of this constructor implies that the side is decided
31 
32  m_rio.setElement(RIO);
33  m_globalPosition.store(std::make_unique<Amg::Vector3D>(associatedSurface().localToGlobal(m_localParams, predictedTrackDirection, positionAlongWire)));
34 
35  Amg::Vector3D loc_gDirection = predictedTrackDirection;
36 
38  if(driftRadius() > std::numeric_limits<float>::epsilon()) {
39  // Set loc_gDirection's perpendicular distance equal to driftRadius
40  Amg::setPerp(loc_gDirection, std::abs(driftRadius()));
41  const double ratio = loc_gDirection.x() / std::abs(driftRadius());
42  const double calc_angle = std::abs(ratio) >= 1. ? M_PI * (ratio < 0.) : std::acos(ratio);
43  m_localAngle = (loc_gDirection.y()<0.) ? 2*M_PI - calc_angle : calc_angle;
44  }
45 }
46 
47 // Partial Constructor :
49  Trk::LocalParameters&& locPos,
50  Amg::MatrixX&& errDriftRadius,
51  const double driftTime,
53  const double positionAlongWire,
54  const MuonDriftCircleErrorStrategy& errorStrategy) :
55  Trk::RIO_OnTrack{std::move(locPos), std::move(errDriftRadius), RIO->identify()},
56  m_status{status},
57  m_positionAlongWire{positionAlongWire},
58  m_driftTime{driftTime},
59  m_errorStrategy{errorStrategy} {
60  assert(m_status!=Trk::DECIDED); // use of this constructor implies that the side is not decided
61  m_rio.setElement(RIO);
62 }
63 
65  Trk::RIO_OnTrack{ other },
66  m_status{other.m_status},
67  m_rio{other.m_rio},
68  m_localAngle{other.m_localAngle},
69  m_positionAlongWire{other.m_positionAlongWire},
70  m_driftTime{other.m_driftTime},
71  m_errorStrategy{other.m_errorStrategy},
72  m_detEl{other.m_detEl} {
73 }
75  Trk::LocalParameters&& locPos,
76  Amg::MatrixX&& errDriftRadius,
77  const Identifier& id,
78  const MuonGM::MdtReadoutElement* detEl,
79  const double driftTime,
81  const double positionAlongWire,
82  const double localAngle,
83  const MuonDriftCircleErrorStrategy& errorStrategy):
84  Trk::RIO_OnTrack{std::move(locPos), std::move(errDriftRadius), id},
85  m_status{status},
86  m_rio{RIO},
87  m_localAngle{localAngle},
88  m_positionAlongWire{positionAlongWire},
89  m_driftTime{driftTime},
90  m_errorStrategy{errorStrategy},
91  m_detEl{detEl} {}
92 
93 
95  if (&other != this){
96  static_cast<Trk::RIO_OnTrack&>(*this) = other;
97  m_status = other.m_status;
98  m_rio = other.m_rio;
99  m_localAngle = other.m_localAngle;
100  m_driftTime = other.m_driftTime;
101  m_errorStrategy = other.m_errorStrategy;
102  m_positionAlongWire = other.m_positionAlongWire;
103  m_detEl = other.m_detEl;
104  m_globalPosition.release();
105  }
106  return *this;
107 }
109  if (!m_globalPosition) {
110  if (side()==Trk::NONE) {
111  // side not defined, so we cannot determine the global position better than the position along the wire
112  Amg::Vector3D loc3Dframe = m_positionAlongWire * Amg::Vector3D::UnitZ();
113  setGlobalPosition(std::move(loc3Dframe));
114  } else {
115  // get global position where track and drift radius intersect.
116  double x = driftRadius()*std::sin(m_localAngle);
117  double y = driftRadius()*std::cos(m_localAngle);
118  Amg::Vector3D loc3Dframe(x, y, m_positionAlongWire);
119  setGlobalPosition(std::move(loc3Dframe));
120  }
121  }
122  return *m_globalPosition;
123 }
124 
126  Amg::Vector3D globPos = associatedSurface().transform() * loc3Dframe;
127  m_globalPosition.set(std::make_unique<Amg::Vector3D>(std::move(globPos)));
128 }
129 
130 MsgStream& MdtDriftCircleOnTrack::dump( MsgStream& stream) const
131 {
132  stream << MSG::INFO<<"MdtDriftCircleOnTrack {"<<std::endl;
134  stream << "DriftTime: "<<m_driftTime<<std::endl;
135  stream << "Status: "<<m_status<<std::endl;
136  stream << "Global position (x,y,z) = ";
137  stream << Amg::toString(globalPosition(),2)<<std::endl;
138 
139  stream << "Position along wire: "<<positionAlongWire()<<", \tlocal angle="<<localAngle()<<std::endl;
140  stream << "Creation strategy: "<<m_errorStrategy;
141  stream<<"}"<<endmsg;
142  return stream;
143 }
144 
145 std::ostream& MdtDriftCircleOnTrack::dump( std::ostream& stream) const
146 {
147  stream << "MdtDriftCircleOnTrack {"<<std::endl;
149  stream << "DriftTime: "<<m_driftTime<<std::endl;
150  stream << "Status: "<<m_status<<std::endl;
151 
152  stream << "Position along wire: "<<positionAlongWire()<<", \tlocal angle="<<localAngle()<<std::endl;
153  // stream << "Creation strategy: "<<m_errorStrategy; //FIXME!
154  stream<<"}"<<std::endl;
155  return stream;
156 }
157 
158 }
159 
Trk::LocalParameters
Definition: LocalParameters.h:98
Muon::MuonDriftCircleErrorStrategy
Definition: MuonDriftCircleErrorStrategy.h:15
Trk::RIO_OnTrack::dump
virtual MsgStream & dump(MsgStream &out) const override
returns the some information about this RIO_OnTrack.
Definition: RIO_OnTrack.cxx:32
Trk::NONE
@ NONE
it was not possible to determine the which side of the straw the track passed;
Definition: DriftCircleSide.h:18
Amg::MatrixX
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Definition: EventPrimitives.h:27
StraightLineSurface.h
Muon::MdtDriftCircleOnTrack::m_detEl
const MuonGM::MdtReadoutElement * m_detEl
Definition: MdtDriftCircleOnTrack.h:241
Trk::DriftCircleStatus
DriftCircleStatus
Enumerates the 'status' of the wire on which the tracks passed (based on the TRT_Side enum,...
Definition: DriftCircleStatus.h:16
Muon::MdtDriftCircleOnTrack::dump
virtual MsgStream & dump(MsgStream &stream) const override final
Dumps information about the PRD.
Definition: MdtDriftCircleOnTrack.cxx:130
M_PI
#define M_PI
Definition: ActiveFraction.h:11
Muon::MdtDriftCircleOnTrack::operator=
MdtDriftCircleOnTrack & operator=(const MdtDriftCircleOnTrack &)
Definition: MdtDriftCircleOnTrack.cxx:94
Trk::RIO_OnTrack
Definition: RIO_OnTrack.h:70
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
MdtDriftCircleOnTrack.h
Muon
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
Definition: TrackSystemController.h:45
Muon::MdtDriftCircleOnTrack::m_rio
ElementLinkToIDC_MDT_Container m_rio
the pointer to the MdtPrepData object (mutable because it might need to be recreated when reading tra...
Definition: MdtDriftCircleOnTrack.h:223
x
#define x
AthenaPoolTestWrite.stream
string stream
Definition: AthenaPoolTestWrite.py:12
Muon::MdtDriftCircleOnTrack::globalPosition
virtual const Amg::Vector3D & globalPosition() const override final
Returns the global Position.
Definition: MdtDriftCircleOnTrack.cxx:108
Trk::UNDECIDED
@ UNDECIDED
sign of drift radius has not been determined
Definition: DriftCircleStatus.h:20
Muon::MdtDriftCircleOnTrack::m_localAngle
double m_localAngle
This angle is the position of the point of closest approach in cylindrical coordinates,...
Definition: MdtDriftCircleOnTrack.h:229
Muon::MdtDriftCircleOnTrack::side
Trk::DriftCircleSide side() const
Returns the side on which the drift radius is wrt to the track.
Definition: MdtDriftCircleOnTrack.h:249
Amg::toString
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Definition: GeoPrimitivesToStringConverter.h:40
TRT::Hit::driftTime
@ driftTime
Definition: HitInfo.h:43
MuonGM::MdtReadoutElement
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MdtReadoutElement.h:51
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
Trk::driftRadius
@ driftRadius
trt, straws
Definition: ParamDefs.h:53
Muon::MdtDriftCircleOnTrack::m_positionAlongWire
double m_positionAlongWire
This is the position of the point of closest approach, in the local z coord (i.e.
Definition: MdtDriftCircleOnTrack.h:232
Muon::MdtDriftCircleOnTrack::localAngle
double localAngle() const
Returns the local angle, as determined by the extrapolation used when creating this Trk::RIO_OnTrack.
Definition: MdtDriftCircleOnTrack.h:282
Muon::MdtDriftCircleOnTrack::positionAlongWire
double positionAlongWire() const
Returns the position along the wire, as determined by the extrapolation used when creating this Trk::...
Definition: MdtDriftCircleOnTrack.h:281
Muon::MdtDriftCircleOnTrack::driftRadius
double driftRadius() const
Returns the value of the drift radius.
Definition: MdtDriftCircleOnTrack.h:277
Muon::MdtDriftCircleOnTrack::m_status
Trk::DriftCircleStatus m_status
information on the status of the Mdt measurement - see Trk::DriftCircleStatus for definitions
Definition: MdtDriftCircleOnTrack.h:220
Muon::MdtDriftCircleOnTrack::m_globalPosition
CxxUtils::CachedUniquePtr< Amg::Vector3D > m_globalPosition
global position of the measurement.
Definition: MdtDriftCircleOnTrack.h:226
Trk::DECIDED
@ DECIDED
sign of drift radius has been determined
Definition: DriftCircleStatus.h:18
Amg::setPerp
void setPerp(Amg::Vector3D &v, double perp)
scales the vector in the xy plane without changing the z coordinate nor the angles
Definition: GeoPrimitivesHelpers.h:94
Trk::PrepRawData::identify
Identifier identify() const
return the identifier
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
RIO_OnTrack.h
Muon::MdtDriftCircleOnTrack
This class represents the corrected MDT measurements, where the corrections include the effects of wi...
Definition: MdtDriftCircleOnTrack.h:37
Muon::MdtPrepData
Class to represent measurements from the Monitored Drift Tubes.
Definition: MdtPrepData.h:33
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
LocalParameters.h
Trk::MeasurementBaseType::RIO_OnTrack
@ RIO_OnTrack
Definition: MeasurementBase.h:49
Muon::MdtDriftCircleOnTrack::setGlobalPosition
void setGlobalPosition(Amg::Vector3D &&loc3Dframe) const
Uses the passed loc3Dframe to calculate and set the global coord of this hit.
Definition: MdtDriftCircleOnTrack.cxx:125
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
y
#define y
python.compareTCTs.ratio
ratio
Definition: compareTCTs.py:295
Muon::MdtDriftCircleOnTrack::associatedSurface
virtual const Trk::StraightLineSurface & associatedSurface() const override final
Returns the surface on which this measurement was taken.
Definition: MdtDriftCircleOnTrack.h:271
GeoPrimitivesHelpers.h
merge.status
status
Definition: merge.py:17
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
Muon::MdtDriftCircleOnTrack::m_driftTime
double m_driftTime
This is the drift time used to obtain the drift radius.
Definition: MdtDriftCircleOnTrack.h:235
Muon::MdtDriftCircleOnTrack::MdtDriftCircleOnTrack
MdtDriftCircleOnTrack()=default
Default ctor - for use by POOL only.
Trk::Surface::transform
const Amg::Transform3D & transform() const
Returns HepGeom::Transform3D by reference.
Muon::MdtDriftCircleOnTrack::m_errorStrategy
MuonDriftCircleErrorStrategy m_errorStrategy
Records information about the 'strategy' used by Muon::MdtDriftCircleOnTrackCreator to make this obje...
Definition: MdtDriftCircleOnTrack.h:238
Identifier
Definition: IdentifierFieldParser.cxx:14