ATLAS Offline Software
Loading...
Searching...
No Matches
MuonR4::SpacePointCalibrator Class Reference

#include <SpacePointCalibrator.h>

Inheritance diagram for MuonR4::SpacePointCalibrator:
Collaboration diagram for MuonR4::SpacePointCalibrator:

Public Types

enum class  ProjectorType {
  e1DimNoTime = 0 , e1DimRotNoTime = 1 , e2DimNoTime = 2 , e1DimWithTime = 3 ,
  e1DimRotWithTime = 4 , e2DimWithTime = 5
}
 Enum encoding the possible projectors used in ATLAS. More...
template<typename trajectory_t>
using TrackState_t = typename Acts::MultiTrajectory<trajectory_t>::TrackStateProxy
 Abbrivation of the track state proxy type.
template<typename trajectory_t>
using ConstTrackState_t = typename Acts::MultiTrajectory<trajectory_t>::ConstTrackStateProxy
 Abbrivation of the const track state proxy type.

Public Member Functions

StatusCode initialize () override final
CalibSpacePointPtr calibrate (const EventContext &ctx, const SpacePoint *spacePoint, const Amg::Vector3D &seedPosInChamb, const Amg::Vector3D &seedDirInChamb, const double timeDelay) const override final
CalibSpacePointPtr calibrate (const EventContext &ctx, const CalibratedSpacePoint &spacePoint, const Amg::Vector3D &seedPosInChamb, const Amg::Vector3D &seedDirInChamb, const double timeDelay) const override final
CalibSpacePointVec calibrate (const EventContext &ctx, const std::vector< const SpacePoint * > &spacePoints, const Amg::Vector3D &seedPosInChamb, const Amg::Vector3D &seedDirInChamb, const double timeDelay) const override final
CalibSpacePointVec calibrate (const Acts::CalibrationContext &ctx, const Amg::Vector3D &seedPosInChamb, const Amg::Vector3D &seedDirInChamb, const double timeDelay, const CalibSpacePointVec &spacePoints) const override final
void updateSigns (const Amg::Vector3D &trackPos, const Amg::Vector3D &trackDir, CalibSpacePointVec &hitsToCalib) const override final
double driftVelocity (const Acts::CalibrationContext &ctx, const CalibratedSpacePoint &spacePoint) const override final
double driftAcceleration (const Acts::CalibrationContext &ctx, const CalibratedSpacePoint &spacePoint) const override final
void calibrateSourceLink (const Acts::GeometryContext &geoctx, const Acts::CalibrationContext &cctx, const Acts::SourceLink &link, ActsTrk::MutableTrackContainer::TrackStateProxy state) const override final
void stampSignsOnMeasurements (const xAOD::MuonSegment &segment) const override final
double driftRadius (const Acts::CalibrationContext &cctx, const CalibratedSpacePoint &spacePoint, const double timeDelay) const override final
double driftVelocity (const Acts::CalibrationContext &cctx, const CalibratedSpacePoint &spacePoint, const double timeDelay) const override final
double driftAcceleration (const Acts::CalibrationContext &cctx, const CalibratedSpacePoint &spacePoint, const double timeDelay) const override final
template<std::size_t Dim, typename trajectory_t, typename pos_t, typename cov_t>
void setState (const ProjectorType projector, const pos_t &locpos, const cov_t &cov, Acts::SourceLink link, TrackState_t< trajectory_t > &trackState) const
 Copy the local position & covariance into the Acts track state proxy.

Private Member Functions

void calibrateCombinedPrd (const EventContext &ctx, const ActsTrk::GeometryContext &gctx, const xAOD::CombinedMuonStrip *combinedPrd, ActsTrk::MutableTrackContainer::TrackStateProxy state) const
 Calibrates the track states from a combined muon strip.
std::pair< double, double > calibrateMM (const EventContext &ctx, const ActsTrk::GeometryContext &gctx, const xAOD::MMCluster &cluster, const Amg::Vector3D &globalPos, const Amg::Vector3D &globalDir) const
 Calibrates the position and covariance of a MicroMegas (MM) cluster.
std::pair< double, double > calibratesTGC (const EventContext &ctx, const ActsTrk::GeometryContext &gctx, const xAOD::sTgcStripCluster &cluster, std::optional< double > posAlongTheStrip, const Amg::Vector3D &globalPos, const Amg::Vector3D &globalDir) const
 Calibrates the position and covariance of an sTGC (small-strip Thin Gap Chamber) cluster.

Private Attributes

SG::ReadHandleKey< ActsTrk::GeometryContextm_geoCtxKey {this, "AlignmentKey", "ActsAlignment", "cond handle key"}
 access to the ACTS geometry context
ServiceHandle< Muon::IMuonIdHelperSvcm_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
ToolHandle< IMdtCalibrationToolm_mdtCalibrationTool {this, "MdtCalibrationTool", ""}
ToolHandle< Muon::INSWCalibToolm_nswCalibTool {this, "NSWCalibTool", ""}
ToolHandle< Muon::IMMClusterBuilderToolm_clusterBuilderToolMM {this, "MMClusterBuilder", ""}
const MuonGMR4::MuonDetectorManagerm_detMgr {nullptr}
Gaudi::Property< double > m_muonPropSpeed {this, "PropagationSpeed", 1./ Gaudi::Units::c_light }
 Assumed propagation velocity of the muon through the detector.
Gaudi::Property< double > m_rpcSignalVelocity
 How fast does an electron signal travel along an rpc strip.
Gaudi::Property< double > m_rpcTimeResolution
Gaudi::Property< bool > m_useRpcTime {this, "useRpcTime", false}
 Load the Rpc time on the track states for the track fit.
Gaudi::Property< bool > m_useTgcTime
 Load the Tgc bunch crossing ID on the track states.
Gaudi::Property< bool > m_usesTgcTime
Gaudi::Property< bool > m_MdtSignFromSegment

Static Private Attributes

static constexpr std::array< Acts::BoundSubspaceIndices, 6 > s_boundSpaceIndices
 Array to map the Projector types to the bound index configurations used by the ATLAS detector measurements.

Detailed Description

Definition at line 30 of file SpacePointCalibrator.h.

Member Typedef Documentation

◆ ConstTrackState_t

template<typename trajectory_t>
using ActsTrk::detail::MeasurementCalibratorBase::ConstTrackState_t = typename Acts::MultiTrajectory<trajectory_t>::ConstTrackStateProxy
inherited

Abbrivation of the const track state proxy type.

Definition at line 44 of file MeasurementCalibratorBase.h.

◆ TrackState_t

template<typename trajectory_t>
using ActsTrk::detail::MeasurementCalibratorBase::TrackState_t = typename Acts::MultiTrajectory<trajectory_t>::TrackStateProxy
inherited

Abbrivation of the track state proxy type.

Definition at line 41 of file MeasurementCalibratorBase.h.

Member Enumeration Documentation

◆ ProjectorType

Enum encoding the possible projectors used in ATLAS.

Their integer representations correspond to the element index in the s_boundSpaceIndices member

Enumerator
e1DimNoTime 
e1DimRotNoTime 

Project out solely the locX (Applies to Itk strips, Rpc, Tgc, sTgc, Mm)

e2DimNoTime 

Project out solely the locY - Complementary projector if the strip plane is rotated (Applies to Itk endcap strips, Rpc, Tgc, sTgc)

e1DimWithTime 

Project out the two spatial coordinates - (Applies to ITk pixel, BI-Rpc, sTgc pad)

e1DimRotWithTime 

Project out the locX & time coordinate - (Applies to Rpc, Tgc, Mm, sTgc)

e2DimWithTime 

Project out the locY & time coordinate - (Applies to Rpc, Tgc, sTgc)

Definition at line 29 of file MeasurementCalibratorBase.h.

29 {
30 e1DimNoTime = 0,
31 e1DimRotNoTime = 1,
33 e2DimNoTime = 2,
34 e1DimWithTime = 3,
35 e1DimRotWithTime = 4,
36 e2DimWithTime = 5,
37 };

Member Function Documentation

◆ calibrate() [1/4]

