Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 09:42:22

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 #pragma once
0010 
0011 #include "Acts/TrackFitting/KalmanFitter.hpp"
0012 #include "Acts/Utilities/Result.hpp"
0013 
0014 #include <vector>
0015 
0016 namespace Acts {
0017 
0018 namespace CkfTypes {
0019 
0020 /// expected max number of track states that are expected to be added by
0021 /// stateCandidateCreator
0022 /// @note if the number of states exceeds this number dynamic memory allocation will occur.
0023 ///       the number is chosen to yield a container size of 64 bytes.
0024 
0025 static constexpr std::size_t s_maxBranchesPerSurface = 10;
0026 template <typename T>
0027 using BranchVector = boost::container::small_vector<T, s_maxBranchesPerSurface>;
0028 
0029 using BoundState = std::tuple<BoundTrackParameters, BoundMatrix, double>;
0030 
0031 }  // namespace CkfTypes
0032 
0033 /// Return type of the `BranchStopper` delegate for the
0034 /// CombinatorialKalmanFilter
0035 enum class CombinatorialKalmanFilterBranchStopperResult {
0036   Continue,
0037   StopAndDrop,
0038   StopAndKeep,
0039 };
0040 
0041 /// Extension struct which holds the delegates to customize the CKF behavior
0042 template <typename track_container_t>
0043 struct CombinatorialKalmanFilterExtensions {
0044   /// Type alias for track state container backend
0045   using traj_t = typename track_container_t::TrackStateContainerBackend;
0046   /// Type alias for track proxy from the container
0047   using TrackProxy = typename track_container_t::TrackProxy;
0048   /// Type alias for track state proxy from the container
0049   using TrackStateProxy = typename track_container_t::TrackStateProxy;
0050 
0051   /// Type alias for branch stopper result enumeration
0052   using BranchStopperResult = CombinatorialKalmanFilterBranchStopperResult;
0053 
0054   /// Type alias for Kalman filter updater delegate
0055   using Updater = typename KalmanFitterExtensions<traj_t>::Updater;
0056   /// Type alias for branch stopper delegate function
0057   using BranchStopper =
0058       Delegate<BranchStopperResult(const TrackProxy&, const TrackStateProxy&)>;
0059 
0060   /// The updater incorporates measurement information into the track parameters
0061   Updater updater{DelegateFuncTag<detail::voidFitterUpdater<traj_t>>{}};
0062 
0063   /// The branch stopper is called during the filtering by the Actor.
0064   BranchStopper branchStopper{DelegateFuncTag<voidBranchStopper>{}};
0065 
0066   /// @brief Delegate the extension of the trajectory onto the given surface to
0067   ///        an external unit.
0068   ///
0069   /// @note Expected to create track states for measurements associated to the
0070   ///       given surface which match the given bound state. Moreover the
0071   ///       The "filtered" data is not expected to be set, but the outlier
0072   ///       flag should be set for states that are considered to be outlier.
0073   ///
0074   /// @param geoContext The current geometry context
0075   /// @param calibrationContext pointer to the current calibration context
0076   /// @param surface the surface at which new track states are to be created
0077   /// @param boundState the current bound state of the trajectory
0078   /// @param prevTip Index pointing at previous trajectory state (i.e. tip)
0079   /// @param trackStateCandidates a temporary buffer that can be used to collect track states
0080   /// @param trajectory the trajectory to which the new states are to be added
0081   /// @param logger a logger for messages
0082   /// @return indices of new track states which extend the trajectory given by prevTip
0083 
0084   using TrackStateCreator =
0085       Delegate<Result<CkfTypes::BranchVector<TrackIndexType>>(
0086           const GeometryContext& geoContext,
0087           const CalibrationContext& calibrationContext, const Surface& surface,
0088           const CkfTypes::BoundState& boundState, TrackIndexType prevTip,
0089           std::vector<TrackStateProxy>& trackStateCandidates,
0090           traj_t& trajectory, const Logger& logger)>;
0091 
0092   /// The delegate to create new track states.
0093   /// @note a reference implementation can be found in @ref TrackStateCreator
0094   ///   which makes uses of @ref MeasurementSelector and SourceLinkAccessor
0095   TrackStateCreator createTrackStates;
0096 
0097  private:
0098   /// Default branch stopper which will never stop
0099   /// @return false
0100   static BranchStopperResult voidBranchStopper(
0101       const TrackProxy& /*track*/, const TrackStateProxy& /*trackState*/) {
0102     return BranchStopperResult::Continue;
0103   }
0104 };
0105 }  // namespace Acts