Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // G4tgbVolumeMgr << 26 // >> 27 // >> 28 // >> 29 // class G4tgbVolume 27 // 30 // 28 // Class description: 31 // Class description: 29 // 32 // 30 // Class to manage volumes: G4VSolids, G4Logic 33 // Class to manage volumes: G4VSolids, G4LogicalVolumes, G4VPhysicalVolumes. 31 // It is a singleton, accesed always through c 34 // It is a singleton, accesed always through calls to GetInstance(). 32 35 33 // Author: P.Arce, CIEMAT (November 2007) << 36 // History: 34 // ------------------------------------------- << 37 // - Created. P.Arce, CIEMAT (November 2007) 35 #ifndef G4tgbVolumeMgr_hh << 38 // ------------------------------------------------------------------------- 36 #define G4tgbVolumeMgr_hh 1 << 39 >> 40 #ifndef G4tgbVolumeMgr_h >> 41 #define G4tgbVolumeMgr_h 37 42 38 #include "globals.hh" 43 #include "globals.hh" 39 44 40 #include <string> 45 #include <string> 41 #include <vector> 46 #include <vector> 42 #include <map> 47 #include <map> 43 48 44 #include "G4VSolid.hh" 49 #include "G4VSolid.hh" 45 #include "G4LogicalVolume.hh" 50 #include "G4LogicalVolume.hh" 46 #include "G4VPhysicalVolume.hh" 51 #include "G4VPhysicalVolume.hh" 47 52 48 class G4tgbVolume; 53 class G4tgbVolume; 49 class G4tgrVolume; 54 class G4tgrVolume; 50 class G4tgbDetectorBuilder; 55 class G4tgbDetectorBuilder; 51 56 52 using G4mssvol = std::map<G4String, G4tgbVolum << 57 typedef std::map< G4String, G4tgbVolume* > G4mssvol; 53 using G4mmssol = std::multimap<G4String, G4VSo << 58 typedef std::multimap< G4String, G4VSolid* > G4mmssol; 54 using G4mmslv = std::multimap<G4String, G4Logi << 59 typedef std::multimap< G4String, G4LogicalVolume* > G4mmslv; 55 using G4mmspv = std::multimap<G4String, G4VPhy << 60 typedef std::multimap< G4String, G4VPhysicalVolume* > G4mmspv; 56 using G4mlvlv = std::map<G4LogicalVolume*, G4L << 61 typedef std::map< G4LogicalVolume*, G4LogicalVolume* > G4mlvlv; 57 using G4mpvpv = std::map<G4VPhysicalVolume*, G << 62 typedef std::map< G4VPhysicalVolume*, G4VPhysicalVolume* > G4mpvpv; 58 << 63 59 class G4tgbVolumeMgr << 64 //---------------------------------------------------------------------------- 60 { << 65 class G4tgbVolumeMgr 61 public: << 66 { >> 67 public: // with description 62 68 63 G4tgbVolumeMgr(); 69 G4tgbVolumeMgr(); 64 ~G4tgbVolumeMgr(); << 70 ~G4tgbVolumeMgr(); 65 71 66 static G4tgbVolumeMgr* GetInstance(); << 72 static G4tgbVolumeMgr* GetInstance(); 67 // Get the only instance << 73 // Get the only instance 68 74 69 void AddTextFile(const G4String& fname); << 75 void AddTextFile( const G4String& fname ); 70 G4VPhysicalVolume* ReadAndConstructDetecto 76 G4VPhysicalVolume* ReadAndConstructDetector(); 71 77 72 void CopyVolumes(); 78 void CopyVolumes(); 73 // Build a G4tgbVolume per each G4tgbVol 79 // Build a G4tgbVolume per each G4tgbVolume 74 80 75 G4tgbVolume* FindVolume(const G4String& vo << 81 G4tgbVolume* FindVolume( const G4String& volname); 76 // Find a G4tgbVolume by name 82 // Find a G4tgbVolume by name 77 83 78 void RegisterMe(const G4tgbVolume* vol); << 84 void RegisterMe( const G4tgbVolume* vol ); 79 // Register a G4tgbVolume 85 // Register a G4tgbVolume 80 void RegisterMe(const G4VSolid* solid); << 86 void RegisterMe( const G4VSolid* solid ); 81 // Register a G4VSolid 87 // Register a G4VSolid 82 void RegisterMe(const G4LogicalVolume* lv) << 88 void RegisterMe( const G4LogicalVolume* lv ); 83 // Register a G4LogicalVolume 89 // Register a G4LogicalVolume 84 void RegisterMe(const G4VPhysicalVolume* p << 90 void RegisterMe( const G4VPhysicalVolume* pv ); 85 // Register a G4VPhysicalVolume 91 // Register a G4VPhysicalVolume 86 void RegisterChildParentLVs(const G4Logica << 92 void RegisterChildParentLVs( const G4LogicalVolume* logvol, 87 const G4Logica << 93 const G4LogicalVolume* parentLV ); 88 // Register a child and its parent LV 94 // Register a child and its parent LV 89 95 90 G4VSolid* FindG4Solid(const G4String& name << 96 G4VSolid* FindG4Solid( const G4String& name ); 91 // Find if solid already exists, compari << 97 // Find if solid already exists, comparing the name and all parameters 92 // (could be checked before creating it, 98 // (could be checked before creating it, but it would be quite 93 // complicated, because it would have to 99 // complicated, because it would have to compare the parameters, and 94 // they depend on the type of solid) 100 // they depend on the type of solid) 95 101 96 G4LogicalVolume* FindG4LogVol(const G4Stri << 102 G4LogicalVolume* FindG4LogVol( const G4String& theName, 97 const G4bool << 103 const G4bool bExists = 0 ); 98 // Find a G4LogicalVolume if it already 104 // Find a G4LogicalVolume if it already exists 99 105 100 G4VPhysicalVolume* FindG4PhysVol(const G4S << 106 G4VPhysicalVolume* FindG4PhysVol( const G4String& theName, 101 const G4b << 107 const G4bool bExists = 0 ); 102 // Find a G4VPhysicalVolume if it alread 108 // Find a G4VPhysicalVolume if it already exists 103 109 104 G4VPhysicalVolume* GetTopPhysVol(); 110 G4VPhysicalVolume* GetTopPhysVol(); 105 // Get the top PV in the hierarchy tree: 111 // Get the top PV in the hierarchy tree: calls topLV, because 106 // physicalvolumes are not placed until 112 // physicalvolumes are not placed until geometry is initialized 107 113 108 G4LogicalVolume* GetTopLogVol(); 114 G4LogicalVolume* GetTopLogVol(); 109 // Get the top LV in the hierarchy tree 115 // Get the top LV in the hierarchy tree 110 116 111 void BuildPhysVolTree(); 117 void BuildPhysVolTree(); 112 118 113 // Dumping methods 119 // Dumping methods 114 120 115 void DumpSummary(); 121 void DumpSummary(); 116 void DumpG4LogVolTree(); 122 void DumpG4LogVolTree(); 117 void DumpG4LogVolLeaf(const G4LogicalVolum 123 void DumpG4LogVolLeaf(const G4LogicalVolume* lv, unsigned int leafDepth); 118 void DumpG4PhysVolTree(); 124 void DumpG4PhysVolTree(); 119 void DumpG4PhysVolLeaf(const G4VPhysicalVo 125 void DumpG4PhysVolLeaf(const G4VPhysicalVolume* pv, unsigned int leafDepth); 120 void DumpG4SolidList(); 126 void DumpG4SolidList(); 121 127 122 const std::multimap<G4String, G4VSolid*>& << 128 public: // without description 123 { << 129 124 return theSolids; << 130 const std::multimap< G4String, G4VSolid* >& GetSolids() const 125 } << 131 { return theSolids; } 126 void SetDetectorBuilder(G4tgbDetectorBuild << 132 void SetDetectorBuilder( G4tgbDetectorBuilder* db ) 127 { << 133 { theDetectorBuilder = db; } 128 theDetectorBuilder = db; << 129 } << 130 G4tgbDetectorBuilder* GetDetectorBuilder() 134 G4tgbDetectorBuilder* GetDetectorBuilder() const 131 { << 135 { return theDetectorBuilder; } 132 return theDetectorBuilder; << 133 } << 134 136 135 private: 137 private: 136 138 137 static G4ThreadLocal G4tgbVolumeMgr* theIn 139 static G4ThreadLocal G4tgbVolumeMgr* theInstance; 138 140 139 G4mssvol theVolumeList; 141 G4mssvol theVolumeList; 140 // Map of G4tgbVolume's: G4String is the 142 // Map of G4tgbVolume's: G4String is the G4tgbVolume name, 141 // G4tgbVolume* the pointer to it. 143 // G4tgbVolume* the pointer to it. 142 144 143 G4mmssol theSolids; 145 G4mmssol theSolids; 144 // Solids container 146 // Solids container 145 147 146 G4mmslv theLVs; 148 G4mmslv theLVs; 147 // Logical volume container 149 // Logical volume container 148 G4mmspv thePVs; 150 G4mmspv thePVs; 149 // Physical volume container 151 // Physical volume container 150 152 151 G4mlvlv theLVTree; 153 G4mlvlv theLVTree; 152 // Logical volume tree for navigation (f 154 // Logical volume tree for navigation (from parent to children): 153 // first is parent, then child 155 // first is parent, then child 154 G4mlvlv theLVInvTree; 156 G4mlvlv theLVInvTree; 155 // Logical volume tree for inverse navig 157 // Logical volume tree for inverse navigation (from children to parent): 156 // first is child, then parent 158 // first is child, then parent 157 159 158 G4mpvpv thePVTree; 160 G4mpvpv thePVTree; 159 // Physical volume tree for navigation ( 161 // Physical volume tree for navigation (from parent to children): 160 // first is parent, then child 162 // first is parent, then child 161 G4mpvpv thePVInvTree; 163 G4mpvpv thePVInvTree; 162 // Physical volume tree for inverse navi 164 // Physical volume tree for inverse navigation (from children to parents): 163 // first is child, then parent 165 // first is child, then parent 164 166 165 G4tgbDetectorBuilder* theDetectorBuilder = << 167 G4tgbDetectorBuilder* theDetectorBuilder; 166 }; 168 }; 167 169 168 #endif 170 #endif 169 171