Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-17 07:59:45

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 <atomic>
0012 #include <vector>
0013 
0014 namespace Acts::Experimental {
0015 
0016 /// Region-of-interest descriptor with eta/phi/zed bounds.
0017 class RoiDescriptor {
0018  public:
0019   /// Iterator type for RoI constituents
0020   using roi_iterator = std::vector<const RoiDescriptor*>::const_iterator;
0021   /// convenient
0022   static constexpr bool FULLSCAN = true;
0023   /// Flag for region-of-interest mode
0024   static constexpr bool ROI = false;
0025 
0026   /**
0027    * @brief constructor
0028    * @param eta      eta of RoI
0029    * @param etaMinus eta at rear  of RoI
0030    * @param etaPlus  eta at front of RoI
0031    * @param phi      phi of RoI
0032    * @param phiMinus minimum phi of RoI
0033    * @param phiPlus  maximum phi of RoI
0034    * @param zed      zed of RoI
0035    * @param zedMinus zed at rear  of RoI
0036    * @param zedPlus  zed at front of RoI
0037    */
0038   RoiDescriptor(double eta, double etaMinus, double etaPlus, double phi,
0039                 double phiMinus, double phiPlus, double zed = 0,
0040                 double zedMinus = -s_zedWidthDefault,
0041                 double zedPlus = s_zedWidthDefault);
0042 
0043   // Methods to retrieve data members
0044 
0045   /// Get phi coordinate of RoI center
0046   /// @return Phi coordinate
0047   double phi() const { return m_phi; }
0048   /// Get eta coordinate of RoI center
0049   /// @return Eta coordinate
0050   double eta() const { return m_eta; }
0051   /// Get z coordinate of RoI center
0052   /// @return Z coordinate
0053   double zed() const { return m_zed; }
0054 
0055   /// these quantities probably don't need to be used any more
0056   /// - they are implemented here only because we had them in
0057   ///   the original legacy interface
0058 
0059   /// Get z at the most forward end of the RoI
0060   /// @return Z at front
0061   double zedPlus() const {
0062     return m_zedPlus;
0063   }  //!< z at the most forward end of the RoI
0064   /// Get z at the most backward end of the RoI
0065   /// @return Z at rear
0066   double zedMinus() const {
0067     return m_zedMinus;
0068   }  //!< z at the most backward end of the RoI
0069 
0070   /// Gets eta at zedPlus
0071   /// @return Eta at front
0072   double etaPlus() const { return m_etaPlus; }
0073   /// Gets eta at zMinus
0074   /// @return Eta at rear
0075   double etaMinus() const { return m_etaMinus; }
0076 
0077   /// Gets phiPlus
0078   /// @return Maximum phi
0079   double phiPlus() const { return m_phiPlus; }
0080   /// Gets phiMinus
0081   /// @return Minimum phi
0082   double phiMinus() const { return m_phiMinus; }
0083 
0084   /// versioning
0085   /// Get version identifier
0086   /// @return Version number
0087   int version() const { return m_version; }
0088   /// Set version identifier
0089   /// @param v Version number
0090   void version(int v) { m_version = v; }
0091 
0092   /// output
0093   // virtual operator std::string() const ;
0094 
0095   /// is this a full scan RoI?
0096   /// @return True if full scan RoI
0097   bool isFullscan() const { return m_fullscan; }
0098 
0099   /// SuperRoI compatibility methods
0100 
0101   /// am I a SuperRoi?
0102   /// @return True if composite RoI
0103   bool composite() const { return m_composite; }
0104   /// Set composite flag
0105   /// @param b True to mark as composite
0106   void setComposite(bool b = true) { m_composite = b; }
0107 
0108   /// Always manage constituents
0109   /// @return True if managing constituents
0110   bool manageConstituents() const { return m_manageConstituents; }
0111   /// Set whether to manage constituents
0112   /// @param b True to manage constituents
0113   void manageConstituents(bool b) { m_manageConstituents = b; }
0114 
0115   /// number of constituents
0116   /// @return Number of constituent RoIs
0117   unsigned size() const { return m_roiDescriptors.size(); }
0118 
0119   /// find an RoiDescriptor constituent
0120   /// @param i Index of the constituent
0121   /// @return The RoI constituent at the given index
0122   const RoiDescriptor* at(int i) const { return m_roiDescriptors.at(i); }
0123 
0124   /// clear the vector
0125   void clear() { m_roiDescriptors.clear(); }  // setComposite(false); }
0126 
0127   /// reserve elements in vector
0128   /// @param s Number of elements to reserve
0129   void reserve(std::size_t s) { m_roiDescriptors.reserve(s); }
0130 
0131   /// add a RoiDescriptor
0132   /// @param roi RoI constituent to add
0133   void push_back(const RoiDescriptor* roi) {
0134     m_roiDescriptors.push_back(roi);
0135     setComposite(true);
0136   }
0137 
0138   /// iterators
0139   /// @return Begin iterator
0140   roi_iterator begin() const { return m_roiDescriptors.begin(); }
0141   /// Get end iterator
0142   /// @return End iterator
0143   roi_iterator end() const { return m_roiDescriptors.end(); }
0144 
0145   /// return the gradients
0146   /// Get dz/dr at the rear of the RoI
0147   /// @return Gradient dzdr at rear
0148   double dzdrMinus() const {
0149     return m_dzdrMinus;
0150   }  //!<  dz/dr at the rear of the RoI
0151   /// Get dz/dr at the front of the RoI
0152   /// @return Gradient dzdr at front
0153   double dzdrPlus() const { return m_dzdrPlus; }
0154 
0155   /// Get dr/dz at the rear of the RoI
0156   /// @return Gradient drdz at rear
0157   double drdzMinus() const { return m_drdzMinus; }
0158   /// Get dr/dz at the front of the RoI
0159   /// @return Gradient drdz at front
0160   double drdzPlus() const { return m_drdzPlus; }
0161 
0162   /// methods to calculate z position at the RoI boundary
0163   /// at a given radius
0164   /// Get minimum z at given radius
0165   /// @param r Radius coordinate
0166   /// @return Minimum z position
0167   double zedMin(double r) const;
0168   /// Get maximum z at given radius
0169   /// @param r Radius coordinate
0170   /// @return Maximum z position
0171   double zedMax(double r) const;
0172 
0173   /// Get z at the most forward end of the RoI at outer radius
0174   /// @return Z at front outer radius
0175   double zedOuterPlus() const {
0176     return m_zedOuterPlus;
0177   }  //!< z at the most forward end of the RoI
0178   /// Get z at the most backward end of the RoI at outer radius
0179   /// @return Z at rear outer radius
0180   double zedOuterMinus() const {
0181     return m_zedOuterMinus;
0182   }  //!< z at the most backward end of the RoI
0183 
0184   /// Get minimum rho at given z
0185   /// @param z Z coordinate
0186   /// @return Minimum rho
0187   double rhoMin(double z) const;
0188   /// Get maximum rho at given z
0189   /// @param z Z coordinate
0190   /// @return Maximum rho
0191   double rhoMax(double z) const;
0192 
0193   /// Get default z-width
0194   /// @return Default z width
0195   static double zedWidthDefault() { return s_zedWidthDefault; }
0196 
0197   /// set default z-width (but only before any RoiDescriptor has been created)
0198   /// @param d Default z width value
0199   static void zedWidthDefault(double d);
0200 
0201   // fromn trig
0202   /// Get RoI identifier
0203   /// @return RoI ID
0204   unsigned int roiId() const { return m_roiId; }
0205   /// Get lvl1 event number
0206   /// @return Level 1 ID
0207   unsigned int l1Id() const { return m_l1Id; }
0208   /// Get lvl1 RoI word
0209   /// @return RoI word
0210   unsigned int roiWord() const { return m_roiWord; }
0211 
0212  private:
0213   /// default parameters - there may be better ways, but this will do
0214   static std::atomic<double> s_zedWidthDefault;
0215   /// to ensure default width is only set once at job startup
0216   static std::atomic<bool> s_firstInstanceCreated;
0217 
0218   float m_phi{};  //!< phi of RoI center
0219   float m_eta{};  //!< eta of RoI center
0220   float m_zed{};  //!< zed of RoI center
0221 
0222   float m_phiMinus{};  //!< most negative RoI in azimuthal
0223   float m_phiPlus{};   //!< most positive RoI in azimuthal
0224   float m_etaMinus{};  //!< eta of RoI at zedMinus
0225   float m_etaPlus{};   //!< eta of RoI at zedPlus
0226   float m_zedMinus{};  //!< z position at most negative position along the
0227                        //!< beamline
0228   float
0229       m_zedPlus{};  //!< z position at most positive position along the beamline
0230 
0231   float m_dzdrMinus{};  //!<  dz/dr at the rear of the RoI
0232   float m_dzdrPlus{};   //!<  dz/dr at the front of the RoI
0233 
0234   float m_drdzMinus{};  //!<  dr/dz at the rear of the RoI
0235   float m_drdzPlus{};   //!<  dr/dz at the front of the RoI
0236 
0237   float
0238       m_zedOuterMinus{};  //!< z at rear of RoI at the outer radius ( = 1100 mm)
0239   float
0240       m_zedOuterPlus{};  //!< z at front of RoI at the outer radius ( = 1100 mm)
0241 
0242   bool m_fullscan{};            //!< flag this as a full detector RoI
0243   bool m_composite{};           //!< flag this as a composite RoI
0244   bool m_manageConstituents{};  //!< flag to determine whether constituents
0245                                 //!< should be managed
0246 
0247   int m_version{};  //!< transient version identifier
0248 
0249   std::vector<const RoiDescriptor*> m_roiDescriptors;  //!< roi constituents
0250 
0251   // from trig
0252   unsigned int m_l1Id{0};     //!< lvl1 event number
0253   unsigned int m_roiId{0};    //!< RoI number
0254   unsigned int m_roiWord{0};  //!< lvl1 RoI word from which this RoI was
0255                               //!< initially constructed
0256 
0257   //   std::string str( const RoiDescriptor& d );                           //<!
0258   //   printing helper std::ostream& operator<<( std::ostream& m, const
0259   //   RoiDescriptor& d ); //<! printing helper (wraps above)
0260 };
0261 
0262 }  // namespace Acts::Experimental