Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4GDMLWriteStructure Class Reference

#include <G4GDMLWriteStructure.hh>

Inheritance diagram for G4GDMLWriteStructure:
Collaboration diagram for G4GDMLWriteStructure:

Public Member Functions

 G4GDMLWriteStructure ()
 
virtual ~G4GDMLWriteStructure ()
 
virtual void StructureWrite (xercesc::DOMElement *)
 
void AddVolumeAuxiliary (G4GDMLAuxStructType myaux, const G4LogicalVolume *const)
 
void SetEnergyCutsExport (G4bool)
 
void SetSDExport (G4bool)
 
- Public Member Functions inherited from G4GDMLWriteParamvol
virtual void ParamvolWrite (xercesc::DOMElement *, const G4VPhysicalVolume *const)
 
virtual void ParamvolAlgorithmWrite (xercesc::DOMElement *paramvolElement, const G4VPhysicalVolume *const paramvol)
 
- Public Member Functions inherited from G4GDMLWriteSetup
virtual void SetupWrite (xercesc::DOMElement *, const G4LogicalVolume *const)
 
- Public Member Functions inherited from G4GDMLWriteSolids
virtual void AddSolid (const G4VSolid *const)
 
virtual void SolidsWrite (xercesc::DOMElement *)
 
- Public Member Functions inherited from G4GDMLWriteMaterials
void AddIsotope (const G4Isotope *const)
 
void AddElement (const G4Element *const)
 
void AddMaterial (const G4Material *const)
 
virtual void MaterialsWrite (xercesc::DOMElement *)
 
- Public Member Functions inherited from G4GDMLWriteDefine
G4ThreeVector GetAngles (const G4RotationMatrix &)
 
void ScaleWrite (xercesc::DOMElement *element, const G4String &name, const G4ThreeVector &scl)
 
void RotationWrite (xercesc::DOMElement *element, const G4String &name, const G4ThreeVector &rot)
 
void PositionWrite (xercesc::DOMElement *element, const G4String &name, const G4ThreeVector &pos)
 
void FirstrotationWrite (xercesc::DOMElement *element, const G4String &name, const G4ThreeVector &rot)
 
void FirstpositionWrite (xercesc::DOMElement *element, const G4String &name, const G4ThreeVector &pos)
 
void AddPosition (const G4String &name, const G4ThreeVector &pos)
 
virtual void DefineWrite (xercesc::DOMElement *)
 
- Public Member Functions inherited from G4GDMLWrite
G4Transform3D Write (const G4String &filename, const G4LogicalVolume *const topLog, const G4String &schemaPath, const G4int depth, G4bool storeReferences=true)
 
void AddModule (const G4VPhysicalVolume *const topVol)
 
void AddModule (const G4int depth)
 
void AddAuxiliary (G4GDMLAuxStructType myaux)
 
virtual void ExtensionWrite (xercesc::DOMElement *)
 
virtual void UserinfoWrite (xercesc::DOMElement *)
 
virtual void AddExtension (xercesc::DOMElement *, const G4LogicalVolume *const)
 
G4String GenerateName (const G4String &, const void *const)
 

Protected Member Functions

void DivisionvolWrite (xercesc::DOMElement *, const G4PVDivision *const)
 
void PhysvolWrite (xercesc::DOMElement *, const G4VPhysicalVolume *const topVol, const G4Transform3D &transform, const G4String &moduleName)
 
void ReplicavolWrite (xercesc::DOMElement *, const G4VPhysicalVolume *const)
 
G4Transform3D TraverseVolumeTree (const G4LogicalVolume *const topVol, const G4int depth)
 
void SurfacesWrite ()
 
void BorderSurfaceCache (const G4LogicalBorderSurface *const)
 
void SkinSurfaceCache (const G4LogicalSkinSurface *const)
 
const G4LogicalBorderSurfaceGetBorderSurface (const G4VPhysicalVolume *const)
 
const G4LogicalSkinSurfaceGetSkinSurface (const G4LogicalVolume *const)
 
G4bool FindOpticalSurface (const G4SurfaceProperty *)
 
void ExportEnergyCuts (const G4LogicalVolume *const)
 
void ExportSD (const G4LogicalVolume *const)
 
- Protected Member Functions inherited from G4GDMLWriteParamvol
 G4GDMLWriteParamvol ()
 
virtual ~G4GDMLWriteParamvol ()
 
void Box_dimensionsWrite (xercesc::DOMElement *, const G4Box *const)
 
void Trd_dimensionsWrite (xercesc::DOMElement *, const G4Trd *const)
 
void Trap_dimensionsWrite (xercesc::DOMElement *, const G4Trap *const)
 
void Tube_dimensionsWrite (xercesc::DOMElement *, const G4Tubs *const)
 
void Cone_dimensionsWrite (xercesc::DOMElement *, const G4Cons *const)
 
void Sphere_dimensionsWrite (xercesc::DOMElement *, const G4Sphere *const)
 
void Orb_dimensionsWrite (xercesc::DOMElement *, const G4Orb *const)
 
void Torus_dimensionsWrite (xercesc::DOMElement *, const G4Torus *const)
 
void Ellipsoid_dimensionsWrite (xercesc::DOMElement *, const G4Ellipsoid *const)
 
void Para_dimensionsWrite (xercesc::DOMElement *, const G4Para *const)
 
void Hype_dimensionsWrite (xercesc::DOMElement *, const G4Hype *const)
 
void Polycone_dimensionsWrite (xercesc::DOMElement *, const G4Polycone *const)
 
void Polyhedra_dimensionsWrite (xercesc::DOMElement *, const G4Polyhedra *const)
 
void ParametersWrite (xercesc::DOMElement *, const G4VPhysicalVolume *const, const G4int &)
 
- Protected Member Functions inherited from G4GDMLWriteSetup
 G4GDMLWriteSetup ()
 
virtual ~G4GDMLWriteSetup ()
 
- Protected Member Functions inherited from G4GDMLWriteSolids
 G4GDMLWriteSolids ()
 
virtual ~G4GDMLWriteSolids ()
 
void MultiUnionWrite (xercesc::DOMElement *solElement, const G4MultiUnion *const)
 
