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

#include <G4tgbVolumeMgr.hh>

Public Member Functions

 G4tgbVolumeMgr ()
 
 ~G4tgbVolumeMgr ()
 
void AddTextFile (const G4String &fname)
 
G4VPhysicalVolumeReadAndConstructDetector ()
 
void CopyVolumes ()
 
G4tgbVolumeFindVolume (const G4String &volname)
 
void RegisterMe (const G4tgbVolume *vol)
 
void RegisterMe (const G4VSolid *solid)
 
void RegisterMe (const G4LogicalVolume *lv)
 
void RegisterMe (const G4VPhysicalVolume *pv)
 
void RegisterChildParentLVs (const G4LogicalVolume *logvol, const G4LogicalVolume *parentLV)
 
G4VSolidFindG4Solid (const G4String &name)
 
G4LogicalVolumeFindG4LogVol (const G4String &theName, const G4bool bExists=false)
 
G4VPhysicalVolumeFindG4PhysVol (const G4String &theName, const G4bool bExists=false)
 
G4VPhysicalVolumeGetTopPhysVol ()
 
G4LogicalVolumeGetTopLogVol ()
 
void BuildPhysVolTree ()
 
void DumpSummary ()
 
void DumpG4LogVolTree ()
 
void DumpG4LogVolLeaf (const G4LogicalVolume *lv, unsigned int leafDepth)
 
void DumpG4PhysVolTree ()
 
void DumpG4PhysVolLeaf (const G4VPhysicalVolume *pv, unsigned int leafDepth)
 
void DumpG4SolidList ()
 
const std::multimap< G4String, G4VSolid * > & GetSolids () const
 
void SetDetectorBuilder (G4tgbDetectorBuilder *db)
 
G4tgbDetectorBuilderGetDetectorBuilder () const
 

Static Public Member Functions

static G4tgbVolumeMgrGetInstance ()
 

Detailed Description

Definition at line 59 of file G4tgbVolumeMgr.hh.

Constructor & Destructor Documentation

◆ G4tgbVolumeMgr()

G4tgbVolumeMgr::G4tgbVolumeMgr ( )

Definition at line 51 of file G4tgbVolumeMgr.cc.

52{
54 // NOTE: problems building matrices with not enough figures,
55 // like :ROTM RR30 0.866025 0.5 0. -0.5 0.866025 0. 0. 0 -1
56 theDetectorBuilder = new G4tgbDetectorBuilder();
57}
static G4ReflectionFactory * Instance()
void SetScalePrecision(G4double scaleValue)

Referenced by GetInstance().

◆ ~G4tgbVolumeMgr()

G4tgbVolumeMgr::~G4tgbVolumeMgr ( )

Definition at line 60 of file G4tgbVolumeMgr.cc.

61{
62 delete theDetectorBuilder;
63 delete theInstance;
64}

Member Function Documentation

◆ AddTextFile()

void G4tgbVolumeMgr::AddTextFile ( const G4String fname)

Definition at line 77 of file G4tgbVolumeMgr.cc.

78{
80}
void AddTextFile(const G4String &fname)
static G4tgrFileReader * GetInstance()

◆ BuildPhysVolTree()

void G4tgbVolumeMgr::BuildPhysVolTree ( )

Definition at line 328 of file G4tgbVolumeMgr.cc.

329{
330 /*
331 G4PhysicalVolumeStore* pvs = G4PhysicalVolumeStore::GetInstance();
332 for( auto cite = pvs->cbegin(); cite != pvs->cend(); ++cite )
333 {
334 thePVTree[ *cite ] = (*cite)->GetMother();
335 thePVInvTree[ (*cite)->GetMother() ] = *cite;
336 }
337 */
338}

◆ CopyVolumes()

void G4tgbVolumeMgr::CopyVolumes ( )

Definition at line 136 of file G4tgbVolumeMgr.cc.

137{
138 //--------- Loop G4tgbVolume's and create a G4tgbVolume for each DetUnit
140 for(auto cite = vollist.cbegin(); cite != vollist.cend(); ++cite)
141 {
142 G4tgrVolume* tgrvol = const_cast<G4tgrVolume*>((*cite).second);
143 G4tgbVolume* svol = new G4tgbVolume(tgrvol);
144 RegisterMe(svol);
145 }
146}
std::map< G4String, G4tgrVolume * > G4mapsvol
void RegisterMe(const G4tgbVolume *vol)
const G4mapsvol & GetVolumeMap()
static G4tgrVolumeMgr * GetInstance()

