Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-22 07:51:56

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