Transform the space point into the local frame to calculate the propagation time towards the readout
99 {
100 const ActsTrk::GeometryContext* gctx{nullptr};
102 return nullptr;
103 }
105 const Amg::Transform3D& locToGlob{spacePoint->msSector()->localToGlobalTransform(*gctx)};
107
108
109
110 Amg::Vector3D calibSpPos = spacePoint->dimension() == 2 ? spPos
111 : spPos +
Amg::intersect<3>(posInChamb, dirInChamb, spPos, chDir).value_or(0) * chDir;
112
116 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));
227 calibSP->setCovariance(cov);
228 break;
229 }
234
235 std::pair<double, double> calibPosCov {
calibrateMM(ctx, *gctx, *cluster, globalPos, globalDir)};
236
237 ATH_MSG_DEBUG(
"Calibrated pos and cov" << calibPosCov.first <<
" " << calibPosCov.second);
238 cov[Acts::toUnderlying(AxisDefs::etaCov)] = calibPosCov.second;
240
241
242 Amg::Vector3D calibSpPosInLayer = toChamberTrans.inverse() * calibSpPos;
244 calibSpPosInLayer.x() = calibPosCov.first;
246 calibSpPos = toChamberTrans * calibSpPosInLayer;
247
248 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint, std::move(calibSpPos));
249 calibSP->setCovariance(cov);
251
252 break;
253 }
256
257
260 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint, std::move(calibSpPos));
261 calibSP->setCovariance(cov);
262 break;
263 }
264
265 std::optional<double> posAlongTheStrip{std::nullopt};
266
267
268 if(spacePoint->secondaryMeasurement()) {
271
272 if (secMeas->numDimensions() == 2) {
273 posAlongTheStrip = static_cast<double>(secMeas->localPosition<2>()[0]);
274 } else {
275 posAlongTheStrip = static_cast<double>(secMeas->localPosition<1>()[0]);
276 }
277 } else {
279 }
280
283
285 const auto [calibPos, calibCov] =
calibratesTGC(ctx, *gctx, *stripClus, posAlongTheStrip, globalPos, globalDir);
286
287 ATH_MSG_DEBUG(
"Calibrated pos and cov" << calibPos <<
" " << calibCov);
288 cov[Acts::toUnderlying(AxisDefs::etaCov)] = calibCov;
290
291
292 Amg::Vector3D calibSpPosInLayer = toChamberTrans.inverse() * calibSpPos;
294 calibSpPosInLayer.x() = calibPos;
296 calibSpPos = toChamberTrans * calibSpPosInLayer;
297
298 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint, std::move(calibSpPos));
299 calibSP->setCovariance(cov);
301 break;
302 }
303
304 default:
306 }
307 return calibSP;
308 }
#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