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 // $Id: G4tgbVolumeMgr.hh 66872 2013-01-15 01:25:57Z japost $ >> 28 // >> 29 // >> 30 // class G4tgbVolume 27 // 31 // 28 // Class description: 32 // Class description: 29 // 33 // 30 // Class to manage volumes: G4VSolids, G4Logic 34 // Class to manage volumes: G4VSolids, G4LogicalVolumes, G4VPhysicalVolumes. 31 // It is a singleton, accesed always through c 35 // It is a singleton, accesed always through calls to GetInstance(). 32 36 33 // Author: P.Arce, CIEMAT (November 2007) << 37 // History: 34 // ------------------------------------------- << 38 // - Created. P.Arce, CIEMAT (November 2007) 35 #ifndef G4tgbVolumeMgr_hh << 39 // ------------------------------------------------------------------------- 36 #define G4tgbVolumeMgr_hh 1 << 40 >> 41 #ifndef G4tgbVolumeMgr_h >> 42 #define G4tgbVolumeMgr_h 37 43 38 #include "globals.hh" 44 #include "globals.hh" 39 45 40 #include <string> 46 #include <string> 41 #include <vector> 47 #include <vector> 42 #include <map> 48 #include <map> 43 49 44 #include "G4VSolid.hh" 50 #include "G4VSolid.hh" 45 #include "G4LogicalVolume.hh" 51 #include "G4LogicalVolume.hh" 46 #include "G4VPhysicalVolume.hh" 52 #include "G4VPhysicalVolume.hh" 47 53 48 class G4tgbVolume; 54 class G4tgbVolume; 49 class G4tgrVolume; 55 class G4tgrVolume; 50 class G4tgbDetectorBuilder; 56 class G4tgbDetectorBuilder; 51 57 52 using G4mssvol = std::map<G4String, G4tgbVolum << 58 typedef std::map< G4String, G4tgbVolume* > G4mssvol; 53 using G4mmssol = std::multimap<G4String, G4VSo << 59 typedef std::multimap< G4String, G4VSolid* > G4mmssol; 54 using G4mmslv = std::multimap<G4String, G4Logi << 60 typedef std::multimap< G4String, G4LogicalVolume* > G4mmslv; 55 using G4mmspv = std::multimap<G4String, G4VPhy << 61 typedef std::multimap< G4String, G4VPhysicalVolume* > G4mmspv; 56 using G4mlvlv = std::map<G4LogicalVolume*, G4L << 62 typedef std::map< G4LogicalVolume*, G4LogicalVolume* > G4mlvlv; 57 using G4mpvpv = std::map<G4VPhysicalVolume*, G << 63 typedef std::map< G4VPhysicalVolume*, G4VPhysicalVolume* > G4mpvpv; 58 << 64 59 class G4tgbVolumeMgr << 65 //---------------------------------------------------------------------------- 60 { << 66 class G4tgbVolumeMgr 61 public: << 67 { >> 68 public: // with description 62 69 63 G4tgbVolumeMgr(); 70 G4tgbVolumeMgr(); 64 ~G4tgbVolumeMgr(); << 71 ~G4tgbVolumeMgr(); 65 72 66 static G4tgbVolumeMgr* GetInstance(); << 73 static G4tgbVolumeMgr* GetInstance(); 67 // Get the only instance << 74 // Get the only instance 68 75 69 void AddTextFile(const G4String& fname); << 76 void AddTextFile( const G4String& fname ); 70 G4VPhysicalVolume* ReadAndConstructDetecto 77 G4VPhysicalVolume* ReadAndConstructDetector(); 71 78 72 void CopyVolumes(); 79 void CopyVolumes(); 73 // Build a G4tgbVolume per each G4tgbVol 80 // Build a G4tgbVolume per each G4tgbVolume 74 81 75 G4tgbVolume* FindVolume(const G4String& vo << 82 G4tgbVolume* FindVolume( const G4String& volname); 76 // Find a G4tgbVolume by name 83 // Find a G4tgbVolume by name 77 84 78 void RegisterMe(const G4tgbVolume* vol); << 85 void RegisterMe( const G4tgbVolume* vol ); 79 // Register a G4tgbVolume 86 // Register a G4tgbVolume 80 void RegisterMe(const G4VSolid* solid); << 87 void RegisterMe( const G4VSolid* solid ); 81 // Register a G4VSolid 88 // Register a G4VSolid 82 void RegisterMe(const G4LogicalVolume* lv) << 89 void RegisterMe( const G4LogicalVolume* lv ); 83 // Register a G4LogicalVolume 90 // Register a G4LogicalVolume 84 void RegisterMe(const G4VPhysicalVolume* p << 91 void RegisterMe( const G4VPhysicalVolume* pv ); 85 // Register a G4VPhysicalVolume 92 // Register a G4VPhysicalVolume 86 void RegisterChildParentLVs(const G4Logica << 93 void RegisterChildParentLVs( const G4LogicalVolume* logvol, 87 const G4Logica << 94 const G4LogicalVolume* parentLV ); 88 // Register a child and its parent LV 95 // Register a child and its parent LV 89 96 90 G4VSolid* FindG4Solid(const G4String& name << 97 G4VSolid* FindG4Solid( const G4String& name ); 91 // Find if solid already exists, compari << 98 // Find if solid already exists, comparing the name and all parameters 92 // (could be checked before creating it, 99 // (could be checked before creating it, but it would be quite 93 // complicated, because it would have to 100 // complicated, because it would have to compare the parameters, and 94 // they depend on the type of solid) 101 // they depend on the type of solid) 95 102 96 G4LogicalVolume* FindG4LogVol(const G4Stri << 103 G4LogicalVolume* FindG4LogVol( const G4String& theName, 97 const G4bool << 104 const G4bool bExists = 0 ); 98 // Find a G4LogicalVolume if it already 105 // Find a G4LogicalVolume if it already exists 99 106 100 G4VPhysicalVolume* FindG4PhysVol(const G4S << 107 G4VPhysicalVolume* FindG4PhysVol( const G4String& theName, 101 const G4b << 108 const G4bool bExists = 0 ); 102 // Find a G4VPhysicalVolume if it alread 109 // Find a G4VPhysicalVolume if it already exists 103 110 104 G4VPhysicalVolume* GetTopPhysVol(); 111 G4VPhysicalVolume* GetTopPhysVol(); 105 // Get the top PV in the hierarchy tree: 112 // Get the top PV in the hierarchy tree: calls topLV, because 106 // physicalvolumes are not placed until 113 // physicalvolumes are not placed until geometry is initialized 107 114 108 G4LogicalVolume* GetTopLogVol(); 115 G4LogicalVolume* GetTopLogVol(); 109 // Get the top LV in the hierarchy tree 116 // Get the top LV in the hierarchy tree 110 117 111 void BuildPhysVolTree(); 118 void BuildPhysVolTree(); 112 119 113 // Dumping methods 120 // Dumping methods 114 121 115 void DumpSummary(); 122 void DumpSummary(); 116 void DumpG4LogVolTree(); 123 void DumpG4LogVolTree(); 117 void DumpG4LogVolLeaf(const G4LogicalVolum 124 void DumpG4LogVolLeaf(const G4LogicalVolume* lv, unsigned int leafDepth); 118 void DumpG4PhysVolTree(); 125 void DumpG4PhysVolTree(); 119 void DumpG4PhysVolLeaf(const G4VPhysicalVo 126 void DumpG4PhysVolLeaf(const G4VPhysicalVolume* pv, unsigned int leafDepth); 120 void DumpG4SolidList(); 127 void DumpG4SolidList(); 121 128 122 const std::multimap<G4String, G4VSolid*>& << 129 public: // without description 123 { << 130 124 return theSolids; << 131 const std::multimap< G4String, G4VSolid* >& GetSolids() const 125 } << 132 { return theSolids; } 126 void SetDetectorBuilder(G4tgbDetectorBuild << 133 void SetDetectorBuilder( G4tgbDetectorBuilder* db ) 127 { << 134 { theDetectorBuilder = db; } 128 theDetectorBuilder = db; << 129 } << 130 G4tgbDetectorBuilder* GetDetectorBuilder() 135 G4tgbDetectorBuilder* GetDetectorBuilder() const 131 { << 136 { return theDetectorBuilder; } 132 return theDetectorBuilder; << 133 } << 134 137 135 private: 138 private: 136 139 137 static G4ThreadLocal G4tgbVolumeMgr* theIn 140 static G4ThreadLocal G4tgbVolumeMgr* theInstance; 138 141 139 G4mssvol theVolumeList; 142 G4mssvol theVolumeList; 140 // Map of G4tgbVolume's: G4String is the 143 // Map of G4tgbVolume's: G4String is the G4tgbVolume name, 141 // G4tgbVolume* the pointer to it. 144 // G4tgbVolume* the pointer to it. 142 145 143 G4mmssol theSolids; 146 G4mmssol theSolids; 144 // Solids container 147 // Solids container 145 148 146 G4mmslv theLVs; 149 G4mmslv theLVs; 147 // Logical volume container 150 // Logical volume container 148 G4mmspv thePVs; 151 G4mmspv thePVs; 149 // Physical volume container 152 // Physical volume container 150 153 151 G4mlvlv theLVTree; 154 G4mlvlv theLVTree; 152 // Logical volume tree for navigation (f 155 // Logical volume tree for navigation (from parent to children): 153 // first is parent, then child 156 // first is parent, then child 154 G4mlvlv theLVInvTree; 157 G4mlvlv theLVInvTree; 155 // Logical volume tree for inverse navig 158 // Logical volume tree for inverse navigation (from children to parent): 156 // first is child, then parent 159 // first is child, then parent 157 160 158 G4mpvpv thePVTree; 161 G4mpvpv thePVTree; 159 // Physical volume tree for navigation ( 162 // Physical volume tree for navigation (from parent to children): 160 // first is parent, then child 163 // first is parent, then child 161 G4mpvpv thePVInvTree; 164 G4mpvpv thePVInvTree; 162 // Physical volume tree for inverse navi 165 // Physical volume tree for inverse navigation (from children to parents): 163 // first is child, then parent 166 // first is child, then parent 164 167 165 G4tgbDetectorBuilder* theDetectorBuilder = << 168 G4tgbDetectorBuilder* theDetectorBuilder; 166 }; 169 }; 167 170 168 #endif 171 #endif 169 172