Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-22 08:24:02

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   using traj_t = typename track_container_t::TrackStateContainerBackend;
0045   using TrackProxy = typename track_container_t::TrackProxy;
0046   using TrackStateProxy = typename track_container_t::TrackStateProxy;
0047 
0048   using BranchStopperResult = CombinatorialKalmanFilterBranchStopperResult;
0049 
0050   using Updater = typename KalmanFitterExtensions<traj_t>::Updater;
0051   using BranchStopper =
0052       Delegate<BranchStopperResult(const TrackProxy&, const TrackStateProxy&)>;
0053 
0054   /// The updater incorporates measurement information into the track parameters
0055   Updater updater{DelegateFuncTag<detail::voidFitterUpdater<traj_t>>{}};
0056 
0057   /// The branch stopper is called during the filtering by the Actor.
0058   BranchStopper branchStopper{DelegateFuncTag<voidBranchStopper>{}};
0059 
0060   /// @brief Delegate the extension of the trajectory onto the given surface to
0061   ///        an external unit.
0062   ///
0063   /// @note Expected to create track states for measurements associated to the
0064   ///       given surface which match the given bound state. Moreover the
0065   ///       The "filtered" data is not expected to be set, but the outlier
0066   ///       flag should be set for states that are considered to be outlier.
0067   ///
0068   /// @param geoContext The current geometry context
0069   /// @param calibrationContext pointer to the current calibration context
0070   /// @param surface the surface at which new track states are to be created
0071   /// @param boundState the current bound state of the trajectory
0072   /// @param prevTip Index pointing at previous trajectory state (i.e. tip)
0073   /// @param trackStateCandidates a temporary buffer that can be used to collect track states
0074   /// @param trajectory the trajectory to which the new states are to be added
0075   /// @param logger a logger for messages
0076   /// @return indices of new track states which extend the trajectory given by prevTip
0077 
0078   using TrackStateCreator =
0079       Delegate<Result<CkfTypes::BranchVector<TrackIndexType>>(
0080           const GeometryContext& geoContext,
0081           const CalibrationContext& calibrationContext, const Surface& surface,
0082           const CkfTypes::BoundState& boundState, TrackIndexType prevTip,
0083           std::vector<TrackStateProxy>& trackStateCandidates,
0084           traj_t& trajectory, const Logger& logger)>;
0085 
0086   /// The delegate to create new track states.
0087   /// @note a reference implementation can be found in @ref TrackStateCreator
0088   ///   which makes uses of @ref MeasurementSelector and SourceLinkAccessor
0089   TrackStateCreator createTrackStates;
0090 
0091  private:
0092   /// Default branch stopper which will never stop
0093   /// @return false
0094   static BranchStopperResult voidBranchStopper(
0095       const TrackProxy& /*track*/, const TrackStateProxy& /*trackState*/) {
0096     return BranchStopperResult::Continue;
0097   }
0098 };
0099 }  // namespace Acts