void BooleanWrite (xercesc::DOMElement *, const G4BooleanSolid *const)
 
void ScaledWrite (xercesc::DOMElement *, const G4ScaledSolid *const)
 
void BoxWrite (xercesc::DOMElement *, const G4Box *const)
 
void ConeWrite (xercesc::DOMElement *, const G4Cons *const)
 
void ElconeWrite (xercesc::DOMElement *, const G4EllipticalCone *const)
 
void EllipsoidWrite (xercesc::DOMElement *, const G4Ellipsoid *const)
 
void EltubeWrite (xercesc::DOMElement *, const G4EllipticalTube *const)
 
void XtruWrite (xercesc::DOMElement *, const G4ExtrudedSolid *const)
 
void HypeWrite (xercesc::DOMElement *, const G4Hype *const)
 
void OrbWrite (xercesc::DOMElement *, const G4Orb *const)
 
void ParaWrite (xercesc::DOMElement *, const G4Para *const)
 
void ParaboloidWrite (xercesc::DOMElement *, const G4Paraboloid *const)
 
void PolyconeWrite (xercesc::DOMElement *, const G4Polycone *const)
 
void GenericPolyconeWrite (xercesc::DOMElement *, const G4GenericPolycone *const)
 
void PolyhedraWrite (xercesc::DOMElement *, const G4Polyhedra *const)
 
void SphereWrite (xercesc::DOMElement *, const G4Sphere *const)
 
void TessellatedWrite (xercesc::DOMElement *, const G4TessellatedSolid *const)
 
void TetWrite (xercesc::DOMElement *, const G4Tet *const)
 
void TorusWrite (xercesc::DOMElement *, const G4Torus *const)
 
void GenTrapWrite (xercesc::DOMElement *, const G4GenericTrap *const)
 
void TrapWrite (xercesc::DOMElement *, const G4Trap *const)
 
void TrdWrite (xercesc::DOMElement *, const G4Trd *const)
 
void TubeWrite (xercesc::DOMElement *, const G4Tubs *const)
 
void CutTubeWrite (xercesc::DOMElement *, const G4CutTubs *const)
 
void TwistedboxWrite (xercesc::DOMElement *, const G4TwistedBox *const)
 
void TwistedtrapWrite (xercesc::DOMElement *, const G4TwistedTrap *const)
 
void TwistedtrdWrite (xercesc::DOMElement *, const G4TwistedTrd *const)
 
void TwistedtubsWrite (xercesc::DOMElement *, const G4TwistedTubs *const)
 
void ZplaneWrite (xercesc::DOMElement *, const G4double &, const G4double &, const G4double &)
 
void RZPointWrite (xercesc::DOMElement *, const G4double &, const G4double &)
 
void OpticalSurfaceWrite (xercesc::DOMElement *, const G4OpticalSurface *const)
 
- Protected Member Functions inherited from G4GDMLWriteMaterials
 G4GDMLWriteMaterials ()
 
virtual ~G4GDMLWriteMaterials ()
 
void AtomWrite (xercesc::DOMElement *, const G4double &)
 
void DWrite (xercesc::DOMElement *, const G4double &)
 
void PWrite (xercesc::DOMElement *, const G4double &)
 
void TWrite (xercesc::DOMElement *, const G4double &)
 
void MEEWrite (xercesc::DOMElement *, const G4double &)
 
void IsotopeWrite (const G4Isotope *const)
 
void ElementWrite (const G4Element *const)
 
void MaterialWrite (const G4Material *const)
 
void PropertyWrite (xercesc::DOMElement *, const G4Material *const)
 
void PropertyVectorWrite (const G4String &, const G4PhysicsOrderedFreeVector *const)
 
- Protected Member Functions inherited from G4GDMLWriteDefine
 G4GDMLWriteDefine ()
 
virtual ~G4GDMLWriteDefine ()
 
void Scale_vectorWrite (xercesc::DOMElement *, const G4String &, const G4String &, const G4ThreeVector &)
 
void Rotation_vectorWrite (xercesc::DOMElement *, const G4String &, const G4String &, const G4ThreeVector &)
 
void Position_vectorWrite (xercesc::DOMElement *, const G4String &, const G4String &, const G4ThreeVector &)
 
- Protected Member Functions inherited from G4GDMLWrite
 G4GDMLWrite ()
 
virtual ~G4GDMLWrite ()
 
VolumeMapType & VolumeMap ()
 
xercesc::DOMAttr * NewAttribute (const G4String &, const G4String &)
 
xercesc::DOMAttr * NewAttribute (const G4String &, const G4double &)
 
xercesc::DOMElement * NewElement (const G4String &)
 
G4String Modularize (const G4VPhysicalVolume *const topvol, const G4int depth)
 
void AddAuxInfo (G4GDMLAuxListType *auxInfoList, xercesc::DOMElement *element)
 
G4bool FileExists (const G4String &) const
 
PhysVolumeMapType & PvolumeMap ()
 
DepthMapType & DepthMap ()
 

Protected Attributes

xercesc::DOMElement * structureElement
 
std::vector
< xercesc::DOMElement * > 
borderElementVec
 
std::vector
< xercesc::DOMElement * > 
skinElementVec
 
std::map< const
G4LogicalVolume
*, G4GDMLAuxListType
auxmap
 
- Protected Attributes inherited from G4GDMLWriteSolids
std::vector< const G4VSolid * > solidList
 
xercesc::DOMElement * solidsElement
 
- Protected Attributes inherited from G4GDMLWriteMaterials
std::vector< const G4Isotope * > isotopeList
 
std::vector< const G4Element * > elementList
 
std::vector< const G4Material * > materialList
 
xercesc::DOMElement * materialsElement
 
- Protected Attributes inherited from G4GDMLWriteDefine
xercesc::DOMElement * defineElement
 
- Protected Attributes inherited from G4GDMLWrite
G4String SchemaLocation
 
xercesc::DOMDocument * doc
 
xercesc::DOMElement * extElement
 
xercesc::DOMElement * userinfoElement
 
XMLCh tempStr [10000]
 
G4GDMLAuxListType auxList
 

Additional Inherited Members

- Static Public Member Functions inherited from G4GDMLWrite
static void SetAddPointerToName (G4bool)
 
