Transform the space point into the local frame to calculate the propagation time towards the readout
TODO: Use also the time of the secondary measurement...
Reminder to myself, we should modify the covariance if the space point is 1D? Probably... dunno
75 const Amg::Transform3D& locToGlob{spacePoint->msSector()->localToGlobalTrans(*gctx)};
80 Amg::Vector3D calibSpPos = spacePoint->dimension() == 2 ? spPos
81 : spPos + Amg::intersect<3>(posInChamb, dirInChamb, spPos, chDir).value_or(0) * chDir;
84 switch (spacePoint->type()) {
87 + Amg::intersect<3>(spPos, chDir,
88 posInChamb, dirInChamb).value_or(0) * dirInChamb;
91 const double timeOfArrival = closestApproach.mag() * c_inv + timeOffset;
93 jac.col(0) = spacePoint->normalInChamber().block<2,1>(0,0).
unit();
94 jac.col(1) = spacePoint->directionInChamber().block<2,1>(0,0).
unit();
96 if (spacePoint->dimension() == 1) {
100 calibInput.setTimeOfFlight(timeOfArrival);
101 calibInput.setClosestApproach(std::move(closestApproach));
110 <<std::endl<<calibInput<<std::endl<<calibOutput);
120 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint, std::move(calibSpPos), std::move(chDir), fitState);
121 calibSP->setCovariance<2>(jac.inverse()*diagCov*jac);
122 calibSP->setDriftRadius(calibOutput.
driftRadius());
127 calibInput.setTimeOfFlight(timeOfArrival);
129 MdtCalibInput twinInput{dc->twinIdentify(), dc->twinAdc(), dc->twinTdc(), dc->readoutElement(), *gctx};
131 twinInput.setTimeOfFlight(timeOfArrival);
134 std::move(calibInput),
135 std::move(twinInput));
141 <<std::endl<<calibOutput);
149 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint, std::move(calibSpPos), std::move(chDir), fitState);
150 calibSP->setCovariance<2>(jac.inverse()*diagCov*jac);
162 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint, std::move(calibSpPos), std::move(chDir));
164 cov.block<2,2>(0, 0) = spacePoint->covariance();
168 const double time1 =
strip->time()
169 -
strip->readoutElement()->distanceToEdge(
strip->layerHash(),
170 lPos.block<2,1>(0,0),
173 if (spacePoint->dimension() == 2) {
176 const double time2 = strip2->
time() -
177 strip2->readoutElement()->distanceToEdge(strip2->layerHash(),
178 Eigen::Rotation2D{M_PI_2}*lPos.block<2,1>(0,0),
181 calibSP->setTimeMeasurement(0.5*(time1 + time2));
188 calibSP->setTimeMeasurement(time1);
189 if (
strip->measuresPhi()) {
195 calibSP->setCovariance<3>(std::move(
cov));
198 <<
", at "<<
Amg::toString(calibSP->positionInChamber())<<
", uncalib time: "
199 <<
strip->time()<<
", calib time: "<<calibSP->time()<<
" cov " <<
toString(calibSP->covariance()));
204 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint, std::move(calibSpPos), std::move(chDir));
205 calibSP->setCovariance<2>(spacePoint->covariance());