Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4tgrVolumeMgr Class Reference

#include <G4tgrVolumeMgr.hh>

Public Member Functions

G4tgrSolidCreateSolid (const std::vector< G4String > &wl, G4bool bVOLUtag)
 
void RegisterParentChild (const G4String &parentName, const G4tgrPlace *pl)
 
G4tgrSolidFindSolid (const G4String &name, G4bool exists=false)
 
G4tgrVolumeFindVolume (const G4String &volname, G4bool exists=false)
 
std::vector< G4tgrVolume * > FindVolumes (const G4String &volname, G4bool exists)
 
const G4tgrVolumeGetTopVolume ()
 
std::pair< G4mmapspl::iterator, G4mmapspl::iterator > GetChildren (const G4String &name)
 
void DumpSummary ()
 
void DumpVolumeTree ()
 
void DumpVolumeLeaf (const G4tgrVolume *vol, unsigned int copyNo, unsigned int leafDepth)
 
void RegisterMe (G4tgrSolid *vol)
 
void UnRegisterMe (G4tgrSolid *vol)
 
void RegisterMe (G4tgrVolume *vol)
 
void UnRegisterMe (G4tgrVolume *vol)
 
void RegisterMe (G4tgrPlace *pl)
 
void RegisterMe (G4tgrIsotope *iso)
 
void RegisterMe (G4tgrElement *ele)
 
void RegisterMe (G4tgrMaterial *mat)
 
void RegisterMe (G4tgrRotationMatrix *rm)
 
const G4mapssolGetSolidMap ()
 
const G4mapsvolGetVolumeMap ()
 
const G4mmapsplGetVolumeTree ()
 
std::vector< G4tgrVolume * > GetVolumeList ()
 
std::vector< G4tgrPlace * > GetDetPlaceList ()
 
std::vector< G4tgrIsotope * > GetIsotopeList ()
 
std::vector< G4tgrElement * > GetElementList ()
 
std::vector< G4tgrMaterial * > GetMaterialList ()
 
std::vector< G4tgrRotationMatrix * > GetRotMList ()
 

Static Public Member Functions

static G4tgrVolumeMgrGetInstance ()
 

Detailed Description

Definition at line 52 of file G4tgrVolumeMgr.hh.

Member Function Documentation

◆ CreateSolid()

G4tgrSolid * G4tgrVolumeMgr::CreateSolid ( const std::vector< G4String > &  wl,
G4bool  bVOLUtag 
)

Definition at line 64 of file G4tgrVolumeMgr.cc.

66{
67 G4tgrSolid* sol = FindSolid(wl[1]);
68 if(sol != nullptr)
69 {
70 G4String ErrMessage = "Solid already exists... " + wl[1];
71 G4Exception("G4tgrVolumeMgr::CreateSolid()", "InvalidSetup", FatalException,
72 ErrMessage);
73 }
74
75 std::vector<G4String> wlc = wl;
76 if(bVOLUtag)
77 {
78 wlc.pop_back();
79 }
80
81 G4String wl2 = wlc[2];
82 for(std::size_t ii = 0; ii < wl2.length(); ++ii)
83 {
84 wl2[ii] = toupper(wl2[ii]);
85 }
86 if((wl2 == "UNION") || (wl2 == "SUBTRACTION") || (wl2 == "INTERSECTION"))
87 {
88 //---------- Boolean solid
89 //---------- Create G4tgrSolidBoolean and fill the solid params
90 sol = new G4tgrSolidBoolean(wlc);
91 }
92 else
93 {
94 //---------- Create G4tgrSolidSimple and fill the solid params
95 sol = new G4tgrSolid(wlc);
96 }
97
98 return sol;
99}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
G4tgrSolid * FindSolid(const G4String &name, G4bool exists=false)

Referenced by G4tgrVolume::G4tgrVolume(), and G4tgrLineProcessor::ProcessLine().

◆ DumpSummary()

void G4tgrVolumeMgr::DumpSummary ( )

Definition at line 373 of file G4tgrVolumeMgr.cc.

