14 #include <boost/accumulators/accumulators.hpp>
15 #include <boost/accumulators/statistics.hpp>
19 using namespace ActsExamples;
21 struct ProtoTrackSourceLinkAccessor
26 std::unique_ptr<const Acts::Logger> loggerPtr;
27 Container protoTrackSourceLinks;
31 const auto&
logger = *loggerPtr;
33 if (protoTrackSourceLinks.contains(surface.
geometryId())) {
35 protoTrackSourceLinks.equal_range(surface.
geometryId());
37 <<
" source-links from prototrack on "
39 return {Iterator{
begin}, Iterator{
end}};
45 <<
" source-links from collection on "
47 return {Iterator{
begin}, Iterator{
end}};
52 namespace ActsExamples {
54 TrackFindingFromPrototrackAlgorithm::TrackFindingFromPrototrackAlgorithm(
71 if (initialParameters.size() != protoTracks.size()) {
72 ACTS_FATAL(
"Inconsistent number of parameters and prototracks");
73 return ProcessCode::ABORT;
77 auto pSurface = Acts::Surface::makeShared<Acts::PerigeeSurface>(
100 .connect<&Acts::MeasurementSelector::select<Acts::VectorMultiTrajectory>>(
104 ProtoTrackSourceLinkAccessor sourceLinkAccessor;
105 sourceLinkAccessor.loggerPtr =
logger().
clone(
"SourceLinkAccessor");
106 sourceLinkAccessor.container = &sourceLinks;
110 slAccessorDelegate.connect<&ProtoTrackSourceLinkAccessor::range>(
111 &sourceLinkAccessor);
116 extensions, pOptions, &(*
pSurface));
119 ACTS_DEBUG(
"Invoke track finding with " << initialParameters.size()
122 auto trackContainer = std::make_shared<Acts::VectorTrackContainer>();
123 auto trackStateContainer = std::make_shared<Acts::VectorMultiTrajectory>();
127 tracks.addColumn<
unsigned int>(
"trackGroup");
130 std::size_t nSeed = 0;
131 std::size_t nFailed = 0;
133 std::vector<std::size_t> nTracksPerSeeds;
134 nTracksPerSeeds.reserve(initialParameters.size());
136 for (
auto i = 0ul;
i < initialParameters.size(); ++
i) {
137 sourceLinkAccessor.protoTrackSourceLinks.clear();
140 for (
const auto hitIndex : protoTracks.at(
i)) {
141 if (
auto it = sourceLinks.nth(hitIndex);
it != sourceLinks.end()) {
142 sourceLinkAccessor.protoTrackSourceLinks.insert(*
it);
144 ACTS_FATAL(
"Proto track " <<
i <<
" contains invalid hit index"
146 return ProcessCode::ABORT;
155 ACTS_WARNING(
"Track finding failed for proto track " <<
i <<
" with error"
160 auto& tracksForSeed = result.value();
162 nTracksPerSeeds.push_back(tracksForSeed.size());
164 for (
auto& track : tracksForSeed) {
165 seedNumber(track) = nSeed;
170 std::lock_guard<std::mutex> guard(
m_mutex);
172 std::copy(nTracksPerSeeds.begin(), nTracksPerSeeds.end(),
185 <<
" failed (" << ((100.f * nFailed) / nSeed) <<
"%)");
186 ACTS_DEBUG(
"Finalized track finding with " << tracks.size()
187 <<
" track candidates.");
188 auto constTrackStateContainer =
189 std::make_shared<Acts::ConstVectorMultiTrajectory>(
192 auto constTrackContainer = std::make_shared<Acts::ConstVectorTrackContainer>(
196 constTrackStateContainer};
205 ACTS_INFO(
"TrackFindingFromPrototracksAlgorithm statistics:");
206 namespace ba = boost::accumulators;
207 using Accumulator = ba::accumulator_set<
208 float, ba::features<ba::tag::sum, ba::tag::mean, ba::tag::variance>>;
210 Accumulator totalAcc;
212 [&](
auto v) { totalAcc(static_cast<float>(
v)); });
215 << std::sqrt(ba::variance(totalAcc)));