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
74 const Amg::Transform3D& locToGlob{spacePoint->msSector()->localToGlobalTrans(*gctx)};
79 Amg::Vector3D calibSpPos = spacePoint->dimension() == 2 ? spPos
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;
92 jac.col(0) = spacePoint->normalInChamber().block<2,1>(0,0).
unit();
93 jac.col(1) = spacePoint->directionInChamber().block<2,1>(0,0).
unit();
95 if (spacePoint->dimension() == 1) {
100 calibInput.setTimeOfFlight(timeOfArrival);
101 calibInput.setClosestApproach(std::move(closestApproach));
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));
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);
159 calibSP = std::make_unique<CalibratedSpacePoint>(spacePoint, std::move(calibSpPos), std::move(chDir));
161 cov.block<2,2>(0, 0) = spacePoint->covariance();
165 const double time1 =
strip->time()
166 -
strip->readoutElement()->distanceToEdge(
strip->layerHash(),
167 lPos.block<2,1>(0,0),
170 if (spacePoint->dimension() == 2) {
173 const double time2 = strip2->
time() -
174 strip2->readoutElement()->distanceToEdge(strip2->layerHash(),
175 Eigen::Rotation2D{M_PI_2}*lPos.block<2,1>(0,0),
178 calibSP->setTimeMeasurement(0.5*(time1 + time2));
185 calibSP->setTimeMeasurement(time1);
186 if (
strip->measuresPhi()) {
192 calibSP->setCovariance<3>(std::move(
cov));
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());