374{
375 //---------- Dump number of objects of each class
376 G4cout << " @@@@@@@@@@@@@@@@@@ Dumping Detector Summary " << G4endl;
377 G4cout << " @@@ Geometry built inside world volume: "
378 << GetTopVolume()->GetName() << G4endl;
379 G4cout << " Number of G4tgrVolume's: " << theG4tgrVolumeMap.size() << G4endl;
380 unsigned int nPlace = 0;
381 for(auto cite = theG4tgrVolumeMap.cbegin();
382 cite != theG4tgrVolumeMap.cend(); ++cite)
383 {
384 nPlace += ((*cite).second)->GetPlacements().size();
385 }
386 G4cout << " Number of G4tgrPlace's: " << nPlace << G4endl;
387
389 G4cout << " Number of G4tgrIsotope's: " << matef->GetIsotopeList().size()
390 << G4endl;
391 G4cout << " Number of G4tgrElement's: " << matef->GetElementList().size()
392 << G4endl;
393 G4cout << " Number of G4tgrMaterial's: " << matef->GetMaterialList().size()
394 << G4endl;
395
397 G4cout << " Number of G4tgrRotationMatrix's: "
398 << rotmf->GetRotMatList().size() << G4endl;
399
400 //---------- Dump detail list of objects of each class
402
403 matef->DumpIsotopeList();
404 matef->DumpElementList();
405 matef->DumpMaterialList();
406 rotmf->DumpRotmList();
407}
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
const G4mstgrelem & GetElementList() const
const G4mstgrmate & GetMaterialList() const
static G4tgrMaterialFactory * GetInstance()
const G4mstgrisot & GetIsotopeList() const
std::vector< G4tgrRotationMatrix * > GetRotMatList() const
static G4tgrRotationMatrixFactory * GetInstance()
const G4tgrVolume * GetTopVolume()
const G4String & GetName() const
Definition: G4tgrVolume.hh:83

◆ DumpVolumeLeaf()

void G4tgrVolumeMgr::DumpVolumeLeaf ( const G4tgrVolume vol,
unsigned int  copyNo,
unsigned int  leafDepth 
)

Definition at line 345 of file G4tgrVolumeMgr.cc.

347{
348 for(std::size_t ii = 0; ii < leafDepth; ++ii)
349 {
350 G4cout << " ";
351 }
352 G4cout << " VOL:(" << leafDepth << ")" << vol->GetName() << " copy No "
353 << copyNo << G4endl;
354
355 //---------- construct the children of this VOL
356 std::pair<G4mmapspl::iterator, G4mmapspl::iterator> children =
357 GetChildren(vol->GetName());
358 G4mmapspl::const_iterator cite;
359
360 ++leafDepth;
361 for(cite = children.first; cite != children.second; ++cite)
362 {
363 //---- find G4tgrVolume pointed by G4tgrPlace
364 const G4tgrPlace* pla = (*cite).second;
365 const G4tgrVolume* volchild = pla->GetVolume();
366 //--- find copyNo
367 unsigned int cn = pla->GetCopyNo();
368 DumpVolumeLeaf(volchild, cn, leafDepth);
369 }
370}
unsigned int GetCopyNo() const
Definition: G4tgrPlace.hh:54
G4tgrVolume * GetVolume() const
Definition: G4tgrPlace.hh:53
void DumpVolumeLeaf(const G4tgrVolume *vol, unsigned int copyNo, unsigned int leafDepth)
std::pair< G4mmapspl::iterator, G4mmapspl::iterator > GetChildren(const G4String &name)

Referenced by DumpVolumeLeaf(), and DumpVolumeTree().

◆ DumpVolumeTree()

void G4tgrVolumeMgr::DumpVolumeTree ( )

Definition at line 335 of file G4tgrVolumeMgr.cc.

336{
337 G4cout << " @@@@@@@@@@@@@@@@ DUMPING G4tgrVolume's Tree " << G4endl;
338
339 const G4tgrVolume* vol = GetTopVolume();
340
341 DumpVolumeLeaf(vol, 0, 0);
342}

Referenced by DumpSummary().

◆ FindSolid()

G4tgrSolid * G4tgrVolumeMgr::FindSolid ( const G4String name,
G4bool  exists = false 
)

Definition at line 178 of file G4tgrVolumeMgr.cc.

179{
180 G4tgrSolid* vol = nullptr;
181
182 G4mapssol::const_iterator svite = theG4tgrSolidMap.find(volname);
183 if(svite == theG4tgrSolidMap.cend())
184 {
185 if(exists)
186 {
187 for(svite = theG4tgrSolidMap.cbegin();
188 svite != theG4tgrSolidMap.cend(); ++svite)
189 {
190 G4cerr << " VOL:" << (*svite).first << G4endl;
191 }
192 G4String ErrMessage = "Solid not found... " + volname;
193 G4Exception("G4tgrVolumeMgr::FindSolid()", "InvalidSetup", FatalException,
194 ErrMessage);
195 }
196 }
197 else
198 {
199 vol = const_cast<G4tgrSolid*>((*svite).second);
200 }
201
202 return vol;
203}
G4GLOB_DLL std::ostream G4cerr

