20 #include <unordered_map>
22 namespace ActsAlignment {
31 size_t measurementDim = 0;
34 size_t trackParametersDim = 0;
37 size_t alignmentDof = 0;
104 template <
typename traj_t,
typename parameters_t = BoundTrackParameters>
107 const size_t& entryIndex,
109 globalTrackParamsCov,
110 const std::unordered_map<const Surface*, size_t>& idxedAlignSurfaces,
112 using CovMatrix =
typename parameters_t::CovarianceMatrix;
118 std::vector<std::pair<size_t, bool>> measurementStates;
119 measurementStates.reserve(15);
124 size_t nAlignSurfaces = 0;
127 multiTraj.visitBackwards(entryIndex, [&](
const auto& ts) {
129 if (ts.hasSmoothed()) {
143 bool isAlignable =
false;
144 const auto surface = &ts.referenceSurface();
145 auto it = idxedAlignSurfaces.find(
surface);
146 if (
it != idxedAlignSurfaces.end()) {
154 measurementStates.push_back({ts.index(), isAlignable});
161 if (nAlignSurfaces == 0) {
191 const auto& [sourceTrackParamsCov, stateRowIndices] = globalTrackParamsCov;
197 size_t iSurface = nAlignSurfaces;
198 for (
const auto& [rowStateIndex, isAlignable] : measurementStates) {
199 const auto&
state = multiTraj.getTrackState(rowStateIndex);
200 const size_t measdim =
state.calibratedSize();
202 iMeasurement -= measdim;
206 state.effectiveCalibratedCovariance();
208 measdim) = measCovariance;
215 alignState.
residual.segment(iMeasurement, measdim) =
216 state.effectiveCalibrated() - H *
state.smoothed();
233 FreeVector pathDerivative = FreeVector::Zero();
234 pathDerivative.head<3>() = direction;
237 surface->alignmentToBoundDerivative(gctx, freeParams, pathDerivative);
245 iMeasurement, iSurface *
eAlignmentSize, measdim, eAlignmentSize) =
252 for (
unsigned int iColState = 0; iColState < measurementStates.size();
254 size_t colStateIndex = measurementStates.at(iColState).first;
256 CovMatrix correlation =
258 stateRowIndices.at(rowStateIndex),
259 stateRowIndices.at(colStateIndex));
264 iParams, iCol) = correlation;