CalibSpacePointVec MuonR4::SpacePointCalibrator::calibrate ( const Acts::CalibrationContext & ctx,
const Amg::Vector3D & seedPosInChamb,
const Amg::Vector3D & seedDirInChamb,
const double timeDelay,
const CalibSpacePointVec & spacePoints ) const
finaloverride

Definition at line 80 of file SpacePointCalibrator.cxx.

84 {
85 CalibSpacePointVec newCalib{};
86 const EventContext* ctx = cctx.get<const EventContext*>();
87 newCalib.reserve(spacePoints.size());
88 for (const CalibSpacePointPtr& sp : spacePoints){
89 newCalib.emplace_back(calibrate(*ctx, *sp, segPos, segDir, timeDelay));
90 }
91 return newCalib;
92 }
static Double_t sp
CalibSpacePointPtr calibrate(const EventContext &ctx, const SpacePoint *spacePoint, const Amg::Vector3D &seedPosInChamb, const Amg::Vector3D &seedDirInChamb, const double timeDelay) const override final
ISpacePointCalibrator::CalibSpacePointVec CalibSpacePointVec
ISpacePointCalibrator::CalibSpacePointPtr CalibSpacePointPtr

◆ calibrate() [2/4]

CalibSpacePointPtr MuonR4::SpacePointCalibrator::calibrate ( const EventContext & ctx,
const CalibratedSpacePoint & spacePoint,
const Amg::Vector3D & seedPosInChamb,
const Amg::Vector3D & seedDirInChamb,
const double timeDelay ) const
finaloverride

Definition at line 61 of file SpacePointCalibrator.cxx.

65 {
66 CalibSpacePointPtr calibSP{};
67 if (spacePoint.type() != xAOD::UncalibMeasType::Other){
68 calibSP = calibrate(ctx, spacePoint.spacePoint(), segPos, segDir, timeDelay);
69 } else {
70 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint);
71 }
72 if (spacePoint.fitState() == State::Outlier) {
73 calibSP->setFitState(State::Outlier);
74 } else if (spacePoint.fitState() == State::Duplicate) {
75 calibSP->setFitState(State::Duplicate);
76 }
77 return calibSP;
78 }

◆ calibrate() [3/4]

CalibSpacePointPtr MuonR4::SpacePointCalibrator::calibrate ( const EventContext & ctx,
const SpacePoint * spacePoint,
const Amg::Vector3D & seedPosInChamb,
const Amg::Vector3D & seedDirInChamb,
const double timeDelay ) const
finaloverride

In valid drift radius has been created

Set time measurement used by the fast fitter, corrected by the tube T0 and a fast estimate of the time of flight

Set time measurement used by the fast fitter, corrected by the tube T0 and a fast estimate of the time of flight

Transform the space point into the local frame to calculate the propagation time towards the readout

Average the time

Add the difference to the covariance though

Definition at line 94 of file SpacePointCalibrator.cxx.

