Transform the space point into the local frame to calculate the propagation time towards the readout
98 {
99 const ActsTrk::GeometryContext* gctx{nullptr};
102 }
104 const Amg::Transform3D& locToGlob{spacePoint->msSector()->localToGlobalTransform(*gctx)};
106
107
108
109 Amg::Vector3D calibSpPos = spacePoint->dimension() == 2 ? spPos
110 : spPos +
Amg::intersect<3>(posInChamb, dirInChamb, spPos, chDir).value_or(0) * chDir;
111
115 switch (spacePoint->type()) {
120 posInChamb, dirInChamb).value_or(0) * dirInChamb;
121
122 Amg::Vector3D closestApproach{locToGlob* locClosestApproach};
124
125 if (
ATH_LIKELY(spacePoint->dimension() == 1)) {
127 MdtCalibInput calibInput{*dc, *gctx};
129 Acts::abs(dirInChamb.phi() - 90._degree) > 1.e-7 );
135 State fitState{State::Valid};
137 if (calibOutput.
status() != Muon::MdtDriftCircleStatus::MdtStatusDriftTime) {
139 <<std::endl<<calibInput<<std::endl<<calibOutput);
140 fitState = State::FailedCalib;
141 cov[Acts::toUnderlying(AxisDefs::etaCov)] = dc->readoutElement()->innerTubeRadius();
142 } else {
144 }
145 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint, std::move(calibSpPos), fitState);
146 calibSP->setCovariance(cov);
147 calibSP->setDriftRadius(calibOutput.
driftRadius());
149 double fastToF {(locToGlob * calibSP->localPosition()).norm() * c_inv};
153 << ", ToF / fastToF: " << fastToF << " / " << closestApproach.mag() * c_inv
155 } else {
157 MdtCalibInput calibInput{*dc, *gctx};
160
161 MdtCalibInput twinInput{dc->twinIdentify(), dc->twinAdc(), dc->twinTdc(), dc->readoutElement(), *gctx};
164
166 std::move(calibInput),
167 std::move(twinInput));
168
169 State fitState{State::Valid};
170 if (calibOutput.
primaryStatus() != Muon::MdtDriftCircleStatus::MdtStatusDriftTime) {
172 <<std::endl<<calibOutput);
173 cov[Acts::toUnderlying(AxisDefs::etaCov)] = Acts::square(dc->readoutElement()->innerTubeRadius());
174 cov[Acts::toUnderlying(AxisDefs::phiCov)] = Acts::square(0.5* dc->readoutElement()->activeTubeLength(dc->measurementHash()));
175 fitState = State::FailedCalib;
176 } else {
177 cov[Acts::toUnderlying(AxisDefs::etaCov)] = Acts::square(calibOutput.
uncertPrimaryR());
178 cov[Acts::toUnderlying(AxisDefs::phiCov)] = Acts::square(calibOutput.
sigmaZ());
179 }
180 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint, std::move(calibSpPos), fitState);
181 calibSP->setCovariance(cov);
184 double fastToF {(locToGlob * calibSP->localPosition()).norm() * c_inv};
185 double tubeT0 {
m_mdtCalibrationTool->getCalibConstants(ctx, dc->identify())->tubeCalib->getCalib(dc->identify())->t0};
186
188 }
189 break;
190 }
193
198 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint, std::move(calibSpPos));
199
201
202 const double time1 =
strip->time()
203 -
strip->readoutElement()->distanceToEdge(
strip->layerHash(), lPos,
205
206 if (spacePoint->dimension() == 2) {
208
209 const double time2 = strip2->
time() -
210 strip2->readoutElement()->distanceToEdge(strip2->layerHash(),lPos, EdgeSide::readOut)/
m_rpcSignalVelocity;
215 } else {
217 }
218 calibSP->setCovariance(cov);
220 <<
", at "<<
Amg::toString(calibSP->localPosition())<<
", uncalib time: "
222 <<
", time Uncert: "<<
ActsTrk::timeToAthena(std::sqrt(calibSP->covariance()[Acts::toUnderlying(AxisDefs::timeCov)])));
223 break;
224 }
226 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint, std::move(calibSpPos));
228 if (spacePoint->primaryMeasurement()->measuresPhi()) {
232 const auto& sensorPlane =
strip->readoutElement()->sensorLayout(
strip->layerHash());
233 const auto& radialDesign =
strip->readoutElement()->stripLayout(
strip->layerHash());
234 cov[Acts::toUnderlying(AxisDefs::phiCov)] = Acts::square(
235 radialDesign.stripPitch(
strip->channelNumber(), sensorPlane->to2D(lPos,
true))) / 12.;
236 }
237 calibSP->setCovariance(cov);
238 break;
239 }
244
245 std::pair<double, double> calibPosCov {
calibrateMM(ctx, *gctx, *cluster, globalPos, globalDir)};
246
247 ATH_MSG_DEBUG(
"Calibrated pos and cov" << calibPosCov.first <<
" " << calibPosCov.second);
248 cov[Acts::toUnderlying(AxisDefs::etaCov)] = calibPosCov.second;
250
251
252 Amg::Vector3D calibSpPosInLayer = toChamberTrans.inverse() * calibSpPos;
254 calibSpPosInLayer.x() = calibPosCov.first;
256 calibSpPos = toChamberTrans * calibSpPosInLayer;
257
258 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint, std::move(calibSpPos));
259 calibSP->setCovariance(cov);
261
262 break;
263 }
266
267
270 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint, std::move(calibSpPos));
271 calibSP->setCovariance(cov);
272 break;
273 }
274
275 std::optional<double> posAlongTheStrip{std::nullopt};
276
277
278 if(spacePoint->secondaryMeasurement()) {
281
282 if (secMeas->numDimensions() == 2) {
283 posAlongTheStrip = static_cast<double>(secMeas->localPosition<2>()[0]);
284 } else {
285 posAlongTheStrip = static_cast<double>(secMeas->localPosition<1>()[0]);
286 }
287 } else {
289 }
290
293
295 const auto [calibPos, calibCov] =
calibratesTGC(ctx, *gctx, *stripClus, posAlongTheStrip, globalPos, globalDir);
296
297 ATH_MSG_DEBUG(
"Calibrated pos and cov" << calibPos <<
" " << calibCov);
298 cov[Acts::toUnderlying(AxisDefs::etaCov)] = calibCov;
300
301
302 Amg::Vector3D calibSpPosInLayer = toChamberTrans.inverse() * calibSpPos;
304 calibSpPosInLayer.x() = calibPos;
306 calibSpPos = toChamberTrans * calibSpPosInLayer;
307
308 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint, std::move(calibSpPos));
309 calibSP->setCovariance(cov);
311 break;
312 }
313
314 default:
316 }
317 return calibSP;
318 }
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
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 MuonGMR4::MmReadoutElement * readoutElement() const override final
Retrieve the associated MmReadoutElement.
IdentifierHash layerHash() const override final
Returns the hash of the associated layer (Needed for surface retrieval).
const Identifier & identify() const
Returns the Athena identifier of the measurement.
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
UncalibMeasType
Define the type of the uncalibrated measurement.
RpcMeasurement_v1 RpcMeasurement
sTgcMeasurement_v1 sTgcMeasurement