38 #include <Geant4/G4Material.hh>
39 #include <Geant4/G4ReflectedSolid.hh>
40 #include <Geant4/G4DisplacedSolid.hh>
41 #include <Geant4/G4LogicalVolumeStore.hh>
42 #include <Geant4/G4PhysicalVolumeStore.hh>
43 #include <Geant4/G4ReflectionFactory.hh>
44 #include <Geant4/G4PVDivision.hh>
45 #include <Geant4/G4PVReplica.hh>
46 #include <Geant4/G4Region.hh>
47 #include <Geant4/G4OpticalSurface.hh>
48 #include <Geant4/G4LogicalSkinSurface.hh>
49 #include <Geant4/G4LogicalBorderSurface.hh>
51 #include <Geant4/G4ProductionCuts.hh>
52 #include <Geant4/G4ProductionCutsTable.hh>
53 #include <Geant4/G4Gamma.hh>
54 #include <Geant4/G4Electron.hh>
55 #include <Geant4/G4Positron.hh>
56 #include <Geant4/G4Proton.hh>
89 if (axis==
kXAxis) { axisString =
"kXAxis"; }
90 else if (axis==
kYAxis) { axisString =
"kYAxis"; }
91 else if (axis==
kZAxis) { axisString =
"kZAxis"; }
92 else if (axis==
kRho) { axisString =
"kRho"; }
93 else if (axis==
kPhi) { axisString =
"kPhi"; unitString =
"rad"; }
101 xercesc::DOMElement* divisionvolElement =
NewElement(
"divisionvol");
102 divisionvolElement->setAttributeNode(
NewAttribute(
"axis",axisString));
103 divisionvolElement->setAttributeNode(
NewAttribute(
"number",number));
104 divisionvolElement->setAttributeNode(
NewAttribute(
"width",width));
105 divisionvolElement->setAttributeNode(
NewAttribute(
"offset",offset));
106 divisionvolElement->setAttributeNode(
NewAttribute(
"unit",unitString));
107 xercesc::DOMElement* volumerefElement =
NewElement(
"volumeref");
108 volumerefElement->setAttributeNode(
NewAttribute(
"ref",volumeref));
109 divisionvolElement->appendChild(volumerefElement);
110 volumeElement->appendChild(divisionvolElement);
131 xercesc::DOMElement* physvolElement =
NewElement(
"physvol");
132 physvolElement->setAttributeNode(
NewAttribute(
"name",name));
133 if (copynumber) physvolElement->setAttributeNode(
NewAttribute(
"copynumber", copynumber));
135 volumeElement->appendChild(physvolElement);
150 if (ModuleName.empty())
152 xercesc::DOMElement* volumerefElement =
NewElement(
"volumeref");
153 volumerefElement->setAttributeNode(
NewAttribute(
"ref",volumeref));
154 physvolElement->appendChild(volumerefElement);
158 xercesc::DOMElement* fileElement =
NewElement(
"file");
159 fileElement->setAttributeNode(
NewAttribute(
"name",ModuleName));
160 fileElement->setAttributeNode(
NewAttribute(
"volname",volumeref));
161 physvolElement->appendChild(fileElement);
200 xercesc::DOMElement* replicavolElement =
NewElement(
"replicavol");
201 replicavolElement->setAttributeNode(
NewAttribute(
"number",number));
202 xercesc::DOMElement* volumerefElement =
NewElement(
"volumeref");
203 volumerefElement->setAttributeNode(
NewAttribute(
"ref",volumeref));
204 replicavolElement->appendChild(volumerefElement);
205 xercesc::DOMElement* replicateElement =
NewElement(
"replicate_along_axis");
206 replicavolElement->appendChild(replicateElement);
208 xercesc::DOMElement* dirElement =
NewElement(
"direction");
210 { dirElement->setAttributeNode(
NewAttribute(
"x",
"1")); }
212 { dirElement->setAttributeNode(
NewAttribute(
"y",
"1")); }
214 { dirElement->setAttributeNode(
NewAttribute(
"z",
"1")); }
216 { dirElement->setAttributeNode(
NewAttribute(
"rho",
"1")); }
218 { dirElement->setAttributeNode(
NewAttribute(
"phi",
"1"));
220 replicateElement->appendChild(dirElement);
222 xercesc::DOMElement* widthElement =
NewElement(
"width");
223 widthElement->setAttributeNode(
NewAttribute(
"value",width));
224 widthElement->setAttributeNode(
NewAttribute(
"unit",unitString));
225 replicateElement->appendChild(widthElement);
227 xercesc::DOMElement* offsetElement =
NewElement(
"offset");
228 offsetElement->setAttributeNode(
NewAttribute(
"value",offset));
229 offsetElement->setAttributeNode(
NewAttribute(
"unit",unitString));
230 replicateElement->appendChild(offsetElement);
232 volumeElement->appendChild(replicavolElement);
238 if (!bsurf) {
return; }
244 xercesc::DOMElement* borderElement =
NewElement(
"bordersurface");
246 borderElement->setAttributeNode(
NewAttribute(
"surfaceproperty",
253 xercesc::DOMElement* volumerefElement1 =
NewElement(
"physvolref");
254 xercesc::DOMElement* volumerefElement2 =
NewElement(
"physvolref");
255 volumerefElement1->setAttributeNode(
NewAttribute(
"ref",volumeref1));
256 volumerefElement2->setAttributeNode(
NewAttribute(
"ref",volumeref2));
257 borderElement->appendChild(volumerefElement1);
258 borderElement->appendChild(volumerefElement2);
266 G4Exception(
"PHG4GDMLWriteStructure::BorderSurfaceCache()",
279 if (!ssurf) {
return; }
285 xercesc::DOMElement* skinElement =
NewElement(
"skinsurface");
287 skinElement->setAttributeNode(
NewAttribute(
"surfaceproperty",
292 xercesc::DOMElement* volumerefElement =
NewElement(
"volumeref");
293 volumerefElement->setAttributeNode(
NewAttribute(
"ref",volumeref));
294 skinElement->appendChild(volumerefElement);
302 G4Exception(
"PHG4GDMLWriteStructure::SkinSurfaceCache()",
315 std::vector<const G4OpticalSurface*>::const_iterator
pos;
317 if (pos !=
opt_vec.end()) {
return false; }
332 std::vector<G4LogicalSkinSurface*>::const_iterator
pos;
333 for (pos = stable->begin(); pos != stable->end(); ++
pos)
335 if (lvol == (*pos)->GetLogicalVolume())
353 std::vector<G4LogicalBorderSurface*>::const_iterator
pos;
354 for (pos = btable->begin(); pos != btable->end(); ++
pos)
356 if (pvol == (*pos)->GetVolume1())
367 std::cout <<
"PHG4GDML: Writing surfaces..." << std::endl;
369 std::vector<xercesc::DOMElement*>::const_iterator
pos;
382 std::cout <<
"PHG4GDML: Writing structure..." << std::endl;
398 if (
config->get_excluded_logical_vol().find(volumePtr) !=
config->get_excluded_logical_vol().end())
408 std::map<const G4LogicalVolume*, PHG4GDMLAuxListType>::iterator auxiter;
414 G4String ErrorMessage =
"Referenced solid in volume '"
416 +
"' was displaced/reflected too many times!";
417 G4Exception(
"PHG4GDMLWriteStructure::TraverseVolumeTree()",
423 R = R*refl->GetTransform3D();
424 solidPtr = refl->GetConstituentMovedSolid();
432 disp->GetObjectTranslation());
433 solidPtr = disp->GetConstituentMovedSolid();
455 if (trans>0) { invR = R.
inverse(); }
465 xercesc::DOMElement* volumeElement =
NewElement(
"volume");
466 volumeElement->setAttributeNode(
NewAttribute(
"name",name));
467 xercesc::DOMElement* materialrefElement =
NewElement(
"materialref");
468 materialrefElement->setAttributeNode(
NewAttribute(
"ref",materialref));
469 volumeElement->appendChild(materialrefElement);
470 xercesc::DOMElement* solidrefElement =
NewElement(
"solidref");
471 solidrefElement->setAttributeNode(
NewAttribute(
"ref",solidref));
472 volumeElement->appendChild(solidrefElement);
476 for (
G4int i=0;i<daughterCount;i++)
483 if (
config->get_excluded_physical_vol().find(physvol) !=
config->get_excluded_physical_vol().end())
491 if (ModuleName.empty())
503 = dynamic_cast<const G4PVDivision*>(physvol))
507 G4String ErrorMessage =
"Division volume in '" + name
508 +
"' can not be related to reflected solid!";
509 G4Exception(
"PHG4GDMLWriteStructure::TraverseVolumeTree()",
518 G4String ErrorMessage =
"Parameterised volume in '" + name
519 +
"' can not be related to reflected solid!";
520 G4Exception(
"PHG4GDMLWriteStructure::TraverseVolumeTree()",
529 G4String ErrorMessage =
"Replica volume in '" + name
530 +
"' can not be related to reflected solid!";
531 G4Exception(
"PHG4GDMLWriteStructure::TraverseVolumeTree()",
545 PhysvolWrite(volumeElement,physvol,invR*
P*daughterR,ModuleName);
555 auxiter =
auxmap.find(volumePtr);
556 if (auxiter !=
auxmap.end())
558 AddAuxInfo(&(auxiter->second), volumeElement);
589 auxmap[lvol].push_back(myaux);
635 std::ostringstream os;