29{
32
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
46 bool putLeaf = false;
47 bool putBranch = false;
48 bool putFullPV = false;
49
50
51 if(thePhys->getNChildVols() == 0)
52 {
54
55 if(sharedLeafLV.find(theLog) != sharedLeafLV.end())
56 return sharedLeafLV[
theLog];
57 else
58 putLeaf = true;
59 }
60
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 {
71 return clonedLV[clonePV];
72 }
73 }
74 else
75 {
76 if(sharedBranchLV.find(&(*thePhys)) == sharedBranchLV.end())
77 putBranch = true;
78 else
79 {
81 return sharedBranchLV[&(*thePhys)];
82 }
83 }
84
85
86 theG4Mat=theMaterialFactory.
Build(
theLog->getMaterial());
87 theG4Solid = theSolidFactory.Build(
theLog->getShape(),
theLog->getName());
88
89 theG4Log = new G4LogicalVolume(theG4Solid,
90 theG4Mat,
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)
G4Material * Build(const GeoMaterial *)