Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-21 08:03:09

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       MaxVal
0060     };
0061     /// @brief Detector side encoding
0062     enum class DetSide : std::int8_t { UnDef = 0, A = 1, C = -1 };
0063     /// @brief Print the Identifier's stationName to a string
0064     static std::string toString(const StationName st);
0065     /// @brief Print the Identifier's technologyField to a string
0066     static std::string toString(const TechField tech);
0067     /// @brief Print the Identifier's detector side to a string
0068     static std::string toString(const DetSide side);
0069 
0070     /// @brief Constructor taking the encoded 32 bit integer
0071     explicit MuonId(std::uint32_t rawRep);
0072     /// @brief Returns the integer representation of the Identifier
0073     std::uint32_t toInt() const;
0074     /// @brief Empty default Identifier constructor
0075     explicit MuonId() = default;
0076     /// @brief Default copy constructor
0077     MuonId(const MuonId& other) = default;
0078     /// @brief Default move constructor
0079     MuonId(MuonId&& other) = default;
0080     /// @brief Default copy assignment
0081     MuonId& operator=(const MuonId& other) = default;
0082     /// @brief Default move assignment
0083     MuonId& operator=(MuonId&& other) = default;
0084     /// @brief Returns the technology of the measurement
0085     TechField technology() const { return m_tech; }
0086     /// @brief Returns the MS station in which the measurement was recorded
0087     StationName msStation() const { return m_stName; }
0088     /// @brief Returns the sector in which the measurement was recorded
0089     std::uint16_t sector() const { return m_sector; }
0090     /// @brief Returns the detector side
0091     DetSide side() const { return m_side; }
0092     /// @brief Returns the layer
0093     std::uint8_t detLayer() const { return m_layer; }
0094     /// @brief Returns the channel number
0095     std::uint16_t channel() const { return m_channel; }
0096     /// @brief Returns whether the id corresponds to a precision coordinate (eta) measurement
0097     bool measuresEta() const { return m_measEta; }
0098     /// @brief Returns whether the id corresponds to a non-precision coordinate (phi) measurement
0099     bool measuresPhi() const { return m_measPhi; }
0100     /// @brief Returns whether the id corresponds to a channel carrying time information
0101     bool measuresTime() const { return m_measTime; }
0102     /// @brief Returns whether two Identifiers belong to the same station, which
0103     ///        is characterized that both share the same msStation, sector &
0104     ///        side field.
0105     bool sameStation(const MuonId& other) const {
0106       return msStation() == other.msStation() && sector() == other.sector() &&
0107              side() == other.side();
0108     }
0109     /// @brief Set the fields needed to Identify the detector in the system
0110     /// @param stName: StationName where the muon station is located
0111     /// @param side: Positive or negative side
0112     /// @param sector: Phi sector in which the chamber is installed
0113     /// @param tech: Technology of the chamber within the chamber
0114     void setChamber(StationName stName, DetSide side, std::uint16_t sector,
0115                     TechField tech);
0116     /// @brief Set the measurement layer & channel */
0117     void setLayAndCh(std::uint8_t layer, std::uint16_t ch);
0118     /// @brief Define the measurement type of the space point
0119     /// @param measEta: Flag stating whether the space point measures the precision (eta) coordinate
0120     /// @param measPhi: Flag stating whether the space point measures the non-precsion (phi) coordinate
0121     /// @param measTime: Flag stating whether the space point carries time information
0122     void setCoordFlags(bool measEta, bool measPhi, bool measTime = false);
0123     /// @brief prints the Muon identifier to string
0124     std::string toString() const;
0125 
0126    private:
0127     TechField m_tech{TechField::UnDef};
0128     StationName m_stName{StationName::UnDef};
0129     DetSide m_side{DetSide::UnDef};
0130     std::uint16_t m_sector{1};
0131     std::uint8_t m_layer{1};
0132     std::uint16_t m_channel{1};
0133     bool m_measEta{false};
0134     bool m_measPhi{false};
0135     bool m_measTime{false};
0136   };
0137   /// @brief Empty default constructor
0138   MuonSpacePoint() = default;
0139   /// @brief Copy constructor
0140   MuonSpacePoint(const MuonSpacePoint& other) = default;
0141   /// @brief Move constructor
0142   MuonSpacePoint(MuonSpacePoint&& other) = default;
0143   /// @brief Copy assignment
0144   MuonSpacePoint& operator=(const MuonSpacePoint& other) = default;
0145   /// @brief Move assignment
0146   MuonSpacePoint& operator=(MuonSpacePoint&& other) = default;
0147   /// @brief Returns the Identifier of the space point
0148   const MuonId& id() const { return m_id; }
0149   /// @brief Returnt the geometry Identifier of the space point
0150   const Acts::GeometryIdentifier& geometryId() const { return m_geoId; }
0151   /// @brief Returns the local measurement position
0152   const Acts::Vector3& localPosition() const { return m_pos; }
0153   /// @brief Returns the local sensor direction
0154   const Acts::Vector3& sensorDirection() const { return m_dir; }
0155   /// @brief Returns the normal vector to the plane
0156   const Acts::Vector3& planeNormal() const { return m_norm; }
0157   /// @brief Returns the vector pointing to the next wire / strip
0158   const Acts::Vector3& toNextSensor() const { return m_toNext; }
0159   /// @brief Returns the space point covariance values
0160   const std::array<double, 3>& covariance() const { return m_cov; }
0161   /// @brief Returns the drift radius
0162   double driftRadius() const { return m_radius; }
0163   /// @brief Returns the measurement time *
0164   double time() const { return m_time; }
0165   /// @brief Returns whether the measurement is a straw measurement
0166   bool isStraw() const { return id().technology() == MuonId::TechField::Mdt; }
0167   /// @brief Returns whether the measurement provides time information
0168   bool hasTime() const { return id().measuresTime(); }
0169   /// @brief Returns whether the measurement constrains the bending plane
0170   bool measuresLoc1() const { return id().measuresEta(); }
0171   /// @brief Returns whether the measurement constrains the non-bending plane
0172   bool measuresLoc0() const { return id().measuresPhi(); }
0173   /// @brief Define the space point's identifier
0174   void setId(const MuonId& id);
0175   /// @brief Define the space point coordinates.
0176   /// @param pos: Space point position
0177   /// @param sensorDir: Direction of the sensor
0178   /// @param toNextSensor: Vector pointing to the next sensor
0179   void defineCoordinates(Acts::Vector3&& pos, Acts::Vector3&& sensorDir,
0180                          Acts::Vector3&& toNextSensor);
0181   /// @brief Define the space point radius
0182   void setRadius(const double r);
0183   /// @brief Define the time of the space point measurement
0184   void setTime(const double t);
0185   /// @brief Define the spatial components of the covariance
0186   void setCovariance(const double covX, const double covY, const double covT);
0187   /// @brief Set the geometry identifier
0188   void setGeometryId(const Acts::GeometryIdentifier& geoId);
0189 
0190  private:
0191   MuonId m_id{};
0192   Acts::Vector3 m_pos{Acts::Vector3::Zero()};
0193   Acts::Vector3 m_dir{Acts::Vector3::Zero()};
0194   Acts::Vector3 m_toNext{Acts::Vector3::Zero()};
0195   Acts::Vector3 m_norm{Acts::Vector3::Zero()};
0196 
0197   std::array<double, 3> m_cov{Acts::filledArray<double, 3>(0.)};
0198   double m_radius{0.};
0199   double m_time{0.};
0200   Acts::GeometryIdentifier m_geoId{};
0201 };
0202 
0203 static_assert(Acts::Experimental::CompositeSpacePoint<MuonSpacePoint>);
0204 /// @brief Abbrivation of the MuonSpace point container as a jagged vector of
0205 ///        space point objects. The inner vector represents a collection of
0206 ///        spacepoints that are close-by together in space, a so-called bucket
0207 using MuonSpacePointBucket = std::vector<MuonSpacePoint>;
0208 using MuonSpacePointContainer = std::vector<MuonSpacePointBucket>;
0209 
0210 /// @brief ostream operator of the Muon space point Identifier
0211 std::ostream& operator<<(std::ostream& ostr,
0212                          const ActsExamples::MuonSpacePoint::MuonId& id);
0213 /// @brief osteram operator of the Space point
0214 std::ostream& operator<<(std::ostream& ostr,
0215                          const ActsExamples::MuonSpacePoint& sp);
0216 }  // namespace ActsExamples