98 {
99 const ActsTrk::GeometryContext* gctx{nullptr};
100 if (!SG::get(gctx, m_geoCtxKey, ctx).isSuccess()) {
101 return nullptr;
102 }
103 const Amg::Vector3D& spPos{spacePoint->localPosition()};
104 const Amg::Transform3D& locToGlob{spacePoint->msSector()->localToGlobalTransform(*gctx)};
105 const Amg::Vector3D& chDir{spacePoint->sensorDirection()};
106
107 // Adjust the space point position according to the external seed. But only if the space point
108 // is a 1D strip
109 Amg::Vector3D calibSpPos = spacePoint->dimension() == 2 ? spPos
110 : spPos + Amg::intersect<3>(posInChamb, dirInChamb, spPos, chDir).value_or(0) * chDir;
111
112 SpacePoint::Cov_t cov = spacePoint->covariance();
113 CalibSpacePointPtr calibSP{};
114 ATH_MSG_VERBOSE("Calibrate "<<(*spacePoint) <<" -> updated pos "<<Amg::toString(calibSpPos));
115 switch (spacePoint->type()) {
117 const Amg::Vector3D locClosestApproach = posInChamb
118 + Amg::intersect<3>(spPos, chDir,
119 posInChamb, dirInChamb).value_or(0) * dirInChamb;
120
121 Amg::Vector3D closestApproach{locToGlob* locClosestApproach};
122 const double timeOfArrival = closestApproach.mag() * c_inv + ActsTrk::timeToAthena(timeDelay);
123
124 if (ATH_LIKELY(spacePoint->dimension() == 1)) {
125 auto* dc = static_cast<const xAOD::MdtDriftCircle*>(spacePoint->primaryMeasurement());
126 MdtCalibInput calibInput{*dc, *gctx};
127 calibInput.setTrackDirection(locToGlob.linear() * dirInChamb,
128 Acts::abs(dirInChamb.phi() - 90._degree) > 1.e-7 );
129 calibInput.setTimeOfFlight(timeOfArrival);
130 calibInput.setClosestApproach(std::move(closestApproach));
131 ATH_MSG_VERBOSE("Parse hit calibration "<<m_idHelperSvc->toString(dc->identify())<<", "<<calibInput);
132 MdtCalibOutput calibOutput = m_mdtCalibrationTool->calibrate(ctx, calibInput);
133 ATH_MSG_VERBOSE("Returned calibration object "<<calibOutput);
134 State fitState{State::Valid};
136 if (calibOutput.status() != Muon::MdtDriftCircleStatus::MdtStatusDriftTime) {
137 ATH_MSG_DEBUG("Failed to create a valid hit from "<<m_idHelperSvc->toString(dc->identify())
138 <<std::endl<<calibInput<<std::endl<<calibOutput);
139 fitState = State::FailedCalib;
140 cov[Acts::toUnderlying(AxisDefs::etaCov)] = dc->readoutElement()->innerTubeRadius();
141 } else {
142 cov[Acts::toUnderlying(AxisDefs::etaCov)] = Acts::square(calibOutput.driftRadiusUncert());
143 }
144 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint, std::move(calibSpPos), fitState);
145 calibSP->setCovariance(cov);
146 calibSP->setDriftRadius(calibOutput.driftRadius());
148 double fastToF {(locToGlob * calibSP->localPosition()).norm() * c_inv};
149 calibSP->setTimeMeasurement(ActsTrk::timeToActs(dc->tdc() * IMdtCalibrationTool::tdcBinSize -
150 calibOutput.tubeT0() - fastToF - calibOutput.signalPropagationTime()));
151 ATH_MSG_VERBOSE("Mdt time Meas: " << ActsTrk::timeToAthena(calibSP->time())
152 << ", ToF / fastToF: " << fastToF << " / " << closestApproach.mag() * c_inv
153 << ", tubeT0: " << calibOutput.tubeT0() << ", Signal Prop Time: " << calibOutput.signalPropagationTime());
154 } else {
155 auto* dc = static_cast<const xAOD::MdtTwinDriftCircle*>(spacePoint->primaryMeasurement());
156 MdtCalibInput calibInput{*dc, *gctx};
157 calibInput.setClosestApproach(closestApproach);
158 calibInput.setTimeOfFlight(timeOfArrival);
159
160 MdtCalibInput twinInput{dc->twinIdentify(), dc->twinAdc(), dc->twinTdc(), dc->readoutElement(), *gctx};
161 twinInput.setClosestApproach(closestApproach);
162 twinInput.setTimeOfFlight(timeOfArrival);
163
164 MdtCalibTwinOutput calibOutput = m_mdtCalibrationTool->calibrateTwinTubes(ctx,
165 std::move(calibInput),
166 std::move(twinInput));
167
168 State fitState{State::Valid};
169 if (calibOutput.primaryStatus() != Muon::MdtDriftCircleStatus::MdtStatusDriftTime) {
170 ATH_MSG_DEBUG("Failed to create a valid hit from "<<m_idHelperSvc->toString(dc->identify())
171 <<std::endl<<calibOutput);
172 cov[Acts::toUnderlying(AxisDefs::etaCov)] = Acts::square(dc->readoutElement()->innerTubeRadius());
173 cov[Acts::toUnderlying(AxisDefs::phiCov)] = Acts::square(0.5* dc->readoutElement()->activeTubeLength(dc->measurementHash()));
174 fitState = State::FailedCalib;
175 } else {
176 cov[Acts::toUnderlying(AxisDefs::etaCov)] = Acts::square(calibOutput.uncertPrimaryR());
177 cov[Acts::toUnderlying(AxisDefs::phiCov)] = Acts::square(calibOutput.sigmaZ());
178 }
179 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint, std::move(calibSpPos), fitState);
180 calibSP->setCovariance(cov);
181 calibSP->setDriftRadius(calibOutput.primaryDriftR());
183 double fastToF {(locToGlob * calibSP->localPosition()).norm() * c_inv};
184 double tubeT0 {m_mdtCalibrationTool->getCalibConstants(ctx, dc->identify())->tubeCalib->getCalib(dc->identify())->t0};
185 // Remember to add the signal propagation time!!
186 calibSP->setTimeMeasurement(ActsTrk::timeToActs(calibOutput.primaryTdc() * IMdtCalibrationTool::tdcBinSize - tubeT0 - fastToF));
187 }
188 break;
189 }
191 auto* strip = static_cast<const xAOD::RpcMeasurement*>(spacePoint->primaryMeasurement());
192
194 const Amg::Transform3D toGasGap{strip->readoutElement()->globalToLocalTransform(*gctx, strip->layerHash()) * locToGlob};
195 const Amg::Vector3D lPos = toGasGap * calibSpPos;
197 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint, std::move(calibSpPos));
198
199 cov[Acts::toUnderlying(AxisDefs::timeCov)] = Acts::square(ActsTrk::timeToActs(m_rpcTimeResolution));
200
201 const double time1 = strip->time()
202 - strip->readoutElement()->distanceToEdge(strip->layerHash(), lPos,
203 EdgeSide::readOut) /m_rpcSignalVelocity;
204
205 if (spacePoint->dimension() == 2) {
206 auto* strip2 = static_cast<const xAOD::RpcMeasurement*>(spacePoint->secondaryMeasurement());
207
208 const double time2 = strip2->time() -
209 strip2->readoutElement()->distanceToEdge(strip2->layerHash(),lPos, EdgeSide::readOut)/m_rpcSignalVelocity;
211 calibSP->setTimeMeasurement(ActsTrk::timeToActs(0.5*(time1 + time2)));
213 cov[Acts::toUnderlying(AxisDefs::timeCov)] += Acts::square(ActsTrk::timeToActs(0.5*(time1 - time2)));
214 } else {
215 calibSP->setTimeMeasurement(ActsTrk::timeToActs(time1));
216 }
217 calibSP->setCovariance(cov);
218 ATH_MSG_VERBOSE("Create rpc space point "<<m_idHelperSvc->toString(strip->identify())<<", dimension "<<spacePoint->dimension()
219 << ", at "<<Amg::toString(calibSP->localPosition())<<", uncalib time: "
220 <<strip->time()<<", calib time: "<<ActsTrk::timeToAthena(calibSP->time())<<" cov " <<calibSP->covariance()
221 <<", time Uncert: "<<ActsTrk::timeToAthena(std::sqrt(calibSP->covariance()[Acts::toUnderlying(AxisDefs::timeCov)])));
222 break;
223 }
225 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint, std::move(calibSpPos));
226 calibSP->setCovariance(cov);
227 break;
228 }
230 const xAOD::MMCluster* cluster = static_cast<const xAOD::MMCluster*>(spacePoint->primaryMeasurement());
231 Amg::Vector3D globalPos{locToGlob * posInChamb};
232 Amg::Vector3D globalDir{locToGlob.linear() * dirInChamb};
233
234 std::pair<double, double> calibPosCov {calibrateMM(ctx, *gctx, *cluster, globalPos, globalDir)};
235
236 ATH_MSG_DEBUG("Calibrated pos and cov" << calibPosCov.first << " " << calibPosCov.second);
237 cov[Acts::toUnderlying(AxisDefs::etaCov)] = calibPosCov.second;
238 Amg::Transform3D toChamberTrans{ locToGlob.inverse() * cluster->readoutElement()->localToGlobalTransform(*gctx, cluster->layerHash())};
239
240 // since we want to take the second coordiante from the external estimate we need to transform the sp posiiton to the layer frame, replace the precission coordinate and transform back
241 Amg::Vector3D calibSpPosInLayer = toChamberTrans.inverse() * calibSpPos;
242 ATH_MSG_DEBUG("in layer before calibration" << Amg::toString(calibSpPosInLayer));
243 calibSpPosInLayer.x() = calibPosCov.first;
244 ATH_MSG_DEBUG("in layer after calibration" << Amg::toString(calibSpPosInLayer));
245 calibSpPos = toChamberTrans * calibSpPosInLayer;
246
247 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint, std::move(calibSpPos));
248 calibSP->setCovariance(cov);
249 ATH_MSG_DEBUG("calibrated MM cluster "<<m_idHelperSvc->toString(cluster->identify()) << " loc x old " << cluster->localPosition<1>()[0] << " new loc x " << calibSP->localPosition()[1] << "cov " << calibSP->covariance());
250
251 break;
252 }
254 const auto* cluster = static_cast<const xAOD::sTgcMeasurement*>(spacePoint->primaryMeasurement());
255
256 // We do not apply any correction for pads or wire only space points
257 if (cluster->channelType() != sTgcIdHelper::sTgcChannelTypes::Strip) {
258 ATH_MSG_DEBUG("Calibrating an sTGC Pad or wire " << m_idHelperSvc->toString(cluster->identify()));
259 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint, std::move(calibSpPos));
260 calibSP->setCovariance(cov);
261 break;
262 }
263
264 std::optional<double> posAlongTheStrip{std::nullopt};
265
266 // check if the space point is a strip/wire combination and take the position along the strip from the wire measurement
267 if(spacePoint->secondaryMeasurement()) {
268 const auto* secMeas = static_cast<const xAOD::sTgcMeasurement*>(spacePoint->secondaryMeasurement());
269 ATH_MSG_VERBOSE("Using secondary measurement "<< m_idHelperSvc->toString(secMeas->identify())<<" for sTGC strip cluster " << m_idHelperSvc->toString(cluster->identify()));
270 // Extract scalar value - use 2D for pads (2 dimensions), 1D for wires (1 dimension)
271 if (secMeas->numDimensions() == 2) {
272 posAlongTheStrip = static_cast<double>(secMeas->localPosition<2>()[0]);
273 } else {
274 posAlongTheStrip = static_cast<double>(secMeas->localPosition<1>()[0]);
275 }
276 } else {
277 ATH_MSG_VERBOSE("No secondary measurement for sTGC strip cluster " << m_idHelperSvc->toString(cluster->identify()));
278 }
279
280 Amg::Vector3D globalPos{locToGlob * posInChamb};
281 Amg::Vector3D globalDir{locToGlob.linear() * dirInChamb};
282
283 const auto* stripClus = static_cast<const xAOD::sTgcStripCluster*>(cluster);
284 const auto [calibPos, calibCov] = calibratesTGC(ctx, *gctx, *stripClus, posAlongTheStrip, globalPos, globalDir);
285
286 ATH_MSG_DEBUG("Calibrated pos and cov" << calibPos << " " << calibCov);
287 cov[Acts::toUnderlying(AxisDefs::etaCov)] = calibCov;
288 Amg::Transform3D toChamberTrans{ locToGlob.inverse() * cluster->readoutElement()->localToGlobalTransform(*gctx, cluster->layerHash())};
289
290 // since we want to take the second coordiante from the external estimate we need to transform the sp posiiton to the layer frame, replace the precission coordinate and transform back
291 Amg::Vector3D calibSpPosInLayer = toChamberTrans.inverse() * calibSpPos;
292 ATH_MSG_DEBUG("in layer before calibration" << Amg::toString(calibSpPosInLayer));
293 calibSpPosInLayer.x() = calibPos;
294 ATH_MSG_DEBUG("in layer after calibration" << Amg::toString(calibSpPosInLayer));
295 calibSpPos = toChamberTrans * calibSpPosInLayer;
296
297 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint, std::move(calibSpPos));
298 calibSP->setCovariance(cov);
299 ATH_MSG_DEBUG("calibrated sTGC cluster "<<m_idHelperSvc->toString(cluster->identify()) << " loc x old " << cluster->localPosition<1>()[0] << " new loc x " << calibSP->localPosition()[1] << "cov " << calibSP->covariance());
300 break;
301 }
302
303 default:
304 ATH_MSG_WARNING("Do not know how to calibrate "<<m_idHelperSvc->toString(spacePoint->identify()));
305 }
306 return calibSP;
307 }
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
#define ATH_LIKELY(x)
static constexpr double tdcBinSize
Conversion to go from tdc counts -> drift Time.
void setClosestApproach(const Amg::Vector3D &approach)
Sets the closest approach.
void setTimeOfFlight(const double toF)
Sets the time of flight (Usually globPos.mag() * inverseSpeed of light)
void setTrackDirection(const Amg::Vector3D &trackDir, bool hasPhi)
Sets the direction of the externally determined track.
double driftRadiusUncert() const
Returns the uncertainty on the drift radius.
double driftRadius() const
Returns the drift radius of the calibrated object.
MdtDriftCircleStatus status() const
Status of the calibration.
double signalPropagationTime() const
Returns the signal propagation time.
double tubeT0() const
Returns the point in time where the muon typically enters the chamber.
MdtDriftCircleStatus primaryStatus() const
double primaryDriftR() const
double uncertPrimaryR() const
const Amg::Transform3D & localToGlobalTransform(const ActsTrk::GeometryContext &ctx) const
Returns the transformation from the local coordinate system of the readout element into the global AT...
std::pair< double, double > calibratesTGC(const EventContext &ctx, const ActsTrk::GeometryContext &gctx, const xAOD::sTgcStripCluster &cluster, std::optional< double > posAlongTheStrip, const Amg::Vector3D &globalPos, const Amg::Vector3D &globalDir) const
Calibrates the position and covariance of an sTGC (small-strip Thin Gap Chamber) cluster.
ToolHandle< IMdtCalibrationTool > m_mdtCalibrationTool
Gaudi::Property< double > m_rpcSignalVelocity
How fast does an electron signal travel along an rpc strip.
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
SG::ReadHandleKey< ActsTrk::GeometryContext > m_geoCtxKey
access to the ACTS geometry context
Gaudi::Property< double > m_rpcTimeResolution
std::pair< double, double > calibrateMM(const EventContext &ctx, const ActsTrk::GeometryContext &gctx, const xAOD::MMCluster &cluster, const Amg::Vector3D &globalPos, const Amg::Vector3D &globalDir) const
Calibrates the position and covariance of a MicroMegas (MM) cluster.
std::array< double, 3 > Cov_t
Abrivation of the covariance type.
const Identifier & identify() const
: Returns the Athena identifier of the micro mega cluster It's constructed from the measurementHash &...
IdentifierHash layerHash() const
Returns the hash of the associated layer (Needed for surface retrieval)
const MuonGMR4::MmReadoutElement * readoutElement() const
Retrieve the associated MmReadoutElement.
float time() const
Returns the time.
ConstVectorMap< N > localPosition() const
Returns the local position of the measurement.
constexpr double timeToAthena(const double actsT)
Converts a time unit from Acts to Athena units.
constexpr double timeToActs(const double athenaT)
Converts a time unit from Athena to Acts units.
std::optional< double > intersect(const AmgVector(N)&posA, const AmgVector(N)&dirA, const AmgVector(N)&posB, const AmgVector(N)&dirB)
Calculates the point B' along the line B that's closest to a second line A.
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
CalibratedSpacePoint::State State
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
MdtDriftCircle_v1 MdtDriftCircle
MdtTwinDriftCircle_v1 MdtTwinDriftCircle
sTgcStripCluster_v1 sTgcStripCluster
RpcMeasurement_v1 RpcMeasurement
MMCluster_v1 MMCluster
sTgcMeasurement_v1 sTgcMeasurement

