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