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