- Static Protected Attributes inherited from G4GDMLWriteSolids
static const G4int maxTransforms = 8
 
- Static Protected Attributes inherited from G4GDMLWriteDefine
static const G4double kRelativePrecision = DBL_EPSILON
 
static const G4double kAngularPrecision = DBL_EPSILON
 
static const G4double kLinearPrecision = DBL_EPSILON
 
- Static Protected Attributes inherited from G4GDMLWrite
static G4bool addPointerToName = true
 

Detailed Description

Definition at line 56 of file G4GDMLWriteStructure.hh.

Constructor & Destructor Documentation

G4GDMLWriteStructure::G4GDMLWriteStructure ( )

Definition at line 60 of file G4GDMLWriteStructure.cc.

61  : G4GDMLWriteParamvol(), cexport(false)
62 {
63  reflFactory = G4ReflectionFactory::Instance();
64 }
static G4ReflectionFactory * Instance()

Here is the call graph for this function:

G4GDMLWriteStructure::~G4GDMLWriteStructure ( )
virtual

Definition at line 66 of file G4GDMLWriteStructure.cc.

67 {
68 }

Member Function Documentation

void G4GDMLWriteStructure::AddVolumeAuxiliary ( G4GDMLAuxStructType  myaux,
const G4LogicalVolume * const  lvol 
)

Definition at line 564 of file G4GDMLWriteStructure.cc.

566 {
567  std::map<const G4LogicalVolume*,
568  G4GDMLAuxListType>::iterator pos = auxmap.find(lvol);
569 
570  if (pos == auxmap.end()) { auxmap[lvol] = G4GDMLAuxListType(); }
571 
572  auxmap[lvol].push_back(myaux);
573 }
std::map< const G4LogicalVolume *, G4GDMLAuxListType > auxmap
std::vector< G4GDMLAuxStructType > G4GDMLAuxListType
static const G4double pos

Here is the caller graph for this function:

void G4GDMLWriteStructure::BorderSurfaceCache ( const G4LogicalBorderSurface * const  bsurf)
protected

Definition at line 232 of file G4GDMLWriteStructure.cc.

233 {
234  if (!bsurf) { return; }
235 
236  const G4SurfaceProperty* psurf = bsurf->GetSurfaceProperty();
237 
238  // Generate the new element for border-surface
239  //
240  xercesc::DOMElement* borderElement = NewElement("bordersurface");
241  borderElement->setAttributeNode(NewAttribute("name", bsurf->GetName()));
242  borderElement->setAttributeNode(NewAttribute("surfaceproperty",
243  psurf->GetName()));
244 
245  const G4String volumeref1 = GenerateName(bsurf->GetVolume1()->GetName(),
246  bsurf->GetVolume1());
247  const G4String volumeref2 = GenerateName(bsurf->GetVolume2()->GetName(),
248  bsurf->GetVolume2());
249  xercesc::DOMElement* volumerefElement1 = NewElement("physvolref");
250  xercesc::DOMElement* volumerefElement2 = NewElement("physvolref");
251  volumerefElement1->setAttributeNode(NewAttribute("ref",volumeref1));
252  volumerefElement2->setAttributeNode(NewAttribute("ref",volumeref2));
253  borderElement->appendChild(volumerefElement1);
254  borderElement->appendChild(volumerefElement2);
255 
256  if (FindOpticalSurface(psurf))
257  {
258  const G4OpticalSurface* opsurf =
259  dynamic_cast<const G4OpticalSurface*>(psurf);
260  if (!opsurf)
261  {
262  G4Exception("G4GDMLWriteStructure::BorderSurfaceCache()",
263  "InvalidSetup", FatalException, "No optical surface found!");
264  return;
265  }
267  }
268 
269  borderElementVec.push_back(borderElement);
270 }
const G4VPhysicalVolume * GetVolume2() const
const G4String & GetName() const
xercesc::DOMElement * NewElement(const G4String &)
Definition: G4GDMLWrite.cc:160
const G4String & GetName() const
const G4String & GetName() const
void OpticalSurfaceWrite(xercesc::DOMElement *, const G4OpticalSurface *const)
G4String GenerateName(const G4String &, const void *const)
Definition: G4GDMLWrite.cc:123
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
const G4VPhysicalVolume * GetVolume1() const
xercesc::DOMAttr * NewAttribute(const G4String &, const G4String &)
Definition: G4GDMLWrite.cc:136
G4SurfaceProperty * GetSurfaceProperty() const
xercesc::DOMElement * solidsElement
std::vector< xercesc::DOMElement * > borderElementVec
G4bool FindOpticalSurface(const G4SurfaceProperty *)

Here is the call graph for this function:

Here is the caller graph for this function:

void G4GDMLWriteStructure::DivisionvolWrite ( xercesc::DOMElement *  volumeElement,
const G4PVDivision * const  divisionvol 
)
protected

Definition at line 71 of file G4GDMLWriteStructure.cc.

