Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:11:05

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