21 : ActsExamples::
IAlgorithm(
"AlignmentAlgorithm", lvl),
24 throw std::invalid_argument(
"Missing input measurement collection");
27 throw std::invalid_argument(
"Missing input source links collection");
30 throw std::invalid_argument(
"Missing input proto tracks collection");
33 throw std::invalid_argument(
34 "Missing input initial track parameters collection");
37 throw std::invalid_argument(
38 "Missing output alignment parameters collection");
51 const auto& measurements = m_inputMeasurements(ctx);
52 const auto& sourceLinks = m_inputSourceLinks(ctx);
53 const auto& protoTracks = m_inputProtoTracks(ctx);
54 const auto& initialParameters = m_inputInitialTrackParameters(ctx);
57 if (protoTracks.size() != initialParameters.size()) {
58 ACTS_FATAL(
"Inconsistent number of proto tracks and parameters "
59 << protoTracks.size() <<
" vs " << initialParameters.size());
60 return ProcessCode::ABORT;
63 size_t numTracksUsed = protoTracks.size();
64 if (
m_cfg.maxNumTracks > 0 and
65 m_cfg.maxNumTracks < static_cast<int>(protoTracks.size())) {
66 numTracksUsed =
m_cfg.maxNumTracks;
70 std::vector<std::vector<IndexSourceLink>> sourceLinkTrackContainer;
71 sourceLinkTrackContainer.reserve(numTracksUsed);
72 std::vector<IndexSourceLink> trackSourceLinks;
73 for (std::size_t itrack = 0; itrack < numTracksUsed; ++itrack) {
75 const auto& protoTrack = protoTracks[itrack];
78 trackSourceLinks.clear();
79 trackSourceLinks.reserve(protoTrack.size());
82 for (
auto hitIndex : protoTrack) {
83 auto sourceLink = sourceLinks.nth(hitIndex);
84 if (sourceLink == sourceLinks.end()) {
85 ACTS_FATAL(
"Proto track " << itrack <<
" contains invalid hit index"
87 return ProcessCode::ABORT;
89 trackSourceLinks.push_back(*sourceLink);
91 sourceLinkTrackContainer.push_back(trackSourceLinks);
98 auto pSurface = Acts::Surface::makeShared<Acts::PerigeeSurface>(
108 extensions.updater.connect<
111 extensions.smoother.connect<
122 kfOptions,
m_cfg.alignedTransformUpdater,
m_cfg.alignedDetElements,
123 m_cfg.chi2ONdfCutOff,
m_cfg.deltaChi2ONdfCutOff,
m_cfg.maxNumIterations);
125 ACTS_DEBUG(
"Invoke track-based alignment with " << numTracksUsed
128 (*
m_cfg.align)(sourceLinkTrackContainer, initialParameters, alignOptions);
130 const auto& alignOutput = result.value();
131 alignedParameters = alignOutput.alignedParameters;
133 "Alignment finished with deltaChi2 = " << result.value().deltaChi2);
135 ACTS_WARNING(
"Alignment failed with " << result.error());
139 m_outputAlignmentParameters(ctx,
std::move(alignedParameters));