Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-20 07:47:04

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