Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-23 07:34:27

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/EventData/MultiComponentTrackParameters.hpp"
0012 #include "Acts/EventData/MultiTrajectory.hpp"
0013 #include "Acts/Geometry/GeometryContext.hpp"
0014 #include "Acts/MagneticField/MagneticFieldContext.hpp"
0015 #include "Acts/Propagator/PropagatorOptions.hpp"
0016 #include "Acts/TrackFitting/GsfComponent.hpp"
0017 #include "Acts/TrackFitting/detail/VoidFitterComponents.hpp"
0018 #include "Acts/Utilities/CalibrationContext.hpp"
0019 #include "Acts/Utilities/Delegate.hpp"
0020 #include "Acts/Utilities/Logger.hpp"
0021 
0022 namespace Acts {
0023 
0024 /// @addtogroup track_fitting
0025 /// @{
0026 
0027 /// @enum ComponentMergeMethod
0028 ///
0029 /// Available reduction methods for the reduction of a Gaussian mixture
0030 enum class ComponentMergeMethod { eMean, eMaxWeight };
0031 
0032 namespace GsfConstants {
0033 constexpr std::string_view kFinalMultiComponentStateColumn =
0034     "gsf-final-multi-component-state";
0035 using FinalMultiComponentState =
0036     std::optional<MultiComponentBoundTrackParameters>;
0037 constexpr std::string_view kFwdSumMaterialXOverX0 =
0038     "gsf-fwd-sum-material-x-over-x0";
0039 constexpr std::string_view kFwdMaxMaterialXOverX0 =
0040     "gsf-fwd-max-material-x-over-x0";
0041 }  // namespace GsfConstants
0042 
0043 /// The extensions needed for the GSF
0044 template <typename traj_t>
0045 struct GsfExtensions {
0046   /// Type alias for mutable track state proxy
0047   using TrackStateProxy = typename traj_t::TrackStateProxy;
0048   /// Type alias for const track state proxy
0049   using ConstTrackStateProxy = typename traj_t::ConstTrackStateProxy;
0050 
0051   /// Type alias for calibrator delegate function
0052   using Calibrator =
0053       Delegate<void(const GeometryContext &, const CalibrationContext &,
0054                     const SourceLink &, TrackStateProxy)>;
0055 
0056   /// Type alias for updater delegate function
0057   using Updater = Delegate<Result<void>(const GeometryContext &,
0058                                         TrackStateProxy, const Logger &)>;
0059 
0060   /// Type alias for outlier finder delegate function
0061   using OutlierFinder = Delegate<bool(ConstTrackStateProxy)>;
0062 
0063   /// Type alias for component reducer delegate function
0064   using ComponentReducer =
0065       Delegate<void(std::vector<GsfComponent> &, std::size_t, const Surface &)>;
0066 
0067   /// The Calibrator is a dedicated calibration algorithm that allows
0068   /// to calibrate measurements using track information, this could be
0069   /// e.g. sagging for wires, module deformations, etc.
0070   Calibrator calibrator;
0071 
0072   /// The updater incorporates measurement information into the track parameters
0073   Updater updater;
0074 
0075   /// Determines whether a measurement is supposed to be considered as an
0076   /// outlier
0077   OutlierFinder outlierFinder;
0078 
0079   /// Retrieves the associated surface from a source link
0080   SourceLinkSurfaceAccessor surfaceAccessor;
0081 
0082   /// Takes a vector of components and reduces its number
0083   ComponentReducer mixtureReducer;
0084 
0085   /// Default constructor which connects the default void components
0086   GsfExtensions() {
0087     calibrator.template connect<&detail::voidFitterCalibrator<traj_t>>();
0088     updater.template connect<&detail::voidFitterUpdater<traj_t>>();
0089     outlierFinder.template connect<&detail::voidOutlierFinder<traj_t>>();
0090     surfaceAccessor.connect<&detail::voidSurfaceAccessor>();
0091     mixtureReducer
0092         .template connect<&detail::voidComponentReducer<GsfComponent>>();
0093   }
0094 };
0095 
0096 /// Options for configuring the Gaussian-sum filter fit.
0097 template <typename traj_t>
0098 struct GsfOptions {
0099   /// Geometry context for this fit
0100   std::reference_wrapper<const GeometryContext> geoContext;
0101   /// Magnetic field context for this fit
0102   std::reference_wrapper<const MagneticFieldContext> magFieldContext;
0103   /// Calibration context for this fit
0104   std::reference_wrapper<const CalibrationContext> calibrationContext;
0105 
0106   /// Extensions for GSF components
0107   GsfExtensions<traj_t> extensions;
0108 
0109   /// Propagator options
0110   PropagatorPlainOptions propagatorPlainOptions;
0111 
0112   /// Reference surface for the final track parameters
0113   const Surface *referenceSurface = nullptr;
0114 
0115   /// Maximum number of components in the mixture
0116   std::size_t maxComponents = 4;
0117 
0118   /// Minimum weight required to keep a component
0119   double weightCutoff = 1.e-4;
0120 
0121   /// Abort the fit if an error occurs
0122   bool abortOnError = false;
0123 
0124   /// Disable all material handling during the fit
0125   bool disableAllMaterialHandling = false;
0126 
0127   /// Scaling factor for the covariance matrix before reverse filtering.
0128   /// Note that the default value is not tuned and might need adjustment for
0129   /// different use cases.
0130   double reverseFilteringCovarianceScaling = 100.0;
0131 
0132   /// Whether to use the external-surfaces mechanism of the navigator which
0133   /// switches off the boundary-check for measurement surfaces.
0134   bool useExternalSurfaces = true;
0135 
0136   /// Column name for final multi-component state storage
0137   std::string_view finalMultiComponentStateColumn = "";
0138 
0139   /// Method for merging components
0140   ComponentMergeMethod componentMergeMethod = ComponentMergeMethod::eMaxWeight;
0141 
0142   /// Constructor from contexts
0143   /// @param geoCtxt The geometry context
0144   /// @param magFieldCtxt The magnetic field context
0145   /// @param calibCtxt The calibration context
0146   GsfOptions(const GeometryContext &geoCtxt,
0147              const MagneticFieldContext &magFieldCtxt,
0148              const CalibrationContext &calibCtxt)
0149       : geoContext(geoCtxt),
0150         magFieldContext(magFieldCtxt),
0151         calibrationContext(calibCtxt),
0152         propagatorPlainOptions(geoCtxt, magFieldCtxt) {}
0153 };
0154 
0155 /// @}
0156 
0157 }  // namespace Acts