31 #include <system_error>
37 : ActsExamples::
IAlgorithm(
"TrackFittingAlgorithm", level),
40 throw std::invalid_argument(
"Missing input tracks collection");
43 throw std::invalid_argument(
"Missing output tracks collection");
54 auto trackContainer = std::make_shared<Acts::VectorTrackContainer>();
55 auto trackStateContainer = std::make_shared<Acts::VectorMultiTrajectory>();
59 std::vector<Acts::SourceLink> trackSourceLinks;
60 std::vector<const Acts::Surface*> surfSequence;
66 if (
m_cfg.pickTrack > -1 and
67 m_cfg.pickTrack != static_cast<int>(itrack++)) {
76 track.referenceSurface().getSharedPtr(), track.parameters(),
77 track.covariance(), track.particleHypothesis());
79 trackSourceLinks.clear();
82 for (
auto state : track.trackStatesReversed()) {
83 surfSequence.push_back(&
state.referenceSurface());
85 if (not
state.hasCalibrated()) {
93 if (surfSequence.empty()) {
99 << initialParams.fourPosition(ctx.
geoContext).transpose()
100 <<
" -> " << initialParams.direction().transpose());
102 ACTS_DEBUG(
"Invoke direct fitter for track " << itrack);
103 auto result = (*
m_cfg.fit)(trackSourceLinks, initialParams,
options,
104 calibrator, surfSequence, tracks);
108 const auto& refittedTrack = result.value();
109 if (refittedTrack.hasReferenceSurface()) {
110 ACTS_VERBOSE(
"Refitted parameters for track " << itrack);
113 ACTS_DEBUG(
"No refitted parameters for track " << itrack);
117 << itrack <<
" with error: " << result.error() <<
", "
118 << result.error().message());
122 std::stringstream ss;
123 trackStateContainer->statistics().toStream(ss);
127 std::make_shared<Acts::ConstVectorTrackContainer>(
129 std::make_shared<Acts::ConstVectorMultiTrajectory>(
132 m_outputTracks(ctx,
std::move(constTracks));