Referenced by G4tgbDetectorConstruction::Construct(), and G4tgbDetectorBuilder::ConstructDetector().

◆ DumpG4LogVolLeaf()

void G4tgbVolumeMgr::DumpG4LogVolLeaf ( const G4LogicalVolume lv,
unsigned int  leafDepth 
)

Definition at line 390 of file G4tgbVolumeMgr.cc.

392{
393 for(std::size_t ii = 0; ii < leafDepth; ++ii)
394 {
395 G4cout << " ";
396 }
397 G4cout << " LV:(" << leafDepth << ")" << lv->GetName() << G4endl;
398
399 //---------- construct the children of this volume
400 // G4LogicalVolume* lvnc = const_cast<G4LogicalVolume*>(lv);
401 // std::pair<G4mlvlv::iterator, G4mlvlv::iterator> children
402 // = theLVTree.equal_range( lvnc );
403 //
404 // G4mlvlv::iterator cite;
405
406 ++leafDepth;
407 // for( cite = children.first; cite != children.second; ++cite )
408 // {
409 // DumpG4LVLeaf( (*cite)->second, leafDepth );
410 // }
411}
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
const G4String & GetName() const

Referenced by DumpG4LogVolTree().

◆ DumpG4LogVolTree()

void G4tgbVolumeMgr::DumpG4LogVolTree ( )

Definition at line 380 of file G4tgbVolumeMgr.cc.

381{
382 G4cout << " @@@@@@@@@@@@@ DUMPING G4LogicalVolume's Tree " << G4endl;
383
385
386 DumpG4LogVolLeaf(lv, 0);
387}
G4LogicalVolume * GetTopLogVol()
void DumpG4LogVolLeaf(const G4LogicalVolume *lv, unsigned int leafDepth)

Referenced by DumpSummary().

◆ DumpG4PhysVolLeaf()

void G4tgbVolumeMgr::DumpG4PhysVolLeaf ( const G4VPhysicalVolume pv,
unsigned int  leafDepth 
)

Definition at line 424 of file G4tgbVolumeMgr.cc.

426{
427 for(std::size_t ii = 0; ii < leafDepth; ++ii)
428 {
429 G4cout << " ";
430 }
431 G4cout << " PV:(" << leafDepth << ")" << pv->GetName() << G4endl;
432
433 //---------- construct the children of this PV
434 // G4VPhysicalVolume* pvnc = const_cast<G4VPhysicalVolume*>(pv);
435 // std::pair<G4mpvpv::iterator, G4mpvpv::iterator> children
436 // = thePVTree.equal_range( pvnc );
437 //
438 // G4mpvpv::iterator cite;
439
440 ++leafDepth;
441 // for( cite = children.first; cite != children.second; ++cite )
442 // {
443 // DumpG4PVLeaf( (*cite)->second, leafDepth );
444 // }
445}
const G4String & GetName() const

Referenced by DumpG4PhysVolTree().

◆ DumpG4PhysVolTree()

void G4tgbVolumeMgr::DumpG4PhysVolTree ( )

Definition at line 414 of file G4tgbVolumeMgr.cc.

415{
416 G4cout << " @@@@@@@@@@@@@ DUMPING G4PhysicalVolume's Tree " << G4endl;
417
419
420 DumpG4PhysVolLeaf(pv, 0);
421}
void DumpG4PhysVolLeaf(const G4VPhysicalVolume *pv, unsigned int leafDepth)
G4VPhysicalVolume * GetTopPhysVol()

Referenced by DumpSummary().

◆ DumpG4SolidList()

void G4tgbVolumeMgr::DumpG4SolidList ( )

Definition at line 370 of file G4tgbVolumeMgr.cc.

371{
372 for(auto cite = theSolids.cbegin(); cite != theSolids.cend(); ++cite)
373 {
374 G4cout << "G4SOLID: " << (*cite).second->GetName() << " of type "
375 << (*cite).second->GetEntityType() << G4endl;
376 }
377}

