Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-17 09:41:39

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/BoundTrackParameters.hpp"
0012 #include "Acts/EventData/SubspaceHelpers.hpp"
0013 #include "Acts/Geometry/GeometryContext.hpp"
0014 #include "Acts/Utilities/Logger.hpp"
0015 #include "ActsExamples/EventData/Index.hpp"
0016 #include "ActsExamples/EventData/SimHit.hpp"
0017 #include "ActsExamples/EventData/SimParticle.hpp"
0018 #include "ActsExamples/EventData/Track.hpp"
0019 #include "ActsExamples/EventData/TruthMatching.hpp"
0020 
0021 #include <optional>
0022 
0023 namespace Acts {
0024 class Surface;
0025 }
0026 
0027 namespace ActsExamples {
0028 
0029 /// The track-state parameters to extract.
0030 enum class TrackParameterType {
0031   /// Parameters before the measurement update
0032   Predicted,
0033   /// Parameters after the measurement update
0034   Filtered,
0035   /// Smoothed parameters
0036   Smoothed,
0037   /// Smoothed parameters with the state's own measurement removed
0038   Unbiased,
0039 };
0040 
0041 /// Compute the truth bound track parameters on a surface from the simulated
0042 /// hits of a measurement.
0043 ///
0044 /// Position, direction, and time are averaged over the simulated hits, the
0045 /// momentum is taken from the first one, and charge and hypothesis from the
0046 /// given particle.
0047 ///
0048 /// @note The hits are averaged regardless of which particle produced them, so
0049 ///       a merged cluster gives a mixture. Same as `RootTrackParameterWriter`.
0050 ///
0051 /// @param gctx The geometry context
0052 /// @param surface The surface to express the truth parameters on
0053 /// @param measurementIndex The index of the measurement on the surface
0054 /// @param particle The truth particle
0055 /// @param simHits The simulated hits container
0056 /// @param measurementSimHitsMap Map from measurement index to simulated hits
0057 /// @param logger A logger for messages
0058 /// @return The parameters without covariance, or nullopt without truth hits
0059 std::optional<Acts::BoundTrackParameters> truthParametersOnSurface(
0060     const Acts::GeometryContext& gctx, const Acts::Surface& surface,
0061     Index measurementIndex, const SimParticle& particle,
0062     const SimHitContainer& simHits,
0063     const MeasurementSimHitsMap& measurementSimHitsMap,
0064     const Acts::Logger& logger);
0065 
0066 /// Extract the reconstructed bound track parameters on the reference surface
0067 /// of a track state.
0068 ///
0069 /// @param state The track state to extract the parameters from
0070 /// @param parameterType Which parameters; if not set, the best available ones
0071 ///        (smoothed, filtered, or predicted). `Unbiased` is never picked
0072 ///        implicitly and has to be requested
0073 /// @param hypothesis The particle hypothesis for the parameters
0074 /// @return The parameters with covariance, or nullopt without a reference
0075 ///         surface or matching parameters
0076 std::optional<Acts::BoundTrackParameters> recoParametersOnSurface(
0077     const ConstTrackStateProxy& state,
0078     std::optional<TrackParameterType> parameterType,
0079     const Acts::ParticleHypothesis& hypothesis);
0080 
0081 /// The residual of track state parameters against the state's own calibrated
0082 /// measurement.
0083 struct MeasurementResidual {
0084   /// The bound parameters the measurement constrains.
0085   Acts::VariableBoundSubspaceHelper subspace;
0086   /// `reco - measurement` in the full bound space, zero outside @c subspace.
0087   Acts::BoundVector residual;
0088   /// The covariance of @c residual, zero outside @c subspace.
0089   Acts::BoundMatrix covariance;
0090 };
0091 
0092 /// Compute the residual of track state parameters against the calibrated
0093 /// measurement of that same state.
0094 ///
0095 /// Both live in the local frame of the state's surface, so this needs neither
0096 /// a geometry context nor truth information.
0097 ///
0098 /// The residual covariance is @f$ V + HPH^T @f$ for parameters that do not
0099 /// use the state's own measurement and @f$ V - HPH^T @f$ for those that do,
0100 /// with @f$ V @f$ the measurement covariance, @f$ P @f$ the parameter
0101 /// covariance, and @f$ H @f$ the projector. The subtracted form is not
0102 /// positive definite in general, so the caller has to handle a non-positive
0103 /// variance.
0104 ///
0105 /// @param state The track state holding the measurement
0106 /// @param parameters The reconstructed parameters on the state's surface
0107 /// @param parameterType Which parameters @p parameters are, deciding the sign
0108 ///        of @f$ HPH^T @f$
0109 /// @return The residual, or nullopt if the state carries no measurement
0110 std::optional<MeasurementResidual> measurementResidual(
0111     const ConstTrackStateProxy& state,
0112     const Acts::BoundTrackParameters& parameters,
0113     TrackParameterType parameterType);
0114 
0115 }  // namespace ActsExamples