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