73 {
74  EAxis axis = kUndefined;
75  G4int number = 0;
76  G4double width = 0.0;
77  G4double offset = 0.0;
78  G4bool consuming = false;
79 
80  divisionvol->GetReplicationData(axis,number,width,offset,consuming);
81  axis = divisionvol->GetDivisionAxis();
82 
83  G4String unitString("mm");
84  G4String axisString("kUndefined");
85  if (axis==kXAxis) { axisString = "kXAxis"; }
86  else if (axis==kYAxis) { axisString = "kYAxis"; }
87  else if (axis==kZAxis) { axisString = "kZAxis"; }
88  else if (axis==kRho) { axisString = "kRho"; }
89  else if (axis==kPhi) { axisString = "kPhi"; unitString = "rad"; }
90 
91  const G4String name
92  = GenerateName(divisionvol->GetName(),divisionvol);
93  const G4String volumeref
94  = GenerateName(divisionvol->GetLogicalVolume()->GetName(),
95  divisionvol->GetLogicalVolume());
96 
97  xercesc::DOMElement* divisionvolElement = NewElement("divisionvol");
98  divisionvolElement->setAttributeNode(NewAttribute("axis",axisString));
99  divisionvolElement->setAttributeNode(NewAttribute("number",number));
100  divisionvolElement->setAttributeNode(NewAttribute("width",width));
101  divisionvolElement->setAttributeNode(NewAttribute("offset",offset));
102  divisionvolElement->setAttributeNode(NewAttribute("unit",unitString));
103  xercesc::DOMElement* volumerefElement = NewElement("volumeref");
104  volumerefElement->setAttributeNode(NewAttribute("ref",volumeref));
105  divisionvolElement->appendChild(volumerefElement);
106  volumeElement->appendChild(divisionvolElement);
107 }
Definition: geomdefs.hh:54
const XML_Char * name
Definition: expat.h:151
EAxis GetDivisionAxis() const
xercesc::DOMElement * NewElement(const G4String &)
Definition: G4GDMLWrite.cc:160
int G4int
Definition: G4Types.hh:78
const G4String & GetName() const
bool G4bool
Definition: G4Types.hh:79
G4String GenerateName(const G4String &, const void *const)
Definition: G4GDMLWrite.cc:123
xercesc::DOMAttr * NewAttribute(const G4String &, const G4String &)
Definition: G4GDMLWrite.cc:136
G4LogicalVolume * GetLogicalVolume() const
EAxis
Definition: geomdefs.hh:54
virtual void GetReplicationData(EAxis &axis, G4int &nReplicas, G4double &width, G4double &offset, G4bool &consuming) const
const G4String & GetName() const
double G4double
Definition: G4Types.hh:76
Definition: geomdefs.hh:54

Here is the call graph for this function:

Here is the caller graph for this function:

void G4GDMLWriteStructure::ExportEnergyCuts ( const G4LogicalVolume * const  lvol)
protected

Definition at line 582 of file G4GDMLWriteStructure.cc.

583 {
584  G4GDMLEvaluator eval;
585  G4ProductionCuts* pcuts = lvol->GetRegion()->GetProductionCuts();
587  G4Gamma* gamma = G4Gamma::Gamma();
588  G4Electron* eminus = G4Electron::Electron();
591 
592  G4double gamma_cut = ctab->ConvertRangeToEnergy(gamma, lvol->GetMaterial(),
593  pcuts->GetProductionCut("gamma"));
594  G4double eminus_cut = ctab->ConvertRangeToEnergy(eminus, lvol->GetMaterial(),
595  pcuts->GetProductionCut("e-"));
596  G4double eplus_cut = ctab->ConvertRangeToEnergy(eplus, lvol->GetMaterial(),
597  pcuts->GetProductionCut("e+"));
598  G4double proton_cut = ctab->ConvertRangeToEnergy(proton, lvol->GetMaterial(),
599  pcuts->GetProductionCut("proton"));
600 
601  G4GDMLAuxStructType gammainfo = {"gammaECut",
602  eval.ConvertToString(gamma_cut), "MeV", 0};
603  G4GDMLAuxStructType eminusinfo = {"electronECut",
604  eval.ConvertToString(eminus_cut), "MeV", 0};
605  G4GDMLAuxStructType eplusinfo = {"positronECut",
606  eval.ConvertToString(eplus_cut), "MeV", 0};
607  G4GDMLAuxStructType protinfo = {"protonECut",
608  eval.ConvertToString(proton_cut), "MeV", 0};
609 
610  AddVolumeAuxiliary(gammainfo, lvol);
611  AddVolumeAuxiliary(eminusinfo, lvol);
612  AddVolumeAuxiliary(eplusinfo, lvol);
613  AddVolumeAuxiliary(protinfo, lvol);
614 }
G4ProductionCuts * GetProductionCuts() const
G4Material * GetMaterial() const
G4double GetProductionCut(G4int index) const
G4Region * GetRegion() const
G4String ConvertToString(G4int ival)
static constexpr double eplus
Definition: G4SIunits.hh:199
static G4Proton * Proton()
Definition: G4Proton.cc:93
static G4Gamma * Gamma()
Definition: G4Gamma.cc:86
static G4ProductionCutsTable * GetProductionCutsTable()
static G4Positron * Positron()
Definition: G4Positron.cc:94
void AddVolumeAuxiliary(G4GDMLAuxStructType myaux, const G4LogicalVolume *const)
static G4Electron * Electron()
Definition: G4Electron.cc:94
G4double ConvertRangeToEnergy(const G4ParticleDefinition *particle, const G4Material *material, G4double range)
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

Here is the caller graph for this function:

void G4GDMLWriteStructure::ExportSD ( const G4LogicalVolume * const  lvol)
protected

Definition at line 624 of file G4GDMLWriteStructure.cc.

625 {
627 
628  if(sd)
629  {
630  G4String SDname = sd->GetName();
631 
632  G4GDMLAuxStructType SDinfo = {"SensDet", SDname, "", 0};
633  AddVolumeAuxiliary(SDinfo, lvol);
634  }
635 }
void AddVolumeAuxiliary(G4GDMLAuxStructType myaux, const G4LogicalVolume *const)
G4VSensitiveDetector * GetSensitiveDetector() const

Here is the call graph for this function:

Here is the caller graph for this function:

G4bool G4GDMLWriteStructure::FindOpticalSurface ( const G4SurfaceProperty psurf)
protected

Definition at line 308 of file G4GDMLWriteStructure.cc.

309 {
310  const G4OpticalSurface* osurf = dynamic_cast<const G4OpticalSurface*>(psurf);
311  std::vector<const G4OpticalSurface*>::const_iterator pos;
312  pos = std::find(opt_vec.begin(), opt_vec.end(), osurf);
313  if (pos != opt_vec.end()) { return false; } // item already created!
314 
315  opt_vec.push_back(osurf); // cache it for future reference
316  return true;
317 }
static const G4double pos

Here is the caller graph for this function:

const G4LogicalBorderSurface * G4GDMLWriteStructure::GetBorderSurface ( const G4VPhysicalVolume * const  pvol)
protected

Definition at line 341 of file G4GDMLWriteStructure.cc.