Referenced by CreateSolid(), G4tgrSolidBoolean::G4tgrSolidBoolean(), and G4tgrVolume::G4tgrVolume().

◆ FindVolume()

G4tgrVolume * G4tgrVolumeMgr::FindVolume ( const G4String volname,
G4bool  exists = false 
)

Definition at line 206 of file G4tgrVolumeMgr.cc.

207{
208 G4tgrVolume* vol = nullptr;
209
210 G4mapsvol::const_iterator svite = theG4tgrVolumeMap.find(volname);
211 if(svite == theG4tgrVolumeMap.cend())
212 {
213 if(exists)
214 {
215 for(svite = theG4tgrVolumeMap.cbegin();
216 svite != theG4tgrVolumeMap.cend(); ++svite)
217 {
218 G4cerr << " VOL:" << (*svite).first << G4endl;
219 }
220 G4String ErrMessage = "Volume not found... " + volname;
221 G4Exception("G4tgrVolumeMgr::FindVolume()", "InvalidSetup",
222 FatalException, ErrMessage);
223 }
224 else
225 {
226 G4String WarMessage = "Volume does not exists... " + volname;
227 G4Exception("G4tgrVolumeMgr::FindVolume()", "SearchFailed", JustWarning,
228 WarMessage);
229 }
230 }
231 else
232 {
233 vol = const_cast<G4tgrVolume*>((*svite).second);
234 }
235
236 return vol;
237}
@ JustWarning

Referenced by G4tgrLineProcessor::FindVolume(), G4tgrSolidBoolean::G4tgrSolidBoolean(), G4tgrVolumeDivision::G4tgrVolumeDivision(), and GetTopVolume().

◆ FindVolumes()

std::vector< G4tgrVolume * > G4tgrVolumeMgr::FindVolumes ( const G4String volname,
G4bool  exists 
)

Definition at line 240 of file G4tgrVolumeMgr.cc.

242{
243 std::vector<G4tgrVolume*> vols;
244
245 G4mapsvol::const_iterator svite;
246 for(svite = theG4tgrVolumeMap.cbegin();
247 svite != theG4tgrVolumeMap.cend(); ++svite)
248 {
249 if(G4tgrUtils::AreWordsEquivalent(volname, (*svite).second->GetName()))
250 {
251 vols.push_back(const_cast<G4tgrVolume*>((*svite).second));
252 }
253 }
254
255 if(vols.size() == 0)
256 {
257 if(exists)
258 {
259 for(svite = theG4tgrVolumeMap.cbegin();
260 svite != theG4tgrVolumeMap.cend(); ++svite)
261 {
262 G4cerr << " VOL:" << (*svite).first << G4endl;
263 }
264 G4String ErrMessage = "Volume not found... " + volname;
265 G4Exception("G4tgrVolumeMgr::FindVolumes()", "InvalidSetup",
266 FatalException, ErrMessage);
267 }
268 else
269 {
270 G4String WarMessage = "Volume does not exists... " + volname;
271 G4Exception("G4tgrVolumeMgr::FindVolumes()", "SearchFailed", JustWarning,
272 WarMessage);
273 }
274 }
275
276 return vols;
277}
static G4bool AreWordsEquivalent(const G4String &word1, const G4String &word2)
Definition: G4tgrUtils.cc:653

Referenced by G4tgrLineProcessor::ProcessLine().

◆ GetChildren()

std::pair< G4mmapspl::iterator, G4mmapspl::iterator > G4tgrVolumeMgr::GetChildren ( const G4String name)

Definition at line 327 of file G4tgrVolumeMgr.cc.

328{
329 std::pair<G4mmapspl::iterator, G4mmapspl::iterator> dite;
330 dite = theG4tgrVolumeTree.equal_range(name);
331 return dite;
332}

Referenced by G4tgbVolume::ConstructG4Volumes(), and DumpVolumeLeaf().

◆ GetDetPlaceList()

std::vector< G4tgrPlace * > G4tgrVolumeMgr::GetDetPlaceList ( )
inline

Definition at line 110 of file G4tgrVolumeMgr.hh.

110{ return theG4tgrPlaceList; }

◆ GetElementList()

std::vector< G4tgrElement * > G4tgrVolumeMgr::GetElementList ( )
inline

Definition at line 112 of file G4tgrVolumeMgr.hh.

112{ return theHgElemList; }

◆ GetInstance()

◆ GetIsotopeList()

std::vector< G4tgrIsotope * > G4tgrVolumeMgr::GetIsotopeList ( )
inline

