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