31 #include <system_error>
38 : ActsExamples::
IAlgorithm(
"TrackParamsEstimationAlgorithm", lvl),
41 throw std::invalid_argument(
"Missing seeds input collection");
44 throw std::invalid_argument(
"Missing track parameters output collection");
47 throw std::invalid_argument(
"Missing tracking geometry");
50 throw std::invalid_argument(
"Missing magnetic field");
69 auto const& seeds = m_inputSeeds(ctx);
73 trackParameters.reserve(seeds.size());
75 std::optional<SimSeedContainer> outputSeeds;
76 if (m_outputSeeds.isInitialized()) {
77 outputSeeds->reserve(seeds.size());
82 if (m_inputTracks.isInitialized() && m_outputTracks.isInitialized()) {
83 const auto& inputTracksRef = m_inputTracks(ctx);
84 if (seeds.size() != inputTracksRef.size()) {
85 ACTS_FATAL(
"Inconsistent number of seeds and prototracks");
86 return ProcessCode::ABORT;
88 inputTracks = &inputTracksRef;
89 outputTracks.emplace();
90 outputTracks->reserve(seeds.size());
98 for (
size_t iseed = 0; iseed < seeds.size(); ++iseed) {
99 const auto&
seed = seeds[iseed];
101 const auto bottomSP =
seed.sp().front();
102 if (bottomSP->sourceLinks().empty()) {
106 const auto& sourceLink = bottomSP->sourceLinks()[0];
109 if (surface ==
nullptr) {
111 "Surface from source link is not found in the tracking geometry");
116 auto fieldRes =
m_cfg.magneticField->getField(
117 {bottomSP->x(), bottomSP->y(), bottomSP->z()},
bCache);
118 if (!fieldRes.ok()) {
119 ACTS_ERROR(
"Field lookup error: " << fieldRes.error());
120 return ProcessCode::ABORT;
128 if (not optParams.has_value()) {
129 ACTS_WARNING(
"Estimation of track parameters for seed " << iseed
133 const auto& params = optParams.value();
134 trackParameters.emplace_back(surface->
getSharedPtr(), params,
135 m_covariance,
m_cfg.particleHypothesis);
137 outputSeeds->push_back(
seed);
139 if (outputTracks && inputTracks !=
nullptr) {
140 outputTracks->push_back(inputTracks->at(iseed));
145 ACTS_VERBOSE(
"Estimated " << trackParameters.size() <<
" track parameters");
147 m_outputTrackParameters(ctx,
std::move(trackParameters));
148 if (m_outputSeeds.isInitialized()) {
149 m_outputSeeds(ctx,
std::move(*outputSeeds));
152 if (m_outputTracks.isInitialized()) {
153 m_outputTracks(ctx,
std::move(*outputTracks));