Transform the space point into the local frame to calculate the propagation time towards the readout
98 {
99 const ActsTrk::GeometryContext* gctx{nullptr};
101 return 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()) {
119 posInChamb, dirInChamb).value_or(0) * dirInChamb;
120
121 Amg::Vector3D closestApproach{locToGlob* locClosestApproach};
123
124 if (
ATH_LIKELY(spacePoint->dimension() == 1)) {
126 MdtCalibInput calibInput{*dc, *gctx};
128 Acts::abs(dirInChamb.phi() - 90._degree) > 1.e-7 );
134 State fitState{State::Valid};
136 if (calibOutput.
status() != Muon::MdtDriftCircleStatus::MdtStatusDriftTime) {
138 <<std::endl<<calibInput<<std::endl<<calibOutput);
139 fitState = State::FailedCalib;
140 cov[Acts::toUnderlying(AxisDefs::etaCov)] = dc->readoutElement()->innerTubeRadius();
141 } else {
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};
152 << ", ToF / fastToF: " << fastToF << " / " << closestApproach.mag() * c_inv
154 } else {
156 MdtCalibInput calibInput{*dc, *gctx};
159
160 MdtCalibInput twinInput{dc->twinIdentify(), dc->twinAdc(), dc->twinTdc(), dc->readoutElement(), *gctx};
163
165 std::move(calibInput),
166 std::move(twinInput));
167
168 State fitState{State::Valid};
169 if (calibOutput.
primaryStatus() != Muon::MdtDriftCircleStatus::MdtStatusDriftTime) {
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);
183 double fastToF {(locToGlob * calibSP->localPosition()).norm() * c_inv};
184 double tubeT0 {
m_mdtCalibrationTool->getCalibConstants(ctx, dc->identify())->tubeCalib->getCalib(dc->identify())->t0};
185
187 }
188 break;
189 }
192
197 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint, std::move(calibSpPos));
198
200
201 const double time1 =
strip->time()
202 -
strip->readoutElement()->distanceToEdge(
strip->layerHash(), lPos,
204
205 if (spacePoint->dimension() == 2) {
207
208 const double time2 = strip2->
time() -
209 strip2->readoutElement()->distanceToEdge(strip2->layerHash(),lPos, EdgeSide::readOut)/
m_rpcSignalVelocity;
214 } else {
216 }
217 calibSP->setCovariance(cov);
219 <<
", at "<<
Amg::toString(calibSP->localPosition())<<
", uncalib time: "
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 }
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;
239
240
241 Amg::Vector3D calibSpPosInLayer = toChamberTrans.inverse() * calibSpPos;
243 calibSpPosInLayer.x() = calibPosCov.first;
245 calibSpPos = toChamberTrans * calibSpPosInLayer;
246
247 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint, std::move(calibSpPos));
248 calibSP->setCovariance(cov);
250
251 break;
252 }
255
256
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
267 if(spacePoint->secondaryMeasurement()) {
270
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 {
278 }
279
282
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;
289
290
291 Amg::Vector3D calibSpPosInLayer = toChamberTrans.inverse() * calibSpPos;
293 calibSpPosInLayer.x() = calibPos;
295 calibSpPos = toChamberTrans * calibSpPosInLayer;
296
297 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint, std::move(calibSpPos));
298 calibSP->setCovariance(cov);
300 break;
301 }
302
303 default:
305 }
306 return calibSP;
307 }
#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 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
sTgcMeasurement_v1 sTgcMeasurement