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
200
201
203
204 const double time1 =
strip->time()
205 -
strip->readoutElement()->distanceToEdge(
strip->layerHash(), lPos,
207
208 if (spacePoint->dimension() == 2) {
210
211 const double time2 = strip2->
time() -
212 strip2->readoutElement()->distanceToEdge(strip2->layerHash(),lPos, EdgeSide::readOut)/
m_rpcSignalVelocity;
217 } else {
219 }
220 calibSP->setCovariance(cov);
222 <<
", at "<<
Amg::toString(calibSP->localPosition())<<
", uncalib time: "
224 <<
", time Uncert: "<<
ActsTrk::timeToAthena(std::sqrt(calibSP->covariance()[Acts::toUnderlying(AxisDefs::timeCov)])));
225 break;
226 }
228 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint, std::move(calibSpPos));
230 if (spacePoint->primaryMeasurement()->measuresPhi()) {
234 const auto& sensorPlane =
strip->readoutElement()->sensorLayout(
strip->layerHash());
235 const auto& radialDesign =
strip->readoutElement()->stripLayout(
strip->layerHash());
236 cov[Acts::toUnderlying(AxisDefs::phiCov)] = Acts::square(
237 radialDesign.stripPitch(
strip->channelNumber(), sensorPlane->to2D(lPos,
true))) / 12.;
238 }
239 calibSP->setCovariance(cov);
240 break;
241 }
246
247 std::pair<double, double> calibPosCov {
calibrateMM(ctx, *gctx, *cluster, globalPos, globalDir)};
248
249 ATH_MSG_DEBUG(
"Calibrated pos and cov" << calibPosCov.first <<
" " << calibPosCov.second);
250 cov[Acts::toUnderlying(AxisDefs::etaCov)] = calibPosCov.second;
252
253
254 Amg::Vector3D calibSpPosInLayer = toChamberTrans.inverse() * calibSpPos;
256 calibSpPosInLayer.x() = calibPosCov.first;
258 calibSpPos = toChamberTrans * calibSpPosInLayer;
259
260 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint, std::move(calibSpPos));
261 calibSP->setCovariance(cov);
263
264 break;
265 }
268
269
272 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint, std::move(calibSpPos));
273 calibSP->setCovariance(cov);
274 break;
275 }
276
277 std::optional<double> posAlongTheStrip{std::nullopt};
278
279
280 if(spacePoint->secondaryMeasurement()) {
283
284 if (secMeas->numDimensions() == 2) {
285 posAlongTheStrip = static_cast<double>(secMeas->localPosition<2>()[0]);
286 } else {
287 posAlongTheStrip = static_cast<double>(secMeas->localPosition<1>()[0]);
288 }
289 } else {
291 }
292
295
297 const auto [calibPos, calibCov] =
calibratesTGC(ctx, *gctx, *stripClus, posAlongTheStrip, globalPos, globalDir);
298
299 ATH_MSG_DEBUG(
"Calibrated pos and cov" << calibPos <<
" " << calibCov);
300 cov[Acts::toUnderlying(AxisDefs::etaCov)] = calibCov;
302
303
304 Amg::Vector3D calibSpPosInLayer = toChamberTrans.inverse() * calibSpPos;
306 calibSpPosInLayer.x() = calibPos;
308 calibSpPos = toChamberTrans * calibSpPosInLayer;
309
310 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint, std::move(calibSpPos));
311 calibSP->setCovariance(cov);
313 break;
314 }
315
316 default:
318 }
319 return calibSP;
320 }
#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(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