File indexing completed on 2025-01-18 09:11:43
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "ActsExamples/Utilities/ProtoTracksToTracks.hpp"
0010
0011 #include "Acts/EventData/SourceLink.hpp"
0012 #include "Acts/Surfaces/PerigeeSurface.hpp"
0013 #include "ActsExamples/EventData/IndexSourceLink.hpp"
0014 #include "ActsExamples/EventData/ProtoTrack.hpp"
0015 #include "ActsExamples/EventData/SimSeed.hpp"
0016 #include "ActsExamples/Framework/WhiteBoard.hpp"
0017 #include "ActsExamples/Utilities/EventDataTransforms.hpp"
0018
0019 #include <algorithm>
0020
0021 namespace ActsExamples {
0022
0023 PrototracksToTracks::PrototracksToTracks(Config cfg, Acts::Logging::Level lvl)
0024 : IAlgorithm("PrototracksToTracks", lvl), m_cfg(std::move(cfg)) {
0025 m_outputTracks.initialize(m_cfg.outputTracks);
0026 m_inputMeasurements.initialize(m_cfg.inputMeasurements);
0027 m_inputProtoTracks.initialize(m_cfg.inputProtoTracks);
0028 }
0029
0030 ProcessCode PrototracksToTracks::execute(const AlgorithmContext& ctx) const {
0031 const auto& measurements = m_inputMeasurements(ctx);
0032
0033 auto trackContainer = std::make_shared<Acts::VectorTrackContainer>();
0034 auto mtj = std::make_shared<Acts::VectorMultiTrajectory>();
0035 TrackContainer tracks(trackContainer, mtj);
0036
0037 const auto& prototracks = m_inputProtoTracks(ctx);
0038 ACTS_DEBUG("Received " << prototracks.size() << " prototracks");
0039
0040 float avgSize = 0;
0041 std::size_t minSize = std::numeric_limits<std::size_t>::max();
0042 std::size_t maxSize = 0;
0043
0044 for (const auto& protoTrack : prototracks) {
0045 if (protoTrack.empty()) {
0046 continue;
0047 }
0048
0049 avgSize += static_cast<float>(protoTrack.size());
0050 minSize = std::min(minSize, protoTrack.size());
0051 maxSize = std::max(maxSize, protoTrack.size());
0052
0053 auto track = tracks.makeTrack();
0054 for (auto measIndex : protoTrack) {
0055 ConstVariableBoundMeasurementProxy measurement =
0056 measurements.getMeasurement(measIndex);
0057 IndexSourceLink sourceLink(measurement.geometryId(), measIndex);
0058
0059 auto trackStateProxy =
0060 track.appendTrackState(Acts::TrackStatePropMask::None);
0061 trackStateProxy.typeFlags().set(Acts::TrackStateFlag::MeasurementFlag);
0062 trackStateProxy.setUncalibratedSourceLink(Acts::SourceLink(sourceLink));
0063 }
0064
0065 track.nMeasurements() = static_cast<std::uint32_t>(protoTrack.size());
0066 track.nHoles() = 0;
0067 track.nOutliers() = 0;
0068 }
0069
0070 ConstTrackContainer constTracks{
0071 std::make_shared<Acts::ConstVectorTrackContainer>(
0072 std::move(*trackContainer)),
0073 std::make_shared<Acts::ConstVectorMultiTrajectory>(std::move(*mtj))};
0074
0075 ACTS_DEBUG("Produced " << constTracks.size() << " tracks");
0076 ACTS_DEBUG("Avg track size: " << avgSize / constTracks.size());
0077 ACTS_DEBUG("Min track size: " << minSize << ", max track size " << maxSize);
0078
0079 m_outputTracks(ctx, std::move(constTracks));
0080
0081 return ProcessCode::SUCCESS;
0082 }
0083
0084 }