Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 08:02:50

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 #pragma once
0009 
0010 #include "Acts/Definitions/Algebra.hpp"
0011 #include "Acts/Definitions/Common.hpp"
0012 #include "Acts/EventData/CompositeSpacePoint.hpp"
0013 #include "Acts/Geometry/GeometryIdentifier.hpp"
0014 #include "Acts/Utilities/ArrayHelpers.hpp"
0015 
0016 #include <cstdint>
0017 #include <iostream>
0018 #include <memory>
0019 #include <optional>
0020 #include <vector>
0021 
0022 namespace ActsExamples {
0023 /// @brief Example implementation of a CompositeSpacePoint concept inspired by the ATLAS Muon::SpacePoint EDM.
0024 ///         The space points are expressed in a local frame such that the x-axis
0025 ///         is parallel to the ATLAS Monitored Drift Tubes (Mdt), the y-axis
0026 ///         points within the tube layer & the z-axis outside of the plane.
0027 class MuonSpacePoint {
0028  public:
0029   /// @brief Identifier helper class to distinguish different measurements
0030   class MuonId {
0031    public:
0032     /// @brief Technology encoding of the measurement
0033     enum class TechField : std::int8_t {
0034       UnDef = -1,
0035       Mdt = 0,
0036       Rpc = 2,
0037       Tgc = 3,
0038       sTgc = 4,
0039       Mm = 5
0040     };
0041     /// @brief ATLAS-MS station encoding
0042     enum class StationName : std::int8_t {
0043       UnDef = -1,
0044       BIS,
0045       BIL,
0046       BMS,
0047       BML,
0048       BOS,
0049       BOL,
0050       BEE,
0051       EIS,
0052       EIL,
0053       EMS,
0054       EML,
0055       EOS,
0056       EOL,
0057       EES,
0058       EEL
0059     };
0060     /// @brief Detector side encoding
0061     enum class DetSide : std::int8_t { UnDef = 0, A = 1, C = -1 };
0062     /// @brief Print the Identifier's stationName to a string
0063     static std::string toString(const StationName st);
0064     /// @brief Print the Identifier's technologyField to a string
0065     static std::string toString(const TechField tech);
0066     /// @brief Print the Identifier's detector side to a string
0067     static std::string toString(const DetSide side);
0068     /// @brief Empty default Identifier constructor
0069     explicit MuonId() = default;
0070     /// @brief Default copy constructor
0071     MuonId(const MuonId& other) = default;
0072     /// @brief Default move constructor
0073     MuonId(MuonId&& other) = default;
0074     /// @brief Default copy assignment
0075     MuonId& operator=(const MuonId& other) = default;
0076     /// @brief Default move assignment
0077     MuonId& operator=(MuonId&& other) = default;
0078     /// @brief Returns the technology of the measurement
0079     TechField technology() const { return m_tech; }
0080     /// @brief Returns the MS station in which the measurement was recorded
0081     StationName msStation() const { return m_stName; }
0082     /// @brief Returns the sector in which the measurement was recorded
0083     std::uint8_t sector() const { return m_sector; }
0084     /// @brief Returns the detector side
0085     DetSide side() const { return m_side; }
0086     /// @brief Returns the layer
0087     std::uint8_t detLayer() const { return m_layer; }
0088     /// @brief Returns the channel number
0089     std::uint16_t channel() const { return m_channel; }
0090     /// @brief Returns whether the id corresponds to a precision coordinate (eta) measurement
0091     bool measuresEta() const { return m_measEta; }
0092     /// @brief Returns whether the id corresponds to a non-precision coordinate (phi) measurement
0093     bool measuresPhi() const { return m_measPhi; }
0094     /// @brief Returns whether two Identifiers belong to the same station, which
0095     ///        is characterized that both share the same msStation, sector &
0096     ///        side field.
0097     bool sameStation(const MuonId& other) const {
0098       return msStation() == other.msStation() && sector() == other.sector() &&
0099              side() == other.side();
0100     }
0101     /// @brief Set the fields needed to Identify the detector in the system
0102     /// @param stName: StationName where the muon station is located
0103     /// @param side: Positive or negative side
0104     /// @param sector: Phi sector in which the chamber is installed
0105     /// @param tech: Technology of the chamber within the chamber
0106     void setChamber(StationName stName, DetSide side, int sector,
0107                     TechField tech);
0108     /// @brief Set the measurement layer & channel */
0109     void setLayAndCh(std::uint8_t layer, std::uint16_t ch);
0110     /// @brief Define the measurement type of the space point
0111     /// @param measEta: Flag stating whether the space point measures the precision (eta) coordinate
0112     /// @param measPhi: Flag stating whether the space point measures the non-precsion (phi) coordinate
0113     void setCoordFlags(bool measEta, bool measPhi);
0114     /// @brief prints the Muon identifier to string
0115     std::string toString() const;
0116 
0117    private:
0118     TechField m_tech{TechField::UnDef};
0119     StationName m_stName{StationName::UnDef};
0120     DetSide m_side{DetSide::UnDef};
0121     std::uint8_t m_sector{0};
0122     std::uint8_t m_layer{0};
0123     std::uint16_t m_channel{0};
0124     bool m_measEta{false};
0125     bool m_measPhi{false};
0126   };
0127   /// @brief Empty default constructor
0128   MuonSpacePoint() = default;
0129   /// @brief Copy constructor
0130   MuonSpacePoint(const MuonSpacePoint& other) = default;
0131   /// @brief Move constructor
0132   MuonSpacePoint(MuonSpacePoint&& other) = default;
0133   /// @brief Copy assignment
0134   MuonSpacePoint& operator=(const MuonSpacePoint& other) = default;
0135   /// @brief Move assignment
0136   MuonSpacePoint& operator=(MuonSpacePoint&& other) = default;
0137   /// @brief Returns the Identifier of the space point
0138   const MuonId& id() const { return m_id; }
0139   /// @brief Returnt the geometry Identifier of the space point
0140   const Acts::GeometryIdentifier& geometryId() const { return m_geoId; }
0141   /// @brief Returns the local measurement position
0142   const Acts::Vector3& localPosition() const { return m_pos; }
0143   /// @brief Returns the local sensor direction
0144   const Acts::Vector3& sensorDirection() const { return m_dir; }
0145   /// @brief Returns the normal vector to the plane
0146   const Acts::Vector3& planeNormal() const { return m_norm; }
0147   /// @brief Returns the vector pointing to the next wire / strip
0148   const Acts::Vector3& toNextSensor() const { return m_toNext; }
0149   /// @brief Returns the space point covariance values
0150   const std::array<double, 3>& covariance() const { return m_cov; }
0151   /// @brief Returns the drift radius
0152   double driftRadius() const { return m_radius; }
0153   /// @brief Returns the measurement time *
0154   double time() const { return m_time.value_or(0.); }
0155   /// @brief Returns whether the measurement is a straw measurement
0156   bool isStraw() const { return id().technology() == MuonId::TechField::Mdt; }
0157   /// @brief Returns whether the measurement provides time information
0158   bool hasTime() const { return m_time.has_value(); }
0159   /// @brief Returns whether the measurement constrains the bending plane
0160   bool measuresLoc1() const { return id().measuresEta(); }
0161   /// @brief Returns whether the measurement constrains the non-bending plane
0162   bool measuresLoc0() const { return id().measuresPhi(); }
0163   /// @brief Define the space point's identifier
0164   void setId(const MuonId& id);
0165   /// @brief Define the space point coordinates.
0166   /// @param pos: Space point position
0167   /// @param sensorDir: Direction of the sensor
0168   /// @param toNextSensor: Vector pointing to the next sensor
0169   void defineCoordinates(Acts::Vector3&& pos, Acts::Vector3&& sensorDir,
0170                          Acts::Vector3&& toNextSensor);
0171   /// @brief Define the space point radius
0172   void setRadius(const double r);
0173   /// @brief Define the time of the space point measurement
0174   void setTime(const double t);
0175   /// @brief Define the spatial components of the covariance
0176   void setCovariance(const double covX, const double covY, const double covT);
0177   /// @brief Set the geometry identifier
0178   void setGeometryId(const Acts::GeometryIdentifier& geoId);
0179 
0180  private:
0181   MuonId m_id{};
0182   Acts::Vector3 m_pos{Acts::Vector3::Zero()};
0183   Acts::Vector3 m_dir{Acts::Vector3::Zero()};
0184   Acts::Vector3 m_toNext{Acts::Vector3::Zero()};
0185   Acts::Vector3 m_norm{Acts::Vector3::Zero()};
0186 
0187   std::array<double, 3> m_cov{Acts::filledArray<double, 3>(0.)};
0188   double m_radius{0.};
0189   std::optional<double> m_time{std::nullopt};
0190   Acts::GeometryIdentifier m_geoId{};
0191 };
0192 
0193 static_assert(Acts::Experimental::CompositeSpacePoint<MuonSpacePoint>);
0194 /// @brief Abbrivation of the MuonSpace point container as a jagged vector of
0195 ///        space point objects. The inner vector represents a collection of
0196 ///        spacepoints that are close-by together in space, a so-called bucket
0197 using MuonSpacePointBucket = std::vector<MuonSpacePoint>;
0198 using MuonSpacePointContainer = std::vector<MuonSpacePointBucket>;
0199 
0200 /// @brief ostream operator of the Muon space point Identifier
0201 std::ostream& operator<<(std::ostream& ostr,
0202                          const ActsExamples::MuonSpacePoint::MuonId& id);
0203 /// @brief osteram operator of the Space point
0204 std::ostream& operator<<(std::ostream& ostr,
0205                          const ActsExamples::MuonSpacePoint& sp);
0206 }  // namespace ActsExamples