37 #include <system_error>
40 #include <boost/histogram.hpp>
44 : ActsExamples::
IAlgorithm(
"TrackFindingAlgorithm", level),
46 m_trackSelector([
this]() -> std::optional<Acts::TrackSelector> {
53 if (
m_cfg.inputMeasurements.empty()) {
54 throw std::invalid_argument(
"Missing measurements input collection");
56 if (
m_cfg.inputSourceLinks.empty()) {
57 throw std::invalid_argument(
"Missing source links input collection");
59 if (
m_cfg.inputInitialTrackParameters.empty()) {
60 throw std::invalid_argument(
61 "Missing initial track parameters input collection");
63 if (
m_cfg.outputTracks.empty()) {
64 throw std::invalid_argument(
"Missing tracks output collection");
67 m_inputMeasurements.initialize(
m_cfg.inputMeasurements);
68 m_inputSourceLinks.initialize(
m_cfg.inputSourceLinks);
69 m_inputInitialTrackParameters.initialize(
m_cfg.inputInitialTrackParameters);
70 m_outputTracks.initialize(
m_cfg.outputTracks);
76 const auto& measurements = m_inputMeasurements(ctx);
77 const auto& sourceLinks = m_inputSourceLinks(ctx);
78 const auto& initialParameters = m_inputInitialTrackParameters(ctx);
81 auto pSurface = Acts::Surface::makeShared<Acts::PerigeeSurface>(
106 .connect<&Acts::MeasurementSelector::select<Acts::VectorMultiTrajectory>>(
118 extensions, pOptions,
pSurface.get());
119 options.smoothingTargetSurfaceStrategy =
120 Acts::CombinatorialKalmanFilterTargetSurfaceStrategy::first;
123 ACTS_DEBUG(
"Invoke track finding with " << initialParameters.size()
126 auto trackContainer = std::make_shared<Acts::VectorTrackContainer>();
127 auto trackStateContainer = std::make_shared<Acts::VectorMultiTrajectory>();
129 auto trackContainerTemp = std::make_shared<Acts::VectorTrackContainer>();
130 auto trackStateContainerTemp =
131 std::make_shared<Acts::VectorMultiTrajectory>();
134 TrackContainer tracksTemp(trackContainerTemp, trackStateContainerTemp);
136 tracks.addColumn<
unsigned int>(
"trackGroup");
137 tracksTemp.addColumn<
unsigned int>(
"trackGroup");
140 unsigned int nSeed = 0;
142 for (std::size_t iseed = 0; iseed < initialParameters.size(); ++iseed) {
147 (*
m_cfg.findTracks)(initialParameters.at(iseed),
options, tracksTemp);
153 ACTS_WARNING(
"Track finding failed for seed " << iseed <<
" with error"
158 auto& tracksForSeed = result.value();
159 for (
auto& track : tracksForSeed) {
160 seedNumber(track) = nSeed;
161 if (!m_trackSelector.has_value() ||
162 m_trackSelector->isValidTrack(track)) {
163 auto destProxy = tracks.getTrack(tracks.addTrack());
164 destProxy.copyFrom(track,
true);
170 if (
m_cfg.computeSharedHits) {
171 computeSharedHits(sourceLinks, tracks);
174 ACTS_DEBUG(
"Finalized track finding with " << tracks.size()
175 <<
" track candidates.");
177 m_memoryStatistics.local().hist +=
178 tracks.trackStateContainer().statistics().hist;
180 auto constTrackStateContainer =
181 std::make_shared<Acts::ConstVectorMultiTrajectory>(
184 auto constTrackContainer = std::make_shared<Acts::ConstVectorTrackContainer>(
188 constTrackStateContainer};
190 m_outputTracks(ctx,
std::move(constTracks));
195 ACTS_INFO(
"TrackFindingAlgorithm statistics:");
196 ACTS_INFO(
"- total seeds: " << m_nTotalSeeds);
197 ACTS_INFO(
"- failed seeds: " << m_nFailedSeeds);
198 ACTS_INFO(
"- failure ratio: " << static_cast<double>(m_nFailedSeeds) /
201 auto memoryStatistics =
202 m_memoryStatistics.combine([](
const auto&
a,
const auto&
b) {
207 std::stringstream ss;
208 memoryStatistics.toStream(ss);
209 ACTS_DEBUG(
"Track State memory statistics (averaged):\n" << ss.str());