Definition at line 111 of file G4tgrVolumeMgr.hh.

111{ return theHgIsotList; }

◆ GetMaterialList()

std::vector< G4tgrMaterial * > G4tgrVolumeMgr::GetMaterialList ( )
inline

Definition at line 113 of file G4tgrVolumeMgr.hh.

113{ return theHgMateList; }

◆ GetRotMList()

std::vector< G4tgrRotationMatrix * > G4tgrVolumeMgr::GetRotMList ( )
inline

Definition at line 114 of file G4tgrVolumeMgr.hh.

114{ return theHgRotMList; }

◆ GetSolidMap()

const G4mapssol & G4tgrVolumeMgr::GetSolidMap ( )
inline

Definition at line 106 of file G4tgrVolumeMgr.hh.

106{ return theG4tgrSolidMap; }

◆ GetTopVolume()

const G4tgrVolume * G4tgrVolumeMgr::GetTopVolume ( )

Definition at line 280 of file G4tgrVolumeMgr.cc.

281{
282 //--- Start from any G4tgrVolume and go upwards until you get to the top.
283 // Check that indeed all volumes drive to the same top volume
284
285 const G4tgrVolume* topVol = nullptr;
286 for(auto itetv = theG4tgrVolumeMap.cbegin();
287 itetv != theG4tgrVolumeMap.cend(); ++itetv)
288 {
289 const G4tgrVolume* vol = (*itetv).second;
290#ifdef G4VERBOSE
292 {
293 G4cout << " G4tgrVolumeMgr::GetTopVolume() - Vol: " << vol->GetName()
294 << " no place = " << vol->GetPlacements().size() << G4endl;
295 }
296#endif
297
298 while(vol->GetPlacements().size() != 0)
299 {
300 vol = FindVolume((*(vol->GetPlacements()).cbegin())->GetParentName(), 1);
301#ifdef G4VERBOSE
303 {
304 G4cout << " G4tgrVolumeMgr::GetTopVolume() - Vol: " << vol->GetName()
305 << " N place = " << vol->GetPlacements().size() << G4endl;
306 }
307#endif
308 }
309 if((topVol != nullptr) && (topVol != vol) &&
310 (topVol->GetType() != "VOLDivision") &&
311 (vol->GetType() != "VOLDivision"))
312 {
313 G4Exception("G4tgrVolumeMgr::GetTopVolume()",
314 "Two world volumes found, second will be taken", JustWarning,
315 (G4String("Both volumes are at the top of a hierarchy: ") +
316 topVol->GetName() + " & " + vol->GetName())
317 .c_str());
318 }
319 topVol = vol;
320 }
321
322 return topVol;
323}
static G4int GetVerboseLevel()
G4tgrVolume * FindVolume(const G4String &volname, G4bool exists=false)
const G4String & GetType() const
Definition: G4tgrVolume.hh:85
const std::vector< G4tgrPlace * > GetPlacements() const
Definition: G4tgrVolume.hh:89

Referenced by G4tgbDetectorConstruction::Construct(), DumpSummary(), DumpVolumeTree(), and G4tgbDetectorBuilder::ReadDetector().

◆ GetVolumeList()

std::vector< G4tgrVolume * > G4tgrVolumeMgr::GetVolumeList ( )
inline

Definition at line 109 of file G4tgrVolumeMgr.hh.

109{ return theG4tgrVolumeList; }

◆ GetVolumeMap()

const G4mapsvol & G4tgrVolumeMgr::GetVolumeMap ( )
inline

Definition at line 107 of file G4tgrVolumeMgr.hh.

107{ return theG4tgrVolumeMap; }

Referenced by G4tgbVolumeMgr::CopyVolumes().

◆ GetVolumeTree()

const G4mmapspl & G4tgrVolumeMgr::GetVolumeTree ( )
inline

Definition at line 108 of file G4tgrVolumeMgr.hh.

108{ return theG4tgrVolumeTree; }

◆ RegisterMe() [1/7]

void G4tgrVolumeMgr::RegisterMe ( G4tgrElement ele)
inline

Definition at line 100 of file G4tgrVolumeMgr.hh.

100{ theHgElemList.push_back(ele); }

◆ RegisterMe() [2/7]

void G4tgrVolumeMgr::RegisterMe ( G4tgrIsotope iso)
inline

Definition at line 99 of file G4tgrVolumeMgr.hh.

99{ theHgIsotList.push_back(iso); }

◆ RegisterMe() [3/7]

void G4tgrVolumeMgr::RegisterMe ( G4tgrMaterial mat)
inline

