ATLAS Offline Software
MdtCalibInput.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
5 #include "GaudiKernel/PhysicalConstants.h"
7 
8 std::ostream& operator<<(std::ostream& ostr, const MdtCalibInput& input){
9  ostr<<"adc: "<<input.adc()<<", ";
10  ostr<<"tdc: "<<input.tdc()<<", ";
11  ostr<<"is masked: "<<(input.isMasked() ? "yay" : "nay")<<", ";
12  ostr<<"global position: "<<Amg::toString(input.globalPos(), 2)<<", ";
13  ostr<<"closest approach: "<<Amg::toString(input.closestApproach(), 2)<<", ";
14  ostr<<"global direction: "<<Amg::toString(input.trackDirection(), 2)<<", ";
15  ostr<<"prop distance: "<<input.signalPropagationDistance()<<", ";
16 
17  ostr<<"ToF: "<<input.timeOfFlight()<<", ";
18  ostr<<"trigger time: "<<input.triggerTime();
19  return ostr;
20 }
21 
23  const MuonGM::MuonDetectorManager& detMgr):
24  m_id{digit.identify()},
25  m_isMasked{digit.is_masked()},
26  m_adc{digit.adc()},
27  m_tdc{digit.tdc()},
28  m_legRE{detMgr.getMdtReadoutElement(m_id)},
29  m_globToLoc{m_legRE->globalToLocalTransf(m_id)},
30  m_globPos{m_legRE->center(m_id)} {}
31 
33  const MuonGMR4::MuonDetectorManager& detMgr,
34  const ActsGeometryContext& gctx):
35  m_id{digit.identify()},
36  m_isMasked{digit.is_masked()},
37  m_adc{digit.adc()},
38  m_tdc{digit.tdc()},
39  m_gctx{&gctx},
40  m_RE{detMgr.getMdtReadoutElement(m_id)},
41  m_hash{m_RE->measurementHash(m_id)},
42  m_globToLoc{m_RE->globalToLocalTrans(gctx, m_hash)},
43  m_globPos{m_RE->center(gctx, m_hash)} {}
44 
45 MdtCalibInput::MdtCalibInput(const Identifier& id, const int adc, const int tdc, const Amg::Vector3D& globPos):
46  m_id{id},
47  m_adc{adc},
48  m_tdc{tdc},
49  m_globPos{globPos} {}
50 
52  m_id{prd.identify()},
53  m_adc{prd.adc()},
54  m_tdc{prd.tdc()},
55  m_legRE{prd.detectorElement()},
56  m_globToLoc{m_legRE->globalToLocalTransf(m_id)},
57  m_globPos{prd.globalPosition()} {
58 
59 }
60 
61 
62 const Identifier& MdtCalibInput::identify() const { return m_id; }
63 int MdtCalibInput::tdc() const{ return m_tdc; }
64 int MdtCalibInput::adc() const{ return m_adc; }
67 bool MdtCalibInput::isMasked() const { return m_isMasked; }
71  m_approach = approach;
73 }
74 std::unique_ptr<Trk::StraightLineSurface> MdtCalibInput::releaseSurface() {
75  return m_saggedSurf.release();
76 }
78 void MdtCalibInput::setTrackDirection(const Amg::Vector3D& trackDir) { m_trackDir = trackDir; }
79 double MdtCalibInput::timeOfFlight() const { return m_ToF; }
80 void MdtCalibInput::setTimeOfFlight(const double toF) { m_ToF = toF; }
81 
82 double MdtCalibInput::triggerTime() const { return m_trigTime; }
83 void MdtCalibInput::setTriggerTime(const double trigTime) { m_trigTime = trigTime; }
84 
86  return m_legRE->surface(identify()).center();
87 }
89 
92  const Amg::Vector3D locBField = m_globToLoc.linear() * fieldInGlob;
94  const Amg::Vector3D locTrkDir = m_globToLoc.linear() * trackDirection();
95 
96  const double perpendComp = locTrkDir.block<2,1>(0,0).dot(locBField.block<2,1>(0,0))
97  / locTrkDir.perp();
98  const double paralelComp = locBField.z();
100  return 1000. * Amg::Vector2D{paralelComp, perpendComp};
101 }
103  if (!m_legRE) {
104  std::stringstream except{};
105  except<<__FILE__<<":"<<__LINE__<<" idealSurface() can only be called together with the legacy readout geometry";
106  throw std::runtime_error(except.str());
107  }
108  return m_legRE->surface(identify());
109 }
111  if (!m_legRE) {
112  std::stringstream except{};
113  except<<__FILE__<<":"<<__LINE__<<" saggedSurface() can only be called together with the legacy readout geometry";
114  throw std::runtime_error(except.str());
115  }
116  if (!m_saggedSurf) {
117  const Trk::SaggedLineSurface& surf{idealSurface()};
118  const Trk::Surface& baseSurf{surf};
119  std::optional<Amg::Vector2D> locApproach = baseSurf.globalToLocal(closestApproach(),1000.);
120  if (!locApproach) {
121  return surf;
122  }
123  std::unique_ptr<Trk::StraightLineSurface> sagged{surf.correctedSurface(*locApproach)};
124  if (!sagged) {
125  return surf;
126  }
127  return (*m_saggedSurf.set(std::move(sagged)));
128  }
129  return (*m_saggedSurf);
130 }
132  double propDist{0.};
133  if (m_legRE) {
134  const double distToRO = m_legRE->distanceFromRO(closestApproach(), identify());
135  propDist = distToRO - m_legRE->RODistanceFromTubeCentre(identify());
136  } else if (m_RE) {
138  }
139  return propDist;
140 }
142 
144  if (m_legRE) return m_legRE->tubeLength(identify());
145  else if (m_RE) return m_RE->tubeLength(m_hash);
146  return 0.;
147  }
150  if (m_legRE) return m_legRE->tubeFrame_localROPos(identify()).z() > 0. ? 1. : -1.;
151  else if (m_RE) return -1.;
152  return 0.;
153 }
MdtCalibInput::tdc
int tdc() const
Returns the tdc counts of the hit.
Definition: MdtCalibInput.cxx:63
MdtCalibInput::distanceToTrack
double distanceToTrack() const
Returns the distance to track (signed)
Definition: MdtCalibInput.cxx:141
MdtCalibInput::m_trackDir
Amg::Vector3D m_trackDir
Definition: MdtCalibInput.h:128
MdtCalibInput::surfaceCenter
const Amg::Vector3D & surfaceCenter() const
Returns the center of the associated surface.
Definition: MdtCalibInput.cxx:85
MdtCalibInput::decriptor
const MuonGMR4::MdtReadoutElement * decriptor() const
Returns the R4 readout element.
Definition: MdtCalibInput.cxx:66
MdtCalibInput::m_globPos
Amg::Vector3D m_globPos
Definition: MdtCalibInput.h:126
MdtCalibInput.h
MuonGM::MdtReadoutElement::tubeLength
double tubeLength(const int tubeLayer, const int tube) const
MdtCalibInput::globalPos
const Amg::Vector3D & globalPos() const
Returns the global position of the hit.
Definition: MdtCalibInput.cxx:68
MuonGMR4::MuonDetectorManager
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MuonDetectorManager.h:61
MdtCalibInput
Definition: MdtCalibInput.h:27
MdtCalibInput::MdtCalibInput
MdtCalibInput(const MdtDigit &digit, const MuonGM::MuonDetectorManager &detMgr)
Constructor taking the MdtDigits – Typically used inside digitization or RDO -> PRD conversion Given ...
Definition: MdtCalibInput.cxx:22
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
MdtDigit
Definition: MdtDigit.h:19
MuonGMR4::MdtReadoutElement::tubeLength
double tubeLength(const IdentifierHash &hash) const
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MdtReadoutElement.cxx:175
MdtCalibInput::triggerTime
double triggerTime() const
Returns the trigger offset time.
Definition: MdtCalibInput.cxx:82
MdtCalibInput::m_isMasked
bool m_isMasked
Definition: MdtCalibInput.h:115
MdtCalibInput::legacyDescriptor
const MuonGM::MdtReadoutElement * legacyDescriptor() const
Returns the legacy readout element.
Definition: MdtCalibInput.cxx:65
MdtCalibInput::isMasked
bool isMasked() const
Returns whether the constructing digit has been masked.
Definition: MdtCalibInput.cxx:67
MuonGM::MdtReadoutElement::RODistanceFromTubeCentre
double RODistanceFromTubeCentre(const Identifier &id) const
MdtCalibInput::m_tdc
int m_tdc
Definition: MdtCalibInput.h:117
MdtCalibInput::closestApproach
const Amg::Vector3D & closestApproach() const
Returns the point of closest approach to the wire.
Definition: MdtCalibInput.cxx:69
CxxUtils::CachedUniquePtrT::set
T * set(std::unique_ptr< T > elt) const
Atomically set the element.
MdtCalibInput::m_legRE
const MuonGM::MdtReadoutElement * m_legRE
Pointer to the readout elements of the legacy geometry.
Definition: MdtCalibInput.h:119
MdtCalibInput::m_approach
Amg::Vector3D m_approach
Definition: MdtCalibInput.h:127
MdtCalibInput::releaseSurface
std::unique_ptr< Trk::StraightLineSurface > releaseSurface()
Releases the sagged line surface (Can be a nullptr)
Definition: MdtCalibInput.cxx:74
checkRpcDigits.digit
digit
Definition: checkRpcDigits.py:186
Trk::Surface::center
const Amg::Vector3D & center() const
Returns the center position of the Surface.
CxxUtils::CachedUniquePtrT::release
std::unique_ptr< T > release() noexcept
Transfer ownership from the element: return the current value as a unique_ptr, leaving the element nu...
MdtCalibInput::identify
const Identifier & identify() const
Returns the Identifier of the hit.
Definition: MdtCalibInput.cxx:62
MuonGM::MdtReadoutElement::distanceFromRO
double distanceFromRO(const Amg::Vector3D &GlobalHitPosition, const Identifier &id) const
MdtCalibInput::setTrackDirection
void setTrackDirection(const Amg::Vector3D &trackDir)
Sets the track direction if it's given from an external seed.
Definition: MdtCalibInput.cxx:78
MdtCalibInput::m_ToF
double m_ToF
Definition: MdtCalibInput.h:132
MdtCalibInput::m_hash
IdentifierHash m_hash
Definition: MdtCalibInput.h:123
Amg::toString
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Definition: GeoPrimitivesToStringConverter.h:40
MdtCalibInput::adc
int adc() const
Returns the amount of accumulated charge.
Definition: MdtCalibInput.cxx:64
MuonGM::MdtReadoutElement
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MdtReadoutElement.h:50
MdtCalibInput::m_gctx
const ActsGeometryContext * m_gctx
Definition: MdtCalibInput.h:121
MdtCalibInput::tubeLength
double tubeLength() const
Returns the tube length.
Definition: MdtCalibInput.cxx:143
MdtCalibInput::m_trigTime
double m_trigTime
Trigger time.
Definition: MdtCalibInput.h:134
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
MdtCalibInput::m_distToTrack
double m_distToTrack
Distance to track (signed)
Definition: MdtCalibInput.h:136
MdtCalibInput::setClosestApproach
void setClosestApproach(const Amg::Vector3D &approach)
Sets the closest approach.
Definition: MdtCalibInput.cxx:70
MdtCalibInput::signalPropagationDistance
double signalPropagationDistance() const
Calculates the distance that the signal has to travel along the wire.
Definition: MdtCalibInput.cxx:131
dot.dot
def dot(G, fn, nodesToHighlight=[])
Definition: dot.py:5
ActsGeometryContext
Include the GeoPrimitives which need to be put first.
Definition: ActsGeometryContext.h:28
MdtCalibInput::m_saggedSurf
CxxUtils::CachedUniquePtrT< Trk::StraightLineSurface > m_saggedSurf
Definition: MdtCalibInput.h:138
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:80
MuonGMR4::MdtReadoutElement
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MdtReadoutElement.h:15
MuonGMR4::MdtReadoutElement::distanceToReadout
double distanceToReadout(const ActsGeometryContext &ctx, const Identifier &measId, const Amg::Vector3D &globPoint) const
Returns the distance along the wire from the readout card The distance is given as the delta z of the...
MdtCalibInput::m_globToLoc
Amg::Transform3D m_globToLoc
Definition: MdtCalibInput.h:125
MdtCalibInput::setTriggerTime
void setTriggerTime(const double trigTime)
Sets the trigger offset time.
Definition: MdtCalibInput.cxx:83
Muon::MdtPrepData
Class to represent measurements from the Monitored Drift Tubes.
Definition: MdtPrepData.h:37
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
MuonGM::MdtReadoutElement::tubeFrame_localROPos
Amg::Vector3D tubeFrame_localROPos(const int tubelayer, const int tube) const
Definition: MuonDetDescr/MuonReadoutGeometry/src/MdtReadoutElement.cxx:282
MdtCalibInput::m_RE
const MuonGMR4::MdtReadoutElement * m_RE
Definition: MdtCalibInput.h:122
Trk::Surface::globalToLocal
virtual bool globalToLocal(const Amg::Vector3D &glob, const Amg::Vector3D &mom, Amg::Vector2D &loc) const =0
Specified by each surface type: GlobalToLocal method without dynamic memory allocation - boolean chec...
ReadFloatFromCool.adc
adc
Definition: ReadFloatFromCool.py:48
MdtCalibInput::m_adc
int m_adc
Definition: MdtCalibInput.h:116
MuonGM::MuonDetectorManager
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonDetectorManager.h:49
operator<<
std::ostream & operator<<(std::ostream &ostr, const MdtCalibInput &input)
Definition: MdtCalibInput.cxx:8
MuonGM::MdtReadoutElement::surface
virtual const Trk::Surface & surface() const override final
Return surface associated with this detector element.
Definition: MuonDetDescr/MuonReadoutGeometry/src/MdtReadoutElement.cxx:875
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:90
Trk::SaggedLineSurface
Definition: SaggedLineSurface.h:35
MdtCalibInput::saggedSurface
const Trk::StraightLineSurface & saggedSurface() const
Returns the surface modeling the wire sagging at the point of the closest approach (Throw exceptions ...
Definition: MdtCalibInput.cxx:110
MdtCalibInput::m_id
Identifier m_id
Definition: MdtCalibInput.h:114
MdtCalibInput::trackDirection
const Amg::Vector3D & trackDirection() const
Returns the track direction (Can be zero)
Definition: MdtCalibInput.cxx:77
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:75
MdtCalibInput::timeOfFlight
double timeOfFlight() const
Returns the time of flight.
Definition: MdtCalibInput.cxx:79
MdtCalibInput::saggedSurfCenter
const Amg::Vector3D & saggedSurfCenter() const
Returns the center of the sagged line surface.
Definition: MdtCalibInput.cxx:88
MdtCalibInput::readOutSide
double readOutSide() const
Returns the sign of the readout position in local coordinates.
Definition: MdtCalibInput.cxx:148
Trk::StraightLineSurface
Definition: StraightLineSurface.h:51
MdtCalibInput::idealSurface
const Trk::SaggedLineSurface & idealSurface() const
Returns the assocaited ideal surface (Throw exception if no legacy RE is available)
Definition: MdtCalibInput.cxx:102