Referenced by DumpSummary().

◆ DumpSummary()

void G4tgbVolumeMgr::DumpSummary ( )

Definition at line 341 of file G4tgbVolumeMgr.cc.

342{
343 //---------- Dump number of objects of each class
344 G4cout << " @@@@@@@@@@@@@ Dumping Geant4 geometry objects Summary " << G4endl;
345 G4cout << " @@@ Geometry built inside world volume: "
346 << GetTopPhysVol()->GetName() << G4endl;
347 G4cout << " Number of G4VSolid's: " << theSolids.size() << G4endl;
348 G4cout << " Number of G4LogicalVolume's: " << theLVs.size() << G4endl;
349 G4cout << " Number of G4VPhysicalVolume's: " << thePVs.size() << G4endl;
350
352 G4cout << " Number of G4Isotope's: " << mateMgr->GetG4IsotopeList().size()
353 << G4endl;
354 G4cout << " Number of G4Element's: " << mateMgr->GetG4ElementList().size()
355 << G4endl;
356 G4cout << " Number of G4Material's: " << mateMgr->GetG4MaterialList().size()
357 << G4endl;
358
360 G4cout << " Number of G4RotationMatrix's: "
361 << rotmMgr->GetG4RotMatList().size() << G4endl;
362
363 //---------- Dump list of objects of each class
367}
const G4msg4elem GetG4ElementList() const
const G4msg4mate GetG4MaterialList() const
const G4msg4isot GetG4IsotopeList() const
static G4tgbMaterialMgr * GetInstance()
const G4msg4rotm & GetG4RotMatList() const
static G4tgbRotationMatrixMgr * GetInstance()
void DumpG4PhysVolTree()

◆ FindG4LogVol()

G4LogicalVolume * G4tgbVolumeMgr::FindG4LogVol ( const G4String theName,
const G4bool  bExists = false 
)

Definition at line 226 of file G4tgbVolumeMgr.cc.

228{
229 G4mmslv::const_iterator mscite = theLVs.find(name);
230 if(mscite == theLVs.cend())
231 {
232 if(exists)
233 {
234 G4String ErrMessage = "Logical volume name " + name + " not found !";
235 G4Exception("G4tgbVolumeMgr::FindG4LogVol()", "InvalidSetup",
236 FatalException, ErrMessage);
237 }
238 return nullptr;
239 }
240 else
241 {
242 return (*mscite).second;
243 }
244}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
const char * name(G4int ptype)

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

◆ FindG4PhysVol()

G4VPhysicalVolume * G4tgbVolumeMgr::FindG4PhysVol ( const G4String theName,
const G4bool  bExists = false 
)

Definition at line 247 of file G4tgbVolumeMgr.cc.

249{
250 G4mmspv::const_iterator mscite = thePVs.find(name);
251 if(mscite == thePVs.cend())
252 {
253 if(exists)
254 {
255 G4String ErrMessage = "Physical volume name " + name + " not found !";
256 G4Exception("G4tgbVolumeMgr::FindG4PhysVol()", "InvalidSetup",
257 FatalException, ErrMessage);
258 }
259 return nullptr;
260 }
261 else
262 {
263 return (*mscite).second;
264 }
265}

◆ FindG4Solid()

G4VSolid * G4tgbVolumeMgr::FindG4Solid ( const G4String name)

Definition at line 166 of file G4tgbVolumeMgr.cc.