◆ calibrate() [4/4]

CalibSpacePointVec MuonR4::SpacePointCalibrator::calibrate ( const EventContext & ctx,
const std::vector< const SpacePoint * > & spacePoints,
const Amg::Vector3D & seedPosInChamb,
const Amg::Vector3D & seedDirInChamb,
const double timeDelay ) const
finaloverride

Definition at line 309 of file SpacePointCalibrator.cxx.

313 {
314 CalibSpacePointVec calibSpacePoints{};
315 calibSpacePoints.reserve(spacePoints.size());
316 for(const SpacePoint* spacePoint : spacePoints) {
317 CalibSpacePointPtr hit = calibrate(ctx, spacePoint, posInChamb, dirInChamb, timeDelay);
318 if (hit) {
319 calibSpacePoints.push_back(std::move(hit));
320 }
321 }
322 return calibSpacePoints;
323 }

◆ calibrateCombinedPrd()

void MuonR4::SpacePointCalibrator::calibrateCombinedPrd ( const EventContext & ctx,
const ActsTrk::GeometryContext & gctx,
const xAOD::CombinedMuonStrip * combinedPrd,
ActsTrk::MutableTrackContainer::TrackStateProxy state ) const
private

Calibrates the track states from a combined muon strip.

It's a pseudo measurement composed out of two 1D strip measurements residing in the same gas gap (Relevant for Rpc/Tgc/sTgc)

Parameters
ctxThe event context providing the necessary conditions and event-specific information.
gctxPointer to the ActsTrk::GeometryContext, used for geometry-related transformations.
combinedPrdPointer to the measurement carrying the actual prds which are to be combined on the track state
stateThe proxy to the actual track state to fill

Construct bound track parameters to fetch the global track position

Definition at line 389 of file SpacePointCalibrator.cxx.

