[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: G4tgrVolumeMgr.hh,v 1.5 2008/12/18 12:59:14 gunter Exp $ |
---|
[1228] | 28 | // GEANT4 tag $Name: geant4-09-03 $ |
---|
[1035] | 29 | // |
---|
| 30 | // |
---|
| 31 | // class G4tgrVolumeMgr |
---|
| 32 | // |
---|
| 33 | // Class description: |
---|
| 34 | // |
---|
| 35 | // Class to manage the detector units. It is a singleton. |
---|
| 36 | |
---|
| 37 | // History: |
---|
| 38 | // - Created. P.Arce, CIEMAT (November 2007) |
---|
| 39 | // ------------------------------------------------------------------------- |
---|
| 40 | |
---|
| 41 | #ifndef G4tgrVolumeMgr_h |
---|
| 42 | #define G4tgrVolumeMgr_h |
---|
| 43 | |
---|
| 44 | #include "globals.hh" |
---|
| 45 | #include "G4tgrSolid.hh" |
---|
| 46 | #include "G4tgrVolume.hh" |
---|
| 47 | #include "G4tgrPlace.hh" |
---|
| 48 | #include "G4tgrIsotope.hh" |
---|
| 49 | #include "G4tgrElement.hh" |
---|
| 50 | #include "G4tgrMaterial.hh" |
---|
| 51 | #include "G4tgrRotationMatrix.hh" |
---|
| 52 | |
---|
| 53 | #include <map> |
---|
| 54 | |
---|
| 55 | typedef std::map< const G4String, const G4tgrSolid* > G4mapssol; |
---|
| 56 | typedef std::map< const G4String, const G4tgrVolume* > G4mapsvol; |
---|
| 57 | typedef std::multimap< const G4String, const G4tgrPlace* > G4mmapspl; |
---|
| 58 | |
---|
| 59 | //---------------------------------------------------------------------------- |
---|
| 60 | class G4tgrVolumeMgr |
---|
| 61 | { |
---|
| 62 | public: // with description |
---|
| 63 | |
---|
| 64 | static G4tgrVolumeMgr* GetInstance(); |
---|
| 65 | // Get the only instance |
---|
| 66 | |
---|
| 67 | G4tgrSolid* CreateSolid( const std::vector<G4String>& wl, G4bool bVOLUtag ); |
---|
| 68 | |
---|
| 69 | void RegisterParentChild( const G4String& parentName, |
---|
| 70 | const G4tgrPlace* pl ); |
---|
| 71 | // Add to theG4tgrVolumeTree |
---|
| 72 | |
---|
| 73 | G4tgrSolid* FindSolid( const G4String& name, G4bool exists = false ); |
---|
| 74 | // Find a G4tgrSolid with name 'name'. If it is not found: |
---|
| 75 | // if exists is true, exit; if exists is false, return 0 |
---|
| 76 | |
---|
| 77 | G4tgrVolume* FindVolume( const G4String& volname, G4bool exists = false ); |
---|
| 78 | // Find a G4tgrVolume with name 'volname'. If it is not found: |
---|
| 79 | // if exists is true, exit; if exists is false, return 0 |
---|
| 80 | |
---|
| 81 | std::vector<G4tgrVolume*> FindVolumes( const G4String& volname, |
---|
| 82 | G4bool exists ); |
---|
| 83 | // Find all G4tgrVolume's with name 'volname'. '*' can be used in the |
---|
| 84 | // name to mean 'any character' or 'any substring'. If it is not found: |
---|
| 85 | // if exists is true, exit; if exists is false, return 0 |
---|
| 86 | |
---|
| 87 | const G4tgrVolume* GetTopVolume(); |
---|
| 88 | // Find the top of the volume tree |
---|
| 89 | |
---|
| 90 | std::pair<G4mmapspl::iterator, G4mmapspl::iterator> |
---|
| 91 | GetChildren( const G4String& name ); |
---|
| 92 | // Find the list of G4tgrPlace children of G4tgrVolume 'name' |
---|
| 93 | |
---|
| 94 | void DumpSummary(); |
---|
| 95 | // Dump summary |
---|
| 96 | void DumpVolumeTree(); |
---|
| 97 | // Dump to cout the tree of G4tgrVolume's |
---|
| 98 | void DumpVolumeLeaf( const G4tgrVolume* vol, unsigned int copyNo, |
---|
| 99 | unsigned int leafDepth); |
---|
| 100 | // Dump a G4tgrVolume indicating its copy no |
---|
| 101 | // and its depth (number of ancestors) |
---|
| 102 | |
---|
| 103 | void RegisterMe( G4tgrSolid* vol); |
---|
| 104 | void UnRegisterMe( G4tgrSolid* vol ); |
---|
| 105 | void RegisterMe( G4tgrVolume* vol); |
---|
| 106 | void UnRegisterMe( G4tgrVolume* vol ); |
---|
| 107 | void RegisterMe( G4tgrPlace* pl ) { theG4tgrPlaceList.push_back( pl ); } |
---|
| 108 | void RegisterMe( G4tgrIsotope* iso ) { theHgIsotList.push_back( iso ); } |
---|
| 109 | void RegisterMe( G4tgrElement* ele ) { theHgElemList.push_back( ele ); } |
---|
| 110 | void RegisterMe( G4tgrMaterial* mat ) { theHgMateList.push_back( mat ); } |
---|
| 111 | void RegisterMe( G4tgrRotationMatrix* rm ) { theHgRotMList.push_back(rm); } |
---|
| 112 | |
---|
| 113 | // Accessors |
---|
| 114 | |
---|
| 115 | const G4mapssol& GetSolidMap() {return theG4tgrSolidMap;} |
---|
| 116 | const G4mapsvol& GetVolumeMap() {return theG4tgrVolumeMap;} |
---|
| 117 | const G4mmapspl& GetVolumeTree() {return theG4tgrVolumeTree;} |
---|
| 118 | std::vector<G4tgrVolume*> GetVolumeList() {return theG4tgrVolumeList;} |
---|
| 119 | std::vector<G4tgrPlace*> GetDetPlaceList() {return theG4tgrPlaceList;} |
---|
| 120 | std::vector<G4tgrIsotope*> GetIsotopeList() {return theHgIsotList;} |
---|
| 121 | std::vector<G4tgrElement*> GetElementList() {return theHgElemList;} |
---|
| 122 | std::vector<G4tgrMaterial*> GetMaterialList() {return theHgMateList;} |
---|
| 123 | std::vector<G4tgrRotationMatrix*> GetRotMList() {return theHgRotMList;} |
---|
| 124 | |
---|
| 125 | private: |
---|
| 126 | |
---|
| 127 | G4tgrVolumeMgr(); |
---|
| 128 | ~G4tgrVolumeMgr(); |
---|
| 129 | |
---|
| 130 | private: |
---|
| 131 | |
---|
| 132 | G4mapssol theG4tgrSolidMap; |
---|
| 133 | // Map of G4tgrSolid's: G4String is the G4tgrSolid name, |
---|
| 134 | // G4tgrSolid* the pointer to it |
---|
| 135 | |
---|
| 136 | G4mapsvol theG4tgrVolumeMap; |
---|
| 137 | // Map of G4tgrVolume's: G4String is the G4tgrVolume name, |
---|
| 138 | // G4tgrVolume* the pointer to it |
---|
| 139 | |
---|
| 140 | G4mmapspl theG4tgrVolumeTree; |
---|
| 141 | // Hierarchy tree of G4tgrVolume's: G4String is the name |
---|
| 142 | // of the parent G4tgrVolume, G4tgrPlace* the pointers to children |
---|
| 143 | |
---|
| 144 | static G4tgrVolumeMgr* theInstance; |
---|
| 145 | |
---|
| 146 | std::vector<G4tgrVolume*> theG4tgrVolumeList; |
---|
| 147 | std::vector<G4tgrPlace*> theG4tgrPlaceList; |
---|
| 148 | std::vector<G4tgrIsotope*> theHgIsotList; |
---|
| 149 | std::vector<G4tgrElement*> theHgElemList; |
---|
| 150 | std::vector<G4tgrMaterial*> theHgMateList; |
---|
| 151 | std::vector<G4tgrRotationMatrix*> theHgRotMList; |
---|
| 152 | }; |
---|
| 153 | |
---|
| 154 | #endif |
---|