167{
168#ifdef G4VERBOSE
170 {
171 G4cout << " G4tgbVolumeMgr::FindG4Solid() - " << name << G4endl;
172 }
173#endif
174
175 G4VSolid* oldSolid = nullptr;
176 std::pair<G4mmssol::iterator, G4mmssol::iterator> mmssdi;
177 mmssdi = theSolids.equal_range(name);
178
179 if(mmssdi.first != mmssdi.second)
180 { // check there is a solid found
181 G4mmssol::const_iterator mmsscite = mmssdi.first;
182
183#ifdef G4VERBOSE
185 {
186 G4cout << " G4tgbVolumeMgr::FindG4Solid() - Solid finding " << name
187 << G4endl;
188 }
189#endif
190 /*
191 G4VSolid overwrites the operator== comparing the addresses
192 => this cannot be used !!
193 Then just compare solids by name =>> POSP tag cannot be used
194 for the moment ...
195 if( solid == *( (*mmsscite).second ) )
196 {
197 oldSolid = (*mmsscite).second;
198 break;
199 }
200 until we write operator== for each solid type, we take a solid
201 with the same name (therefore we will not allow two solids with
202 equal name and different parameters (POSP) )
203 */
204 oldSolid = (*mmsscite).second;
205#ifdef G4VERBOSE
207 {
208 G4cout << " G4tgbVolumeMgr::FindG4Solid() - Solid already found " << name
209 << G4endl;
210 }
211#endif
212 }
213
214#ifdef G4VERBOSE
216 {
217 G4cout << " G4tgbVolumeMgr::FindG4Solid() - Old solid: " << oldSolid
218 << G4endl;
219 }
220#endif
221
222 return oldSolid;
223}
static G4int GetVerboseLevel()

Referenced by G4tgbVolume::FindOrConstructG4Solid().

◆ FindVolume()

G4tgbVolume * G4tgbVolumeMgr::FindVolume ( const G4String volname)

Definition at line 149 of file G4tgbVolumeMgr.cc.

150{
151 G4mssvol::const_iterator cite = theVolumeList.find(volname);
152 if(cite == theVolumeList.cend())
153 {
154 G4String ErrMessage = "G4tgbVolume not found: " + volname + " !";
155 G4Exception("G4tgbVolumeMgr::FindVolume()", "InvalidSetup", FatalException,
156 ErrMessage);
157 return nullptr;
158 }
159 else
160 {
161 return (*cite).second;
162 }
163}

Referenced by G4tgbDetectorConstruction::Construct(), G4tgbDetectorBuilder::ConstructDetector(), G4tgbVolume::ConstructG4PhysVol(), and G4tgbVolume::ConstructG4Volumes().

◆ GetDetectorBuilder()

G4tgbDetectorBuilder * G4tgbVolumeMgr::GetDetectorBuilder ( ) const
inline

Definition at line 130 of file G4tgbVolumeMgr.hh.

131 {
132 return theDetectorBuilder;
133 }

◆ GetInstance()

G4tgbVolumeMgr * G4tgbVolumeMgr::GetInstance ( )
static

Definition at line 67 of file G4tgbVolumeMgr.cc.

68{
69 if(theInstance == nullptr)
70 {
71 theInstance = new G4tgbVolumeMgr();
72 }
73 return theInstance;
74}

Referenced by G4tgbDetectorConstruction::Construct(), G4tgbDetectorBuilder::ConstructDetector(), G4tgbVolume::ConstructG4PhysVol(), G4tgbVolume::ConstructG4Volumes(), and G4tgbVolume::FindOrConstructG4Solid().

◆ GetSolids()

const std::multimap< G4String, G4VSolid * > & G4tgbVolumeMgr::GetSolids ( ) const
inline

Definition at line 122 of file G4tgbVolumeMgr.hh.

123 {
124 return theSolids;
125 }

◆ GetTopLogVol()

G4LogicalVolume * G4tgbVolumeMgr::GetTopLogVol ( )

Definition at line 285 of file G4tgbVolumeMgr.cc.

286{
287 //----------- Start from any G4LogicalVolume, because if you go upwards
288 // you will always end at the top
289#ifdef G4VERBOSE
291 {
292 G4cout << " G4tgbVolumeMgr::GetTopLogVol theLVInvTresize "
293 << theLVInvTree.size() << G4endl;
294 }
295#endif
296 if(theLVInvTree.size() == 0)
297 {
298 G4Exception("G4tgbVolumeMgr::GetTopLogVol()", "InvalidSetup",
299 FatalException, "theLVInvTree has no elements.");
300 }
301 G4LogicalVolume* lv = (*(theLVInvTree.begin())).second;
302
303 //------- if first element is the top LV, its parent is 0
304 if(lv == nullptr)
305 {
306 lv = (*(theLVInvTree.begin())).first;
307 }
308 else
309 {
310 while((*(theLVInvTree.find(lv))).second != nullptr)
311 {
312 //---------- get parent of first position
313 lv = (*(theLVInvTree.find(lv))).second;
314#ifdef G4VERBOSE
316 {
317 G4cout << " G4tgbVolumeMgr::GetTopPhysVol: lv " << lv->GetName()
318 << G4endl;
319 }
320#endif
321 }
322 }
323
324 return lv;
325}