392 {
393 const auto sl = ActsTrk::detail::xAODUncalibMeasCalibrator::pack(combinedPrd);
394
395 auto [cmbPos, cmbCov] = xAOD::positionAndCovariance(combinedPrd);
396 if (combinedPrd->type() == xAOD::UncalibMeasType::RpcStripType) {
397 if (m_useRpcTime) {
398 ATH_MSG_WARNING(__FILE__<<":"<<__LINE__<<" Implement me");
399 }
401
402 } else if (combinedPrd->type() == xAOD::UncalibMeasType::TgcStripType) {
403 if (m_useTgcTime) {
404 ATH_MSG_WARNING(__FILE__<<":"<<__LINE__<<" Implement me");
405 }
406
408 cmbPos, cmbCov, sl, state);
409
410 } else if(combinedPrd->type() == xAOD::UncalibMeasType::sTgcStripType) {
411 if (m_usesTgcTime) {
412 ATH_MSG_WARNING(__FILE__<<":"<<__LINE__<<" Implement me");
413 }
414 // combined sTGC Space points can be strip/wire, strip/pad or pad/wire combinations.
415 const auto* primMeas = static_cast<const xAOD::sTgcMeasurement*>(combinedPrd->primaryStrip());
416
417 if(primMeas->channelType() == sTgcIdHelper::sTgcChannelTypes::Strip) {
418 const auto* primStripMeas = static_cast<const xAOD::sTgcStripCluster*>(primMeas);
420 const Acts::BoundTrackParameters trackPars{state.referenceSurface().getSharedPtr(),
421 state.parameters(), state.covariance(),
422 Acts::ParticleHypothesis::muon()};
423 std::pair<double, double> calibPosCov{calibratesTGC(ctx, gctx, *primStripMeas, cmbPos[1] ,
424 trackPars.position(gctx.context()),
425 trackPars.direction())};
426 cmbPos[0] = calibPosCov.first;
427 cmbCov(0,0) = calibPosCov.second;
428 }
430
431 } else {
432 THROW_EXCEPTION("Undefined uncalibrated measurement "
433 <<m_idHelperSvc->toString(xAOD::identify(combinedPrd)));
434 }
435 }
Acts::GeometryContext context() const
@ e2DimNoTime
Project out solely the locY - Complementary projector if the strip plane is rotated (Applies to Itk e...
void setState(const ProjectorType projector, const pos_t &locpos, const cov_t &cov, Acts::SourceLink link, TrackState_t< trajectory_t > &trackState) const
Copy the local position & covariance into the Acts track state proxy.
static Acts::SourceLink pack(const xAOD::UncalibratedMeasurement *meas)
Helper method to pack an uncalibrated measurement to an Acts source link.
Gaudi::Property< bool > m_useRpcTime
Load the Rpc time on the track states for the track fit.
Gaudi::Property< bool > m_useTgcTime
Load the Tgc bunch crossing ID on the track states.
Gaudi::Property< bool > m_usesTgcTime
const xAOD::UncalibratedMeasurement * primaryStrip() const
Returns the primary associated measurement.
virtual xAOD::UncalibMeasType type() const override final
Returns the type of the measurement type as a simple enumeration.
std::pair< Amg::Vector2D, AmgSymMatrix(2)> positionAndCovariance(const CombinedMuonStrip *combinedPrd)
Returns the position and covariance from a combined strip measurement.
const Identifier & identify(const UncalibratedMeasurement *meas)
Returns the associated identifier from the muon measurement.
#define THROW_EXCEPTION(MESSAGE)
Definition throwExcept.h:10

◆ calibrateMM()

std::pair< double, double > MuonR4::SpacePointCalibrator::calibrateMM ( const EventContext & ctx,
const ActsTrk::GeometryContext & gctx,
const xAOD::MMCluster & cluster,
const Amg::Vector3D & globalPos,
const Amg::Vector3D & globalDir ) const
private

Calibrates the position and covariance of a MicroMegas (MM) cluster.

Parameters
ctxThe event context providing the necessary conditions and event-specific information.
gctxPointer to the ActsTrk::GeometryContext, used for geometry-related transformations.
clusterPointer to the xAOD::MMCluster representing the MicroMegas cluster to be calibrated.
globalPosThe global position from an external measurement.
globalDirThe global position from an external measurement.
calibLocPosThe calibrated local position of the cluster (output parameter).
calibLocCovThe calibrated local covariance of the cluster (output parameter).

Definition at line 344 of file SpacePointCalibrator.cxx.

348 {
349 std::vector<NSWCalib::CalibratedStrip> calibClus;
350 StatusCode sc = m_nswCalibTool->calibrateClus(ctx, gctx, cluster, globalPos, calibClus);
351 if(sc.isFailure()) {
352 ATH_MSG_WARNING("Failed to calibrate MM cluster "<<m_idHelperSvc->toString(cluster.identify()));
353 return std::make_pair(0., 0.);
354 }
355
356 Amg::Vector2D locPos{cluster.localPosition<1>()[0] * Amg::Vector2D::UnitX()};
358
359 Amg::MatrixX calibCov{};
360 calibCov.resize(1,1);
361 calibCov(0,0) = cluster.localCovariance<1>()(0, 0);
362 ATH_MSG_DEBUG("old loc pos " << locPos[0] << " old cov" << calibCov(0,0) );
363
364 Muon::IMMClusterBuilderTool::RIO_Author rotAuthor = m_clusterBuilderToolMM->getCalibratedClusterPosition(ctx, calibClus, locDir ,locPos, calibCov);
365 if(rotAuthor == Muon::IMMClusterBuilderTool::RIO_Author::unKnownAuthor){
366 THROW_EXCEPTION("Failed to calibrate MM cluster "<<m_idHelperSvc->toString(cluster.identify()));
367 }
368 ATH_MSG_DEBUG("new loc pos " << locPos[0] << " new cov" << calibCov(0,0) );
369 return std::make_pair(locPos[0], calibCov(0,0));
370 }
static Double_t sc
Amg::Transform3D globalToLocalTransform(const ActsTrk::GeometryContext &ctx) const
Returns the transformation from the global ATLAS coordinate system into the local coordinate system o...
ToolHandle< Muon::IMMClusterBuilderTool > m_clusterBuilderToolMM
ToolHandle< Muon::INSWCalibTool > m_nswCalibTool
MMClusterOnTrack::Author RIO_Author
Refinement of the cluster position after the cluster calibration loop is ran with a complete external...
ConstMatrixMap< N > localCovariance() const
Returns the local covariance of the measurement.
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Eigen::Matrix< double, 2, 1 > Vector2D
::StatusCode StatusCode
StatusCode definition for legacy code.
Amg::Vector3D toLocal(const Amg::Transform3D &toLocalTrans, const Amg::Vector3D &dir)
Rotates a direction vector into a local frame: x-axis : Parallell to the radial direction of the dete...

◆ calibrateSourceLink()

void MuonR4::SpacePointCalibrator::calibrateSourceLink ( const Acts::GeometryContext & geoctx,
const Acts::CalibrationContext & cctx,
const Acts::SourceLink & link,
ActsTrk::MutableTrackContainer::TrackStateProxy state ) const
finaloverride

Construct bound track parameters to fetch the global track position

Only the combined muonstrip has zero dimensions

Vast majority of the measurements are ordinary drift tubes

Invalid drift radius has been created

Twin tube case

Legacy BM / BO chambers

BI clusters

Definition at line 436 of file SpacePointCalibrator.cxx.

439 {
440
442 const Acts::BoundTrackParameters trackPars{trackState.referenceSurface().getSharedPtr(),
443 trackState.parameters(), trackState.covariance(),
444 Acts::ParticleHypothesis::muon()};
445
446
447 const auto* muonMeas = ActsTrk::detail::xAODUncalibMeasCalibrator::unpack(link);
448 const ActsTrk::GeometryContext* gctx = geoctx.get<const ActsTrk::GeometryContext*>();
449 const EventContext* ctx = cctx.get<const EventContext*>();
450 ATH_MSG_VERBOSE("Calibrate measurement "<<m_idHelperSvc->toString(xAOD::identify(muonMeas))
451 <<" @ surface "<<trackState.referenceSurface().geometryId());
453 if (muonMeas->numDimensions() == 0u) {
454 calibrateCombinedPrd(*ctx, *gctx, static_cast<const xAOD::CombinedMuonStrip*>(muonMeas),
455 trackState);
456 return;
457
458 }
459 const Amg::Vector3D trackPos{trackPars.position(geoctx)};
460 const Amg::Vector3D trackDir{trackPars.direction()};
461
462 switch (muonMeas->type()){
463 using enum xAOD::UncalibMeasType;
464 case MdtDriftCircleType: {
465 const auto* dc = static_cast<const xAOD::MdtDriftCircle*>(muonMeas);
466 MdtCalibInput calibInput{*dc, *gctx};
467 calibInput.setClosestApproach(trackPos);
468 //calibInput.setTimeOfFlight(trackPars.parameters()[Acts::eBoundTime]);
469 calibInput.setTrackDirection(trackDir, true);
470 const double driftSign = m_MdtSignFromSegment ?
471 static_cast<double>(dec_trackSign(*dc)) :
472 Acts::copySign(1.,trackPars.parameters()[Acts::eBoundLoc0]);
473
475 if (ATH_LIKELY(muonMeas->numDimensions() == 1)) {
476 MdtCalibOutput calibOutput = m_mdtCalibrationTool->calibrate(*ctx, calibInput);
477 ATH_MSG_VERBOSE("Returned calibration object "<<calibOutput);
478 AmgVector(1) pos{AmgVector(1)::Zero()};
479 AmgSymMatrix(1) cov{AmgSymMatrix(1)::Identity()};
481 if (calibOutput.status() != Muon::MdtDriftCircleStatus::MdtStatusDriftTime) {
482 ATH_MSG_DEBUG("Failed to create a valid hit from "<<m_idHelperSvc->toString(dc->identify())
483 <<std::endl<<calibInput<<std::endl<<calibOutput);
484 cov(Acts::eBoundLoc0,Acts::eBoundLoc0) = std::pow(dc->readoutElement()->innerTubeRadius(), 2);
485 } else {
486 pos[Acts::eBoundLoc0] = driftSign*calibOutput.driftRadius();
487 cov(Acts::eBoundLoc0, Acts::eBoundLoc0) = std::pow(calibOutput.driftRadiusUncert(), 2);
488 }
490 }
492 else {
493 const auto* twinDC = static_cast<const xAOD::MdtTwinDriftCircle*>(muonMeas);
494 MdtCalibInput twinInput{twinDC->twinIdentify(), twinDC->twinAdc(), twinDC->twinTdc(), twinDC->readoutElement(), *gctx};
495 twinInput.setClosestApproach(trackPos);
496 twinInput.setTimeOfFlight(trackPars.parameters()[Acts::eBoundTime]);
497
498 MdtCalibTwinOutput calibOutput = m_mdtCalibrationTool->calibrateTwinTubes(*ctx,
499 std::move(calibInput),
500 std::move(twinInput));
501 Amg::Vector2D locPos{Amg::Vector2D::Zero()};
502 AmgSymMatrix(2) locCov{AmgSymMatrix(2)::Identity()};
503 if (calibOutput.primaryStatus() != Muon::MdtDriftCircleStatus::MdtStatusDriftTime) {
504 ATH_MSG_DEBUG("Failed to create a valid hit from "<<m_idHelperSvc->toString(dc->identify())
505 <<std::endl<<calibOutput);
506 locCov(Acts::eBoundLoc0, Acts::eBoundLoc0) = std::pow(dc->readoutElement()->innerTubeRadius(), 2);
507 locCov(Acts::eBoundLoc1, Acts::eBoundLoc1) = std::pow(0.5* dc->readoutElement()->activeTubeLength(dc->measurementHash()), 2);
508 } else {
509 locCov(Acts::eBoundLoc0, Acts::eBoundLoc0) = std::pow(calibOutput.uncertPrimaryR(), 2);
510 locCov(Acts::eBoundLoc1, Acts::eBoundLoc1) = std::pow(calibOutput.sigmaZ(), 2);
511 locPos[Acts::eBoundLoc0] = driftSign*calibOutput.primaryDriftR();
512 locPos[Acts::eBoundLoc1] = calibOutput.locZ();
513 }
515 }
516 break;
517 } case RpcStripType: {
518 const auto* rpcClust = static_cast<const xAOD::RpcMeasurement*>(muonMeas);
520 if (ATH_LIKELY(rpcClust->numDimensions() == 1)) {
521
522 if (!m_useRpcTime) {
523 const auto proj = rpcClust->measuresPhi() ? ProjectorType::e1DimRotNoTime
526 rpcClust->localPosition<1>(),
527 rpcClust->localCovariance<1>(), link, trackState);
528 } else {
529 AmgVector(2) measPars{AmgVector(2)::Zero()};
530 AmgSymMatrix(2) measCov{AmgSymMatrix(2)::Identity()};
531 measPars[0] = rpcClust->localPosition<1>()[0];
532 measCov(0,0) = rpcClust->localCovariance<1>()(0, 0);
533 ATH_MSG_WARNING(__FILE__<<":"<<__LINE__<<"Please fix me using the ActsInterops package");
534 measCov(1,1) = std::pow(m_rpcTimeResolution, 2);
535 const auto proj = rpcClust->measuresPhi() ? ProjectorType::e1DimRotWithTime
538 measPars, measCov, link, trackState);
539 }
540 }
542 else {
543 if (!m_useRpcTime) {
545 rpcClust->localPosition<2>(),
546 rpcClust->localCovariance<2>(), link, trackState);
547 } else {
548 AmgVector(3) measPars{AmgVector(3)::Zero()};
549 AmgSymMatrix(3) measCov{AmgSymMatrix(3)::Identity()};
550 measPars.block<2,1>(0,0) = xAOD::toEigen(rpcClust->localPosition<2>());
551 measCov.block<2,2>(0,0) = xAOD::toEigen(rpcClust->localCovariance<2>());
552 ATH_MSG_WARNING(__FILE__<<":"<<__LINE__<<"Please fix me using the ActsInterops package");
553 measCov(2,2) = std::pow(m_rpcTimeResolution, 2);
555 measPars, measCov, link, trackState);
556 }
557 }
558 break;
559 } case TgcStripType: {
560 const auto* tgcClust = static_cast<const xAOD::TgcStrip*>(muonMeas);
561 if (!m_useTgcTime) {
562 const auto proj = tgcClust->measuresPhi() ? ProjectorType::e1DimRotNoTime
565 tgcClust->localPosition<1>(),
566 tgcClust->localCovariance<1>(), link, trackState);
567 } else {
568 ATH_MSG_WARNING("Tgc time calibration to be implemented...");
569 }
570 break;
571 }
572 case MMClusterType: {
573 const auto* mmClust = static_cast<const xAOD::MMCluster*>(muonMeas);
574 std::pair<double, double> calibPosCov{calibrateMM(*ctx,* gctx, *mmClust, trackPos, trackDir)};
575 AmgVector(1) pos{AmgVector(1)(calibPosCov.first)};
576 AmgSymMatrix(1) cov{AmgSymMatrix(1)(calibPosCov.second)};
577
579 pos, cov, link, trackState);
580 break;
581 } case sTgcStripType: {
582 const auto* stgcClust = static_cast<const xAOD::sTgcMeasurement*>(muonMeas);
583
584 if(stgcClust->channelType() == sTgcIdHelper::sTgcChannelTypes::Wire) {
586 muonMeas->localPosition<1>(),
587 muonMeas->localCovariance<1>(), link, trackState);
588 } else if (stgcClust->channelType() == sTgcIdHelper::sTgcChannelTypes::Pad) {
590 stgcClust->localPosition<2>(),
591 stgcClust->localCovariance<2>(), link, trackState);
592 } else { // strips
593 const auto stgCluster = static_cast<const xAOD::sTgcStripCluster*>(muonMeas);
594 std::pair<double, double> calibPosCov{calibratesTGC(*ctx, *gctx, *stgCluster, std::nullopt, trackPos, trackDir)};
595 if(!m_usesTgcTime) {
596 AmgVector(1) pos{calibPosCov.first};
597 AmgSymMatrix(1) cov{calibPosCov.second};
599 pos, cov, link, trackState);
600 } else {
601 ATH_MSG_WARNING("sTGC time calibration to be implemented...");
602 AmgVector(2) pos{AmgVector(2)::Zero()};
603 AmgSymMatrix(2) cov{AmgSymMatrix(2)::Zero()};
604 pos[0] = calibPosCov.first;
605 pos[1] = stgCluster->time();
606 cov(0,0) = calibPosCov.second;
607 ATH_MSG_WARNING(__FILE__<<":"<<__LINE__<<"Please fix me using the ActsInterops package");
608 cov(1,1) = std::pow(25 /*ns*/, 2);
609
611 pos, cov, link, trackState);
612 }
613 }
614 break;
615 } case Other: {
616 ActsTrk::detail::xAODUncalibMeasCalibrator auxCalibrator{};
617 auxCalibrator.calibrate(geoctx, cctx, link, trackState);
618 break;
619 } default: {
620 THROW_EXCEPTION("The parsed measurement is not a muon measurement. Please check.");
621 }
622 }
623 }
#define AmgSymMatrix(dim)
#define AmgVector(rows)
@ e2DimWithTime
Project out the locY & time coordinate - (Applies to Rpc, Tgc, sTgc)
@ e1DimWithTime
Project out the two spatial coordinates - (Applies to ITk pixel, BI-Rpc, sTgc pad)
@ e1DimRotNoTime
Project out solely the locX (Applies to Itk strips, Rpc, Tgc, sTgc, Mm)
@ e1DimRotWithTime
Project out the locX & time coordinate - (Applies to Rpc, Tgc, Mm, sTgc)
void calibrate(const Acts::GeometryContext &gctx, const Acts::CalibrationContext &cctx, const Acts::SourceLink &sl, const MutableTrackStateBackend::TrackStateProxy trackState) const
: Interface method for the Acts fitter to calibrate the trajectory track states from the source link ...
static const xAOD::UncalibratedMeasurement * unpack(const Acts::SourceLink &sl)
Helper method to unpack an Acts source link to an uncalibrated measurement.
void calibrateCombinedPrd(const EventContext &ctx, const ActsTrk::GeometryContext &gctx, const xAOD::CombinedMuonStrip *combinedPrd, ActsTrk::MutableTrackContainer::TrackStateProxy state) const
Calibrates the track states from a combined muon strip.
Gaudi::Property< bool > m_MdtSignFromSegment
void Zero(TH1D *hin)
Definition generate.cxx:32
TgcStrip_v1 TgcStrip
Definition TgcStripFwd.h:9
UncalibMeasType
Define the type of the uncalibrated measurement.
CombinedMuonStrip_v1 CombinedMuonStrip