342 {
343  G4LogicalBorderSurface* surf = 0;
345  if (nsurf)
346  {
347  const G4LogicalBorderSurfaceTable* btable =
349  std::vector<G4LogicalBorderSurface*>::const_iterator pos;
350  for (pos = btable->begin(); pos != btable->end(); pos++)
351  {
352  if (pvol == (*pos)->GetVolume1()) // just the first in the couple
353  { // is enough
354  surf = *pos; break;
355  }
356  }
357  }
358  return surf;
359 }
std::vector< G4LogicalBorderSurface * > G4LogicalBorderSurfaceTable
int G4int
Definition: G4Types.hh:78
static size_t GetNumberOfBorderSurfaces()
static const G4LogicalBorderSurfaceTable * GetSurfaceTable()
static const G4double pos

Here is the call graph for this function:

Here is the caller graph for this function:

const G4LogicalSkinSurface * G4GDMLWriteStructure::GetSkinSurface ( const G4LogicalVolume * const  lvol)
protected

Definition at line 320 of file G4GDMLWriteStructure.cc.

321 {
322  G4LogicalSkinSurface* surf = 0;
324  if (nsurf)
325  {
326  const G4LogicalSkinSurfaceTable* stable =
328  std::vector<G4LogicalSkinSurface*>::const_iterator pos;
329  for (pos = stable->begin(); pos != stable->end(); pos++)
330  {
331  if (lvol == (*pos)->GetLogicalVolume())
332  {
333  surf = *pos; break;
334  }
335  }
336  }
337  return surf;
338 }
int G4int
Definition: G4Types.hh:78
static size_t GetNumberOfSkinSurfaces()
static const G4LogicalSkinSurfaceTable * GetSurfaceTable()
std::vector< G4LogicalSkinSurface * > G4LogicalSkinSurfaceTable
static const G4double pos

Here is the call graph for this function:

Here is the caller graph for this function:

void G4GDMLWriteStructure::PhysvolWrite ( xercesc::DOMElement *  volumeElement,
const G4VPhysicalVolume *const  topVol,
const G4Transform3D transform,
const G4String moduleName 
)
protected

Definition at line 109 of file G4GDMLWriteStructure.cc.

113 {
114  HepGeom::Scale3D scale;
115  HepGeom::Rotate3D rotate;
116  HepGeom::Translate3D translate;
117 
118  T.getDecomposition(scale,rotate,translate);
119 
120  const G4ThreeVector scl(scale(0,0),scale(1,1),scale(2,2));
121  const G4ThreeVector rot = GetAngles(rotate.getRotation());
122  const G4ThreeVector pos = T.getTranslation();
123 
124  const G4String name = GenerateName(physvol->GetName(),physvol);
125  const G4int copynumber = physvol->GetCopyNo();
126 
127  xercesc::DOMElement* physvolElement = NewElement("physvol");
128  physvolElement->setAttributeNode(NewAttribute("name",name));
129  if (copynumber) physvolElement->setAttributeNode(NewAttribute("copynumber", copynumber));
130 
131  volumeElement->appendChild(physvolElement);
132 
133  G4LogicalVolume* lv;
134  // Is it reflected?
135  if (reflFactory->IsReflected(physvol->GetLogicalVolume()))
136  {
137  lv = reflFactory->GetConstituentLV(physvol->GetLogicalVolume());
138  }
139  else
140  {
141  lv = physvol->GetLogicalVolume();
142  }
143 
144  const G4String volumeref = GenerateName(lv->GetName(), lv);
145 
146  if (ModuleName.empty())
147  {
148  xercesc::DOMElement* volumerefElement = NewElement("volumeref");
149  volumerefElement->setAttributeNode(NewAttribute("ref",volumeref));
150  physvolElement->appendChild(volumerefElement);
151  }
152  else
153  {
154  xercesc::DOMElement* fileElement = NewElement("file");
155  fileElement->setAttributeNode(NewAttribute("name",ModuleName));
156  fileElement->setAttributeNode(NewAttribute("volname",volumeref));
157  physvolElement->appendChild(fileElement);
158  }
159 
160  if (std::fabs(pos.x()) > kLinearPrecision
161  || std::fabs(pos.y()) > kLinearPrecision
162  || std::fabs(pos.z()) > kLinearPrecision)
163  {
164  PositionWrite(physvolElement,name+"_pos",pos);
165  }
166  if (std::fabs(rot.x()) > kAngularPrecision
167  || std::fabs(rot.y()) > kAngularPrecision
168  || std::fabs(rot.z()) > kAngularPrecision)
169  {
170  RotationWrite(physvolElement,name+"_rot",rot);
171  }
172  if (std::fabs(scl.x()-1.0) > kRelativePrecision
173  || std::fabs(scl.y()-1.0) > kRelativePrecision
174  || std::fabs(scl.z()-1.0) > kRelativePrecision)
175  {
176  ScaleWrite(physvolElement,name+"_scl",scl);
177  }
178 }
static const G4double kAngularPrecision
const XML_Char * name
Definition: expat.h:151
double x() const
void getDecomposition(Scale3D &scale, Rotate3D &rotation, Translate3D &translation) const
Definition: Transform3D.cc:174
G4LogicalVolume * GetConstituentLV(G4LogicalVolume *reflLV) const
xercesc::DOMElement * NewElement(const G4String &)
Definition: G4GDMLWrite.cc:160
int G4int
Definition: G4Types.hh:78
G4bool IsReflected(G4LogicalVolume *lv) const
double z() const
static const G4double kRelativePrecision
CLHEP::HepRotation getRotation() const
G4String GenerateName(const G4String &, const void *const)
Definition: G4GDMLWrite.cc:123
void RotationWrite(xercesc::DOMElement *element, const G4String &name, const G4ThreeVector &rot)
void ScaleWrite(xercesc::DOMElement *element, const G4String &name, const G4ThreeVector &scl)
xercesc::DOMAttr * NewAttribute(const G4String &, const G4String &)
Definition: G4GDMLWrite.cc:136
static const G4double kLinearPrecision
G4ThreeVector GetAngles(const G4RotationMatrix &)
double y() const
void PositionWrite(xercesc::DOMElement *element, const G4String &name, const G4ThreeVector &pos)
const G4String & GetName() const
static const G4double pos

Here is the call graph for this function:

Here is the caller graph for this function:

void G4GDMLWriteStructure::ReplicavolWrite ( xercesc::DOMElement *  volumeElement,
const G4VPhysicalVolume * const  replicavol 
)
protected

Definition at line 180 of file G4GDMLWriteStructure.cc.

182 {
183  EAxis axis = kUndefined;
184  G4int number = 0;
185  G4double width = 0.0;
186  G4double offset = 0.0;
187  G4bool consuming = false;
188  G4String unitString("mm");
189 
190  replicavol->GetReplicationData(axis,number,width,offset,consuming);
191 
192  const G4String volumeref
193  = GenerateName(replicavol->GetLogicalVolume()->GetName(),
194  replicavol->GetLogicalVolume());
195 
196  xercesc::DOMElement* replicavolElement = NewElement("replicavol");
197  replicavolElement->setAttributeNode(NewAttribute("number",number));
198  xercesc::DOMElement* volumerefElement = NewElement("volumeref");
199  volumerefElement->setAttributeNode(NewAttribute("ref",volumeref));
200  replicavolElement->appendChild(volumerefElement);
201  xercesc::DOMElement* replicateElement = NewElement("replicate_along_axis");
202  replicavolElement->appendChild(replicateElement);
203 
204  xercesc::DOMElement* dirElement = NewElement("direction");
205  if(axis==kXAxis)
206  { dirElement->setAttributeNode(NewAttribute("x","1")); }
207  else if(axis==kYAxis)
208  { dirElement->setAttributeNode(NewAttribute("y","1")); }
209  else if(axis==kZAxis)
210  { dirElement->setAttributeNode(NewAttribute("z","1")); }
211  else if(axis==kRho)
212  { dirElement->setAttributeNode(NewAttribute("rho","1")); }
213  else if(axis==kPhi)
214  { dirElement->setAttributeNode(NewAttribute("phi","1"));
215  unitString="rad"; }
216  replicateElement->appendChild(dirElement);
217 
218  xercesc::DOMElement* widthElement = NewElement("width");
219  widthElement->setAttributeNode(NewAttribute("value",width));
220  widthElement->setAttributeNode(NewAttribute("unit",unitString));
221  replicateElement->appendChild(widthElement);
222 
223  xercesc::DOMElement* offsetElement = NewElement("offset");
224  offsetElement->setAttributeNode(NewAttribute("value",offset));
225  offsetElement->setAttributeNode(NewAttribute("unit",unitString));
226  replicateElement->appendChild(offsetElement);
227 
228  volumeElement->appendChild(replicavolElement);
229 }
Definition: geomdefs.hh:54
xercesc::DOMElement * NewElement(const G4String &)
Definition: G4GDMLWrite.cc:160
int G4int
Definition: G4Types.hh:78
bool G4bool
Definition: G4Types.hh:79
G4String GenerateName(const G4String &, const void *const)
Definition: G4GDMLWrite.cc:123
xercesc::DOMAttr * NewAttribute(const G4String &, const G4String &)
Definition: G4GDMLWrite.cc:136
G4LogicalVolume * GetLogicalVolume() const
EAxis
Definition: geomdefs.hh:54
virtual void GetReplicationData(EAxis &axis, G4int &nReplicas, G4double &width, G4double &offset, G4bool &consuming) const =0
const G4String & GetName() const
double G4double
Definition: G4Types.hh:76
Definition: geomdefs.hh:54

Here is the call graph for this function:

Here is the caller graph for this function:

void G4GDMLWriteStructure::SetEnergyCutsExport ( G4bool  fcuts)

Definition at line 576 of file G4GDMLWriteStructure.cc.

577 {
578  cexport = fcuts;
579 }
void G4GDMLWriteStructure::SetSDExport ( G4bool  fsd)

Definition at line 617 of file G4GDMLWriteStructure.cc.

618 {
619  sdexport = fsd;
620 }
void G4GDMLWriteStructure::SkinSurfaceCache ( const G4LogicalSkinSurface * const  ssurf)
protected

Definition at line 273 of file G4GDMLWriteStructure.cc.

274 {
275  if (!ssurf) { return; }
276 
277  const G4SurfaceProperty* psurf = ssurf->GetSurfaceProperty();
278 
279  // Generate the new element for border-surface
280  //
281  xercesc::DOMElement* skinElement = NewElement("skinsurface");
282  skinElement->setAttributeNode(NewAttribute("name", ssurf->GetName()));
283  skinElement->setAttributeNode(NewAttribute("surfaceproperty",
284  psurf->GetName()));
285 
286  const G4String volumeref = GenerateName(ssurf->GetLogicalVolume()->GetName(),
287  ssurf->GetLogicalVolume());
288  xercesc::DOMElement* volumerefElement = NewElement("volumeref");
289  volumerefElement->setAttributeNode(NewAttribute("ref",volumeref));
290  skinElement->appendChild(volumerefElement);
291 
292  if (FindOpticalSurface(psurf))
293  {
294  const G4OpticalSurface* opsurf =
295  dynamic_cast<const G4OpticalSurface*>(psurf);
296  if (!opsurf)
297  {
298  G4Exception("G4GDMLWriteStructure::SkinSurfaceCache()",
299  "InvalidSetup", FatalException, "No optical surface found!");
300  return;
301  }
303  }
304 
305  skinElementVec.push_back(skinElement);
306 }
const G4LogicalVolume * GetLogicalVolume() const
const G4String & GetName() const
xercesc::DOMElement * NewElement(const G4String &)
Definition: G4GDMLWrite.cc:160
const G4String & GetName() const
void OpticalSurfaceWrite(xercesc::DOMElement *, const G4OpticalSurface *const)
G4String GenerateName(const G4String &, const void *const)
Definition: G4GDMLWrite.cc:123
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
xercesc::DOMAttr * NewAttribute(const G4String &, const G4String &)
Definition: G4GDMLWrite.cc:136
G4SurfaceProperty * GetSurfaceProperty() const
const G4String & GetName() const
std::vector< xercesc::DOMElement * > skinElementVec
xercesc::DOMElement * solidsElement
G4bool FindOpticalSurface(const G4SurfaceProperty *)

Here is the call graph for this function:

Here is the caller graph for this function:

void G4GDMLWriteStructure::StructureWrite ( xercesc::DOMElement *  gdmlElement)
virtual

Implements G4GDMLWrite.

Definition at line 376 of file G4GDMLWriteStructure.cc.

377 {
378  G4cout << "G4GDML: Writing structure..." << G4endl;
379 
380  structureElement = NewElement("structure");
381  gdmlElement->appendChild(structureElement);
382 }
xercesc::DOMElement * structureElement
xercesc::DOMElement * NewElement(const G4String &)
Definition: G4GDMLWrite.cc:160
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

void G4GDMLWriteStructure::SurfacesWrite ( )
protectedvirtual

Implements G4GDMLWrite.

Definition at line 361 of file G4GDMLWriteStructure.cc.

362 {
363  G4cout << "G4GDML: Writing surfaces..." << G4endl;
364 
365  std::vector<xercesc::DOMElement*>::const_iterator pos;
366  for (pos = skinElementVec.begin(); pos != skinElementVec.end(); pos++)
367  {
368  structureElement->appendChild(*pos);
369  }
370  for (pos = borderElementVec.begin(); pos != borderElementVec.end(); pos++)
371  {
372  structureElement->appendChild(*pos);
373  }
374 }
xercesc::DOMElement * structureElement
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
std::vector< xercesc::DOMElement * > skinElementVec
static const G4double pos
std::vector< xercesc::DOMElement * > borderElementVec
G4Transform3D G4GDMLWriteStructure::TraverseVolumeTree ( const G4LogicalVolume *const  topVol,
const G4int  depth 
)
protectedvirtual

Implements G4GDMLWrite.

Definition at line 385 of file G4GDMLWriteStructure.cc.

