Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-20 08:20:00

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