◆ calibratesTGC()

std::pair< double, double > MuonR4::SpacePointCalibrator::calibratesTGC ( const EventContext & ctx,
const ActsTrk::GeometryContext & gctx,
const xAOD::sTgcStripCluster & cluster,
std::optional< double > posAlongTheStrip,
const Amg::Vector3D & globalPos,
const Amg::Vector3D & globalDir ) const
private

Calibrates the position and covariance of an sTGC (small-strip Thin Gap Chamber) cluster.

Parameters
ctxThe event context providing the necessary conditions for the calibration.
gctxPointer to the ActsTrk::GeometryContext, which provides geometry-related information.
clusterPointer to the sTGC strip cluster to be calibrated.
posAlongTheStripThe position along the strip obtained from the secondary measurement(wire), 0 if no wire measurement is present.
globalPosThe global position from an external measurement.
globalDirThe global direction from an external measurement.
[out]calibLocPosThe calibrated local position of the cluster (output parameter).
[out]calibLocCovThe calibrated local covariance of the cluster (output parameter).

Definition at line 372 of file SpacePointCalibrator.cxx.

377 {
378
379 // if the second coordiante was not provided by the wire, take it from the seed track position
380 if(!posAlongTheStrip) {
381 Amg::Vector3D extPosLocal = cluster.readoutElement()->globalToLocalTransform(gctx, cluster.layerHash()) * globalPos;
382 posAlongTheStrip = extPosLocal[1];
383 }
384
385 // For now just copying over the local position and covariance. Eventually this should apply corrections from B-Lines and as build geometry
386
387 return std::make_pair(cluster.localPosition<1>()[0], cluster.localCovariance<1>()(0,0));
388 }
IdentifierHash layerHash() const
Returns the hash of the associated gasGap layer.
const MuonGMR4::sTgcReadoutElement * readoutElement() const
Retrieve the associated sTgcReadoutElement.