386 {
387  if (VolumeMap().find(volumePtr) != VolumeMap().end())
388  {
389  return VolumeMap()[volumePtr]; // Volume is already processed
390  }
391 
392  G4VSolid* solidPtr = volumePtr->GetSolid();
393  G4Transform3D R,invR;
394  G4int trans=0;
395 
396  std::map<const G4LogicalVolume*, G4GDMLAuxListType>::iterator auxiter;
397 
398  while (true) // Solve possible displacement/reflection
399  { // of the referenced solid!
400  if (trans>maxTransforms)
401  {
402  G4String ErrorMessage = "Referenced solid in volume '"
403  + volumePtr->GetName()
404  + "' was displaced/reflected too many times!";
405  G4Exception("G4GDMLWriteStructure::TraverseVolumeTree()",
406  "InvalidSetup", FatalException, ErrorMessage);
407  }
408 
409  if (G4ReflectedSolid* refl = dynamic_cast<G4ReflectedSolid*>(solidPtr))
410  {
411  R = R*refl->GetTransform3D();
412  solidPtr = refl->GetConstituentMovedSolid();
413  trans++;
414  continue;
415  }
416 
417  if (G4DisplacedSolid* disp = dynamic_cast<G4DisplacedSolid*>(solidPtr))
418  {
419  R = R*G4Transform3D(disp->GetObjectRotation(),
420  disp->GetObjectTranslation());
421  solidPtr = disp->GetConstituentMovedSolid();
422  trans++;
423  continue;
424  }
425 
426  break;
427  }
428 
429  //check if it is a reflected volume
430  G4LogicalVolume* tmplv = const_cast<G4LogicalVolume*>(volumePtr);
431 
432  if (reflFactory->IsReflected(tmplv))
433  {
434  tmplv = reflFactory->GetConstituentLV(tmplv);
435  if (VolumeMap().find(tmplv) != VolumeMap().end())
436  {
437  return R; // Volume is already processed
438  }
439  }
440 
441  // Only compute the inverse when necessary!
442  //
443  if (trans>0) { invR = R.inverse(); }
444 
445  const G4String name
446  = GenerateName(tmplv->GetName(), tmplv);
447  const G4String materialref
448  = GenerateName(volumePtr->GetMaterial()->GetName(),
449  volumePtr->GetMaterial());
450  const G4String solidref
451  = GenerateName(solidPtr->GetName(),solidPtr);
452 
453  xercesc::DOMElement* volumeElement = NewElement("volume");
454  volumeElement->setAttributeNode(NewAttribute("name",name));
455  xercesc::DOMElement* materialrefElement = NewElement("materialref");
456  materialrefElement->setAttributeNode(NewAttribute("ref",materialref));
457  volumeElement->appendChild(materialrefElement);
458  xercesc::DOMElement* solidrefElement = NewElement("solidref");
459  solidrefElement->setAttributeNode(NewAttribute("ref",solidref));
460  volumeElement->appendChild(solidrefElement);
461 
462  const G4int daughterCount = volumePtr->GetNoDaughters();
463 
464  for (G4int i=0;i<daughterCount;i++) // Traverse all the children!
465  {
466  const G4VPhysicalVolume* const physvol = volumePtr->GetDaughter(i);
467  const G4String ModuleName = Modularize(physvol,depth);
468 
469  G4Transform3D daughterR;
470 
471  if (ModuleName.empty()) // Check if subtree requested to be
472  { // a separate module!
473  daughterR = TraverseVolumeTree(physvol->GetLogicalVolume(),depth+1);
474  }
475  else
476  {
477  G4GDMLWriteStructure writer;
478  daughterR = writer.Write(ModuleName,physvol->GetLogicalVolume(),
479  SchemaLocation,depth+1);
480  }
481 
482  if (const G4PVDivision* const divisionvol
483  = dynamic_cast<const G4PVDivision*>(physvol)) // Is it division?
484  {
485  if (!G4Transform3D::Identity.isNear(invR*daughterR,kRelativePrecision))
486  {
487  G4String ErrorMessage = "Division volume in '" + name
488  + "' can not be related to reflected solid!";
489  G4Exception("G4GDMLWriteStructure::TraverseVolumeTree()",
490  "InvalidSetup", FatalException, ErrorMessage);
491  }
492  DivisionvolWrite(volumeElement,divisionvol);
493  } else
494  if (physvol->IsParameterised()) // Is it a paramvol?
495  {
496  if (!G4Transform3D::Identity.isNear(invR*daughterR,kRelativePrecision))
497  {
498  G4String ErrorMessage = "Parameterised volume in '" + name
499  + "' can not be related to reflected solid!";
500  G4Exception("G4GDMLWriteStructure::TraverseVolumeTree()",
501  "InvalidSetup", FatalException, ErrorMessage);
502  }
503  ParamvolWrite(volumeElement,physvol);
504  } else
505  if (physvol->IsReplicated()) // Is it a replicavol?
506  {
507  if (!G4Transform3D::Identity.isNear(invR*daughterR,kRelativePrecision))
508  {
509  G4String ErrorMessage = "Replica volume in '" + name
510  + "' can not be related to reflected solid!";
511  G4Exception("G4GDMLWriteStructure::TraverseVolumeTree()",
512  "InvalidSetup", FatalException, ErrorMessage);
513  }
514  ReplicavolWrite(volumeElement,physvol);
515  }
516  else // Is it a physvol?
517  {
518  G4RotationMatrix rot;
519  if (physvol->GetFrameRotation() != 0)
520  {
521  rot = *(physvol->GetFrameRotation());
522  }
523  G4Transform3D P(rot,physvol->GetObjectTranslation());
524 
525  PhysvolWrite(volumeElement,physvol,invR*P*daughterR,ModuleName);
526  }
528  }
529 
530  if (cexport) { ExportEnergyCuts(volumePtr); }
531  // Add optional energy cuts
532 
533  if (sdexport) { ExportSD(volumePtr); }
534  // Add optional SDs
535 
536  // Here write the auxiliary info
537  //
538  auxiter = auxmap.find(volumePtr);
539  if (auxiter != auxmap.end())
540  {
541  AddAuxInfo(&(auxiter->second), volumeElement);
542  }
543 
544  structureElement->appendChild(volumeElement);
545  // Append the volume AFTER traversing the children so that
546  // the order of volumes will be correct!
547 
548  VolumeMap()[tmplv] = R;
549 
550  AddExtension(volumeElement, volumePtr);
551  // Add any possible user defined extension attached to a volume
552 
553  AddMaterial(volumePtr->GetMaterial());
554  // Add the involved materials and solids!
555 
556  AddSolid(solidPtr);
557 
558  SkinSurfaceCache(GetSkinSurface(volumePtr));
559 
560  return R;
561 }
G4String GetName() const
const XML_Char * name
Definition: expat.h:151
void AddAuxInfo(G4GDMLAuxListType *auxInfoList, xercesc::DOMElement *element)
Definition: G4GDMLWrite.cc:90
G4Transform3D TraverseVolumeTree(const G4LogicalVolume *const topVol, const G4int depth)
xercesc::DOMElement * structureElement
G4String SchemaLocation
Definition: G4GDMLWrite.hh:131
virtual G4bool IsReplicated() const =0
const G4LogicalSkinSurface * GetSkinSurface(const G4LogicalVolume *const)
void ExportSD(const G4LogicalVolume *const)
G4LogicalVolume * GetConstituentLV(G4LogicalVolume *reflLV) const
Transform3D inverse() const
Definition: Transform3D.cc:142
void AddMaterial(const G4Material *const)
virtual void ParamvolWrite(xercesc::DOMElement *, const G4VPhysicalVolume *const)
xercesc::DOMElement * NewElement(const G4String &)
Definition: G4GDMLWrite.cc:160
int G4int
Definition: G4Types.hh:78
G4bool IsReflected(G4LogicalVolume *lv) const
static double P[]
static const G4int maxTransforms
G4String Modularize(const G4VPhysicalVolume *const topvol, const G4int depth)
Definition: G4GDMLWrite.cc:329
G4Transform3D Write(const G4String &filename, const G4LogicalVolume *const topLog, const G4String &schemaPath, const G4int depth, G4bool storeReferences=true)
Definition: G4GDMLWrite.cc:166
static const G4double kRelativePrecision
HepGeom::Transform3D G4Transform3D
G4String GenerateName(const G4String &, const void *const)
Definition: G4GDMLWrite.cc:123
void BorderSurfaceCache(const G4LogicalBorderSurface *const)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
virtual G4bool IsParameterised() const =0
void ReplicavolWrite(xercesc::DOMElement *, const G4VPhysicalVolume *const)
const G4RotationMatrix * GetFrameRotation() const
void PhysvolWrite(xercesc::DOMElement *, const G4VPhysicalVolume *const topVol, const G4Transform3D &transform, const G4String &moduleName)
std::map< const G4LogicalVolume *, G4GDMLAuxListType > auxmap
xercesc::DOMAttr * NewAttribute(const G4String &, const G4String &)
Definition: G4GDMLWrite.cc:136
G4LogicalVolume * GetLogicalVolume() const
void SkinSurfaceCache(const G4LogicalSkinSurface *const)
const G4LogicalBorderSurface * GetBorderSurface(const G4VPhysicalVolume *const)
virtual void AddExtension(xercesc::DOMElement *, const G4LogicalVolume *const)
Definition: G4GDMLWrite.cc:78
G4ThreeVector GetObjectTranslation() const
const G4String & GetName() const
void DivisionvolWrite(xercesc::DOMElement *, const G4PVDivision *const)
void ExportEnergyCuts(const G4LogicalVolume *const)
VolumeMapType & VolumeMap()
Definition: G4GDMLWrite.cc:60
static const Transform3D Identity
Definition: Transform3D.h:197
virtual void AddSolid(const G4VSolid *const)

Here is the call graph for this function:

Member Data Documentation

std::map<const G4LogicalVolume*, G4GDMLAuxListType> G4GDMLWriteStructure::auxmap
protected

Definition at line 92 of file G4GDMLWriteStructure.hh.

std::vector<xercesc::DOMElement*> G4GDMLWriteStructure::borderElementVec
protected

Definition at line 90 of file G4GDMLWriteStructure.hh.

std::vector<xercesc::DOMElement*> G4GDMLWriteStructure::skinElementVec
protected

Definition at line 91 of file G4GDMLWriteStructure.hh.

xercesc::DOMElement* G4GDMLWriteStructure::structureElement
protected

Definition at line 89 of file G4GDMLWriteStructure.hh.


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