Definition at line 101 of file G4tgrVolumeMgr.hh.

101{ theHgMateList.push_back(mat); }

◆ RegisterMe() [4/7]

void G4tgrVolumeMgr::RegisterMe ( G4tgrPlace pl)
inline

Definition at line 98 of file G4tgrVolumeMgr.hh.

98{ theG4tgrPlaceList.push_back(pl); }

◆ RegisterMe() [5/7]

void G4tgrVolumeMgr::RegisterMe ( G4tgrRotationMatrix rm)
inline

Definition at line 102 of file G4tgrVolumeMgr.hh.

102{ theHgRotMList.push_back(rm); }

◆ RegisterMe() [6/7]

void G4tgrVolumeMgr::RegisterMe ( G4tgrSolid vol)

Definition at line 102 of file G4tgrVolumeMgr.cc.

103{
104 if(theG4tgrSolidMap.find(sol->GetName()) != theG4tgrSolidMap.cend())
105 {
106 G4String ErrMessage =
107 "Cannot be two solids with the same name... " + sol->GetName();
108 G4Exception("G4tgrVolumeMgr::RegisterMe()", "InvalidSetup", FatalException,
109 ErrMessage);
110 }
111 theG4tgrSolidMap.insert(G4mapssol::value_type(sol->GetName(), sol));
112}

Referenced by G4tgrSolid::G4tgrSolid(), G4tgrSolidBoolean::G4tgrSolidBoolean(), and G4tgrLineProcessor::ProcessLine().

◆ RegisterMe() [7/7]

void G4tgrVolumeMgr::RegisterMe ( G4tgrVolume vol)

Definition at line 131 of file G4tgrVolumeMgr.cc.

132{
133 theG4tgrVolumeList.push_back(vol);
134 if(theG4tgrVolumeMap.find(vol->GetName()) != theG4tgrVolumeMap.cend())
135 {
136 G4String ErrMessage =
137 "Cannot be two volumes with the same name... " + vol->GetName();
138 G4Exception("G4tgrVolumeMgr::RegisterMe()", "InvalidSetup", FatalException,
139 ErrMessage);
140 }
141 theG4tgrVolumeMap.insert(G4mapsvol::value_type(vol->GetName(), vol));
142}

◆ RegisterParentChild()

void G4tgrVolumeMgr::RegisterParentChild ( const G4String parentName,
const G4tgrPlace pl 
)

Definition at line 171 of file G4tgrVolumeMgr.cc.

173{
174 theG4tgrVolumeTree.insert(G4mmapspl::value_type(parentName, pl));
175}

Referenced by G4tgrVolume::AddPlace(), G4tgrVolumeAssembly::AddPlace(), G4tgrVolume::AddPlaceParam(), G4tgrVolume::AddPlaceReplica(), and G4tgrVolumeDivision::G4tgrVolumeDivision().

◆ UnRegisterMe() [1/2]

void G4tgrVolumeMgr::UnRegisterMe ( G4tgrSolid vol)

Definition at line 115 of file G4tgrVolumeMgr.cc.

116{
117 if(theG4tgrSolidMap.find(sol->GetName()) != theG4tgrSolidMap.cend())
118 {
119 G4String ErrMessage =
120 "Cannot unregister a solid that is not registered... " + sol->GetName();
121 G4Exception("G4tgrSolidMgr::unRegisterMe()", "InvalidSetup", FatalException,
122 ErrMessage);
123 }
124 else
125 {
126 theG4tgrSolidMap.erase(theG4tgrSolidMap.find(sol->GetName()));
127 }
128}

◆ UnRegisterMe() [2/2]

void G4tgrVolumeMgr::UnRegisterMe ( G4tgrVolume vol)

Definition at line 145 of file G4tgrVolumeMgr.cc.

146{
147 std::vector<G4tgrVolume*>::const_iterator ite;
148 for(ite = theG4tgrVolumeList.cbegin();
149 ite != theG4tgrVolumeList.cend(); ++ite)
150 {
151 if((*ite) == vol)
152 {
153 break;
154 }
155 }
156 if(ite == theG4tgrVolumeList.cend())
157 {
158 G4String ErrMessage =
159 "Cannot unregister a volume not registered... " + vol->GetName();
160 G4Exception("G4tgrVolumeMgr::unRegisterMe()", "InvalidSetup",
161 FatalException, ErrMessage);
162 }
163 else
164 {
165 theG4tgrVolumeList.erase(ite);
166 }
167 theG4tgrVolumeMap.erase(theG4tgrVolumeMap.find(vol->GetName()));
168}

The documentation for this class was generated from the following files: