ATLAS Offline Software
TRT_DriftCircleOnTrack.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // TRT_DriftCircleOnTrack.cxx, (c) ATLAS Detector software
8 
14 #include "TrkSurfaces/Surface.h"
16 
17 #include "GaudiKernel/MsgStream.h"
18 
19 #include <cassert>
20 #include <limits>
21 #include <memory>
22 #include <ostream>
23 #include <utility>
24 
26  const InDet::TRT_DriftCircle* RIO,
28  Amg::MatrixX&& errDriftRadius,
29  const IdentifierHash& idDE,
30  double predictedLocZ,
31  const Amg::Vector3D& predictedTrackDirection,
33  // call base class constructor
34  : Trk::RIO_OnTrack(std::move(driftRadius), std::move(errDriftRadius), RIO->identify())
35  , m_globalPosition{}
36  , m_positionAlongWire(predictedLocZ)
37  , m_idDE(idDE)
38  , m_status(status)
39  , m_highLevel(RIO->highLevel())
40  , m_timeOverThreshold(RIO->timeOverThreshold())
41  , m_detEl(RIO->detectorElement())
42 {
43 
44  m_rio.setElement(RIO);
45  const Trk::Surface& detElSurf = m_detEl->surface(RIO->identify());
46  if (detElSurf.type() == Trk::SurfaceType::Line) {
47  const Trk::StraightLineSurface& slsf =
48  static_cast<const Trk::StraightLineSurface&>(detElSurf);
49  m_globalPosition =
50  slsf.localToGlobal(m_localParams, predictedTrackDirection, predictedLocZ);
51  }
52  Amg::Vector3D loc_gDirection = predictedTrackDirection;
53  const double dr = m_localParams[Trk::driftRadius];
54 
55  // scaling the direction with drift radius
56  if (dr != 0.) {
57  m_localAngle = std::atan2(loc_gDirection.y(), loc_gDirection.x());
58  } else {
59  m_localAngle = 0.;
60  }
61 }
62 
63 //Constructor used by the converter
67  const Amg::MatrixX& errDriftRadius,
68  IdentifierHash idDE,
69  const Identifier& id,
70  double predictedLocZ,
71  float localAngle,
73  bool highLevel,
74  double timeOverThreshold)
75  : Trk::RIO_OnTrack(Trk::LocalParameters(driftRadius), Amg::MatrixX(errDriftRadius), id)
76  , m_globalPosition{}
77  , m_localAngle(localAngle)
78  , m_positionAlongWire(predictedLocZ)
79  , m_rio(RIO)
80  , m_idDE(idDE)
81  , m_status(status)
82  , m_highLevel(highLevel)
83  , m_timeOverThreshold(timeOverThreshold)
84  , m_detEl(nullptr)
85 {}
86 
87 // Destructor:
89 = default;
90 
91 // default constructor:
93  :
94  Trk::RIO_OnTrack(),
95  m_globalPosition{},
96  m_localAngle(std::numeric_limits<float>::quiet_NaN()),
97  m_positionAlongWire(std::numeric_limits<float>::quiet_NaN()),
98  m_rio(),
99  m_idDE(),
100  m_status(Trk::UNDECIDED),
101  m_highLevel(false),
102  m_timeOverThreshold(0.),
103  m_detEl(nullptr)
104 {}
105 
106 //copy constructor:
108 
109 = default;
110 
111 //assignment operator:
113 {
114  if ( &rot != this) {
117  m_rio = rot.m_rio;
120  m_idDE = rot.m_idDE;
121  m_status = rot.m_status;
122  m_highLevel = rot.m_highLevel;
124  m_detEl = rot.m_detEl;
125  }
126  return *this;
127 }
128 
129 //move assignment operator:
131  noexcept {
132  if ( &rot != this) {
134  m_globalPosition = std::move(rot.m_globalPosition);
135  m_rio = rot.m_rio;
136  m_localAngle = rot.m_localAngle;
137  m_positionAlongWire = rot.m_positionAlongWire;
138  m_idDE = rot.m_idDE;
139  m_status = rot.m_status;
140  m_highLevel = rot.m_highLevel;
141  m_timeOverThreshold = rot.m_timeOverThreshold;
142  m_detEl = rot.m_detEl;
143  }
144  return *this;
145 }
146 
148  if (m_status == Trk::UNDECIDED) return Trk::NONE;
149  if (localParameters()[Trk::driftRadius] < 0. ) return Trk::LEFT;
150  return Trk::RIGHT;
151 }
152 
153 
155 {
156  assert(0!=m_detEl);
157  return (m_detEl->surface(identify()));
158 }
159 
161 
162  return m_globalPosition;
163 }
164 
165 
166 //Global Position Helper for the converter
167 void
169 {
170 
171  //default
172  Amg::Vector3D loc3Dframe(0., 0., m_positionAlongWire);
173  if (side() != Trk::NONE) {
174  // get global position where track and drift radius intersect.
175  double Sf, Cf;
176  sincos(m_localAngle, &Sf, &Cf);
177  double x = localParameters()[Trk::driftRadius] * Sf;
178  double y = localParameters()[Trk::driftRadius] * Cf;
179  /*
180  double x = localParameters()[Trk::driftRadius]*std::sin(m_localAngle);
181  double y = localParameters()[Trk::driftRadius]*std::cos(m_localAngle);
182  */
183  // get local position
184  loc3Dframe = Amg::Vector3D(x, y, m_positionAlongWire);
185  }
186 
187  //We need a surface for the global position
188  const Trk::StraightLineSurface* slsf =
189  dynamic_cast<const Trk::StraightLineSurface*>(&(associatedSurface()));
190  if (slsf) {
191  m_globalPosition = Amg::Vector3D(slsf->transform() * loc3Dframe);
192  } else {
193  throw GaudiException("Dynamic_cast to StraightLineSurface failed!",
194  "TRT_DriftCircleOnTrack::setGlobalPosition()",
195  StatusCode::FAILURE);
196  }
197 }
198 
199 //set Values to be used by the converter
200 void
202  const Trk::PrepRawData*)
203 {
204  m_detEl = dynamic_cast<const InDetDD::TRT_BaseElement* >(detEl);
205  // If we have a m_detEL we can set the global position
206  if (m_detEl) {
208  }
209 }
210 
211 MsgStream& InDet::TRT_DriftCircleOnTrack::dump( MsgStream& sl ) const
212 {
214  std::string name("TRT_DriftCircleOnTrack: ");
215  sl <<name<< "\t identifier = "<< identify()<<endmsg;
216  sl <<name<< "\t time-over-threshold = " << timeOverThreshold()
217  << (highLevel() ? " with TR flag ON":" with TR flag OFF") << endmsg;
218  sl <<name<< "\t driftradius = ("
219  << (localParameters())[Trk::loc1] << ") " <<endmsg;
220  sl <<name<< "\t has Error Matrix: "<<endmsg;
221  sl<<localCovariance()<<endmsg;
222  return sl;
223 }
224 
225 std::ostream& InDet::TRT_DriftCircleOnTrack::dump( std::ostream& sl ) const
226 {
227  sl << "TRT_DriftCircleOnTrack {"<<std::endl;
228 
230 
231  sl << "Global position (x,y,z) = (";
232  this->globalPosition();
233  sl <<this->globalPosition().x()<<", "
234  <<this->globalPosition().y()<<", "
235  <<this->globalPosition().z()<<")"<<std::endl;
236 
237  sl << "\t time-over-threshold = " << timeOverThreshold()
238  << (highLevel() ? " with TR flag ON":" with TR flag OFF")<<std::endl;
239  sl<<"}"<<std::endl;
240 
241  return sl;
242 }
InDet::TRT_DriftCircleOnTrack::side
Trk::DriftCircleSide side() const
returns the side on which the drift radius is.
Definition: TRT_DriftCircleOnTrack.cxx:147
Trk::LocalParameters
Definition: LocalParameters.h:98
InDet::TRT_DriftCircleOnTrack::m_globalPosition
Amg::Vector3D m_globalPosition
global position to be cached
Definition: TRT_DriftCircleOnTrack.h:167
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
InDet::TRT_DriftCircleOnTrack::m_detEl
const InDetDD::TRT_BaseElement * m_detEl
corresponding detector element
Definition: TRT_DriftCircleOnTrack.h:191
Surface.h
Trk::DriftCircleStatus
DriftCircleStatus
Enumerates the 'status' of the wire on which the tracks passed (based on the TRT_Side enum,...
Definition: DriftCircleStatus.h:16
InDet::TRT_DriftCircleOnTrack::m_localAngle
float m_localAngle
local angle to be written out
Definition: TRT_DriftCircleOnTrack.h:170
InDet::TRT_DriftCircleOnTrack::associatedSurface
virtual const Trk::Surface & associatedSurface() const override final
returns the surface for the local to global transformation
Definition: TRT_DriftCircleOnTrack.cxx:154
xAOD::identify
Identifier identify(const UncalibratedMeasurement *meas)
Returns the associated identifier.
Definition: MuonSpectrometer/MuonPhaseII/Event/xAOD/xAODMuonPrepData/Root/UtilFunctions.cxx:61
InDet::TRT_DriftCircleOnTrack::highLevel
bool highLevel() const
returns true if the high level threshold was passed
Definition: TRT_DriftCircleOnTrack.h:234
Trk::TrkDetElementBase
Definition: TrkDetElementBase.h:52
InDet::TRT_DriftCircleOnTrack::TRT_DriftCircleOnTrack
TRT_DriftCircleOnTrack()
Default constructor - needed for POOL.
Definition: TRT_DriftCircleOnTrack.cxx:92
python.TurnDataReader.dr
dr
Definition: TurnDataReader.py:112
InDet::TRT_DriftCircleOnTrack
Definition: TRT_DriftCircleOnTrack.h:53
x
#define x
InDet::TRT_DriftCircle
Definition: TRT_DriftCircle.h:32
Trk::UNDECIDED
@ UNDECIDED
sign of drift radius has not been determined
Definition: DriftCircleStatus.h:20
InDet::TRT_DriftCircleOnTrack::m_rio
ElementLinkToIDCTRT_DriftCircleContainer m_rio
Definition: TRT_DriftCircleOnTrack.h:175
highLevel
bool highLevel(unsigned int m_word)
Definition: driftCircle.h:88
InDet::TRT_DriftCircleOnTrack::setGlobalPositionHelper
void setGlobalPositionHelper()
@calculate and set the global coord of this hit.
Definition: TRT_DriftCircleOnTrack.cxx:168
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
Trk::driftRadius
@ driftRadius
trt, straws
Definition: ParamDefs.h:53
Trk::RIGHT
@ RIGHT
the drift radius is positive (see Trk::AtaStraightLine)
Definition: DriftCircleSide.h:22
InDet::TRT_DriftCircleOnTrack::m_highLevel
bool m_highLevel
the high level flag
Definition: TRT_DriftCircleOnTrack.h:185
InDet::TRT_DriftCircleOnTrack::m_timeOverThreshold
double m_timeOverThreshold
the time over threshold in nsec
Definition: TRT_DriftCircleOnTrack.h:188
Trk::RIO_OnTrack::operator=
RIO_OnTrack & operator=(const RIO_OnTrack &rot)=default
Assignment operator.
TRT_DriftCircleOnTrack.h
TRT_DriftCircle.h
InDet::TRT_DriftCircleOnTrack::m_status
Trk::DriftCircleStatus m_status
the information how the (possibly signed) drift radius should be understood
Definition: TRT_DriftCircleOnTrack.h:182
Trk::MeasurementBase::localCovariance
const Amg::MatrixX & localCovariance() const
Interface method to get the localError.
Definition: MeasurementBase.h:138
Trk::PrepRawData
Definition: PrepRawData.h:62
TRT_BaseElement.h
InDet::TRT_DriftCircleOnTrack::timeOverThreshold
double timeOverThreshold() const
returns time over threshold in ns for valid digits; zero otherwise
Definition: TRT_DriftCircleOnTrack.h:239
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
Amg
Definition of ATLAS Math & Geometry primitives (Amg)
Definition: AmgStringHelpers.h:19
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:220
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
RIO_OnTrack.h
Trk::StraightLineSurface::localToGlobal
virtual void localToGlobal(const Amg::Vector2D &locp, const Amg::Vector3D &mom, Amg::Vector3D &glob) const override final
Specified for StraightLineSurface: LocalToGlobal method without dynamic memory allocation.
Definition: StraightLineSurface.cxx:139
InDet::TRT_DriftCircleOnTrack::~TRT_DriftCircleOnTrack
virtual ~TRT_DriftCircleOnTrack()
Destructor.
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
LocalParameters.h
Trk::MeasurementBaseType::RIO_OnTrack
@ RIO_OnTrack
Definition: MeasurementBase.h:49
Trk::MeasurementBase::localParameters
const LocalParameters & localParameters() const
Interface method to get the LocalParameters.
Definition: MeasurementBase.h:132
Trk::DriftCircleSide
DriftCircleSide
Enumerates the 'side' of the wire on which the tracks passed (i.e.
Definition: DriftCircleSide.h:16
y
#define y
InDet::TRT_DriftCircleOnTrack::setValues
virtual void setValues(const Trk::TrkDetElementBase *detEl, const Trk::PrepRawData *prd) override final
ONLY for use in custom convertor Allows the custom convertor to reset values when persistying/reading...
Definition: TRT_DriftCircleOnTrack.cxx:201
InDet::TRT_DriftCircleOnTrack::m_idDE
IdentifierHash m_idDE
the IdentifierHash - probably not used
Definition: TRT_DriftCircleOnTrack.h:178
Trk::RIO_OnTrack::identify
Identifier identify() const
return the identifier -extends MeasurementBase
Definition: RIO_OnTrack.h:152
timeOverThreshold
double timeOverThreshold(unsigned int m_word)
Definition: driftCircle.h:116
Trk::LEFT
@ LEFT
the drift radius is negative (see Trk::AtaStraightLine)
Definition: DriftCircleSide.h:20
merge.status
status
Definition: merge.py:17
InDet::TRT_DriftCircleOnTrack::operator=
TRT_DriftCircleOnTrack & operator=(const TRT_DriftCircleOnTrack &)
Assignment operator.
Definition: TRT_DriftCircleOnTrack.cxx:112
InDet::TRT_DriftCircleOnTrack::m_positionAlongWire
float m_positionAlongWire
local position along wire to be written out
Definition: TRT_DriftCircleOnTrack.h:173
InDet::TRT_DriftCircleOnTrack::dump
virtual MsgStream & dump(MsgStream &out) const override final
returns some information about this RIO_OnTrack.
Definition: TRT_DriftCircleOnTrack.cxx:211
InDet::TRT_DriftCircleOnTrack::globalPosition
virtual const Amg::Vector3D & globalPosition() const override final
return the global position of this RIO_OnTrack
Definition: TRT_DriftCircleOnTrack.cxx:160
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
Trk::SurfaceType::Line
@ Line
Trk::loc1
@ loc1
Definition: ParamDefs.h:34
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:75
Trk::Surface::transform
const Amg::Transform3D & transform() const
Returns HepGeom::Transform3D by reference.
InDetDD::TRT_BaseElement::surface
virtual const Trk::Surface & surface() const override final
Element Surface: access to the Surface (straw layer)
Trk::Surface::type
constexpr virtual SurfaceType type() const =0
Returns the Surface type to avoid dynamic casts.
Trk::StraightLineSurface
Definition: StraightLineSurface.h:51
InDetDD::TRT_BaseElement
Definition: TRT_BaseElement.h:57
Identifier
Definition: IdentifierFieldParser.cxx:14