Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-05-14 07:56:51

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