Loading [MathJax]/jax/output/SVG/config.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
MdtCalibInput.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
5 
6 #include "GaudiKernel/PhysicalConstants.h"
8 
19 #include <GeoModelKernel/throwExcept.h>
20 
21 std::ostream& operator<<(std::ostream& ostr, const MdtCalibInput& input){
22  ostr<<"adc: "<<input.adc()<<", ";
23  ostr<<"tdc: "<<input.tdc()<<", ";
24  ostr<<"closest approach: "<<Amg::toString(input.closestApproach(), 2)<<", ";
25  ostr<<"global direction: "<<Amg::toString(input.trackDirection(), 2)<<", ";
26  ostr<<"prop distance: "<<input.signalPropagationDistance()<<", ";
27  ostr<<"ToF: "<<input.timeOfFlight()<<", ";
28  ostr<<"trigger time: "<<input.triggerTime();
29  return ostr;
30 }
33  const int16_t adc,
34  const int16_t tdc,
35  const MuonGMR4::MdtReadoutElement* reEle,
36  const ActsGeometryContext& gctx):
37  m_id{id},
38  m_adc{adc},
39  m_tdc{tdc},
40  m_gctx{&gctx},
41  m_RE{reEle},
42  m_hash{std::get<const MuonGMR4::MdtReadoutElement*>(m_RE)->measurementHash(m_id)} {}
43 
45  const MuonGMR4::MuonDetectorManager& detMgr,
46  const ActsGeometryContext& gctx):
48  detMgr.getMdtReadoutElement(digit.identify()), gctx){}
49 
51  const int16_t adc,
52  const int16_t tdc,
53  const MuonGM::MdtReadoutElement* reEle):
54  m_id{id},
55  m_adc{adc},
56  m_tdc{tdc},
57  m_RE{reEle} {}
58 
60  const MuonGM::MuonDetectorManager& detMgr):
62  detMgr.getMdtReadoutElement(digit.identify())) {}
63 
64 
66  const ActsGeometryContext& gctx):
67  m_id{prd.identify()},
68  m_adc{prd.adc()},
69  m_tdc{prd.tdc()},
70  m_gctx{&gctx},
71  m_RE{prd.readoutElement()},
72  m_hash{prd.measurementHash()},
73  m_approach{localToGlobal()* prd.localCirclePosition()} {}
74 
75 
77  m_id{prd.identify()},
78  m_adc{static_cast<int16_t>(prd.adc())},
79  m_tdc{static_cast<int16_t>(prd.tdc())},
80  m_RE{prd.detectorElement()},
81  m_approach{prd.globalPosition()} {
82 }
83 
84 const Identifier& MdtCalibInput::identify() const { return m_id; }
85 int16_t MdtCalibInput::tdc() const{ return m_tdc; }
86 int16_t MdtCalibInput::adc() const{ return m_adc; }
88  return std::visit([](const auto& re) -> const MuonGM::MdtReadoutElement*{
89  using REType = std::decay_t<decltype(re)>;
90  if constexpr( std::is_same_v<REType, const MuonGM::MdtReadoutElement*>){
91  return re;
92  }
93  return nullptr;
94  }, m_RE);
95 }
97  return std::visit([](const auto& re) -> const MuonGMR4::MdtReadoutElement*{
98  using REType = std::decay_t<decltype(re)>;
99  if constexpr( std::is_same_v<REType, const MuonGMR4::MdtReadoutElement*>){
100  return re;
101  }
102  return nullptr;
103  }, m_RE);
104 }
107  m_approach = approach;
108 }
110 void MdtCalibInput::setTrackDirection(const Amg::Vector3D& trackDir, bool hasPhi) {
111  m_trackDir = trackDir;
112  m_trackHasPhi = hasPhi;
113 }
115 double MdtCalibInput::timeOfFlight() const { return m_ToF; }
116 void MdtCalibInput::setTimeOfFlight(const double toF) { m_ToF = toF; }
117 
118 double MdtCalibInput::triggerTime() const { return m_trigTime; }
119 void MdtCalibInput::setTriggerTime(const double trigTime) { m_trigTime = trigTime; }
120 
122  return legacyDescriptor()->surface(identify()).center();
123 }
124 
126  const Amg::Transform3D trf{localToGlobal().inverse()};
128  const Amg::Vector3D locBField = trf.linear() * fieldInGlob;
130  const Amg::Vector3D locTrkDir = trf.linear() * trackDirection();
131 
132  const double perpendComp = locTrkDir.block<2,1>(0,0).dot(locBField.block<2,1>(0,0))
133  / locTrkDir.perp();
134  const double paralelComp = locBField.z();
136  return 1000. * Amg::Vector2D{paralelComp, perpendComp};
137 }
140  assert(re != nullptr);
141  return re->surface(identify());
142 }
144  const double propDist = std::visit([this](const auto& re) ->double {
145  using REType = std::decay_t<decltype(re)>;
146  if constexpr(std::is_same_v<REType, const MuonGMR4::MdtReadoutElement*>){
147  assert(m_gctx != nullptr);
148  return re->distanceToReadout(*m_gctx, m_hash, closestApproach());
149  } else if (std::is_same_v<REType, const MuonGM::MdtReadoutElement*>) {
150  return re->distanceFromRO(closestApproach(), identify()) -
151  re->RODistanceFromTubeCentre(identify());
152  }
153  }, m_RE);
154  return propDist;
155 }
157 
159  const double tubeLength = std::visit([this](const auto& re) ->double{
160  using REType = std::decay_t<decltype(re)>;
161  if constexpr(std::is_same_v<REType, const MuonGMR4::MdtReadoutElement*>){
162  return re->tubeLength(m_hash);
163  } else if (std::is_same_v<REType, const MuonGM::MdtReadoutElement*>) {
164  return re->tubeLength(identify());
165  }
166  }, m_RE);
167  return tubeLength;
168  }
171  const double roSide = std::visit([this](const auto& re) ->double{
172  using REType = std::decay_t<decltype(re)>;
173  if constexpr(std::is_same_v<REType, const MuonGMR4::MdtReadoutElement*>){
174  return re->getParameters().readoutSide;
175  } else if (std::is_same_v<REType, const MuonGM::MdtReadoutElement*>) {
176  return re->tubeFrame_localROPos(identify()).z() > 0. ? 1. : -1.;
177  }
178  }, m_RE);
179  return roSide;
180 }
182  return std::visit([this](const auto& re) ->const Amg::Transform3D&{
183  using REType = std::decay_t<decltype(re)>;
184  if constexpr(std::is_same_v<REType, const MuonGMR4::MdtReadoutElement*>){
185  assert(m_gctx != nullptr);
186  return re->localToGlobalTrans(*m_gctx, m_hash);
187  } else if (std::is_same_v<REType, const MuonGM::MdtReadoutElement*>) {
188  return re->localToGlobalTransf(identify());
189  }
190  }, m_RE);
191 }
193  return localToGlobal().translation();
194 }
MdtCalibInput::distanceToTrack
double distanceToTrack() const
Returns the distance to track (signed)
Definition: MdtCalibInput.cxx:156
MdtCalibInput::m_trackDir
Amg::Vector3D m_trackDir
Global track direction.
Definition: MdtCalibInput.h:166
MdtCalibInput::setTrackDirection
void setTrackDirection(const Amg::Vector3D &trackDir, bool hasPhi)
Sets the direction of the externally determined track.
Definition: MdtCalibInput.cxx:110
MdtCalibInput::surfaceCenter
const Amg::Vector3D & surfaceCenter() const
Returns the center of the associated surface.
Definition: MdtCalibInput.cxx:121
MdtReadoutElement.h
xAOD::identify
const Identifier & identify(const UncalibratedMeasurement *meas)
Returns the associated identifier from the muon measurement.
Definition: MuonSpectrometer/MuonPhaseII/Event/xAOD/xAODMuonPrepData/Root/UtilFunctions.cxx:87
MdtCalibInput::decriptor
const MuonGMR4::MdtReadoutElement * decriptor() const
Returns the R4 readout element.
Definition: MdtCalibInput.cxx:96
MdtCalibInput::m_trackHasPhi
bool m_trackHasPhi
Does the track direction contain a phi constraint.
Definition: MdtCalibInput.h:168
MdtCalibInput.h
StraightLineSurface.h
MuonGMR4::MuonDetectorManager
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MuonDetectorManager.h:62
MdtCalibInput
Definition: MdtCalibInput.h:34
MdtCalibInput::trackDirHasPhi
bool trackDirHasPhi() const
Returns whether the track has a phi constaint or not.
Definition: MdtCalibInput.cxx:114
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
MdtDigit
Definition: MdtDigit.h:19
MdtCalibInput::triggerTime
double triggerTime() const
Returns the trigger offset time.
Definition: MdtCalibInput.cxx:118
MdtCalibInput::legacySurface
const Trk::StraightLineSurface & legacySurface() const
Returns the assocaited ideal surface (Throw exception if no legacy RE is available)
Definition: MdtCalibInput.cxx:138
MdtCalibInput::legacyDescriptor
const MuonGM::MdtReadoutElement * legacyDescriptor() const
Returns the legacy readout element.
Definition: MdtCalibInput.cxx:87
MdtCalibInput::~MdtCalibInput
~MdtCalibInput()
xAOD::MdtDriftCircle_v1::identify
const Identifier & identify() const
: Returns the Athena identifier of the drift circle.
Definition: MdtDriftCircle_v1.cxx:39
MdtCalibInput::closestApproach
const Amg::Vector3D & closestApproach() const
Returns the point of closest approach to the wire.
Definition: MdtCalibInput.cxx:105
MdtDigit.h
MdtPrepData.h
MdtCalibInput::m_approach
Amg::Vector3D m_approach
Point of closest approach of the track.
Definition: MdtCalibInput.h:164
checkRpcDigits.digit
digit
Definition: checkRpcDigits.py:186
Trk::Surface::center
const Amg::Vector3D & center() const
Returns the center position of the Surface.
xAOD::int16_t
setScaleOne setStatusOne setSaturated int16_t
Definition: gFexGlobalRoI_v1.cxx:55
MdtCalibInput::identify
const Identifier & identify() const
Returns the Identifier of the hit.
Definition: MdtCalibInput.cxx:84
MdtCalibInput::m_ToF
double m_ToF
Definition: MdtCalibInput.h:171
MdtCalibInput::m_hash
IdentifierHash m_hash
Measurement hash of the Identifier (needed for Phase II)
Definition: MdtCalibInput.h:162
MdtCalibInput::localToGlobal
const Amg::Transform3D & localToGlobal() const
set whether the
Definition: MdtCalibInput.cxx:181
MdtCalibInput::center
Amg::Vector3D center() const
Translational part of the local -> global transform.
Definition: MdtCalibInput.cxx:192
MdtCalibInput::m_tdc
int16_t m_tdc
Tdc counts of the hit.
Definition: MdtCalibInput.h:153
Amg::toString
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Definition: GeoPrimitivesToStringConverter.h:40
MuonGM::MdtReadoutElement
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MdtReadoutElement.h:51
MdtCalibInput::m_gctx
const ActsGeometryContext * m_gctx
Geometry context, needed to fetch the alignment.
Definition: MdtCalibInput.h:156
MdtCalibInput::tubeLength
double tubeLength() const
Returns the tube length.
Definition: MdtCalibInput.cxx:158
MdtCalibInput::m_trigTime
double m_trigTime
Trigger time.
Definition: MdtCalibInput.h:173
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
MuonDetectorManager.h
MdtCalibInput::m_distToTrack
double m_distToTrack
Distance to track (signed)
Definition: MdtCalibInput.h:175
MdtCalibInput::setClosestApproach
void setClosestApproach(const Amg::Vector3D &approach)
Sets the closest approach.
Definition: MdtCalibInput.cxx:106
MdtCalibInput::signalPropagationDistance
double signalPropagationDistance() const
Calculates the distance that the signal has to travel along the wire.
Definition: MdtCalibInput.cxx:143
dot.dot
def dot(G, fn, nodesToHighlight=[])
Definition: dot.py:5
ActsGeometryContext
Include the GeoPrimitives which need to be put first.
Definition: ActsGeometryContext.h:27
MdtDriftCircle.h
Trk::PrepRawData::identify
Identifier identify() const
return the identifier
MdtCalibInput::setTimeOfFlight
void setTimeOfFlight(const double toF)
Sets the time of flight (Usually globPos.mag() * inverseSpeed of light)
Definition: MdtCalibInput.cxx:116
MuonGMR4::MdtReadoutElement
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MdtReadoutElement.h:22
MdtCalibInput::m_RE
ReadoutEle_t m_RE
Pointer to the associated readout element.
Definition: MdtCalibInput.h:160
MdtCalibInput::setTriggerTime
void setTriggerTime(const double trigTime)
Sets the trigger offset time.
Definition: MdtCalibInput.cxx:119
Muon::MdtPrepData
Class to represent measurements from the Monitored Drift Tubes.
Definition: MdtPrepData.h:33
MdtCalibInput::adc
int16_t adc() const
Returns the amount of accumulated charge.
Definition: MdtCalibInput.cxx:86
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
MuonDetectorManager.h
ReadFloatFromCool.adc
adc
Definition: ReadFloatFromCool.py:48
MdtCalibInput::m_adc
int16_t m_adc
Adc counts of the hit.
Definition: MdtCalibInput.h:151
MuonGM::MuonDetectorManager
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonDetectorManager.h:50
MdtReadoutElement.h
operator<<
std::ostream & operator<<(std::ostream &ostr, const MdtCalibInput &input)
Definition: MdtCalibInput.cxx:21
re
const boost::regex re(r_e)
MuonGM::MdtReadoutElement::surface
virtual const Trk::Surface & surface() const override final
Return surface associated with this detector element.
Definition: MuonDetDescr/MuonReadoutGeometry/src/MdtReadoutElement.cxx:885
GeoPrimitivesToStringConverter.h
MdtCalibInput::projectMagneticField
Amg::Vector2D projectMagneticField(const Amg::Vector3D &fieldInGlob) const
Splits the B-field into the components that point along the transverse track direction & along the tu...
Definition: MdtCalibInput.cxx:125
MdtCalibInput::m_id
Identifier m_id
Tube identifier.
Definition: MdtCalibInput.h:149
CaloLCW_tf.trf
trf
Definition: CaloLCW_tf.py:20
xAOD::MdtDriftCircle_v1
https://gitlab.cern.ch/atlas/athena/-/blob/master/MuonSpectrometer/MuonReconstruction/MuonRecEvent/Mu...
Definition: MdtDriftCircle_v1.h:21
MdtCalibInput::trackDirection
const Amg::Vector3D & trackDirection() const
Returns the track direction (Can be zero)
Definition: MdtCalibInput.cxx:109
MdtCalibInput::tdc
int16_t tdc() const
Returns the tdc counts of the hit.
Definition: MdtCalibInput.cxx:85
MdtCalibInput::timeOfFlight
double timeOfFlight() const
Returns the time of flight.
Definition: MdtCalibInput.cxx:115
MdtCalibInput::readOutSide
double readOutSide() const
Returns the sign of the readout position in local coordinates.
Definition: MdtCalibInput.cxx:169
Trk::StraightLineSurface
Definition: StraightLineSurface.h:51
MdtCalibInput::MdtCalibInput
MdtCalibInput(const Identifier &id, const int16_t adc, const int16_t tdc, const MuonGMR4::MdtReadoutElement *reEle, const ActsGeometryContext &gctx)
Minimal constructor in the PhaseII geomerty setup.
Definition: MdtCalibInput.cxx:32
Identifier
Definition: IdentifierFieldParser.cxx:14