ATLAS Offline Software
Loading...
Searching...
No Matches
Geo2G4LVFactory.cxx File Reference
#include "Geo2G4LVFactory.h"
#include "Geo2G4SolidFactory.h"
#include "GeoMaterial2G4/Geo2G4MaterialFactory.h"
#include "GeoModelKernel/GeoLogVol.h"
#include "GeoModelKernel/GeoFullPhysVol.h"
#include "G4LogicalVolume.hh"
#include "G4Material.hh"
#include <iostream>
#include <map>
Include dependency graph for Geo2G4LVFactory.cxx:

Go to the source code of this file.

Typedefs

typedef std::map< const GeoLogVol *, G4LogicalVolume *, std::less< const GeoLogVol * > > leafVMap
typedef std::map< const GeoVPhysVol *, G4LogicalVolume *, std::less< const GeoVPhysVol * > > branchVMap
typedef std::map< const GeoFullPhysVol *, G4LogicalVolume *, std::less< const GeoFullPhysVol * > > fullPVMap

Functions

G4LogicalVolume *Geo2G4LVFactory::Build ATLAS_NOT_THREAD_SAFE (const PVConstLink &thePhys, bool &descend)

Typedef Documentation

◆ branchVMap

typedef std::map<const GeoVPhysVol*, G4LogicalVolume*, std::less<const GeoVPhysVol*> > branchVMap

Definition at line 19 of file Geo2G4LVFactory.cxx.

◆ fullPVMap

typedef std::map<const GeoFullPhysVol*, G4LogicalVolume*, std::less<const GeoFullPhysVol*> > fullPVMap

Definition at line 21 of file Geo2G4LVFactory.cxx.

◆ leafVMap

typedef std::map<const GeoLogVol*, G4LogicalVolume*, std::less<const GeoLogVol*> > leafVMap

Definition at line 18 of file Geo2G4LVFactory.cxx.

Function Documentation

◆ ATLAS_NOT_THREAD_SAFE()

G4LogicalVolume *Geo2G4LVFactory::Build ATLAS_NOT_THREAD_SAFE ( const PVConstLink & thePhys,
bool & descend )

Definition at line 27 of file Geo2G4LVFactory.cxx.

29{
30 static Geo2G4SolidFactory theSolidFactory;
31 static Geo2G4MaterialFactory theMaterialFactory;
32
33 static leafVMap sharedLeafLV;
34 static branchVMap sharedBranchLV;
35 static fullPVMap clonedLV;
36
37 const GeoFullPhysVol* fullPV = dynamic_cast<const GeoFullPhysVol*>(&(*thePhys));
38 const GeoFullPhysVol* clonePV=0;
39
40 const GeoLogVol* theLog = thePhys->getLogVol();
41 G4LogicalVolume *theG4Log=0;
42 G4Material* theG4Mat=0;
43 G4VSolid* theG4Solid=0;
44
45 descend = true;
46 bool putLeaf = false;
47 bool putBranch = false;
48 bool putFullPV = false;
49
50 // Check if it is a leaf node of Geo tree
51 if(thePhys->getNChildVols() == 0)
52 {
53 descend=false;
54
55 if(sharedLeafLV.find(theLog) != sharedLeafLV.end())
56 return sharedLeafLV[theLog];
57 else // here supposed to be ---> else if(theLog->refCount() > 1)
58 putLeaf = true;
59 }
60 // Work with the Full Physical Volumes
61 else if(fullPV)
62 {
63 clonePV = fullPV->cloneOrigin();
64 if (clonedLV.find(clonePV)==clonedLV.end())
65 {
66 if(clonePV) putFullPV = true;
67 }
68 else
69 {
70 descend = false;
71 return clonedLV[clonePV];
72 }
73 }
74 else
75 {
76 if(sharedBranchLV.find(&(*thePhys)) == sharedBranchLV.end())
77 putBranch = true;
78 else
79 {
80 descend = false;
81 return sharedBranchLV[&(*thePhys)];
82 }
83 }
84 // Actually build the G4Log
85
86 theG4Mat=theMaterialFactory.Build(theLog->getMaterial());
87 theG4Solid = theSolidFactory.Build(theLog->getShape(),theLog->getName());
88
89 theG4Log = new G4LogicalVolume(theG4Solid,
90 theG4Mat,
91 theLog->getName(),
92 0,0,0);
93
94 if(putLeaf) sharedLeafLV[theLog] = theG4Log;
95 if(putBranch) sharedBranchLV[&(*thePhys)] = theG4Log;
96 if(putFullPV) clonedLV[clonePV] = theG4Log;
97
98 return theG4Log;
99}
std::map< const GeoFullPhysVol *, G4LogicalVolume *, std::less< const GeoFullPhysVol * > > fullPVMap
std::map< const GeoLogVol *, G4LogicalVolume *, std::less< const GeoLogVol * > > leafVMap
std::map< const GeoVPhysVol *, G4LogicalVolume *, std::less< const GeoVPhysVol * > > branchVMap
void descend(TDirectory *d, int level, int maxdepth, const std::vector< std::string > &labels)
Definition chains.cxx:107
G4Material * Build(const GeoMaterial *)