◆ driftAcceleration() [1/2]

double MuonR4::SpacePointCalibrator::driftAcceleration ( const Acts::CalibrationContext & cctx,
const CalibratedSpacePoint & spacePoint,
const double timeDelay ) const
finaloverride

Definition at line 656 of file SpacePointCalibrator.cxx.

658 {
659 if(spacePoint.type() == xAOD::UncalibMeasType::MdtDriftCircleType) {
660 const MuonCalib::MdtFullCalibData* calibConsts =
661 m_mdtCalibrationTool->getCalibConstants(*cctx.get<const EventContext*>(), spacePoint.spacePoint()->identify());
662 return ActsTrk::accelerationToActs(calibConsts->rtRelation->rt()->driftAcceleration(ActsTrk::timeToAthena(spacePoint.time() - timeDelay)));
663 }
664 return 0.;
665 }
constexpr double accelerationToActs(const double athenaA)
Converts an acceleration from Athena to Acts units.

◆ driftAcceleration() [2/2]

double MuonR4::SpacePointCalibrator::driftAcceleration ( const Acts::CalibrationContext & ctx,
const CalibratedSpacePoint & spacePoint ) const
finaloverride

Definition at line 334 of file SpacePointCalibrator.cxx.

335 {
336 if(spacePoint.type() == xAOD::UncalibMeasType::MdtDriftCircleType) {
337 const MuonCalib::MdtFullCalibData* calibConsts = m_mdtCalibrationTool->getCalibConstants(*ctx.get<const EventContext*>(), spacePoint.spacePoint()->identify());
338 const std::optional<double> driftTime = calibConsts->rtRelation->tr()->driftTime(spacePoint.driftRadius());
339 return ActsTrk::accelerationToActs(calibConsts->rtRelation->rt()->driftAcceleration(driftTime.value_or(0.)));
340 }
341 return 0.;
342 }
@ driftTime
Definition HitInfo.h:43

◆ driftRadius()

double MuonR4::SpacePointCalibrator::driftRadius ( const Acts::CalibrationContext & cctx,
const CalibratedSpacePoint & spacePoint,
const double timeDelay ) const
finaloverride

Definition at line 635 of file SpacePointCalibrator.cxx.

637 {
638 if(spacePoint.type() == xAOD::UncalibMeasType::MdtDriftCircleType) {
639 const MuonCalib::MdtFullCalibData* calibConsts =
640 m_mdtCalibrationTool->getCalibConstants(*cctx.get<const EventContext*>(), spacePoint.spacePoint()->identify());
641 return calibConsts->rtRelation->rt()->radius(ActsTrk::timeToAthena(spacePoint.time() - timeDelay));
642 }
643 return 0.;
644 }

◆ driftVelocity() [1/2]

double MuonR4::SpacePointCalibrator::driftVelocity ( const Acts::CalibrationContext & cctx,
const CalibratedSpacePoint & spacePoint,
const double timeDelay ) const
finaloverride

Definition at line 646 of file SpacePointCalibrator.cxx.

648 {
649 if(spacePoint.type() == xAOD::UncalibMeasType::MdtDriftCircleType) {
650 const MuonCalib::MdtFullCalibData* calibConsts =
651 m_mdtCalibrationTool->getCalibConstants(*cctx.get<const EventContext*>(), spacePoint.spacePoint()->identify());
652 return ActsTrk::velocityToActs(calibConsts->rtRelation->rt()->driftVelocity(ActsTrk::timeToAthena(spacePoint.time() - timeDelay)));
653 }
654 return 0.;
655 }
constexpr double velocityToActs(const double athenaV)
Converts a velocity from Athena to Acts units.

◆ driftVelocity() [2/2]

double MuonR4::SpacePointCalibrator::driftVelocity ( const Acts::CalibrationContext & ctx,
const CalibratedSpacePoint & spacePoint ) const
finaloverride

Definition at line 324 of file SpacePointCalibrator.cxx.

325 {
326 if(spacePoint.type() == xAOD::UncalibMeasType::MdtDriftCircleType) {
327
328 const MuonCalib::MdtFullCalibData* calibConsts = m_mdtCalibrationTool->getCalibConstants(*ctx.get<const EventContext*>(), spacePoint.spacePoint()->identify());
329 const std::optional<double> driftTime = calibConsts->rtRelation->tr()->driftTime(spacePoint.driftRadius());
330 return ActsTrk::velocityToActs(calibConsts->rtRelation->rt()->driftVelocity(driftTime.value_or(0.)));
331 }
332 return 0.;
333 }

◆ initialize()

StatusCode MuonR4::SpacePointCalibrator::initialize ( )
finaloverride

Definition at line 43 of file SpacePointCalibrator.cxx.

43 {
44 ATH_CHECK(m_geoCtxKey.initialize());
45 ATH_CHECK(m_idHelperSvc.retrieve());
46 ATH_CHECK(m_mdtCalibrationTool.retrieve(EnableTool{m_idHelperSvc->hasMDT()}));
47 ATH_CHECK(m_nswCalibTool.retrieve(EnableTool{m_idHelperSvc->hasMM() || m_idHelperSvc->hasSTGC()}));
48 ATH_CHECK(detStore()->retrieve(m_detMgr));
49 return StatusCode::SUCCESS;
50 }
#define ATH_CHECK
Evaluate an expression and check for errors.
const MuonGMR4::MuonDetectorManager * m_detMgr

◆ setState()

template<std::size_t Dim, typename trajectory_t, typename pos_t, typename cov_t>
void ActsTrk::detail::MeasurementCalibratorBase::setState ( const ProjectorType projector,
const pos_t & locpos,
const cov_t & cov,
Acts::SourceLink link,
TrackState_t< trajectory_t > & trackState ) const
inherited

Copy the local position & covariance into the Acts track state proxy.

Template Parameters
DimDimension of the measurement
trajectory_tData type of the track state proxy backend
pos_tData type of the [Dim x 1] position vector
cov_tData type of the [Dim x Dim] covariance matrix
Parameters
projectorProjector configuration of the measurement
locposCalibrated local postion
covCalibrated local covariance
linkSource link to associate with the state
trackStateRefrence to the track state proxy to write.

◆ stampSignsOnMeasurements()

void MuonR4::SpacePointCalibrator::stampSignsOnMeasurements ( const xAOD::MuonSegment & segment) const
finaloverride

Definition at line 624 of file SpacePointCalibrator.cxx.

