21 m_cfg(std::move(cfg)) {
23 throw std::invalid_argument(
"Missing input source links collection");
26 throw std::invalid_argument(
"Missing input proto tracks collection");
29 throw std::invalid_argument(
30 "Missing input initial track parameters collection");
33 throw std::invalid_argument(
"Missing output trajectories collection");
40 const auto sourceLinks =
42 const auto protoTracks =
45 m_cfg.inputInitialTrackParameters);
48 if (protoTracks.size() != initialParameters.size()) {
49 ACTS_FATAL(
"Inconsistent number of proto tracks and parameters");
50 return ProcessCode::ABORT;
55 trajectories.reserve(protoTracks.size());
58 auto pSurface = Acts::Surface::makeShared<Acts::PerigeeSurface>(
68 std::vector<SimSourceLink> trackSourceLinks;
69 for (std::size_t itrack = 0; itrack < protoTracks.size(); ++itrack) {
71 const auto& protoTrack = protoTracks[itrack];
72 const auto& initialParams = initialParameters[itrack];
75 if (protoTrack.empty()) {
82 trackSourceLinks.clear();
83 trackSourceLinks.reserve(protoTrack.size());
86 for (
auto hitIndex : protoTrack) {
87 auto sourceLink = sourceLinks.nth(hitIndex);
88 if (sourceLink == sourceLinks.end()) {
89 ACTS_FATAL(
"Proto track " << itrack <<
" contains invalid hit index"
91 return ProcessCode::ABORT;
93 trackSourceLinks.push_back(*sourceLink);
97 auto result = m_cfg.fit(trackSourceLinks, initialParams, kfOptions);
100 const auto& fitOutput = result.value();
102 std::vector<size_t> trackTips;
103 trackTips.reserve(1);
104 trackTips.emplace_back(fitOutput.trackTip);
107 if (fitOutput.fittedParameters) {
108 const auto& params = fitOutput.fittedParameters.value();
109 ACTS_VERBOSE(
"Fitted paramemeters for track " << itrack);
112 indexedParams.emplace(fitOutput.trackTip, std::move(params));
114 ACTS_DEBUG(
"No fitted paramemeters for track " << itrack);
117 trajectories.emplace_back(std::move(fitOutput.fittedStates),
118 std::move(trackTips), std::move(indexedParams));
120 ACTS_WARNING(
"Fit failed for track " << itrack <<
" with error"
127 ctx.
eventStore.
add(m_cfg.outputTrajectories, std::move(trajectories));