14 #include "GaudiKernel/PhysicalConstants.h"
25 using namespace SegmentFit;
30 ATH_CHECK(m_mdtCalibrationTool.retrieve(EnableTool{m_idHelperSvc->hasMDT()}));
32 return StatusCode::SUCCESS;
39 const double timeDelay)
const {
42 calibSP = calibrate(ctx, spacePoint.
spacePoint(), segPos, segDir, timeDelay);
44 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint);
56 const double timeDelay)
const {
58 sp = calibrate(ctx, *sp, segPos, segDir, timeDelay);
67 const double timeOffset)
const {
70 if (!
SG::get(gctx, m_geoCtxKey, ctx).isSuccess()) {
80 : spPos + Amg::intersect<3>(posInChamb, dirInChamb, spPos, chDir).value_or(0) * chDir;
83 switch (spacePoint->
type()) {
86 + Amg::intersect<3>(spPos, chDir,
87 posInChamb, dirInChamb).value_or(0) * dirInChamb;
90 const double timeOfArrival = closestApproach.mag() * c_inv + timeOffset;
100 calibInput.setTimeOfFlight(timeOfArrival);
101 calibInput.setClosestApproach(std::move(closestApproach));
102 ATH_MSG_VERBOSE(
"Parse hit calibration "<<m_idHelperSvc->toString(dc->identify())<<
", "<<calibInput);
103 MdtCalibOutput calibOutput = m_mdtCalibrationTool->calibrate(ctx, calibInput);
110 ATH_MSG_DEBUG(
"Failed to create a valid hit from "<<m_idHelperSvc->toString(dc->identify())
111 <<std::endl<<calibInput<<std::endl<<calibOutput);
117 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint, std::move(calibSpPos), std::move(chDir), fitState);
118 calibSP->setCovariance<2>(jac.inverse()*diagCov*jac);
119 calibSP->setDriftRadius(calibOutput.
driftRadius());
124 calibInput.setTimeOfFlight(timeOfArrival);
126 MdtCalibInput twinInput{dc->twinIdentify(), dc->twinAdc(), dc->twinTdc(), dc->readoutElement(), *gctx};
128 twinInput.setTimeOfFlight(timeOfArrival);
131 std::move(calibInput),
132 std::move(twinInput));
137 ATH_MSG_DEBUG(
"Failed to create a valid hit from "<<m_idHelperSvc->toString(dc->identify())
138 <<std::endl<<calibOutput);
146 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint, std::move(calibSpPos), std::move(chDir), fitState);
147 calibSP->setCovariance<2>(jac.inverse()*diagCov*jac);
156 const Amg::Transform3D toGasGap{strip->readoutElement()->globalToLocalTrans(*gctx, strip->layerHash()) * locToGlob};
159 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint, std::move(calibSpPos), std::move(chDir));
161 cov.block<2,2>(0, 0) = spacePoint->covariance();
163 cov(2, 2) = m_rpcTimeResolution * m_rpcTimeResolution;
165 const double time1 = strip->time()
166 - strip->readoutElement()->distanceToEdge(strip->layerHash(),
167 lPos.block<2,1>(0,0),
168 EdgeSide::readOut) /m_rpcSignalVelocity;
173 const double time2 = strip2->
time() -
174 strip2->readoutElement()->distanceToEdge(strip2->layerHash(),
175 Eigen::Rotation2D{M_PI_2}*lPos.block<2,1>(0,0),
176 EdgeSide::readOut)/m_rpcSignalVelocity;
178 calibSP->setTimeMeasurement(0.5*(time1 + time2));
181 cov(2,1) =
cov(1,2) = - strip->readoutElement()->stripPhiPitch() /m_rpcSignalVelocity / std::sqrt(12.)* std::sqrt(
cov(2, 2));
182 cov(2,0) =
cov(0,2) = - strip->readoutElement()->stripEtaPitch() /m_rpcSignalVelocity / std::sqrt(12.)* std::sqrt(
cov(2, 2));
185 calibSP->setTimeMeasurement(time1);
186 if (strip->measuresPhi()) {
187 cov(2,1) =
cov(1,2) = - 0.5 *strip->readoutElement()->stripPhiLength() /m_rpcSignalVelocity * std::sqrt(
cov(2, 2));
189 cov(2,0) =
cov(0,2) = - 0.5 *strip->readoutElement()->stripEtaLength() /m_rpcSignalVelocity * std::sqrt(
cov(2, 2));
192 calibSP->setCovariance<3>(std::move(
cov));
194 ATH_MSG_VERBOSE(
"Create rpc space point "<<m_idHelperSvc->toString(strip->identify())<<
", dimension "<<spacePoint->
dimension()
195 <<
", at "<<
Amg::toString(calibSP->positionInChamber())<<
", uncalib time: "
196 <<strip->time()<<
", calib time: "<<calibSP->time()<<
" cov " <<
toString(calibSP->covariance()));
201 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint, std::move(calibSpPos), std::move(chDir));
202 calibSP->setCovariance<2>(spacePoint->covariance());
215 const double timeOffset)
const {
219 CalibSpacePointPtr hit = calibrate(ctx, spacePoint, posInChamb, dirInChamb, timeOffset);
220 if (hit) calibSpacePoints.push_back(std::move(hit));
222 return calibSpacePoints;