ATLAS Offline Software
Loading...
Searching...
No Matches
MdtCalibInput.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
5
6#include "GaudiKernel/PhysicalConstants.h"
8
19#include <GeoModelKernel/throwExcept.h>
20
21std::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 ActsTrk::GeometryContext& 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
46 const ActsTrk::GeometryContext& gctx):
47 MdtCalibInput(digit.identify(), digit.adc(), digit.tdc(),
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):
61 MdtCalibInput(digit.identify(), digit.adc(), digit.tdc(),
62 detMgr.getMdtReadoutElement(digit.identify())) {}
63
64
66 const ActsTrk::GeometryContext& 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.localMeasurementPos()} {}
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
84const Identifier& MdtCalibInput::identify() const { return m_id; }
85int16_t MdtCalibInput::tdc() const{ return m_tdc; }
86int16_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}
110void MdtCalibInput::setTrackDirection(const Amg::Vector3D& trackDir, bool hasPhi) {
111 m_trackDir = trackDir;
112 m_trackHasPhi = hasPhi;
113}
115double MdtCalibInput::timeOfFlight() const { return m_ToF; }
116void MdtCalibInput::setTimeOfFlight(const double toF) { m_ToF = toF; }
117
118double MdtCalibInput::triggerTime() const { return m_trigTime; }
119void MdtCalibInput::setTriggerTime(const double trigTime) { m_trigTime = trigTime; }
120
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 }
170 const double tubeR = std::visit([](const auto& re) -> double {
171 using REType = std::decay_t<decltype(re)>;
172 if constexpr(std::is_same_v<REType, const MuonGMR4::MdtReadoutElement*>){
173 return re->innerTubeRadius();
174 } else if (std::is_same_v<REType, const MuonGM::MdtReadoutElement*>) {
175 return re->innerTubeRadius();
176 }
177 }, m_RE);
178 return tubeR;
179 }
182 const double roSide = std::visit([this](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->getParameters().readoutSide;
186 } else if (std::is_same_v<REType, const MuonGM::MdtReadoutElement*>) {
187 return re->tubeFrame_localROPos(identify()).z() > 0. ? 1. : -1.;
188 }
189 }, m_RE);
190 return roSide;
191}
193 return std::visit([this](const auto& re) ->const Amg::Transform3D&{
194 using REType = std::decay_t<decltype(re)>;
195 if constexpr(std::is_same_v<REType, const MuonGMR4::MdtReadoutElement*>){
196 assert(m_gctx != nullptr);
197 return re->localToGlobalTrans(*m_gctx, m_hash);
198 } else if (std::is_same_v<REType, const MuonGM::MdtReadoutElement*>) {
199 return re->localToGlobalTransf(identify());
200 }
201 }, m_RE);
202}
204 return localToGlobal().translation();
205}
const boost::regex re(r_e)
std::ostream & operator<<(std::ostream &ostr, const MdtCalibInput &input)
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.
const Amg::Vector3D & surfaceCenter() const
Returns the center of the associated surface.
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.
Amg::Vector3D center() const
Translational part of the local -> global transform.
const ActsTrk::GeometryContext * m_gctx
Geometry context, needed to fetch the alignment.
Amg::Vector3D m_approach
Point of closest approach of the track.
double readOutSide() const
Returns the sign of the readout position in local coordinates.
const MuonGMR4::MdtReadoutElement * decriptor() const
Returns the R4 readout element.
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.
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.
virtual const Trk::Surface & surface() const override final
Return surface associated with this detector element.
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...
const Amg::Vector3D & center() const
Returns the center position of the Surface.
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:130
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
The ReadoutGeomCnvAlg converts the Run4 Readout geometry build from the GeoModelXML into the legacy M...
Definition dot.py:1
STL namespace.
MdtDriftCircle_v1 MdtDriftCircle