Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:11:43

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #include "ActsExamples/Utilities/TrajectoriesToPrototracks.hpp"
0010 
0011 #include "Acts/EventData/MultiTrajectory.hpp"
0012 #include "ActsExamples/EventData/IndexSourceLink.hpp"
0013 #include "ActsExamples/EventData/ProtoTrack.hpp"
0014 #include "ActsExamples/EventData/Trajectories.hpp"
0015 
0016 #include <utility>
0017 #include <vector>
0018 
0019 namespace ActsExamples {
0020 struct AlgorithmContext;
0021 
0022 TrajectoriesToPrototracks::TrajectoriesToPrototracks(Config cfg,
0023                                                      Acts::Logging::Level lvl)
0024     : IAlgorithm("TrajectoriesToPrototracks", lvl), m_cfg(std::move(cfg)) {
0025   m_inputTrajectories.initialize(m_cfg.inputTrajectories);
0026   m_outputProtoTracks.initialize(m_cfg.outputProtoTracks);
0027 }
0028 
0029 ProcessCode TrajectoriesToPrototracks::execute(
0030     const AlgorithmContext& ctx) const {
0031   const auto trajectories = m_inputTrajectories(ctx);
0032 
0033   ProtoTrackContainer tracks;
0034 
0035   for (const auto& trajectory : trajectories) {
0036     for (const auto tip : trajectory.tips()) {
0037       ProtoTrack track;
0038 
0039       trajectory.multiTrajectory().visitBackwards(tip, [&](const auto& state) {
0040         if (!state.typeFlags().test(Acts::TrackStateFlag::MeasurementFlag)) {
0041           return true;
0042         }
0043 
0044         const auto sourceLink =
0045             state.getUncalibratedSourceLink().template get<IndexSourceLink>();
0046         track.push_back(sourceLink.index());
0047 
0048         return true;
0049       });
0050 
0051       tracks.push_back(track);
0052     }
0053   }
0054 
0055   m_outputProtoTracks(ctx, std::move(tracks));
0056 
0057   return ProcessCode::SUCCESS;
0058 }
0059 }  // namespace ActsExamples