Referenced by DumpG4LogVolTree(), and GetTopPhysVol().

◆ GetTopPhysVol()

G4VPhysicalVolume * G4tgbVolumeMgr::GetTopPhysVol ( )

Definition at line 268 of file G4tgbVolumeMgr.cc.

269{
271 G4VPhysicalVolume* pv = (*(thePVs.find(lv->GetName()))).second;
272
273#ifdef G4VERBOSE
275 {
276 G4cout << " G4tgbVolumeMgr::GetTopPhysVol() - pv: " << pv->GetName()
277 << G4endl;
278 }
279#endif
280
281 return pv;
282}

Referenced by G4tgbDetectorBuilder::ConstructDetector(), DumpG4PhysVolTree(), and DumpSummary().

◆ ReadAndConstructDetector()

G4VPhysicalVolume * G4tgbVolumeMgr::ReadAndConstructDetector ( )

Definition at line 83 of file G4tgbVolumeMgr.cc.

84{
85 const G4tgrVolume* tgrVoltop = theDetectorBuilder->ReadDetector();
86 return theDetectorBuilder->ConstructDetector(tgrVoltop);
87}
virtual G4VPhysicalVolume * ConstructDetector(const G4tgrVolume *tgrVoltop)
virtual const G4tgrVolume * ReadDetector()

◆ RegisterChildParentLVs()

void G4tgbVolumeMgr::RegisterChildParentLVs ( const G4LogicalVolume logvol,
const G4LogicalVolume parentLV 
)

Definition at line 126 of file G4tgbVolumeMgr.cc.

128{
129 theLVInvTree[const_cast<G4LogicalVolume*>(logvol)] =
130 const_cast<G4LogicalVolume*>(parentLV);
131 theLVTree[const_cast<G4LogicalVolume*>(parentLV)] =
132 const_cast<G4LogicalVolume*>(logvol);
133}

Referenced by G4tgbVolume::ConstructG4Volumes().

◆ RegisterMe() [1/4]

void G4tgbVolumeMgr::RegisterMe ( const G4LogicalVolume lv)

Definition at line 104 of file G4tgbVolumeMgr.cc.

105{
106 theLVs.insert(
107 G4mmslv::value_type(lv->GetName(), const_cast<G4LogicalVolume*>(lv)));
108
109#ifdef G4VERBOSE
111 {
112 G4cout << " G4tgbVolumeMgr::RegisterMe() - Logical volume registered: "
113 << lv->GetName() << G4endl;
114 }
115#endif
116}

◆ RegisterMe() [2/4]

void G4tgbVolumeMgr::RegisterMe ( const G4tgbVolume vol)

Definition at line 90 of file G4tgbVolumeMgr.cc.

91{
92 theVolumeList.insert(
93 G4mssvol::value_type(vol->GetName(), const_cast<G4tgbVolume*>(vol)));
94}
const G4String & GetName() const
Definition: G4tgbVolume.hh:99

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

◆ RegisterMe() [3/4]

void G4tgbVolumeMgr::RegisterMe ( const G4VPhysicalVolume pv)

Definition at line 119 of file G4tgbVolumeMgr.cc.

120{
121 thePVs.insert(
122 G4mmspv::value_type(pv->GetName(), const_cast<G4VPhysicalVolume*>(pv)));
123}

◆ RegisterMe() [4/4]

void G4tgbVolumeMgr::RegisterMe ( const G4VSolid solid)

Definition at line 97 of file G4tgbVolumeMgr.cc.

98{
99 theSolids.insert(
100 G4mmssol::value_type(solid->GetName(), const_cast<G4VSolid*>(solid)));
101}
G4String GetName() const

◆ SetDetectorBuilder()

void G4tgbVolumeMgr::SetDetectorBuilder ( G4tgbDetectorBuilder db)
inline

Definition at line 126 of file G4tgbVolumeMgr.hh.

127 {
128 theDetectorBuilder = db;
129 }

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