19 : FW::
BareAlgorithm(
"FittingAlgorithm", level), m_cfg(std::move(cfg)) {
21 throw std::invalid_argument(
"Missing input source links collection");
24 throw std::invalid_argument(
"Missing input proto tracks collection");
27 throw std::invalid_argument(
28 "Missing input initial track parameters collection");
31 throw std::invalid_argument(
"Missing output trajectories collection");
38 const auto sourceLinks =
40 const auto protoTracks =
43 m_cfg.inputInitialTrackParameters);
46 if (protoTracks.size() != initialParameters.size()) {
47 ACTS_FATAL(
"Inconsistent number of proto tracks and parameters");
48 return ProcessCode::ABORT;
53 trajectories.reserve(protoTracks.size());
56 auto pSurface = Acts::Surface::makeShared<Acts::PerigeeSurface>(
60 std::vector<SimSourceLink> trackSourceLinks;
61 for (std::size_t itrack = 0; itrack < protoTracks.size(); ++itrack) {
63 const auto& protoTrack = protoTracks[itrack];
64 const auto& initialParams = initialParameters[itrack];
67 if (protoTrack.empty()) {
74 trackSourceLinks.clear();
75 trackSourceLinks.reserve(protoTrack.size());
78 for (
auto hitIndex : protoTrack) {
79 auto sourceLink = sourceLinks.nth(hitIndex);
80 if (sourceLink == sourceLinks.end()) {
81 ACTS_FATAL(
"Proto track " << itrack <<
" contains invalid hit index"
83 return ProcessCode::ABORT;
85 trackSourceLinks.push_back(*sourceLink);
94 auto result = m_cfg.fit(trackSourceLinks, initialParams, kfOptions);
97 const auto& fitOutput = result.value();
98 if (fitOutput.fittedParameters) {
99 const auto& params = fitOutput.fittedParameters.value();
100 ACTS_VERBOSE(
"Fitted paramemeters for track " << itrack);
101 ACTS_VERBOSE(
" position: " << params.position().transpose());
102 ACTS_VERBOSE(
" momentum: " << params.momentum().transpose());
105 trajectories.emplace_back(fitOutput.trackTip,
106 std::move(fitOutput.fittedStates),
109 ACTS_DEBUG(
"No fitted paramemeters for track " << itrack);
111 trajectories.emplace_back(fitOutput.trackTip,
112 std::move(fitOutput.fittedStates));
115 ACTS_WARNING(
"Fit failed for track " << itrack <<
" with error"
122 ctx.
eventStore.
add(m_cfg.outputTrajectories, std::move(trajectories));