624 {
625 const auto [segPos, segLine] = makeLine(localSegmentPars(segment));
626 const Segment* detSeg = MuonR4::detailedSegment(segment);
627 for (const auto& meas : detSeg->measurements()) {
629 dec_trackSign(*meas->spacePoint()->primaryMeasurement()) =
630 SeedingAux::strawSign(segPos, segLine, *meas);
631 }
632 }
633 }
Parameters localSegmentPars(const xAOD::MuonSegment &seg)
Returns the localSegPars decoration from a xAODMuon::Segment.
std::pair< Amg::Vector3D, Amg::Vector3D > makeLine(const Parameters &pars)
Returns the parsed parameters into an Eigen line parametrization.
const Segment * detailedSegment(const xAOD::MuonSegment &seg)
Helper function to navigate from the xAOD::MuonSegment to the MuonR4::Segment.

◆ updateSigns()

void MuonR4::SpacePointCalibrator::updateSigns ( const Amg::Vector3D & trackPos,
const Amg::Vector3D & trackDir,
CalibSpacePointVec & hitsToCalib ) const
finaloverride

Definition at line 52 of file SpacePointCalibrator.cxx.

54 {
55 std::vector<int> signs = SeedingAux::strawSigns(trackPos, trackDir,
56 hitsToCalib);
57 for (const auto [spIdx, sp]: Acts::enumerate(hitsToCalib)) {
58 sp->setDriftRadius(sp->driftRadius() * signs[spIdx]);
59 }
60 }

Member Data Documentation

◆ m_clusterBuilderToolMM

ToolHandle<Muon::IMMClusterBuilderTool> MuonR4::SpacePointCalibrator::m_clusterBuilderToolMM {this, "MMClusterBuilder", ""}
private

Definition at line 144 of file SpacePointCalibrator.h.

144{this, "MMClusterBuilder", ""};

◆ m_detMgr

const MuonGMR4::MuonDetectorManager* MuonR4::SpacePointCalibrator::m_detMgr {nullptr}
private

Definition at line 146 of file SpacePointCalibrator.h.

146{nullptr};

◆ m_geoCtxKey

SG::ReadHandleKey<ActsTrk::GeometryContext> MuonR4::SpacePointCalibrator::m_geoCtxKey {this, "AlignmentKey", "ActsAlignment", "cond handle key"}
private

access to the ACTS geometry context

Definition at line 136 of file SpacePointCalibrator.h.

136{this, "AlignmentKey", "ActsAlignment", "cond handle key"};

◆ m_idHelperSvc

ServiceHandle<Muon::IMuonIdHelperSvc> MuonR4::SpacePointCalibrator::m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
private

Definition at line 138 of file SpacePointCalibrator.h.

138{this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};

◆ m_mdtCalibrationTool

ToolHandle<IMdtCalibrationTool> MuonR4::SpacePointCalibrator::m_mdtCalibrationTool {this, "MdtCalibrationTool", ""}
private

Definition at line 140 of file SpacePointCalibrator.h.

140{this, "MdtCalibrationTool", ""};

◆ m_MdtSignFromSegment

Gaudi::Property<bool> MuonR4::SpacePointCalibrator::m_MdtSignFromSegment
private
Initial value:
{this, "useSegmentSigns", true,
"Mdt drift signs are copied from the segment line instead from the track state"}

Definition at line 167 of file SpacePointCalibrator.h.

167 {this, "useSegmentSigns", true,
168 "Mdt drift signs are copied from the segment line instead from the track state"};

◆ m_muonPropSpeed

Gaudi::Property<double> MuonR4::SpacePointCalibrator::m_muonPropSpeed {this, "PropagationSpeed", 1./ Gaudi::Units::c_light }
private

Assumed propagation velocity of the muon through the detector.

Needs to be replaced by the proper time estimate once the calibrator is exposed to the Acts propagator

Definition at line 151 of file SpacePointCalibrator.h.

151{this, "PropagationSpeed", 1./ Gaudi::Units::c_light };

◆ m_nswCalibTool

ToolHandle<Muon::INSWCalibTool> MuonR4::SpacePointCalibrator::m_nswCalibTool {this, "NSWCalibTool", ""}
private

Definition at line 142 of file SpacePointCalibrator.h.

142{this, "NSWCalibTool", ""};

◆ m_rpcSignalVelocity

Gaudi::Property<double> MuonR4::SpacePointCalibrator::m_rpcSignalVelocity
private
Initial value:
{this, "rpcSignalVelocity", 0.5 * Gaudi::Units::c_light,
"Propagation speed of the signal inside the rpc strip"}

How fast does an electron signal travel along an rpc strip.

Definition at line 154 of file SpacePointCalibrator.h.

154 {this, "rpcSignalVelocity", 0.5 * Gaudi::Units::c_light,
155 "Propagation speed of the signal inside the rpc strip"};

◆ m_rpcTimeResolution

Gaudi::Property<double> MuonR4::SpacePointCalibrator::m_rpcTimeResolution
private
Initial value:
{this, "rpcTimeResolution", 0.6 * Gaudi::Units::nanosecond,
"Estimated time resolution of the strip readout"}

Definition at line 157 of file SpacePointCalibrator.h.

157 {this, "rpcTimeResolution", 0.6 * Gaudi::Units::nanosecond,
158 "Estimated time resolution of the strip readout"};

◆ m_useRpcTime

Gaudi::Property<bool> MuonR4::SpacePointCalibrator::m_useRpcTime {this, "useRpcTime", false}
private

Load the Rpc time on the track states for the track fit.

Definition at line 161 of file SpacePointCalibrator.h.

161{this, "useRpcTime", false};

◆ m_usesTgcTime

Gaudi::Property<bool> MuonR4::SpacePointCalibrator::m_usesTgcTime
private
Initial value:
{this, "usesTgcTime", false,
"Load the sTgc time on the track states for the fit"}

Definition at line 165 of file SpacePointCalibrator.h.

165 {this, "usesTgcTime", false,
166 "Load the sTgc time on the track states for the fit"};

◆ m_useTgcTime

Gaudi::Property<bool> MuonR4::SpacePointCalibrator::m_useTgcTime
private
Initial value:
{this, "useTgcTime", false,
"Load the Tgc BC-ID on the track states for the fit"}

Load the Tgc bunch crossing ID on the track states.

Definition at line 163 of file SpacePointCalibrator.h.

163 {this, "useTgcTime", false,
164 "Load the Tgc BC-ID on the track states for the fit"};

◆ s_boundSpaceIndices

std::array<Acts::BoundSubspaceIndices, 6> ActsTrk::detail::MeasurementCalibratorBase::s_boundSpaceIndices
staticconstexprprivateinherited
Initial value:
{
Acts::BoundSubspaceIndices{Acts::eBoundLoc0},
Acts::BoundSubspaceIndices{Acts::eBoundLoc1},
Acts::BoundSubspaceIndices{Acts::eBoundLoc0, Acts::eBoundLoc1},
Acts::BoundSubspaceIndices{Acts::eBoundLoc0, Acts::eBoundTime},
Acts::BoundSubspaceIndices{Acts::eBoundLoc1, Acts::eBoundTime},
Acts::BoundSubspaceIndices{Acts::eBoundLoc0, Acts::eBoundLoc1, Acts::eBoundTime}
}

Array to map the Projector types to the bound index configurations used by the ATLAS detector measurements.

Definition at line 66 of file MeasurementCalibratorBase.h.

66 {
67 Acts::BoundSubspaceIndices{Acts::eBoundLoc0}, // One dimenion without time
68 Acts::BoundSubspaceIndices{Acts::eBoundLoc1}, // Complementary one dimension without time
69 Acts::BoundSubspaceIndices{Acts::eBoundLoc0, Acts::eBoundLoc1},
70 Acts::BoundSubspaceIndices{Acts::eBoundLoc0, Acts::eBoundTime}, // One dimension with time
71 Acts::BoundSubspaceIndices{Acts::eBoundLoc1, Acts::eBoundTime}, // Complementary one dimension with time
72 Acts::BoundSubspaceIndices{Acts::eBoundLoc0, Acts::eBoundLoc1, Acts::eBoundTime}
73 };

The documentation for this class was generated from the following files: