Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-13 08:05:02

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2019-2024 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 http://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Definitions/TrackParametrization.hpp"
0012 #include "Acts/EventData/MeasurementHelpers.hpp"
0013 #include "Acts/EventData/MultiTrajectory.hpp"
0014 #include "Acts/EventData/TrackParameters.hpp"
0015 #include "Acts/EventData/Types.hpp"
0016 #include "Acts/Geometry/GeometryHierarchyMap.hpp"
0017 #include "Acts/Geometry/GeometryIdentifier.hpp"
0018 #include "Acts/TrackFinding/CombinatorialKalmanFilterError.hpp"
0019 #include "Acts/Utilities/Logger.hpp"
0020 #include "Acts/Utilities/Result.hpp"
0021 
0022 #include <cassert>
0023 #include <cstddef>
0024 #include <iterator>
0025 #include <limits>
0026 #include <utility>
0027 #include <vector>
0028 
0029 namespace Acts {
0030 
0031 /// Selection cuts for associating measurements with predicted track
0032 /// parameters on a surface.
0033 ///
0034 /// The default configuration only takes the best matching measurement without a
0035 /// cut on the local chi2.
0036 struct MeasurementSelectorCuts {
0037   /// bins in |eta| to specify variable selections
0038   std::vector<double> etaBins{};
0039   /// Maximum local chi2 contribution to classify as measurement.
0040   std::vector<double> chi2CutOff{15};
0041   /// Maximum number of associated measurements on a single surface.
0042   std::vector<std::size_t> numMeasurementsCutOff{1};
0043   /// Maximum local chi2 contribution to classify as outlier.
0044   std::vector<double> chi2CutOffOutlier{};
0045 };
0046 
0047 /// @brief Measurement selection struct selecting those measurements compatible
0048 /// with the given track parameter against provided criteria on one surface
0049 ///
0050 /// The selection criteria could be allowed maximum chi2
0051 /// and allowed maximum number of measurements on one surface
0052 ///
0053 /// If there is no compatible measurement, the measurement with the minimum
0054 /// chi2 will be selected and the status will be tagged as an outlier
0055 ///
0056 class MeasurementSelector {
0057  public:
0058   /// Geometry-dependent cut configuration.
0059   ///
0060   /// Different components on the geometry can require different cut settings.
0061   /// The configuration must either contain explicit settings for all geometry
0062   /// components that are used or contain a global default.
0063   using Config = Acts::GeometryHierarchyMap<MeasurementSelectorCuts>;
0064 
0065   /// @brief Default constructor
0066   ///
0067   /// This will use the default configuration for the cuts.
0068   MeasurementSelector();
0069 
0070   /// @brief Constructor with cuts
0071   ///
0072   /// @param cuts The cuts to use
0073   explicit MeasurementSelector(const MeasurementSelectorCuts& cuts);
0074 
0075   /// @brief Constructor with config
0076   ///
0077   /// @param config a config instance
0078   explicit MeasurementSelector(const Config& config);
0079 
0080   /// @brief Function that select the measurements compatible with
0081   /// the given track parameter on a surface
0082   ///
0083   /// @param candidates The track state candidates which already contain predicted parameters
0084   /// @param isOutlier The indicator for outlier or not
0085   /// @param logger The logger wrapper
0086   ///
0087   /// @return Pair of iterators into @a candidates marking the range of selected candidates
0088   ///
0089 
0090   template <typename traj_t>
0091   Result<std::pair<
0092       typename std::vector<typename traj_t::TrackStateProxy>::iterator,
0093       typename std::vector<typename traj_t::TrackStateProxy>::iterator>>
0094   select(std::vector<typename traj_t::TrackStateProxy>& candidates,
0095          bool& isOutlier, const Logger& logger) const;
0096 
0097  private:
0098   struct InternalCutBin {
0099     double maxTheta{};
0100     std::size_t maxNumMeasurements{};
0101     double maxChi2Measurement{};
0102     double maxChi2Outlier{};
0103   };
0104   using InternalCutBins = std::vector<InternalCutBin>;
0105   using InternalConfig = Acts::GeometryHierarchyMap<InternalCutBins>;
0106 
0107   struct Cuts {
0108     std::size_t numMeasurements{};
0109     double chi2Measurement{};
0110     double chi2Outlier{};
0111   };
0112 
0113   static InternalCutBins convertCutBins(const MeasurementSelectorCuts& config);
0114 
0115   static Cuts getCutsByTheta(const InternalCutBins& config, double theta);
0116   Result<Cuts> getCuts(const GeometryIdentifier& geoID, double theta) const;
0117 
0118   double calculateChi2(
0119       const double* fullCalibrated, const double* fullCalibratedCovariance,
0120       TrackStateTraits<MultiTrajectoryTraits::MeasurementSizeMax,
0121                        false>::Parameters predicted,
0122       TrackStateTraits<MultiTrajectoryTraits::MeasurementSizeMax,
0123                        false>::Covariance predictedCovariance,
0124       BoundSubspaceIndices projector, unsigned int calibratedSize) const;
0125 
0126   InternalConfig m_config;
0127 };
0128 
0129 }  // namespace Acts
0130 
0131 #include "MeasurementSelector.ipp"