Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:17:53

0001 // Tell emacs that this is a C++ source
0002 //  -*- C++ -*-.
0003 
0004 #ifndef MICROMEGAS_CYLINDERGEOMMICROMEGAS_H
0005 #define MICROMEGAS_CYLINDERGEOMMICROMEGAS_H
0006 
0007 /*!
0008  * \file CylinderGeomMicromegas.h
0009  * \author Hugo Pereira Da Costa <hugo.pereira-da-costa@cea.fr>
0010  */
0011 
0012 #include "MicromegasDefs.h"
0013 #include "MicromegasTile.h"
0014 
0015 #include <g4detectors/PHG4CylinderGeom.h>
0016 
0017 #include <TGeoMatrix.h>
0018 
0019 #include <cmath>
0020 #include <iostream>
0021 
0022 class ActsGeometry;
0023 class TVector2;
0024 class TVector3;
0025 class PHG4Hit;
0026 
0027 class CylinderGeomMicromegas : public PHG4CylinderGeom
0028 {
0029   public:
0030 
0031   //* empty constructor
0032   explicit CylinderGeomMicromegas()
0033   {}
0034 
0035   //* constructor
0036   CylinderGeomMicromegas(int layer )
0037     : m_layer( layer )
0038   {}
0039 
0040   //! print information about this layer
0041   void identify(std::ostream&) const override;
0042 
0043   //!@name accessors
0044   //@{
0045   int get_layer() const override {return m_layer;}
0046   double get_radius() const override {return m_radius;}
0047   double get_thickness() const override { return m_thickness;}
0048   double get_zmin() const override {return m_zmin;}
0049   double get_zmax() const override {return m_zmax;}
0050   double get_pitch() const { return m_pitch; }
0051 
0052   //! segmentation type
0053   MicromegasDefs::SegmentationType get_segmentation_type() const {return m_segmentation_type;}
0054 
0055   //! drift direction
0056   MicromegasDefs::DriftDirection get_drift_direction() const {return m_drift_direction;}
0057 
0058   // check if hit radius matches this cylinder
0059   bool check_radius( const TVector3& ) const;
0060 
0061   //! convert world to local position coordinates in (planar) tile reference frame
0062   TVector3 get_local_from_world_coords( uint tileid, ActsGeometry*, const TVector3& ) const;
0063 
0064   //! convert world to local direction coordinates in (planar) tile reference frame
0065   TVector3 get_local_from_world_vect( uint tileid, ActsGeometry*, const TVector3& ) const;
0066 
0067   //! convert local to world position coordinates in (planar) tile reference frame
0068   TVector3 get_world_from_local_coords( uint tileid, ActsGeometry*, const TVector2& ) const;
0069 
0070   //! convert local to world position coordinates in (planar) tile reference frame
0071   TVector3 get_world_from_local_coords( uint tileid, ActsGeometry*, const TVector3& ) const;
0072 
0073   //! convert local to world direction coordinates in (planar) tile reference frame
0074   TVector3 get_world_from_local_vect( uint tileid, ActsGeometry*, const TVector3& ) const;
0075 
0076   //! get tile for a given world location assuming tiles are portion of cylinder centered around tile center
0077   /** it is used to find the tile hit by a given track.
0078    * The track is first extrapolated to the layer cylinder, the relevant tile is found, if any
0079    * the track is then extrapolated a second time to the correct tile plane
0080    */
0081   int find_tile_cylindrical( const TVector3& ) const;
0082 
0083   //! get number of tiles
0084   size_t get_tiles_count() const { return m_tiles.size(); }
0085 
0086   //! get tile for given tileid
0087   const MicromegasTile& get_tile( uint tileid ) const
0088   {
0089     assert( tileid < m_tiles.size() );
0090     return m_tiles[tileid];
0091   }
0092 
0093   //! get strip for a give world location and tile
0094   int find_strip_from_world_coords( uint tileid, ActsGeometry*, const TVector3& ) const;
0095 
0096   //! get strip for a give world location and tile
0097   int find_strip_from_local_coords( uint tileid, ActsGeometry*, const TVector2& ) const;
0098 
0099   //! get strip length for a given tile
0100   double get_strip_length( uint tileid, ActsGeometry* ) const;
0101 
0102   //! get number of strips
0103   uint get_strip_count( uint tileid, ActsGeometry* ) const;
0104 
0105   //! get local coordinates for a given tile and strip
0106   TVector2 get_local_coordinates( uint tileid, ActsGeometry*, uint stripnum ) const;
0107 
0108   //! get world coordinates for a given tile and strip
0109   TVector3 get_world_coordinates( uint tileid, ActsGeometry*, uint stripnum ) const;
0110 
0111   /// reference radius used in macro to convert tile size in azimuth into a angle range (cm)
0112   static constexpr double reference_radius = 82;
0113 
0114   /// shortcut for min/max window
0115   using range_t = std::pair<double, double>;
0116 
0117   /// get the phi range, in global coordinates, corresponding to a given tile
0118   range_t get_phi_range(uint tileid, ActsGeometry* ) const;
0119 
0120   /**
0121    * get the theta range, in r,z plane, measured with respect to (0,0), in global coordinates, corresponding to a given tile
0122    * Note: theta is calculated with respect to the vertical axis, as theta = std::atan2(z, r).
0123    */
0124   range_t get_theta_range(uint tileid, ActsGeometry* ) const;
0125 
0126   //@}
0127 
0128   //!@name modifiers
0129   //@{
0130   void set_layer(const int i) override {m_layer = i;}
0131   void set_radius(const double value) override {m_radius = value;}
0132   void set_thickness(const double value) override {m_thickness = value;}
0133   void set_zmin(const double value) override {m_zmin = value;}
0134   void set_zmax(const double value) override {m_zmax = value;}
0135   void set_pitch( double value ) { m_pitch = value; }
0136 
0137   //! tiles
0138   void set_tiles( const MicromegasTile::List& tiles ) {m_tiles = tiles;}
0139 
0140   //! segmentation
0141   void set_segmentation_type( MicromegasDefs::SegmentationType value ) {m_segmentation_type = value;}
0142 
0143   //! drift direction
0144   void set_drift_direction( MicromegasDefs::DriftDirection value ) {m_drift_direction = value;}
0145   //@}
0146 
0147   private:
0148 
0149   //! layer id
0150   int m_layer = 0;
0151 
0152   //! segmentation type
0153   MicromegasDefs::SegmentationType m_segmentation_type = MicromegasDefs::SegmentationType::SEGMENTATION_PHI;
0154 
0155   //! drift direction
0156   MicromegasDefs::DriftDirection m_drift_direction = MicromegasDefs::DriftDirection::OUTWARD;
0157 
0158   //! layer radius
0159   double m_radius = 0;
0160 
0161   //! layer thickness
0162   double m_thickness = 0;
0163 
0164   //! layer z extend
0165   double m_zmin = 0;
0166 
0167   //! layer z extend
0168   double m_zmax = 0;
0169 
0170   //! 1mm pitch by default
0171   double m_pitch = 0.1;
0172 
0173   //! tiles
0174   /**
0175    * \brief tiles are only used in "find_tile_cylindrical".
0176    * For all other methods we use ACTS surfaces instead
0177    */
0178   MicromegasTile::List m_tiles;
0179 
0180   ClassDefOverride(CylinderGeomMicromegas, 1)
0181 };
0182 
0183 #endif