ATLAS Offline Software
Loading...
Searching...
No Matches
MdtCalibInput.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
5
6#include "GaudiKernel/PhysicalConstants.h"
8
19#include <GeoModelKernel/throwExcept.h>
20
21#include <cassert>
22
23namespace {
24 static constexpr double s_inverseSpeed{1. / Gaudi::Units::c_light};
25}
26
27void MdtCalibInput::print(std::ostream& ostr) const {
28 ostr<<"adc: "<<adc()<<", ";
29 ostr<<"tdc: "<<tdc()<<", ";
30 if (m_approach.isValid()) {
31 ostr<<"closest approach: "<<Amg::toString(closestApproach(), 2)<<", ";
32 }
33 ostr<<"global direction: "<<Amg::toString(trackDirection(), 2)<<", ";
34 ostr<<"prop distance: "<<signalPropagationDistance()<<", ";
35 if (m_ToF.isValid()) {
36 ostr<<"ToF: "<<timeOfFlight()<<", ";
37 }
38 ostr<<"trigger time: "<<triggerTime();
39
40}
43 const int16_t adc,
44 const int16_t tdc,
45 const MuonGMR4::MdtReadoutElement* reEle,
46 const ActsTrk::GeometryContext& gctx):
47 m_id{id},
48 m_adc{adc},
49 m_tdc{tdc},
50 m_gctx{&gctx},
51 m_RE{reEle},
52 m_hash{reEle->measurementHash(m_id)} {}
53
56 const ActsTrk::GeometryContext& gctx):
57 MdtCalibInput{digit.identify(), digit.adc(), digit.tdc(),
58 detMgr.getMdtReadoutElement(digit.identify()), gctx} {}
59
61 const int16_t adc,
62 const int16_t tdc,
63 const MuonGM::MdtReadoutElement* reEle):
64 m_id{id},
65 m_adc{adc},
66 m_tdc{tdc},
67 m_RE{reEle} {}
68
70 const MuonGM::MuonDetectorManager& detMgr):
71 MdtCalibInput{digit.identify(), digit.adc(), digit.tdc(),
72 detMgr.getMdtReadoutElement(digit.identify())} {}
73
74
76 const ActsTrk::GeometryContext& gctx):
77 m_id{prd.identify()},
78 m_adc{prd.adc()},
79 m_tdc{prd.tdc()},
80 m_gctx{&gctx},
81 m_RE{prd.readoutElement()},
82 m_hash{prd.measurementHash()},
83 m_approach{localToGlobal()* prd.localMeasurementPos()} {}
84
85
87 m_id{prd.identify()},
88 m_adc{static_cast<int16_t>(prd.adc())},
89 m_tdc{static_cast<int16_t>(prd.tdc())},
90 m_RE{prd.detectorElement()},
91 m_approach{prd.globalPosition()} {
92}
93
94const Identifier& MdtCalibInput::identify() const { return m_id; }
95int16_t MdtCalibInput::tdc() const{ return m_tdc; }
96int16_t MdtCalibInput::adc() const{ return m_adc; }
98 if (std::holds_alternative<const MuonGM::MdtReadoutElement*>(m_RE)) {
99 return std::get<const MuonGM::MdtReadoutElement*>(m_RE);
100 }
101 return nullptr;
102}
104 if (std::holds_alternative<const MuonGMR4::MdtReadoutElement*>(m_RE)) {
105 return std::get<const MuonGMR4::MdtReadoutElement*>(m_RE);
106 }
107 return nullptr;
108}
110 if (!m_approach.isValid()) {
111 m_approach.set(localToGlobal().translation());
112 }
113 assert(m_approach.ptr() != nullptr);
114 return *m_approach.ptr();
115}
117 m_approach.store(approach);
118}
120void MdtCalibInput::setTrackDirection(const Amg::Vector3D& trackDir, bool hasPhi) {
121 m_trackDir = trackDir;
122 m_trackHasPhi = hasPhi;
123}
126 if (!m_ToF.isValid()) {
127 m_ToF.set(closestApproach().mag() * s_inverseSpeed);
128 }
129 assert(m_ToF.ptr() != nullptr);
130 return *m_ToF.ptr();
131}
132void MdtCalibInput::setTimeOfFlight(const double toF) { m_ToF.store(toF); }
133
134double MdtCalibInput::triggerTime() const { return m_trigTime; }
135void MdtCalibInput::setTriggerTime(const double trigTime) { m_trigTime = trigTime; }
136
138 const Amg::Transform3D trf{localToGlobal().inverse()};
140 const Amg::Vector3D locBField = trf.linear() * fieldInGlob;
142 const Amg::Vector3D locTrkDir = trf.linear() * trackDirection();
143
144 const double perpendComp = locTrkDir.block<2,1>(0,0).dot(locBField.block<2,1>(0,0))
145 / locTrkDir.perp();
146 const double paralelComp = locBField.z();
148 return 1000. * Amg::Vector2D{paralelComp, perpendComp};
149}
152 assert(re != nullptr);
153 return re->surface(identify());
154}
156 const double propDist = std::visit([this](const auto& re) ->double {
157 using REType = std::decay_t<decltype(re)>;
158 if constexpr(std::is_same_v<REType, const MuonGMR4::MdtReadoutElement*>){
159 assert(m_gctx != nullptr);
160 return re->distanceToReadout(*m_gctx, m_hash, closestApproach());
161 } else if (std::is_same_v<REType, const MuonGM::MdtReadoutElement*>) {
162 return re->distanceFromRO(closestApproach(), identify()) -
163 re->RODistanceFromTubeCentre(identify());
164 }
165 }, m_RE);
166 return propDist;
167}
169
171 const double tubeLength = 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->tubeLength(m_hash);
175 } else if (std::is_same_v<REType, const MuonGM::MdtReadoutElement*>) {
176 return re->tubeLength(identify());
177 }
178 }, m_RE);
179 return tubeLength;
180 }
182 const double tubeR = std::visit([](const auto& re) -> double {
183 using REType = std::decay_t<decltype(re)>;
184 if constexpr(std::is_same_v<REType, const MuonGMR4::MdtReadoutElement*>){
185 return re->innerTubeRadius();
186 } else if (std::is_same_v<REType, const MuonGM::MdtReadoutElement*>) {
187 return re->innerTubeRadius();
188 }
189 }, m_RE);
190 return tubeR;
191 }
194 const double roSide = std::visit([this](const auto& re) ->double{
195 using REType = std::decay_t<decltype(re)>;
196 if constexpr(std::is_same_v<REType, const MuonGMR4::MdtReadoutElement*>){
197 return re->getParameters().readoutSide;
198 } else if (std::is_same_v<REType, const MuonGM::MdtReadoutElement*>) {
199 return re->tubeFrame_localROPos(identify()).z() > 0. ? 1. : -1.;
200 }
201 }, m_RE);
202 return roSide;
203}
205 return std::visit([this](const auto& re) ->const Amg::Transform3D&{
206 using REType = std::decay_t<decltype(re)>;
207 if constexpr(std::is_same_v<REType, const MuonGMR4::MdtReadoutElement*>){
208 assert(m_gctx != nullptr);
209 return re->localToGlobalTransform(*m_gctx, m_hash);
210 } else if (std::is_same_v<REType, const MuonGM::MdtReadoutElement*>) {
211 return re->localToGlobalTransf(identify());
212 }
213 }, m_RE);
214}
const boost::regex re(r_e)
Scalar mag() const
mag method
const MuonGM::MdtReadoutElement * legacyDescriptor() const
Returns the legacy readout element.
void setClosestApproach(const Amg::Vector3D &approach)
Sets the closest approach.
double timeOfFlight() const
Returns the time of flight.
int16_t tdc() const
Returns the tdc counts of the hit.
MdtCalibInput(const Identifier &id, const int16_t adc, const int16_t tdc, const MuonGMR4::MdtReadoutElement *reEle, const ActsTrk::GeometryContext &gctx)
Minimal constructor in the PhaseII geomerty setup.
bool trackDirHasPhi() const
Returns whether the track has a phi constaint or not.
double m_trigTime
Trigger time.
void setTimeOfFlight(const double toF)
Sets the time of flight (Usually globPos.mag() * inverseSpeed of light)
double distanceToTrack() const
Returns the distance to track (signed)
double triggerTime() const
Returns the trigger offset time.
double signalPropagationDistance() const
Calculates the distance that the signal has to travel along the wire.
Identifier m_id
Tube identifier.
int16_t m_tdc
Tdc counts of the hit.
void print(std::ostream &ostr) const
Print the object on screen.
const ActsTrk::GeometryContext * m_gctx
Geometry context, needed to fetch the alignment.
double readOutSide() const
Returns the sign of the readout position in local coordinates.
const MuonGMR4::MdtReadoutElement * decriptor() const
Returns the R4 readout element.
CxxUtils::CachedValue< double > m_ToF
Time of flight.
void setTrackDirection(const Amg::Vector3D &trackDir, bool hasPhi)
Sets the direction of the externally determined track.
IdentifierHash m_hash
Measurement hash of the Identifier (needed for Phase II)
int16_t adc() const
Returns the amount of accumulated charge.
void setTriggerTime(const double trigTime)
Sets the trigger offset time.
const Amg::Vector3D & closestApproach() const
Returns the point of closest approach to the wire.
Amg::Vector3D m_trackDir
Global track direction.
const Identifier & identify() const
Returns the Identifier of the hit.
CxxUtils::CachedValue< Amg::Vector3D > m_approach
Point of closest approach of the track.
ReadoutEle_t m_RE
Pointer to the associated readout element.
int16_t m_adc
Adc counts of the hit.
double tubeLength() const
Returns the tube length.
double innerTubeR() const
Returns the inner tube radius.
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...
bool m_trackHasPhi
Does the track direction contain a phi constraint.
const Trk::StraightLineSurface & legacySurface() const
Returns the assocaited ideal surface (Throw exception if no legacy RE is available)
const Amg::Vector3D & trackDirection() const
Returns the track direction (Can be zero)
double m_distToTrack
Distance to track (signed)
const Amg::Transform3D & localToGlobal() const
Local to global transformation of the tube.
Readout element to describe the Monitored Drift Tube (Mdt) chambers Mdt chambers usually comrpise out...
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
Class to represent measurements from the Monitored Drift Tubes.
Definition MdtPrepData.h:33
Class for a StraightLineSurface in the ATLAS detector to describe dirft tube and straw like detectors...
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition dot.py:1
MdtDriftCircle_v1 MdtDriftCircle