Transform the space point into the local frame to calculate the propagation time towards the readout
106 {
107 const ActsTrk::GeometryContext* gctx{nullptr};
110 }
112 const Amg::Transform3D& locToGlob{spacePoint->msSector()->localToGlobalTransform(*gctx)};
114
115
116
117 Amg::Vector3D calibSpPos = spacePoint->dimension() == 2 ? spPos
118 : spPos +
Amg::intersect<3>(posInChamb, dirInChamb, spPos, chDir).value_or(0) * chDir;
119
123 switch (spacePoint->type()) {
128 posInChamb, dirInChamb).value_or(0) * dirInChamb;
129
130 Amg::Vector3D closestApproach{locToGlob* locClosestApproach};
132
133 if (
ATH_LIKELY(spacePoint->dimension() == 1)) {
135 MdtCalibInput calibInput{*dc, *gctx};
137 std::abs(dirInChamb.phi() - 90._degree) > 1.e-7 );
143 State fitState{State::Valid};
145 if (calibOutput.
status() != Muon::MdtDriftCircleStatus::MdtStatusDriftTime) {
147 <<std::endl<<calibInput<<std::endl<<calibOutput);
148 fitState = State::FailedCalib;
149 cov[Acts::toUnderlying(AxisDefs::etaCov)] = dc->readoutElement()->innerTubeRadius();
150 } else {
152 }
153 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint, std::move(calibSpPos), fitState);
154 calibSP->setCovariance(cov);
155 calibSP->setDriftRadius(calibOutput.
driftRadius());
157 double fastToF {(locToGlob * calibSP->localPosition()).norm() * c_inv};
161 << ", ToF / fastToF: " << fastToF << " / " << closestApproach.mag() * c_inv
163 } else {
165 MdtCalibInput calibInput{*dc, *gctx};
168
169 MdtCalibInput twinInput{dc->twinIdentify(), dc->twinAdc(), dc->twinTdc(), dc->readoutElement(), *gctx};
172
174 std::move(calibInput),
175 std::move(twinInput));
176
177 State fitState{State::Valid};
178 if (calibOutput.
primaryStatus() != Muon::MdtDriftCircleStatus::MdtStatusDriftTime) {
180 <<std::endl<<calibOutput);
181 cov[Acts::toUnderlying(AxisDefs::etaCov)] = Acts::square(dc->readoutElement()->innerTubeRadius());
182 cov[Acts::toUnderlying(AxisDefs::phiCov)] = Acts::square(0.5* dc->readoutElement()->activeTubeLength(dc->measurementHash()));
183 fitState = State::FailedCalib;
184 } else {
185 cov[Acts::toUnderlying(AxisDefs::etaCov)] = Acts::square(calibOutput.
uncertPrimaryR());
186 cov[Acts::toUnderlying(AxisDefs::phiCov)] = Acts::square(calibOutput.
sigmaZ());
187 }
188 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint, std::move(calibSpPos), fitState);
189 calibSP->setCovariance(cov);
192 double fastToF {(locToGlob * calibSP->localPosition()).norm() * c_inv};
193 double tubeT0 {
m_mdtCalibrationTool->getCalibConstants(ctx, dc->identify())->tubeCalib->getCalib(dc->identify())->t0};
194
196 }
197 break;
198 }
201
206 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint, std::move(calibSpPos));
207
208
209
211
212 const double time1 =
strip->time()
213 -
strip->readoutElement()->distanceToEdge(
strip->layerHash(), lPos,
215
216 if (spacePoint->dimension() == 2) {
218
219 const double time2 = strip2->
time() -
220 strip2->readoutElement()->distanceToEdge(strip2->layerHash(),lPos, EdgeSide::readOut)/
m_rpcSignalVelocity;
225 } else {
227 }
228 calibSP->setCovariance(cov);
230 <<
", at "<<
Amg::toString(calibSP->localPosition())<<
", uncalib time: "
232 <<
", time Uncert: "<<
ActsTrk::timeToAthena(std::sqrt(calibSP->covariance()[Acts::toUnderlying(AxisDefs::timeCov)])));
233 break;
234 }
236 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint, std::move(calibSpPos));
238 if (spacePoint->primaryMeasurement()->measuresPhi()) {
242 const auto& sensorPlane =
strip->readoutElement()->sensorLayout(
strip->layerHash());
243 const auto& radialDesign =
strip->readoutElement()->stripLayout(
strip->layerHash());
244 cov[Acts::toUnderlying(AxisDefs::phiCov)] = Acts::square(
245 radialDesign.stripPitch(
strip->channelNumber(), sensorPlane->to2D(lPos,
true))) / 12.;
246 }
247 calibSP->setCovariance(cov);
248 break;
249 }
254
255 std::pair<double, double> calibPosCov {
calibrateMM(ctx, *gctx, *cluster, globalPos, globalDir)};
256
257 ATH_MSG_DEBUG(
"Calibrated pos and cov" << calibPosCov.first <<
" " << calibPosCov.second);
258 cov[Acts::toUnderlying(AxisDefs::etaCov)] = calibPosCov.second;
260
261
262 Amg::Vector3D calibSpPosInLayer = toChamberTrans.inverse() * calibSpPos;
264 calibSpPosInLayer.x() = calibPosCov.first;
266 calibSpPos = toChamberTrans * calibSpPosInLayer;
267
268 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint, std::move(calibSpPos));
269 calibSP->setCovariance(cov);
271
272 break;
273 }
276
277
280 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint, std::move(calibSpPos));
281 calibSP->setCovariance(cov);
282 break;
283 }
284
285 std::optional<double> posAlongTheStrip{std::nullopt};
286
287
288 if(spacePoint->secondaryMeasurement()) {
291
292 if (secMeas->numDimensions() == 2) {
293 posAlongTheStrip = static_cast<double>(secMeas->localPosition<2>()[0]);
294 } else {
295 posAlongTheStrip = static_cast<double>(secMeas->localPosition<1>()[0]);
296 }
297 } else {
299 }
300
303
305 const auto [calibPos, calibCov] =
calibratesTGC(ctx, *gctx, *stripClus, posAlongTheStrip, globalPos, globalDir);
306
307 ATH_MSG_DEBUG(
"Calibrated pos and cov" << calibPos <<
" " << calibCov);
308 cov[Acts::toUnderlying(AxisDefs::etaCov)] = calibCov;
310
311
312 Amg::Vector3D calibSpPosInLayer = toChamberTrans.inverse() * calibSpPos;
314 calibSpPosInLayer.x() = calibPos;
316 calibSpPos = toChamberTrans * calibSpPosInLayer;
317
318 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint, std::move(calibSpPos));
319 calibSP->setCovariance(cov);
321 break;
322 }
323
324 default:
326 }
327 return calibSP;
328 }
#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 override final
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
ActsTrk::GeoContextReadKey_t 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(T actsT)
Converts a time unit from Acts to Athena units.
constexpr auto timeToActs(T 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