Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:18:13

0001 #ifndef PHG4MICROMEGASSURVEY_H
0002 #define PHG4MICROMEGASSURVEY_H
0003 
0004 /*!
0005  * \file PHG4MicromegasSurvey.h
0006  * \author Hugo Pereira Da Costa <hugo.pereira-da-costa@cea.fr>
0007  * \brief implements survey data for TPOT definition
0008  */
0009 
0010 /**
0011  * survey data are provided in the form of a G4Transform3D object for each TPOT detector
0012  * it is to be applied on top of the default GEANT tranformation as defined in PHG4MicromegasDetector
0013  * to move the strips from their "ideal" to their surveyed position
0014  */
0015 
0016 #include <Geant4/G4Transform3D.hh>
0017 
0018 #include <array>
0019 #include <string>
0020 #include <unordered_map>
0021 
0022 class PHG4MicromegasSurvey
0023 {
0024  public:
0025   /// constructor
0026   PHG4MicromegasSurvey();
0027 
0028   /// get module name from tile and layer
0029   std::string get_module_name(int layer, uint tile) const;
0030 
0031   /// get transformation from tile and layer
0032   G4Transform3D get_transformation(int layer, uint tile) const;
0033 
0034  private:
0035   /// internal detector definition (tile number, detector)
0036   struct tile_id_t
0037   {
0038     tile_id_t(int layer, uint tile)
0039       : m_layer(layer)
0040       , m_tile(tile)
0041     {
0042     }
0043     int m_layer = 0;
0044     uint m_tile = 0;
0045 
0046     bool operator==(const tile_id_t& other) const
0047     {
0048       return other.m_layer == m_layer && other.m_tile == m_tile;
0049     }
0050   };
0051 
0052   struct tile_id_hash_t
0053   {
0054     std::size_t operator()(const tile_id_t& id) const noexcept
0055     {
0056       return id.m_tile + (id.m_layer << 4);
0057     }
0058   };
0059 
0060   /// map tile_id to module name
0061   using tile_map_t = std::unordered_map<tile_id_t, std::string, tile_id_hash_t>;
0062   tile_map_t m_tile_map;
0063 
0064   /// internal G4Transformation format
0065   using rotation_t = std::array<double, 3>;
0066   using translation_t = std::array<double, 3>;
0067   struct transformation_t
0068   {
0069     transformation_t(const rotation_t& rotation, const translation_t& translation)
0070       : m_rotation(rotation)
0071       , m_translation(translation)
0072     {
0073     }
0074 
0075     /// x, y and z axis rotation in order, degrees
0076     rotation_t m_rotation = {{0}};
0077 
0078     /// x, y, z translation, cm
0079     translation_t m_translation = {{0}};
0080   };
0081 
0082   /// map module name to transformation
0083   using transformation_map_t = std::unordered_map<std::string, transformation_t>;
0084   transformation_map_t m_transformation_map;
0085 };
0086 
0087 #endif