Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-08-29 07:50:43

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/Units.hpp"
0012 #include "Acts/Utilities/CalibrationContext.hpp"
0013 #include "Acts/Utilities/Logger.hpp"
0014 #include "ActsExamples/EventData/MuonSpacePoint.hpp"
0015 
0016 #include <memory>
0017 
0018 namespace ActsExamples {
0019 
0020 /// @brief Calibration class of MuonSpacePoints primarily designed for hits recorded by the ATLAS experiment
0021 class MuonSpacePointCalibrator {
0022  public:
0023   enum class CalibPolyType { Chebychev, Legendre };
0024   /// @brief Calibration configuration struct */
0025   struct Config {
0026     /// @brief Coefficients of the r-t relation parametrised as othogonal polynomial
0027     std::vector<double> rtCoefficients{9.0077,  6.7416,    -1.5805,
0028                                        0.56482, -0.1911,   0.018885,
0029                                        0.03027, -0.034393, 0.023613};
0030     ///  @brief Coefficients of the t-r relation as othogonal polynomial
0031     std::vector<double> trCoefficients{256.328, 348.773, 118.157, 18.667,
0032                                        -6.4899};
0033     /// @brief Coefficients of the drift radius uncertainty parameterized as an othogonal polynomial
0034     ///        as a function of the drift time
0035     std::vector<double> rtUncertCoefficients{0.10833, -0.071956, 0.037702,
0036                                              -0.011763};
0037     /// @brief Type of the calibration polynomial
0038     CalibPolyType rtPolyType{CalibPolyType::Chebychev};
0039     /// @brief Type of the calibration polynomial
0040     CalibPolyType trPolyType{CalibPolyType::Legendre};
0041     /// @brief Type of the calibration polynomial
0042     CalibPolyType rtUncertPolyType{CalibPolyType::Chebychev};
0043     /// @brief Minimum drift time covered by the r-t relation
0044     double minDriftT{0.};
0045     /// @brief Maximum drift time covered by the r-t relation
0046     double maxDriftT{740.203 * Acts::UnitConstants::ns};
0047     /// @brief Minimum radius mapped by the t-r relation
0048     double minTubeR{0.065987 * Acts::UnitConstants::mm};
0049     /// @brief Maximum radius mapped by the t-r relation
0050     double maxTubeR{14.567 * Acts::UnitConstants::mm};
0051     /// @brief Propagation velocity of the electronic signal along the wire
0052     double propagationV{0.};
0053     /// @brief Include trackT0 & time offset in the calibration
0054     bool includeTrackT0{false};
0055     /// @brief Pitch between two Rpc strips oriented parallel to
0056     ///        the Mdt tubes
0057     double rpcEtaStripPitch{2.6 * Acts::UnitConstants::cm};
0058     /// @brief Pitch between two Rpc strips oriented orthogonal
0059     ///     to the Mdt tubes
0060     double rpcPhiStripPitch{3.5 * Acts::UnitConstants::cm};
0061     /// @brief Time resolution of the Rpc detectors
0062     double rpcTimeResolution{0.6 * Acts::UnitConstants::ns};
0063   };
0064 
0065   /// @brief default constructor */
0066   MuonSpacePointCalibrator(const Config& cfg,
0067                            std::unique_ptr<const Acts::Logger> logger);
0068   /// @brief Abbrivation of the uncalibrated space point container type
0069   using UnCalibSpVec_t = std::vector<const MuonSpacePoint*>;
0070   /// @brief Abbrivation to access a single element in the uncalibrated spacepoint container
0071   using UnCalibSp_t = UnCalibSpVec_t::value_type;
0072   /// @brief Use unique pointer for the calibrated measurements
0073   using CalibSp_t = std::unique_ptr<MuonSpacePoint>;
0074   /// @brief Use a simple vector of unique_ptrs as container type
0075   using CalibSpCont_t = std::vector<CalibSp_t>;
0076 
0077   /// @brief Calibrate a list of input space points
0078   /// @param ctx: Calibration context
0079   /// @param trackPos: Position of the track expressed in the MuonSpacePoint's frame
0080   /// @param trackDir: Direction of the track expressed in the MonSpacePoint's frame
0081   /// @param trackT0: Offset in the time of arrival of the track
0082   /// @param uncalibCont: List of uncalibrated space points.
0083   CalibSpCont_t calibrate(const Acts::CalibrationContext& ctx,
0084                           const Acts::Vector3& trackPos,
0085                           const Acts::Vector3& trackDir, const double trackT0,
0086                           const UnCalibSpVec_t& uncalibCont) const;
0087 
0088   /// @param ctx: Calibration context
0089   /// @param trackPos: Position of the track expressed in the MuonSpacePoint's frame
0090   /// @param trackDir: Direction of the track expressed in the MonSpacePoint's frame
0091   /// @param trackT0: Offset in the time of arrival of the track
0092   /// @param spacePoint: Reference to the space point to calibrate
0093   /// @param outContainer: Reference to the mutable output container into which the
0094   ///                      calibrated space point is appended.
0095   void calibrate(const Acts::CalibrationContext& ctx,
0096                  const Acts::Vector3& trackPos, const Acts::Vector3& trackDir,
0097                  const double trackT0, const MuonSpacePoint& spacePoint,
0098                  CalibSpCont_t& outContainer) const;
0099   /// @brief Returns the associated drift velocity for a Mdt space point with
0100   ///        drift radius R
0101   /// @param ctx: Calibration context
0102   /// @param sp: Reference to the space point of interest
0103   double driftVelocity(const Acts::CalibrationContext& ctx,
0104                        const MuonSpacePoint& sp) const;
0105   /// @brief Returns the associated drift acceleration for a Mdt space point with
0106   ///        drift radius R
0107   /// @param ctx: Calibration context
0108   /// @param sp: Reference to the space point of interest
0109   double driftAcceleration(const Acts::CalibrationContext& ctx,
0110                            const MuonSpacePoint& sp) const;
0111 
0112   /// @brief Calculates the drift radius from the drift time of a Mdt
0113   ///        measurement
0114   /// @param driftTime: Drift time in nanoseconds
0115   double driftRadius(const double driftTime) const;
0116   /// @brief Calculates the drift radius from the drift time
0117   /// @param driftTime: Drift time in nanoseconds
0118   double driftVelocity(const double driftTime) const;
0119   /// @brief Calculates the drift radius from the drift time
0120   /// @param driftTime: Drift time in nanoseconds
0121   double driftAcceleration(const double driftTime) const;
0122   /// @brief Calculate the drift time from the drift radius
0123   /// @param driftRadius: Drift radius in mm
0124   double driftTime(const double driftRadius) const;
0125   /// @brief Calculates the uncertainty on the drift radius measurement
0126   ///        as a function of the drift radius
0127   double driftRadiusUncert(const double driftRadius) const;
0128   /// @brief  Const access to the config
0129   const Config& config() const { return m_cfg; }
0130 
0131  private:
0132   /// @brief Evaluate the polynomial or its derivative which is either passed as a
0133   ///        series of Legendre or Cheby polynomials
0134   /// @param xValue: Unbounded value where the polynomial shall be evaluated
0135   /// @param derivative: Order of the derivative to evaluate. 0 is the bare
0136   ///                    polynomial itself
0137   /// @param polyType: Flag toglging whether the polynomial is Legendre or Cheby
0138   /// @param upperBound: Upper boundary of the passable xValues. If exceeded a nullopt
0139   ///                    is returned
0140   /// @param lowerBound: Lower boundary of the possible xValues. If exceeded a nullopt is returned.
0141   ///                    lowerBound & upperBound are used to map the xValue into
0142   ///                    the interval [-1;1]
0143   /// @param coeffs: List of the coefficient expansion
0144   std::optional<double> expandPolySeries(
0145       const double xValue, unsigned derivative, const CalibPolyType polyType,
0146       const double upperBound, const double lowerBound,
0147       const std::vector<double>& coeffs) const;
0148 
0149   const Acts::Logger& logger() const { return *m_logger; }
0150 
0151   std::unique_ptr<const Acts::Logger> m_logger{};
0152   Config m_cfg{};
0153   /// @brief Boundary values on the drift radius uncertainty
0154   double m_minDriftRUncert{driftRadius(m_cfg.minDriftT)};
0155   double m_maxDriftRUncert{driftRadius(m_cfg.maxDriftT)};
0156 };
0157 }  // namespace ActsExamples