Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 // Tell emacs that this is a C++ source
0002 //  -*- C++ -*-.
0003 #ifndef PHG4MICROMEGASDETECTOR_H
0004 #define PHG4MICROMEGASDETECTOR_H
0005 
0006 /*!
0007  * \file PHG4MicromegasDetector.h
0008  * \author Hugo Pereira Da Costa <hugo.pereira-da-costa@cea.fr>
0009  */
0010 
0011 #include <g4main/PHG4Detector.h>
0012 #include <micromegas/MicromegasDefs.h>
0013 #include <micromegas/MicromegasTile.h>
0014 
0015 #include <map>
0016 #include <set>
0017 #include <string>
0018 
0019 class G4LogicalVolume;
0020 class G4VPhysicalVolume;
0021 class PHCompositeNode;
0022 class PHG4MicromegasDisplayAction;
0023 class PHG4Subsystem;
0024 class PHParameters;
0025 
0026 class PHG4MicromegasDetector : public PHG4Detector
0027 {
0028  public:
0029   //! constructor
0030   PHG4MicromegasDetector(PHG4Subsystem*, PHCompositeNode*, PHParameters*, const std::string&);
0031 
0032   //! construct
0033   void ConstructMe(G4LogicalVolume*) override;
0034 
0035   void Print(const std::string& what = "ALL") const override;
0036 
0037   //! set first layer number
0038   void set_first_layer(int layer) { m_FirstLayer = layer; }
0039 
0040   //! get first layer number
0041   int get_first_layer() const { return m_FirstLayer; }
0042 
0043   //! returns true if passed volume is an active volume of this detector
0044   int IsInDetector(G4VPhysicalVolume*) const;
0045 
0046   //! return layer associated to a given volume, or -1 if invalid
0047   int get_layer(G4VPhysicalVolume*) const;
0048 
0049   //! return tile id associated to a given volume, or -1 if invalid
0050   int get_tileid(G4VPhysicalVolume*) const;
0051 
0052   //! super detector name
0053   void SuperDetector(const std::string& name) { m_SuperDetector = name; }
0054 
0055   //! super detector name
0056   const std::string &SuperDetector() const { return m_SuperDetector; }
0057 
0058   //! access the display action
0059   PHG4MicromegasDisplayAction* GetDisplayAction() { return m_DisplayAction; }
0060 
0061  private:
0062   //! setup tiles
0063   /** the method is now private because tiles are now hard coded */
0064   void setup_tiles();
0065 
0066   //! create needed material
0067   void create_materials() const;
0068 
0069   //! construct
0070   void construct_micromegas(G4LogicalVolume*);
0071 
0072   //! create a micromegas detector of given type
0073   /** returns the master logical volume that can then be placed inside the world logical volume */
0074   G4LogicalVolume* construct_micromegas_tile(int tileid, MicromegasDefs::SegmentationType);
0075 
0076   //! construct FEE board
0077   G4LogicalVolume* construct_fee_board(int id);
0078 
0079   //! add geometry node
0080   /*! this handles the internal (module/strips) segmentation, needed for tracking*/
0081   void add_geometry_node();
0082 
0083   //! vis attribute handling (save memory in batch)
0084   PHG4MicromegasDisplayAction* m_DisplayAction{nullptr};
0085 
0086   //! detector parameters
0087   PHParameters* m_Params{nullptr};
0088 
0089   //! first layer number
0090   /* there are two layers in the detector */
0091   int m_FirstLayer{0};
0092 
0093   //! cache active setting
0094   bool m_ActiveFlag{false};
0095 
0096   //! cache support active setting
0097   bool m_SupportActiveFlag{false};
0098 
0099   //! map layer index to radius (cm)
0100   /** it is filled while creating G4 volumes */
0101   std::map<int, double> m_layer_radius;
0102 
0103   //! map layer index to thickness (cm)
0104   /** it is filled while creating G4 volumes */
0105   std::map<int, double> m_layer_thickness;
0106 
0107   //! active volumes, and mapping to layer
0108   /*! it is needed in the stepping action to map a volume to a given layer */
0109   std::map<G4VPhysicalVolume*, int> m_activeVolumes;
0110 
0111   //! map active volumes to tile number
0112   /*! it is needed in the stepping action to map a volume to a given tile id */
0113   std::map<G4VPhysicalVolume*, int> m_tiles_map;
0114 
0115   //! also store passive volumes
0116   std::set<G4VPhysicalVolume*> m_passiveVolumes;
0117 
0118   //! super detector name
0119   std::string m_SuperDetector;
0120 
0121   //! micromegas tiles
0122   MicromegasTile::List m_tiles;
0123 };
0124 
0125 #endif  // MICROMEGASDETECTOR_H