Import Geant4 9.2.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 15:58:43 +02:00
parent 96c8bcd0af
commit b79225fb37
7544 changed files with 245407 additions and 91099 deletions
+3 -2
View File
@@ -1,4 +1,4 @@
# $Id: GNUmakefile,v 1.6 2007/12/11 15:00:49 gcosmo Exp $
# $Id: GNUmakefile,v 1.10 2008/07/02 14:15:16 gcosmo Exp $
# -----------------------------------------------------------------------
# GNUmakefile for persistency library. Gabriele Cosmo, 16/11/96.
# -----------------------------------------------------------------------
@@ -13,6 +13,7 @@ include $(G4INSTALL)/config/architecture.gmk
CPPFLAGS += -I$(G4INSTALL)/source/global/management/include \
-I$(G4INSTALL)/source/global/HEPGeometry/include \
-I$(G4INSTALL)/source/global/HEPNumerics/include \
-I$(G4INSTALL)/source/digits_hits/hits/include \
-I$(G4INSTALL)/source/digits_hits/digits/include \
-I$(G4INSTALL)/source/particles/management/include \
@@ -23,7 +24,7 @@ CPPFLAGS += -I$(G4INSTALL)/source/global/management/include \
-I$(G4INSTALL)/source/intercoms/include \
-I$(G4INSTALL)/source/geometry/management/include \
-I$(G4INSTALL)/source/geometry/volumes/include \
-I$(G4INSTALL)/source/geometry/management/include \
-I$(G4INSTALL)/source/geometry/navigation/include \
-I$(G4INSTALL)/source/geometry/solids/CSG/include \
-I$(G4INSTALL)/source/geometry/solids/Boolean/include \
-I$(G4INSTALL)/source/geometry/solids/specific/include \
+276 -1
View File
@@ -1,4 +1,4 @@
$Id: History,v 1.5 2007/11/30 15:11:22 gcosmo Exp $
$Id: History,v 1.96 2008/12/04 08:32:08 gcosmo Exp $
-------------------------------------------------------------------
=========================================================
@@ -17,6 +17,281 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
4 December 2008 Gabriele Cosmo (gdml-V09-01-21)
- Updated default GDML schema location in G4GDMLParser to point to new
GDML schema.
21 November 2008 Tatiana Nikitina (gdml-V09-01-20)
- Updated schema to include new features introduced in reader/writer plugin.
21 November 2008 Gabriele Cosmo (gdml-V09-01-19)
- Added missing solid Elliptical-Cone to reader and writer.
20 November 2008 Gabriele Cosmo (gdml-V09-01-18)
- Implemented mechanism for importing GDML descriptions with extensions
to the GDML schema, identified by a new tag "extension".
- Added implementation .cc file for G4GDMLParser.
17 November 2008 Gabriele Cosmo (gdml-V09-01-17)
- Get rid of module-name pre-pended to entity names.
- Added StripNamePointers() method to G4GDMLParser, utility to be invoked in
the user-code to strip off pointers from entity names in a GDML modular setup
after loading all modules.
14 November 2008 Gabriele Cosmo (gdml-V09-01-16)
- Enhanced name stripping in G4GDMLRead, to remove also additional IDs
prepended to the original name of entities in the case of modular GDML files.
13 November 2008 Gabriele Cosmo (gdml-V09-01-15)
- Added support for new serializer API as introduced in Xerces-3.0.0.
- Cleared compilation warnings on Intel-icc compiler.
22 August 2008 Tatiana Nikitina (gdml-V09-01-14)
- G4GDMLReadStructure: added methods ReplicaRead(), AxisRead(), QuantityRead()
and introduced corrections in order to read replica volumes conforming to the
GDML Schema. Added possibility to read/write replication for Rho and Phi axes.
- G4GDMLWriteStructure: introduced corrections in order to write replica
volumes conforming to the GDML Schema.
20 August 2008 Gabriele Cosmo (gdml-V09-01-13)
- G4GDMLParser: added argument to Write() for specify if appending or not
reference pointer to generated names. Default is TRUE.
- G4GDMLRead: implemented filtering of names to remove from entity names
appended reference pointer which may have been generated. Simplified
name generated for physical-volumes to only append "_PV" to its logical
volume name.
- Removed wherever applicable additional strings appended to names.
18 August 2008 Gabriele Cosmo (gdml-V09-01-12)
- G4GDMLWriteSolids: fixes in naming convention for solids; added specification
of units where missing. Introduced parsing of vertices for tessellated solids
to avoid duplication in writing.
29 July 2008 Tatiana Nikitina
- Fixes to parameterisation read and write to match the schema.
24 July 2008 Tatiana Nikitina
- Added to reader the possibility to have a reference to position and rotation
for Boolean solids, as it was possible in GDML_2_10_0.
24 July 2008 Tatiana Nikitina
- Fixes in reading/writing G4TwistedTrap shapes.
22 July 2008 Tatiana Nikitina
- Added G4Paraboloid to list of supported solids for reader and writer.
16 July 2008 Gabriele Cosmo (gdml-V09-01-11)
- Renamed internal methods wherever needed to match code policy and having
them starting with capital letter.
15 July 2008 Gabriele Cosmo (gdml-V09-01-10)
- Code review, formatting and adoption of canonical form for calls to
G4Exception. Usage of std:: namespace for calls to standard mathematical
functions.
- Added class G4STRead, copy of the original class implemented by Z.Torzsok.
- Corrected compilation error on Windows/VC++8 compiler for incorrect
signature of method in base class.
3 July 2008 Gabriele Cosmo (gdml-V09-01-09)
- Corrected bugs introduced in last commits for modularization of files;
Restored original use of maps.
- Corrected syntax for parser writer to (optionally) take a pointer to the
top physical-volume instead of the logical volume.
25 June 2008 Zoltan Torzsok (gdml-V09-01-08)
- Units are set according to CLHEP units in G4GDMLEvaluator.
23 June 2008 Zoltan Torzsok
- Optimised string handling. Schema location can be set in the writer.
20 June 2008 Zoltan Torzsok (gdml-V09-01-07)
- Set correct URL for schema for 'noNamespaceSchemaLocation' parameter.
17 June 2008 Zoltan Torzsok
- Added schema validation.
- Added schema definition files.
10 June 2008 Zoltan Torzsok (gdml-V09-01-06)
- Modularization can be done either by physvol/depth/mixed.
Volume auxiliary information is requested by pointer instead of by name.
9 June 2008 Zoltan Torzsok
- Naming convention can be configured in the writer.
5 June 2008 Zoltan Torzsok
- Module name is optional now. If no name is specified,
the logical volume name will be the filename.
2 June 2008 Zoltan Torzsok (gdml-V09-01-05)
- Writer checks if the file to be created does already exist.
- Added GetVolume() function.
29 May 2008 Zoltan Torzsok
- Added support for writing modular files.
28 May 2008 Zoltan Torzsok
- Only the referenced materials/elements/isotopes are written out, not the
whole material/element/isotope store.
- Assigned the name to world physical volume.
27 May 2008 Zoltan Torzsok
- Optimized/simplified writing of structure: no array required for sorting.
- Only the referenced solids are written out, not the whole solid store.
23 May 2008 Zoltan Torzsok
- Writer: precision is now considered in case of scale, rotation and position
of the physical-volume. DBL_EPSILON is used to filter precision for avoiding
unnecessary scaling, rotation or positioning.
6 May 2008 Zoltan Torzsok (gdml-V09-01-04)
- Added a constant limiting the maximum number of reflections/displacements of a single solid
21 April 2008 Zoltan Torzsok
- Divisionvol, replicavol and paramvol are resolved now.
11 April 2008 Zoltan Torzsok (gdml-V09-01-03)
- Referenced solid in volume is resolved in case of displacements/reflections.
10 April 2008 Zoltan Torzsok
- Added text output to console to inform of progress during processing.
9 April 2008 Zoltan Torzsok
- Worked out an algorithm for sorting logical volumes in the writer.
4 April 2008 Zoltan Torzsok
- Modified writing out of volumes to happen in recursive way.
Still needs optimization. Does not recompute touched branches!
1 April 2008 Z.Torzsok
- Corrected function names to have all starting with capital letter.
11 March 2008 Z.Torzsok (gdml-V09-01-02)
- Added border surface to reader.
- Added skin surface to reader.
- Fixed compilation problems on Intel/icc compiler.
7 March 2008 Z.Torzsok (gdml-V09-01-01)
- Material properties added to reader
20 February 2008 Z.Torzsok
- Completed support for parameterised volumes in writer.
- Name is added to physvol in reader.
19 February 2008 Z.Torzsok
- Replicavol is simplified and no longer restricted to replication along axes.
18 February 2008 Z.Torzsok
- Added G4GDMLWriteParamvol class implementing the parameterised volumes
in the writer. Added box parameterisation and succesfully tested.
15 February 2008 Z.Torzsok
- Division volumes added to writer and succesfully tested.
14 February 2008 Z.Torzsok
- Replica volumes added to writer and succesfully tested.
13 February 2008 Z.Torzsok
- Added getRotationMatrix() function to G4GDMLReadDefine: this function
converts rotation angles into a rotation matrix. This wad used in physvol,
reflectedSolid and boolean solid. Now this conversion is in one place
- Added 'firstrotation' and 'firstposition' to boolean solid. Now the first
solid can be transformed too (Boolean solid is succesfully tested).
11 February 2008 Z.Torzsok
- Added matrices to writer.
- Exception handling is added to loops (identify infinite loops).
8 Febryary 2008 Z.Torzsok
- Naming of physvol changed to 'ReferencedVolumeName_in_MotherVolumeName'.
7 February 2008 Z.Torzsok
- Added twistedtrap and twistedtubs to writer.
6 february 2008 Z.Torzsok
- Tet, Twistedbox and Twistedtrd added to writer and succesfully tested.
5 February 2008 Z.Torzsok
- Hype, orb and para added to writer.
Succesfully tested, except the para.
1 February 2008 Z.Torzsok
- Ellipsoid and elliptical-tube added to writer.
31 January 2008 Z.Torzsok
- Quantities now can be referenced
- Naming of physical volumes changed: MotherLogicalName_daughter(index)
30 January 2008 Z.Torzsok
- If there is only one setup defined, name does not matter, that setup
will be loaded.
- Temperature, pressure and state are now processed in the reader.
Added Nist support.
28 January 2008 Z.Torzsok
- Element added to writer.
- Polyhedra and torus added to writer.
- Now the package is able to read/write the CMS geometry.
25 January 2008 Z.Torzsok
- Bugs fixed in the writer in G4GMLWriteStructure::physvolWrite():
the signs of the rotational angles were incorrect in certain cases
(180 degrees, 90 degrees,...). The reflection was incorrect in case
of reflecting a subtree.
- Now the package is capable of reading and writing back the LHCb
geometry correctly.
23 January 2008 Z.Torzsok
- Composite materials added to writer.
- Cone and tube added to writer.
- Boolean solid (intersection, subtraction, union) added to writer.
22 January 2008 Z.Torzsok
- Extruded solid is added to writer.
- Reflected solid is removed from the written GDML files.
Scale transformation is used instead.
- Optimization to tha case of reading multiple GDML files and writing out
into a single GDML file:
The mother volume is moved to the end of the list after its daugthers are
processed... only when necessary, when new logical volumes come from the
daughters!
21 January 2008 Z.Torzsok
- Reflected solid is added to the writer.
- Solved problem of reading multiple GDML files and writing out into a single
GDML file:
if a logical volume (let's say the mother volume) is instantiated, it will
be added to the end of list of volumes (G4LogicalVolumeStore).
Once this logical volume is instantiated we can add daughters.
If a daughter refers to an external file, additional logical volumes will
come. These logical volumes will be added to the list as well, AFTER the
mother volume. In the mother volume these logical volumes can be referenced
...but these logical volumes are not instantiated yet when we instantiate
the mother! That's why we move the mother volume at the end of the list
after the daughters are processed.
18 January 2008 Z.Torzsok
- The class hierarchy of the GDML parser/writer is finished:
Write <- WriteDefine <- WriteMaterials <- WriteSolids
<- WriteSetup <- WriteStructure
Parser Read <- ReadDefine <- ReadMaterials <- ReadSolids
<- ReadSetup <- ReadParamvol <- ReadStructure.
16 January 2008 Z.Torzsok
- Starting the materials section.
15 January 2008 Z.Torzsok
- Writer implements the setup section too.
11 January 2008 Z.Torzsok (gdml-V09-01-00)
- Reader is now capable of resolving entities.
08 January 2008 Z.Torzsok
- Vertex referencing is fixed in tessellated solid
(using the identifier "vertex" according to the schema).
07 January 2008 Z.Torzsok
- Starting to implement the writer.
30 November, 07 Z.Torzsok (gdml-V09-00-04)
- Fine tuning of the class hierarchy and fixed issue with reflections.
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4GDMLEvaluator.hh,v 1.10 2007/11/28 10:27:18 ztorzsok Exp $
// GEANT4 tag $Name: geant4-09-01 $
// $Id: G4GDMLEvaluator.hh,v 1.16 2008/07/16 15:46:33 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
//
// class G4GDMLEvaluator
@@ -42,24 +42,32 @@
#define _G4GDMLEVALUATOR_INCLUDED_
#include <CLHEP/Evaluator/Evaluator.h>
#include <vector>
#include "G4Types.hh"
#include "G4String.hh"
#include "G4Box.hh"
#include "globals.hh"
class G4GDMLEvaluator
{
public:
class G4GDMLEvaluator {
HepTool::Evaluator eval;
std::vector<G4String> variableList;
public:
G4GDMLEvaluator();
void defineConstant(const G4String&,G4double);
void defineVariable(const G4String&,G4double);
void setVariable(const G4String&,G4double);
void checkVariable(const G4String&);
void DefineConstant(const G4String&, G4double);
void DefineVariable(const G4String&, G4double);
void DefineMatrix(const G4String&, G4int, std::vector<G4double>);
void SetVariable(const G4String&, G4double);
G4bool IsVariable(const G4String&) const;
G4String SolveBrackets(const G4String&);
G4double Evaluate(const G4String&);
G4int EvaluateInteger(const G4String&);
G4double GetConstant(const G4String&);
G4double GetVariable(const G4String&);
private:
HepTool::Evaluator eval;
std::vector<G4String> variableList;
};
#endif
@@ -0,0 +1,103 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4GDMLParameterisation.hh,v 1.10 2008/07/16 15:46:33 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
//
// class G4GDMLParameterisation
//
// Class description:
//
// GDML class for interpretation of parameterisations.
// History:
// - Created. Zoltan Torzsok, November 2007
// -------------------------------------------------------------------------
#ifndef _G4GDMLPARAMETERISATION_INCLUDED_
#define _G4GDMLPARAMETERISATION_INCLUDED_
#include "G4VPVParameterisation.hh"
#include "G4VPhysicalVolume.hh"
#include "G4ThreeVector.hh"
#include "G4Box.hh"
#include "G4Trd.hh"
#include "G4Trap.hh"
#include "G4Cons.hh"
#include "G4Sphere.hh"
#include "G4Orb.hh"
#include "G4Torus.hh"
#include "G4Para.hh"
#include "G4Hype.hh"
#include "G4Tubs.hh"
#include "G4Polycone.hh"
#include "G4Polyhedra.hh"
#include "G4RotationMatrix.hh"
#include "G4ThreeVector.hh"
#include <vector>
class G4GDMLParameterisation : public G4VPVParameterisation
{
public:
struct PARAMETER
{
G4RotationMatrix* pRot;
G4ThreeVector position;
G4double dimension[16];
PARAMETER() { memset(dimension,0,sizeof(dimension)); }
};
G4int GetSize() const;
void AddParameter(const PARAMETER&);
private:
void ComputeTransformation(const G4int,G4VPhysicalVolume*) const;
void ComputeDimensions(G4Box&,const G4int,const G4VPhysicalVolume*) const;
void ComputeDimensions(G4Trd&,const G4int,const G4VPhysicalVolume*) const;
void ComputeDimensions(G4Trap&,const G4int,const G4VPhysicalVolume*) const;
void ComputeDimensions(G4Cons&,const G4int,const G4VPhysicalVolume*) const;
void ComputeDimensions(G4Sphere&,const G4int,const G4VPhysicalVolume*) const;
void ComputeDimensions(G4Orb&,const G4int,const G4VPhysicalVolume*) const;
void ComputeDimensions(G4Torus&,const G4int,const G4VPhysicalVolume*) const;
void ComputeDimensions(G4Para&,const G4int,const G4VPhysicalVolume*) const;
void ComputeDimensions(G4Hype&,const G4int,const G4VPhysicalVolume*) const;
void ComputeDimensions(G4Tubs&,const G4int,const G4VPhysicalVolume*) const;
void ComputeDimensions(G4Polycone&,const G4int,const G4VPhysicalVolume*) const;
void ComputeDimensions(G4Polyhedra&,const G4int,const G4VPhysicalVolume*) const;
private:
std::vector<PARAMETER> parameterList;
};
#endif
@@ -24,28 +24,97 @@
// ********************************************************************
//
//
// $Id: G4GDMLParser.hh,v 1.10 2007/11/30 11:58:46 ztorzsok Exp $
// GEANT4 tag $Name: geant4-09-01 $
// $Id: G4GDMLParser.hh,v 1.56 2008/12/04 08:31:47 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
//
// class G4GDMLParser
//
// Class description:
//
// GDML main parser.
// History:
// - Created. Zoltan Torzsok, November 2007
// -------------------------------------------------------------------------
#ifndef _G4GDMLPARSER_INCLUDED_
#define _G4GDMLPARSER_INCLUDED_
#include "G4GDMLStructure.hh"
#include "G4GDMLReadStructure.hh"
#include "G4GDMLWriteStructure.hh"
#include "G4STRead.hh"
#define G4GDML_DEFAULT_SCHEMALOCATION G4String("http://service-spi.web.cern.ch/service-spi/app/releases/GDML/schema/gdml.xsd")
class G4GDMLParser
{
public: // with description
G4GDMLParser();
G4GDMLParser(G4GDMLReadStructure*);
~G4GDMLParser();
//
// Parser constructors & destructor
inline void Read(const G4String& filename, G4bool Validate=true);
//
// Imports geometry with world-volume, specified by the GDML filename
// in input. Validation against schema is activated by default.
inline void ReadModule(const G4String& filename, G4bool Validate=true);
//
// Imports a single GDML module, specified by the GDML filename
// in input. Validation against schema is activated by default.
inline void Write(const G4String& filename,
const G4VPhysicalVolume* const pvol = 0,
G4bool storeReferences = true,
const G4String& SchemaLocation = G4GDML_DEFAULT_SCHEMALOCATION);
//
// Exports on a GDML file, specified by 'filename' a geometry tree
// starting from 'pvol' as top volume. Uniqueness of stored entities
// is guaranteed by storing pointer-references by default.
// Alternative path for the schema location can be specified; by default
// the URL to the GDML web site is used.
inline G4LogicalVolume* ParseST(const G4String& name,
G4Material* medium,
G4Material* solid);
//
// Imports a tessellated geometry stored as STEP-Tools files
// 'name.geom' and 'name.tree'. It returns a pointer of a generated
// mother volume with 'medium' material associated, including the
// imported tessellated geometry with 'solid' material associated.
// Methods for Reader
//
inline G4double GetConstant(const G4String& name);
inline G4double GetVariable(const G4String& name);
inline G4double GetQuantity(const G4String& name);
inline G4ThreeVector GetPosition(const G4String& name);
inline G4ThreeVector GetRotation(const G4String& name);
inline G4ThreeVector GetScale(const G4String& name);
inline G4GDMLMatrix GetMatrix(const G4String& name);
inline G4LogicalVolume* GetVolume(const G4String& name);
inline G4VPhysicalVolume* GetWorldVolume(const G4String& setupName="Default");
inline G4GDMLAuxListType GetVolumeAuxiliaryInformation(const G4LogicalVolume* const logvol);
inline void StripNamePointers() const;
// Methods for Writer
//
inline void AddModule(const G4VPhysicalVolume* const physvol);
inline void AddModule(const G4int depth);
inline void SetAddPointerToName(G4bool set);
private:
G4GDMLReadStructure* reader;
G4GDMLWriteStructure* writer;
G4bool ucode;
class G4GDMLParser {
G4GDMLStructure structure;
public:
void Read(const G4String& fileName) { structure.Parse(fileName); }
G4VPhysicalVolume* GetWorldVolume(const G4String& setupName="Default") { return structure.getTopVolume(setupName); }
};
#include "G4GDMLParser.icc"
#endif
@@ -0,0 +1,173 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4GDMLParser.icc,v 1.7 2008/11/20 15:33:52 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
//
// class G4GDMLParser inline methods
//
// -------------------------------------------------------------------------
inline
void G4GDMLParser::Read(const G4String& filename, G4bool Validate)
{
reader->Read(filename,Validate,false);
}
inline
void G4GDMLParser::ReadModule(const G4String& filename, G4bool Validate)
{
reader->Read(filename,Validate,true);
}
inline
void G4GDMLParser::Write(const G4String& filename,
const G4VPhysicalVolume* const pvol,
G4bool refs,
const G4String& SchemaLocation)
{
const G4int depth = 0;
G4LogicalVolume* lvol = 0;
if (!pvol)
{
G4VPhysicalVolume* worldPV = GetWorldVolume();
if (!worldPV)
{
G4Exception("G4DMLParser::Write()", "InvalidSetup", FatalException,
"Detector-Construction needs to be registered first!");
}
lvol = worldPV->GetLogicalVolume();
}
else
{
lvol = pvol->GetLogicalVolume();
}
writer->Write(filename,lvol,SchemaLocation,depth,refs);
}
inline
G4LogicalVolume* G4GDMLParser::ParseST(const G4String& filename,
G4Material* medium,
G4Material* solid)
{
G4STRead reader;
return reader.Read(filename, medium, solid);
}
//
// Methods for Reader
//
inline
G4double G4GDMLParser::GetConstant(const G4String& name)
{
return reader->GetConstant(name);
}
inline
G4double G4GDMLParser::GetVariable(const G4String& name)
{
return reader->GetVariable(name);
}
inline
G4double G4GDMLParser::GetQuantity(const G4String& name)
{
return reader->GetQuantity(name);
}
inline
G4ThreeVector G4GDMLParser::GetPosition(const G4String& name)
{
return reader->GetPosition(name);
}
inline
G4ThreeVector G4GDMLParser::GetRotation(const G4String& name)
{
return reader->GetRotation(name);
}
inline
G4ThreeVector G4GDMLParser::GetScale(const G4String& name)
{
return reader->GetScale(name);
}
inline
G4GDMLMatrix G4GDMLParser::GetMatrix(const G4String& name)
{
return reader->GetMatrix(name);
}
inline
G4LogicalVolume* G4GDMLParser::GetVolume(const G4String& name)
{
return reader->GetVolume(name);
}
inline
G4VPhysicalVolume* G4GDMLParser::GetWorldVolume(const G4String& setupName)
{
return reader->GetWorldVolume(setupName);
}
inline
G4GDMLAuxListType
G4GDMLParser::GetVolumeAuxiliaryInformation(const G4LogicalVolume* const logvol)
{
return reader->GetVolumeAuxiliaryInformation(logvol);
}
inline
void G4GDMLParser::StripNamePointers() const
{
reader->StripNames();
}
//
// Methods for Writer
//
inline
void G4GDMLParser::AddModule(const G4VPhysicalVolume* const physvol)
{
writer->AddModule(physvol);
}
inline
void G4GDMLParser::AddModule(const G4int depth)
{
writer->AddModule(depth);
}
inline
void G4GDMLParser::SetAddPointerToName(G4bool set)
{
writer->SetAddPointerToName(set);
}
@@ -0,0 +1,145 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4GDMLRead.hh,v 1.26 2008/11/20 15:33:52 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
// class G4GDMLRead
//
// Class description:
//
// GDML reader.
// History:
// - Created. Zoltan Torzsok, November 2007
// -------------------------------------------------------------------------
#ifndef _G4GDMLBASE_INCLUDED_
#define _G4GDMLBASE_INCLUDED_
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/sax/HandlerBase.hpp>
#include <xercesc/util/XMLUni.hpp>
#include <xercesc/dom/DOM.hpp>
#include "G4GDMLEvaluator.hh"
#include "G4LogicalVolume.hh"
#include "G4VisAttributes.hh"
#include "G4PVPlacement.hh"
#include <sstream>
class G4GDMLErrorHandler : public xercesc::ErrorHandler
{
G4bool Suppress;
public:
G4GDMLErrorHandler(const G4bool set) { Suppress = set; }
void warning(const xercesc::SAXParseException& exception)
{
if (Suppress) { return; }
char* message = xercesc::XMLString::transcode(exception.getMessage());
G4cout << "G4GDML: VALIDATION WARNING! " << message
<< " at line: " << exception.getLineNumber() << G4endl;
xercesc::XMLString::release(&message);
}
void error(const xercesc::SAXParseException& exception)
{
if (Suppress) { return; }
char* message = xercesc::XMLString::transcode(exception.getMessage());
G4cout << "G4GDML: VALIDATION ERROR! " << message
<< " at line: " << exception.getLineNumber() << G4endl;
xercesc::XMLString::release(&message);
}
void fatalError(const xercesc::SAXParseException& exception)
{
error(exception);
}
void resetErrors() {}
};
class G4GDMLRead
{
public: // with description
virtual void DefineRead(const xercesc::DOMElement* const)=0;
virtual void MaterialsRead(const xercesc::DOMElement* const)=0;
virtual void SetupRead(const xercesc::DOMElement* const)=0;
virtual void SolidsRead(const xercesc::DOMElement* const)=0;
virtual void Paramvol_contentRead(const xercesc::DOMElement* const)=0;
virtual void Volume_contentRead(const xercesc::DOMElement* const)=0;
virtual void StructureRead(const xercesc::DOMElement* const)=0;
//
// Pure virtual methods implemented in concrete reader plugin's classes
virtual void ExtensionRead(const xercesc::DOMElement* const);
//
// To be implemented in the client code for handling extensions
// to the GDML schema, identified with the tag "extension".
// The implementation should be placed inside a user-class
// inheriting from G4GDMLReadStructure and being registered
// as argument to G4GDMLParser.
virtual G4LogicalVolume* GetVolume(const G4String&) const=0;
virtual G4String GetSetup(const G4String&)=0;
//
// More pure virtual methods implemented in the reader plugin.
void Read(const G4String&, G4bool SetValidate, G4bool IsModule);
//
// Main method for reading GDML files.
void StripNames() const;
//
// Strip off pointers from entity IDs.
protected:
G4GDMLEvaluator eval;
G4bool Validate;
G4String Transcode(const XMLCh* const);
G4String GenerateName(const G4String& name, G4bool strip=false);
G4String Strip(const G4String&) const;
void StripName(G4String&) const;
void GeneratePhysvolName(const G4String&,G4VPhysicalVolume*);
void LoopRead(const xercesc::DOMElement* const,
void(G4GDMLRead::*)(const xercesc::DOMElement* const));
private:
G4int InLoop;
};
#endif
@@ -0,0 +1,103 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// class G4GDMLReadDefine
//
// Class description:
//
// GDML class for positionings and transformations according to
// specifications in Geant4.
// History:
// - Created. Zoltan Torzsok, November 2007
// -------------------------------------------------------------------------
#ifndef _G4GDMLREADDEFINE_INCLUDED_
#define _G4GDMLREADDEFINE_INCLUDED_
#include <map>
#include "G4ThreeVector.hh"
#include "G4GDMLRead.hh"
class G4GDMLMatrix
{
public:
G4GDMLMatrix();
G4GDMLMatrix(size_t rows0,size_t cols0);
~G4GDMLMatrix();
void Set(size_t r,size_t c,G4double a);
G4double Get(size_t r,size_t c) const;
size_t GetRows() const;
size_t GetCols() const;
private:
G4double *m;
size_t rows,cols;
};
class G4GDMLReadDefine : public G4GDMLRead
{
public:
G4double GetConstant(const G4String&);
G4double GetVariable(const G4String&);
G4double GetQuantity(const G4String&);
G4ThreeVector GetPosition(const G4String&);
G4ThreeVector GetRotation(const G4String&);
G4ThreeVector GetScale(const G4String&);
G4GDMLMatrix GetMatrix(const G4String&);
virtual void DefineRead(const xercesc::DOMElement* const);
protected:
G4RotationMatrix GetRotationMatrix(const G4ThreeVector&);
void VectorRead(const xercesc::DOMElement* const,G4ThreeVector&);
G4String RefRead(const xercesc::DOMElement* const);
void ConstantRead(const xercesc::DOMElement* const);
void MatrixRead(const xercesc::DOMElement* const);
void PositionRead(const xercesc::DOMElement* const);
void RotationRead(const xercesc::DOMElement* const);
void ScaleRead(const xercesc::DOMElement* const);
void VariableRead(const xercesc::DOMElement* const);
void QuantityRead(const xercesc::DOMElement* const);
protected:
std::map<G4String,G4double> quantityMap;
std::map<G4String,G4ThreeVector> positionMap;
std::map<G4String,G4ThreeVector> rotationMap;
std::map<G4String,G4ThreeVector> scaleMap;
std::map<G4String,G4GDMLMatrix> matrixMap;
};
#endif
@@ -0,0 +1,80 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4GDMLReadMaterials.hh,v 1.9 2008/11/20 15:33:52 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
//
// class G4GDMLReadMaterials
//
// Class description:
//
// GDML class for loading isotopes, elements and materials according to
// specifications in Geant4.
// History:
// - Created. Zoltan Torzsok, November 2007
// -------------------------------------------------------------------------
#ifndef _G4GDMLREADMATERIALS_INCLUDED_
#define _G4GDMLREADMATERIALS_INCLUDED_
#include "G4Element.hh"
#include "G4Isotope.hh"
#include "G4Material.hh"
#include "G4NistManager.hh"
#include "G4GDMLReadDefine.hh"
class G4GDMLReadMaterials : public G4GDMLReadDefine
{
public:
G4Element* GetElement(const G4String&, G4bool verbose=true) const;
G4Isotope* GetIsotope(const G4String&, G4bool verbose=true) const;
G4Material* GetMaterial(const G4String&, G4bool verbose=true) const;
virtual void MaterialsRead(const xercesc::DOMElement* const);
protected:
G4double AtomRead(const xercesc::DOMElement* const);
G4int CompositeRead(const xercesc::DOMElement* const,G4String&);
G4double DRead(const xercesc::DOMElement* const);
G4double PRead(const xercesc::DOMElement* const);
G4double TRead(const xercesc::DOMElement* const);
void ElementRead(const xercesc::DOMElement* const);
G4double FractionRead(const xercesc::DOMElement* const,G4String&);
void IsotopeRead(const xercesc::DOMElement* const);
void MaterialRead(const xercesc::DOMElement* const);
void MixtureRead(const xercesc::DOMElement* const,G4Element*);
void MixtureRead(const xercesc::DOMElement* const,G4Material*);
void PropertyRead(const xercesc::DOMElement* const,G4Material*);
};
#endif
@@ -0,0 +1,93 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4GDMLReadParamvol.hh,v 1.6 2008/11/20 15:33:52 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
//
// class G4GDMLReadParamvol
//
// Class description:
//
// GDML class for importing parameterised geometrical entities.
// History:
// - Created. Zoltan Torzsok, November 2007
// -------------------------------------------------------------------------
#ifndef _G4GDMLREADPARAMVOL_INCLUDED_
#define _G4GDMLREADPARAMVOL_INCLUDED_
#include "G4LogicalVolume.hh"
#include "G4PVParameterised.hh"
#include "G4PVPlacement.hh"
#include "G4VPhysicalVolume.hh"
#include "G4GDMLParameterisation.hh"
#include "G4GDMLReadSetup.hh"
class G4GDMLReadParamvol : public G4GDMLReadSetup
{
public:
virtual void ParamvolRead(const xercesc::DOMElement* const,G4LogicalVolume*);
virtual void Paramvol_contentRead(const xercesc::DOMElement* const);
protected:
void Box_dimensionsRead(const xercesc::DOMElement* const,
G4GDMLParameterisation::PARAMETER&);
void Trd_dimensionsRead(const xercesc::DOMElement* const,
G4GDMLParameterisation::PARAMETER&);
void Trap_dimensionsRead(const xercesc::DOMElement* const,
G4GDMLParameterisation::PARAMETER&);
void Tube_dimensionsRead(const xercesc::DOMElement* const,
G4GDMLParameterisation::PARAMETER&);
void Cone_dimensionsRead(const xercesc::DOMElement* const,
G4GDMLParameterisation::PARAMETER&);
void Sphere_dimensionsRead(const xercesc::DOMElement* const,
G4GDMLParameterisation::PARAMETER&);
void Orb_dimensionsRead(const xercesc::DOMElement* const,
G4GDMLParameterisation::PARAMETER&);
void Torus_dimensionsRead(const xercesc::DOMElement* const,
G4GDMLParameterisation::PARAMETER&);
void Para_dimensionsRead(const xercesc::DOMElement* const,
G4GDMLParameterisation::PARAMETER&);
void Hype_dimensionsRead(const xercesc::DOMElement* const,
G4GDMLParameterisation::PARAMETER&);
void ParameterisedRead(const xercesc::DOMElement* const);
void ParametersRead(const xercesc::DOMElement* const);
protected:
G4GDMLParameterisation* parameterisation;
};
#endif
@@ -24,36 +24,40 @@
// ********************************************************************
//
//
// $Id: G4GDMLSetup.hh,v 1.9 2007/11/29 13:13:06 ztorzsok Exp $
// GEANT4 tag $Name: geant4-09-01 $
// $Id: G4GDMLReadSetup.hh,v 1.5 2008/11/20 15:33:52 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
//
// class G4GDMLSetup
// class G4GDMLReadSetup
//
// Class description:
//
// GDML class for geometry setup of physical volumes.
// GDML class for geometry setup of solids.
// History:
// - Created. Zoltan Torzsok, November 2007
// -------------------------------------------------------------------------
#ifndef _G4GDMLSETUP_INCLUDED_
#define _G4GDMLSETUP_INCLUDED_
#ifndef _G4GDMLREADSETUP_INCLUDED_
#define _G4GDMLREADSETUP_INCLUDED_
#include <map>
#include "G4String.hh"
#include "G4GDMLSolids.hh"
#include "G4GDMLReadSolids.hh"
class G4GDMLReadSetup : public G4GDMLReadSolids
{
public:
G4String GetSetup(const G4String&);
virtual void SetupRead(const xercesc::DOMElement* const element);
protected:
class G4GDMLSetup : public G4GDMLSolids {
private:
std::map<G4String,G4String> setupMap;
protected:
void setupRead(const xercesc::DOMElement* const element);
public:
G4String getSetup(const G4String&);
};
#endif
@@ -24,11 +24,11 @@
// ********************************************************************
//
//
// $Id: G4GDMLSolids.hh,v 1.16 2007/11/30 14:51:20 ztorzsok Exp $
// GEANT4 tag $Name: geant4-09-01 $
// $Id: G4GDMLReadSolids.hh,v 1.12 2008/11/21 09:32:46 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
//
// class G4GDMLSolids
// class G4GDMLReadSolids
//
// Class description:
//
@@ -38,18 +38,20 @@
// - Created. Zoltan Torzsok, November 2007
// -------------------------------------------------------------------------
#ifndef _G4GDMLSOLIDS_INCLUDED_
#define _G4GDMLSOLIDS_INCLUDED_
#ifndef _G4GDMLREADSOLIDS_INCLUDED_
#define _G4GDMLREADSOLIDS_INCLUDED_
#include "G4Box.hh"
#include "G4Cons.hh"
#include "G4Ellipsoid.hh"
#include "G4EllipticalCone.hh"
#include "G4EllipticalTube.hh"
#include "G4ExtrudedSolid.hh"
#include "G4Hype.hh"
#include "G4IntersectionSolid.hh"
#include "G4Orb.hh"
#include "G4Para.hh"
#include "G4Paraboloid.hh"
#include "G4Polycone.hh"
#include "G4Polyhedra.hh"
#include "G4QuadrangularFacet.hh"
@@ -65,47 +67,61 @@
#include "G4Trd.hh"
#include "G4TriangularFacet.hh"
#include "G4Tubs.hh"
#include "G4TwistedBox.hh"
#include "G4TwistedTrap.hh"
#include "G4TwistedTrd.hh"
#include "G4TwistedTubs.hh"
#include "G4UnionSolid.hh"
#include "G4OpticalSurface.hh"
#include "G4SurfaceProperty.hh"
#include "G4GDMLMaterials.hh"
#include "G4GDMLReadMaterials.hh"
class G4GDMLSolids : public G4GDMLMaterials {
private:
class G4GDMLReadSolids : public G4GDMLReadMaterials
{
enum BooleanOp {UNION,SUBTRACTION,INTERSECTION};
typedef struct zplaneType { G4double rmin,rmax,z; };
typedef struct { G4double rmin,rmax,z; } zplaneType;
void booleanRead(const xercesc::DOMElement* const,const BooleanOp);
void boxRead(const xercesc::DOMElement* const);
void coneRead(const xercesc::DOMElement* const);
void ellipsoidRead(const xercesc::DOMElement* const);
void eltubeRead(const xercesc::DOMElement* const);
void hypeRead(const xercesc::DOMElement* const);
void loopRead(const xercesc::DOMElement* const);
void orbRead(const xercesc::DOMElement* const);
void paraRead(const xercesc::DOMElement* const);
void polyconeRead(const xercesc::DOMElement* const);
void polyhedraRead(const xercesc::DOMElement* const);
G4QuadrangularFacet* quadrangularRead(const xercesc::DOMElement* const);
G4String refRead(const xercesc::DOMElement* const);
void reflectedSolidRead(const xercesc::DOMElement* const);
G4ExtrudedSolid::ZSection sectionRead(const xercesc::DOMElement* const,G4double);
void sphereRead(const xercesc::DOMElement* const);
void tessellatedRead(const xercesc::DOMElement* const);
void tetRead(const xercesc::DOMElement* const);
void torusRead(const xercesc::DOMElement* const);
void trapRead(const xercesc::DOMElement* const);
void trdRead(const xercesc::DOMElement* const);
G4TriangularFacet* triangularRead(const xercesc::DOMElement* const);
void tubeRead(const xercesc::DOMElement* const);
G4TwoVector twoDimVertexRead(const xercesc::DOMElement* const,G4double);
void xtruRead(const xercesc::DOMElement* const);
zplaneType zplaneRead(const xercesc::DOMElement* const,G4double);
void solidsRead(const xercesc::DOMElement* const);
protected:
G4ThreeVector positionRead(const xercesc::DOMElement* const);
G4ThreeVector rotationRead(const xercesc::DOMElement* const);
G4ThreeVector scaleRead(const xercesc::DOMElement* const);
G4VSolid* getSolid(const G4String&) const;
public:
G4VSolid* GetSolid(const G4String&) const;
G4SurfaceProperty* GetSurfaceProperty(const G4String&) const;
virtual void SolidsRead(const xercesc::DOMElement* const);
protected:
void BooleanRead(const xercesc::DOMElement* const,const BooleanOp);
void BoxRead(const xercesc::DOMElement* const);
void ConeRead(const xercesc::DOMElement* const);
void ElconeRead(const xercesc::DOMElement* const);
void EllipsoidRead(const xercesc::DOMElement* const);
void EltubeRead(const xercesc::DOMElement* const);
void XtruRead(const xercesc::DOMElement* const);
void HypeRead(const xercesc::DOMElement* const);
void OrbRead(const xercesc::DOMElement* const);
void ParaRead(const xercesc::DOMElement* const);
void ParaboloidRead(const xercesc::DOMElement* const);
void PolyconeRead(const xercesc::DOMElement* const);
void PolyhedraRead(const xercesc::DOMElement* const);
G4QuadrangularFacet* QuadrangularRead(const xercesc::DOMElement* const);
void ReflectedSolidRead(const xercesc::DOMElement* const);
G4ExtrudedSolid::ZSection SectionRead(const xercesc::DOMElement* const,G4double);
void SphereRead(const xercesc::DOMElement* const);
void TessellatedRead(const xercesc::DOMElement* const);
void TetRead(const xercesc::DOMElement* const);
void TorusRead(const xercesc::DOMElement* const);
void TrapRead(const xercesc::DOMElement* const);
void TrdRead(const xercesc::DOMElement* const);
void TubeRead(const xercesc::DOMElement* const);
void TwistedboxRead(const xercesc::DOMElement* const);
void TwistedtrapRead(const xercesc::DOMElement* const);
void TwistedtrdRead(const xercesc::DOMElement* const);
void TwistedtubsRead(const xercesc::DOMElement* const);
G4TriangularFacet* TriangularRead(const xercesc::DOMElement* const);
G4TwoVector TwoDimVertexRead(const xercesc::DOMElement* const,G4double);
zplaneType ZplaneRead(const xercesc::DOMElement* const);
void OpticalsurfaceRead(const xercesc::DOMElement* const);
};
#endif
@@ -0,0 +1,105 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4GDMLReadStructure.hh,v 1.22 2008/11/20 15:33:52 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
//
// class G4GDMLReadStructure
//
// Class description:
//
// GDML class for import of structures.
// History:
// - Created. Zoltan Torzsok, November 2007
// -------------------------------------------------------------------------
#ifndef _G4GDMLREADSTRUCTURE_INCLUDED_
#define _G4GDMLREADSTRUCTURE_INCLUDED_
#include "G4AssemblyVolume.hh"
#include "G4LogicalVolume.hh"
#include "G4LogicalVolumeStore.hh"
#include "G4PhysicalVolumeStore.hh"
#include "G4PVDivision.hh"
#include "G4PVPlacement.hh"
#include "G4PVReplica.hh"
#include "G4SolidStore.hh"
#include "G4VPhysicalVolume.hh"
#include "G4ReflectionFactory.hh"
#include "G4PhysicalVolumeStore.hh"
#include "G4LogicalSkinSurface.hh"
#include "G4LogicalBorderSurface.hh"
#include "G4PVDivisionFactory.hh"
#include "G4GDMLReadParamvol.hh"
struct G4GDMLAuxPairType
{
G4String type;
G4double value;
};
typedef std::vector<G4GDMLAuxPairType> G4GDMLAuxListType;
typedef std::map<const G4LogicalVolume*,G4GDMLAuxListType> G4GDMLAuxMapType;
class G4GDMLReadStructure : public G4GDMLReadParamvol
{
public:
G4VPhysicalVolume* GetPhysvol(const G4String&) const;
G4LogicalVolume* GetVolume(const G4String&) const;
G4GDMLAuxListType GetVolumeAuxiliaryInformation(const G4LogicalVolume* const);
G4VPhysicalVolume* GetWorldVolume(const G4String&);
virtual void VolumeRead(const xercesc::DOMElement* const);
virtual void Volume_contentRead(const xercesc::DOMElement* const);
virtual void StructureRead(const xercesc::DOMElement* const);
protected:
G4GDMLAuxPairType AuxiliaryRead(const xercesc::DOMElement* const);
void BordersurfaceRead(const xercesc::DOMElement* const);
void DivisionvolRead(const xercesc::DOMElement* const);
G4LogicalVolume* FileRead(const xercesc::DOMElement* const);
void PhysvolRead(const xercesc::DOMElement* const);
void ReplicavolRead(const xercesc::DOMElement* const, G4int number);
void ReplicaRead(const xercesc::DOMElement* const replicaElement,
G4LogicalVolume* logvol,G4int number);
EAxis AxisRead(const xercesc::DOMElement* const axisElement);
G4double QuantityRead(const xercesc::DOMElement* const readElement);
void SkinsurfaceRead(const xercesc::DOMElement* const);
protected:
G4GDMLAuxMapType auxMap;
G4LogicalVolume *pMotherLogical;
};
#endif
@@ -0,0 +1,107 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4GDMLWrite.hh,v 1.37 2008/08/19 15:03:17 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
//
// class G4GDMLWrite
//
// Class description:
//
// GDML writer.
// History:
// - Created. Zoltan Torzsok, November 2007
// -------------------------------------------------------------------------
#ifndef _G4GDMLWRITE_INCLUDED_
#define _G4GDMLWRITE_INCLUDED_
#include <sys/stat.h>
#include <iostream>
#include <xercesc/dom/DOM.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/framework/LocalFileFormatTarget.hpp>
#include "G4LogicalVolume.hh"
#include "G4Transform3D.hh"
#include "G4PVDivision.hh"
class G4GDMLWrite
{
typedef std::map<const G4LogicalVolume*,G4Transform3D> VolumeMapType;
typedef std::map<const G4VPhysicalVolume*,G4String> PhysVolumeMapType;
typedef std::map<G4int,G4int> DepthMapType;
public: // without description
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);
static void SetAddPointerToName(G4bool);
protected:
G4String SchemaLocation;
VolumeMapType& VolumeMap();
G4String GenerateName(const G4String&,const void* const);
xercesc::DOMAttr* NewAttribute(const G4String&, const G4String&);
xercesc::DOMAttr* NewAttribute(const G4String&, const G4double&);
xercesc::DOMElement* NewElement(const G4String&);
virtual void DefineWrite(xercesc::DOMElement*)=0;
virtual void MaterialsWrite(xercesc::DOMElement*)=0;
virtual void SolidsWrite(xercesc::DOMElement*)=0;
virtual void StructureWrite(xercesc::DOMElement*)=0;
virtual G4Transform3D TraverseVolumeTree(const G4LogicalVolume* const,
const G4int)=0;
virtual void SetupWrite(xercesc::DOMElement*,
const G4LogicalVolume* const)=0;
G4String Modularize(const G4VPhysicalVolume* const topvol,
const G4int depth);
private:
G4bool FileExists(const G4String&) const;
PhysVolumeMapType& PvolumeMap();
DepthMapType& DepthMap();
private:
static G4bool addPointerToName;
xercesc::DOMDocument* doc;
XMLCh tempStr[100];
};
#endif
@@ -0,0 +1,94 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4GDMLWriteDefine.hh,v 1.11 2008/07/16 15:46:33 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
//
// class G4GDMLWriteDefine
//
// Class description:
//
// GDML writer class for positionings and transformations.
// History:
// - Created. Zoltan Torzsok, November 2007
// -------------------------------------------------------------------------
#ifndef _G4GDMLWRITEDEFINE_INCLUDED_
#define _G4GDMLWRITEDEFINE_INCLUDED_
#include "G4GDMLWrite.hh"
#include <sstream>
class G4GDMLWriteDefine : public G4GDMLWrite
{
protected:
G4ThreeVector GetAngles(const G4RotationMatrix&);
void ScaleWrite(xercesc::DOMElement* element, const G4String& name,
const G4ThreeVector& scl)
{ Scale_vectorWrite(element,"scale",name,scl); }
void RotationWrite(xercesc::DOMElement* element, const G4String& name,
const G4ThreeVector& rot)
{ Rotation_vectorWrite(element,"rotation",name,rot); }
void PositionWrite(xercesc::DOMElement* element, const G4String& name,
const G4ThreeVector& pos)
{ Position_vectorWrite(element,"position",name,pos); }
void FirstrotationWrite(xercesc::DOMElement* element, const G4String& name,
const G4ThreeVector& rot)
{ Rotation_vectorWrite(element,"firstrotation",name,rot); }
void FirstpositionWrite(xercesc::DOMElement* element, const G4String& name,
const G4ThreeVector& pos)
{ Position_vectorWrite(element,"firstposition",name,pos); }
void AddPosition(const G4String& name,
const G4ThreeVector& pos)
{ Position_vectorWrite(defineElement,"position",name,pos); }
protected:
static const G4double kRelativePrecision;
static const G4double kAngularPrecision;
static const G4double kLinearPrecision;
private:
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&);
void DefineWrite(xercesc::DOMElement*);
private:
xercesc::DOMElement* defineElement;
};
#endif
@@ -24,44 +24,55 @@
// ********************************************************************
//
//
// $Id: G4GDMLMaterials.hh,v 1.10 2007/11/30 11:58:46 ztorzsok Exp $
// GEANT4 tag $Name: geant4-09-01 $
// $Id: G4GDMLWriteMaterials.hh,v 1.12 2008/07/16 15:46:33 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
//
// class G4GDMLMaterials
// class G4GDMLWriteMaterials
//
// Class description:
//
// GDML class for loading isotopes, elements and materials according to
// specifications in Geant4.
// GDML class for writing materials definitions.
// History:
// - Created. Zoltan Torzsok, November 2007
// -------------------------------------------------------------------------
#ifndef _G4GDMLMATERIALS_INCLUDED_
#define _G4GDMLMATERIALS_INCLUDED_
#include "G4GDMLDefine.hh"
#ifndef _G4GDMLWRITEMATERIALS_INCLUDED_
#define _G4GDMLWRITEMATERIALS_INCLUDED_
#include "G4Element.hh"
#include "G4Isotope.hh"
#include "G4Material.hh"
class G4GDMLMaterials : public G4GDMLDefine {
private:
G4double atomRead(const xercesc::DOMElement* const);
G4double DRead(const xercesc::DOMElement* const);
void elementRead(const xercesc::DOMElement* const);
G4double fractionRead(const xercesc::DOMElement* const,G4String&);
void isotopeRead(const xercesc::DOMElement* const);
void materialRead(const xercesc::DOMElement* const);
void mixtureRead(const xercesc::DOMElement* const,G4Element*);
void mixtureRead(const xercesc::DOMElement* const,G4Material*);
void materialsRead(const xercesc::DOMElement* const);
protected:
G4Isotope* getIsotope(const G4String&) const;
G4Material* getMaterial(const G4String&) const;
#include "G4GDMLWriteDefine.hh"
class G4GDMLWriteMaterials : public G4GDMLWriteDefine
{
protected:
void AddIsotope(const G4Isotope* const);
void AddElement(const G4Element* const);
void AddMaterial(const G4Material* const);
private:
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 IsotopeWrite(const G4Isotope* const);
void ElementWrite(const G4Element* const);
void MaterialWrite(const G4Material* const);
void MaterialsWrite(xercesc::DOMElement*);
private:
std::vector<const G4Isotope*> isotopeList;
std::vector<const G4Element*> elementList;
std::vector<const G4Material*> materialList;
xercesc::DOMElement* materialsElement;
};
#endif
@@ -0,0 +1,75 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4GDMLWriteParamvol.hh,v 1.10 2008/08/13 13:58:53 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
//
// class G4GDMLWriteParamvol
//
// Class description:
//
// GDML class for writing parameterised entities dimensions.
// History:
// - Created. Zoltan Torzsok, November 2007
// -------------------------------------------------------------------------
#ifndef _G4GDMLWRITEPARAMVOL_INCLUDED_
#define _G4GDMLWRITEPARAMVOL_INCLUDED_
#include "G4PVParameterised.hh"
#include "G4VPhysicalVolume.hh"
#include "G4GDMLWriteSetup.hh"
class G4GDMLWriteParamvol : public G4GDMLWriteSetup
{
protected:
void ParamvolWrite(xercesc::DOMElement*, const G4VPhysicalVolume* const);
private:
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 Para_dimensionsWrite(xercesc::DOMElement*, const G4Para* const);
void Hype_dimensionsWrite(xercesc::DOMElement*, const G4Hype* const);
void ParametersWrite(xercesc::DOMElement*,
const G4VPhysicalVolume* const, const G4int&);
void ParamvolAlgorithmWrite(xercesc::DOMElement* paramvolElement,
const G4VPhysicalVolume* const paramvol);
};
#endif
@@ -24,45 +24,30 @@
// ********************************************************************
//
//
// $Id: G4GDMLDefine.hh,v 1.11 2007/11/30 11:58:46 ztorzsok Exp $
// GEANT4 tag $Name: geant4-09-01 $
// $Id: G4GDMLWriteSetup.hh,v 1.7 2008/07/16 15:46:34 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
//
// class G4GDMLDefine
// class G4GDMLWriteSetup
//
// Class description:
//
// GDML class for positionings and transformations according to
// specifications in Geant4.
// GDML writer class for geometry setup of volumes.
// History:
// - Created. Zoltan Torzsok, November 2007
// -------------------------------------------------------------------------
#ifndef _G4GDMLDEFINE_INCLUDED_
#define _G4GDMLDEFINE_INCLUDED_
#ifndef _G4GDMLWRITESETUP_INCLUDED_
#define _G4GDMLWRITESETUP_INCLUDED_
#include <map>
#include "G4GDMLWriteSolids.hh"
#include "G4ThreeVector.hh"
#include "G4GDMLBase.hh"
class G4GDMLWriteSetup : public G4GDMLWriteSolids
{
private:
class G4GDMLDefine : public G4GDMLBase {
private:
std::map<G4String,G4ThreeVector*> positionMap;
std::map<G4String,G4ThreeVector*> rotationMap;
std::map<G4String,G4ThreeVector*> scaleMap;
void constantRead(const xercesc::DOMElement* const);
void positionRead(const xercesc::DOMElement* const);
void rotationRead(const xercesc::DOMElement* const);
void scaleRead(const xercesc::DOMElement* const);
void variableRead(const xercesc::DOMElement* const);
void defineRead(const xercesc::DOMElement* const);
protected:
G4ThreeVector* getPosition(const G4String&);
G4ThreeVector* getRotation(const G4String&);
G4ThreeVector* getScale(const G4String&);
void SetupWrite(xercesc::DOMElement*, const G4LogicalVolume* const);
};
#endif
@@ -0,0 +1,118 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4GDMLWriteSolids.hh,v 1.32 2008/11/21 09:32:46 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
//
// class G4GDMLWriteSolids
//
// Class description:
//
// GDML class for writing solids.
// History:
// - Created. Zoltan Torzsok, November 2007
// -------------------------------------------------------------------------
#ifndef _G4GDMLWRITESOLIDS_INCLUDED_
#define _G4GDMLWRITESOLIDS_INCLUDED_
#include "G4BooleanSolid.hh"
#include "G4Box.hh"
#include "G4Cons.hh"
#include "G4Ellipsoid.hh"
#include "G4EllipticalCone.hh"
#include "G4EllipticalTube.hh"
#include "G4ExtrudedSolid.hh"
#include "G4Hype.hh"
#include "G4Orb.hh"
#include "G4Para.hh"
#include "G4Paraboloid.hh"
#include "G4IntersectionSolid.hh"
#include "G4Polycone.hh"
#include "G4Polyhedra.hh"
#include "G4ReflectedSolid.hh"
#include "G4Sphere.hh"
#include "G4SubtractionSolid.hh"
#include "G4TessellatedSolid.hh"
#include "G4Tet.hh"
#include "G4Torus.hh"
#include "G4Trap.hh"
#include "G4Trd.hh"
#include "G4Tubs.hh"
#include "G4TwistedBox.hh"
#include "G4TwistedTrap.hh"
#include "G4TwistedTrd.hh"
#include "G4TwistedTubs.hh"
#include "G4UnionSolid.hh"
#include "G4GDMLWriteMaterials.hh"
class G4GDMLWriteSolids : public G4GDMLWriteMaterials
{
protected:
void AddSolid(const G4VSolid* const);
private:
void BooleanWrite(xercesc::DOMElement*, const G4BooleanSolid* 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 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 TrapWrite(xercesc::DOMElement*, const G4Trap* const);
void TrdWrite(xercesc::DOMElement*, const G4Trd* const);
void TubeWrite(xercesc::DOMElement*, const G4Tubs* 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 SolidsWrite(xercesc::DOMElement*);
private:
std::vector<const G4VSolid*> solidList;
xercesc::DOMElement* solidsElement;
};
#endif
@@ -24,53 +24,53 @@
// ********************************************************************
//
//
// $Id: G4GDMLStructure.hh,v 1.16 2007/11/30 14:51:20 ztorzsok Exp $
// GEANT4 tag $Name: geant4-09-01 $
// $Id: G4GDMLWriteStructure.hh,v 1.34 2008/07/16 15:46:34 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
//
// class G4GDMLStructure
// class G4GDMLWriteStructure
//
// Class description:
//
// GDML class for loading physical volumes according to various
// specifications in Geant4.
// GDML class for export of structures.
// History:
// - Created. Zoltan Torzsok, November 2007
// -------------------------------------------------------------------------
#ifndef _G4GDMLSTRUCTURE_INCLUDED_
#define _G4GDMLSTRUCTURE_INCLUDED_
#ifndef _G4GDMLWRITESTRUCTURE_INCLUDED_
#define _G4GDMLWRITESTRUCTURE_INCLUDED_
#include "G4LogicalVolume.hh"
#include "G4LogicalVolumeStore.hh"
#include "G4PhysicalVolumeStore.hh"
#include "G4Material.hh"
#include "G4PVDivision.hh"
#include "G4PVPlacement.hh"
#include "G4PVReplica.hh"
#include "G4SolidStore.hh"
#include "G4VPhysicalVolume.hh"
#include "G4ReflectionFactory.hh"
#include "G4ReflectedSolid.hh"
#include "G4Transform3D.hh"
#include "G4GDMLSetup.hh"
#include "G4GDMLWriteParamvol.hh"
class G4GDMLStructure : public G4GDMLSetup {
private:
EAxis directionRead(const xercesc::DOMElement* const);
void divisionvolRead(const xercesc::DOMElement* const,G4LogicalVolume*);
G4LogicalVolume* fileRead(const xercesc::DOMElement* const);
void loopRead(const xercesc::DOMElement* const);
void paramvolRead(const xercesc::DOMElement* const,G4LogicalVolume*);
void physvolRead(const xercesc::DOMElement* const,G4LogicalVolume*);
G4double quantityRead(const xercesc::DOMElement* const);
G4String refRead(const xercesc::DOMElement* const);
void replicate_along_axisRead(const xercesc::DOMElement* const,G4double&,G4double&,EAxis&);
void replicavolRead(const xercesc::DOMElement* const,G4LogicalVolume*);
void volumeRead(const xercesc::DOMElement* const);
void volume_contentRead(const xercesc::DOMElement* const,G4LogicalVolume*);
void volume_loopRead(const xercesc::DOMElement* const,G4LogicalVolume*);
void structureRead(const xercesc::DOMElement* const);
protected:
G4LogicalVolume* getVolume(const G4String&) const;
class G4GDMLWriteStructure : public G4GDMLWriteParamvol
{
private:
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);
void StructureWrite(xercesc::DOMElement*);
G4Transform3D TraverseVolumeTree(const G4LogicalVolume* const topVol,
const G4int depth);
private:
xercesc::DOMElement* structureElement;
static const int maxReflections = 8; // Constant for limiting the number
// of displacements/reflections applied
// to a single solid
};
#endif
@@ -24,56 +24,60 @@
// ********************************************************************
//
//
// $Id: G4GDMLBase.hh,v 1.3 2007/11/30 11:58:46 ztorzsok Exp $
// GEANT4 tag $Name: geant4-09-01 $
// $Id: G4STRead.hh,v 1.3 2008/07/17 14:05:50 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
// class G4GDMLBase
//
// class G4STRead
//
// Class description:
//
// GDML class for import of triangularised geometry descriptions
// (.geom and .tree structures) generated out of STEP files from
// CAD systems (STWriter STEP Tool and similar...).
// History:
// - Created. Zoltan Torzsok, November 2007
// -------------------------------------------------------------------------
#ifndef _G4GDMLBASE_INCLUDED_
#define _G4GDMLBASE_INCLUDED_
#ifndef _G4STREAD_INCLUDED_
#define _G4STREAD_INCLUDED_
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/util/XMLUni.hpp>
#include <xercesc/dom/DOM.hpp>
#include <sstream>
#include <fstream>
#include <vector>
#include <map>
#include "G4TessellatedSolid.hh"
#include "G4QuadrangularFacet.hh"
#include "G4TriangularFacet.hh"
#include "G4LogicalVolume.hh"
#include "G4PVPlacement.hh"
#include "G4VisAttributes.hh"
#include "G4Material.hh"
#include "G4Box.hh"
#include "G4GDMLEvaluator.hh"
class G4STRead
{
public: // with description
class G4GDMLBase {
private:
xercesc::XercesDOMParser* parser; // This should be a static member
G4String prename;
protected:
G4GDMLEvaluator eval;
G4LogicalVolume* Read(const G4String&, G4Material* mediumMaterial,
G4Material* solidMaterial);
private:
G4String GenerateName(const G4String&);
void TessellatedRead(const std::string&);
void FacetRead(const std::string&);
void PhysvolRead(const std::string&);
void ReadGeom(const G4String&);
void ReadTree(const G4String&);
virtual void defineRead(const xercesc::DOMElement* const)=0;
virtual void materialsRead(const xercesc::DOMElement* const)=0;
virtual void solidsRead(const xercesc::DOMElement* const)=0;
virtual void structureRead(const xercesc::DOMElement* const)=0;
virtual void setupRead(const xercesc::DOMElement* const)=0;
private:
virtual G4LogicalVolume* getVolume(const G4String&) const=0;
virtual G4String getSetup(const G4String&)=0;
public:
G4GDMLBase();
~G4GDMLBase();
void Parse(const G4String& fileName);
G4PVPlacement* getTopVolume(const G4String& setupName);
G4Box* world_box;
G4ThreeVector world_extent;
G4Material* solid_material;
G4Material* medium_material;
G4LogicalVolume* world_volume;
std::vector<G4TessellatedSolid*> tessellatedList;
std::map<G4TessellatedSolid*,G4LogicalVolume*> volumeMap;
};
#endif
+216
View File
@@ -0,0 +1,216 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" version="1.0" xmlns:gdml="http://cern.ch/2001/Schemas/GDML" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="gdml_core.xsd"/>
<xs:include schemaLocation="gdml_define.xsd"/>
<xs:include schemaLocation="gdml_materials.xsd"/>
<xs:include schemaLocation="gdml_solids.xsd"/>
<xs:include schemaLocation="gdml_replicas.xsd"/>
<xs:include schemaLocation="gdml_parameterised.xsd"/>
<xs:include schemaLocation="gdml_extensions.xsd"/>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType abstract="true" name="IdentifiableVolumeType">
<xs:attribute name="name" type="xs:ID" use="required"/>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="SinglePlacementType">
<xs:annotation>
<xs:documentation>Represents a single unique copy a of an associated logical volume
in geometrical hierarchy</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:choice minOccurs="1">
<xs:element name="file" type="FileReferenceType"/>
<xs:element name="volumeref" type="ReferenceType"/>
</xs:choice>
<xs:choice minOccurs="0">
<xs:element name="position" type="positionType"/>
<xs:element name="positionref" type="ReferenceType"/>
</xs:choice>
<xs:choice minOccurs="0">
<xs:element name="rotation" type="rotationType"/>
<xs:element name="rotationref" type="ReferenceType"/>
</xs:choice>
<xs:choice minOccurs="0">
<xs:element name="scale" type="scaleType"/>
<xs:element name="scaleref" type="ReferenceType"/>
</xs:choice>
</xs:sequence>
<xs:attribute name="name" type="xs:ID"></xs:attribute>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="DivisionPlacementType">
<xs:annotation>
<xs:documentation>Represents a division of the associated logical volume
in geometrical hierarchy</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="volumeref" type="ReferenceType"/>
</xs:sequence>
<xs:attribute name="axis" type="xs:string" use="required"></xs:attribute>
<xs:attribute name="number" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="width" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="offset" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute default="mm" name="unit" type="xs:string"></xs:attribute>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="VolumeType">
<xs:annotation>
<xs:documentation>Represents a top of a geometrical sub-hierarchy not placed in space
None of its children can coincide with its boundary defined by an associated solid
Two different placements of the same logical volume represent two different geometrical
hierarchies in space</xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="IdentifiableVolumeType">
<xs:sequence>
<xs:element name="materialref" type="ReferenceType"/>
<xs:element name="solidref" type="ReferenceType"/>
<xs:choice minOccurs="0">
<xs:element maxOccurs="unbounded" name="physvol" type="SinglePlacementType"/>
<xs:element maxOccurs="1" minOccurs="1" name="divisionvol" type="DivisionPlacementType"/>
<xs:element maxOccurs="1" minOccurs="1" ref="replicavol"/>
<xs:element maxOccurs="1" minOccurs="1" name="paramvol" type="ParameterisedPlacementType"/>
</xs:choice>
<xs:element maxOccurs="unbounded" minOccurs="0" ref="loop"/>
<xs:element name="auxiliary" maxOccurs="unbounded" minOccurs="0" type="AuxiliaryType"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="AssemblyVolumeType">
<xs:annotation>
<xs:documentation>Allows to create a group of volumes bound together without a boundary
All the volumes exits inside the same virtual reference system of the assmebly volume
they belong to
When assembly volume is placed all its children follow the global transformation applied
to their assembly volume
After the assembly volume is placed its children exist as standalone placements in space
independent of each other</xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="IdentifiableVolumeType">
<xs:choice>
<xs:element maxOccurs="unbounded" name="physvol" type="SinglePlacementType"/>
<xs:element maxOccurs="1" minOccurs="1" ref="replicavol"/>
<xs:element maxOccurs="1" minOccurs="1" name="paramvol" type="ParameterisedPlacementType"/>
</xs:choice>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="LogicalSurfaceType">
<xs:annotation>
<xs:documentation>Base type for logical surfaces (for the moment only optical)
</xs:documentation>
</xs:annotation>
<xs:attribute name="name" type="xs:ID" use="required"></xs:attribute>
<xs:attribute name="surfaceproperty" type="ExpressionOrIDREFType" use="required"></xs:attribute>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element abstract="true" name="Surface" type="LogicalSurfaceType">
<xs:annotation>
<xs:documentation>Abstract element for all solids substitution group</xs:documentation>
</xs:annotation>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="bordersurface" substitutionGroup="Surface">
<xs:annotation>
<xs:documentation>Surface between two physical volumes</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="LogicalSurfaceType">
<xs:sequence>
<xs:element name="physvolref" type="ReferenceType"/>
<xs:element name="physvolref" type="ReferenceType"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="skinsurface" substitutionGroup="Surface">
<xs:annotation>
<xs:documentation>Surface between two physical volumes</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="LogicalSurfaceType">
<xs:sequence>
<xs:element name="volumeref" type="ReferenceType"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="structure">
<xs:annotation>
<xs:documentation>Definitions of a geometrical hierarchy of a set of volumes</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:choice maxOccurs="unbounded">
<xs:element name="volume" type="VolumeType"/>
<xs:element name="assembly" type="AssemblyVolumeType"/>
<xs:element maxOccurs="unbounded" minOccurs="0" ref="loop"/>
<xs:element ref="ParameterisationAlgorithm"/>
</xs:choice>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="Surface"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="gdml">
<xs:complexType>
<xs:sequence>
<xs:element ref="define"/>
<xs:element ref="materials"/>
<xs:element ref="solids"/>
<xs:element ref="structure"/>
<xs:element maxOccurs="unbounded" name="setup">
<xs:annotation>
<xs:documentation>Geometry setup representing the particular geometry hierarchy by refferring to
a given volume which becomes the top level volume</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="world" type="ReferenceType">
<xs:annotation>
<xs:documentation>A reference to the previously defined volume
in the structure block chosen by this setup
World volumme can't be an assembly volume</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
<xs:attribute name="name" type="xs:ID" use="required"/>
<xs:attribute name="version" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute fixed="2.10.0" name="version" type="xs:string">
<xs:annotation>
<xs:documentation>The GDML Schema version consists of 3 digits X.Y.Z
where these mean:
X - major number, increased when major new
features or backward incompatible bug fixes
are added and means the GDML Processor is
allowed to refuse processing of such a
document if this is using the more recent
version of the GDML Schema then GDML Processor
understands
Y - minor number, increased when incremental and
backward compatible changes or improvements
are made into the GDML Schema. GDML Processor
should be able to process such a document
using higher minor version number then that of
the GDML Processor
Z - bugfix revision number, increased when fully
backward compatible changes which resolve a
problem in GDML Schema are applied</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>
+199
View File
@@ -0,0 +1,199 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xs:schema []>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" version="1.0" xmlns:gdml="http://cern.ch/2001/Schemas/GDML" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:simpleType name="InlineExpressionType">
<xs:restriction base="xs:string"></xs:restriction>
</xs:simpleType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:simpleType name="ExpressionOrIDREFType">
<xs:union memberTypes="xs:IDREF InlineExpressionType xs:double "></xs:union>
</xs:simpleType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="IdentifiableExpressionType">
<xs:simpleContent>
<xs:extension base="InlineExpressionType">
<xs:attribute name="name" type="xs:ID" use="required"></xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<!--
<xs:complexType name="ExpressionType" mixed="true">
<xs:annotation>
<xs:documentation>
A base type for expressions
</xs:documentation>
</xs:annotation>
</xs:complexType>
-->
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<!--
<xs:complexType name="IdentifiableExpressionType" mixed="true">
<xs:annotation>
<xs:documentation>
Named (referenced), global scope,
expression (may contain named constants and quantities)
</xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="ExpressionType">
<xs:attribute name="name" type="xs:ID" use="required"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
-->
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="ConstantType">
<xs:annotation>
<xs:documentation>An anonymous, local scope, value</xs:documentation>
</xs:annotation>
<xs:attribute name="value" type="ExpressionOrIDREFType" use="required"></xs:attribute>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="VariableType">
<xs:annotation>
<xs:documentation>An anonymous, local scope, value</xs:documentation>
</xs:annotation>
<xs:attribute name="value" type="ExpressionOrIDREFType" use="required"></xs:attribute>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="IdentifiableConstantType">
<xs:annotation>
<xs:documentation>Named (referenced), global scope, constant value</xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="ConstantType">
<xs:attribute name="name" type="xs:ID" use="required"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="IdentifiableVariableType">
<xs:annotation>
<xs:documentation>Named (referenced), local scope, variable value</xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="VariableType">
<xs:attribute name="name" type="xs:ID" use="required"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="QuantityType">
<xs:annotation>
<xs:documentation>An anonymous quantity, local scope, with a unit,
(possibly of a given type) quantity</xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="ConstantType">
<!-- The unit attribute was originally required,
but set to optional and is recommended to provide
a default value in its derived type
-->
<xs:attribute name="unit" type="xs:string" use="optional"></xs:attribute>
<xs:attribute name="type" type="xs:string" use="optional"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="IdentifiableQuantityType">
<xs:annotation>
<xs:documentation>Named (referenced), global scope,(possibly of a given type) quantity</xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="QuantityType">
<xs:attribute name="name" type="xs:ID" use="required"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="ThreeVectorType">
<xs:annotation>
<xs:documentation>An anonymous, 3 dimensional, local scope, vector of doubles</xs:documentation>
</xs:annotation>
<xs:attribute default="0.0" name="x" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="0.0" name="y" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="0.0" name="z" type="ExpressionOrIDREFType"></xs:attribute>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="MatrixType">
<xs:annotation>
<xs:documentation>A bi-dimensional matrix of doubles</xs:documentation>
</xs:annotation>
<xs:attribute name="name" type="xs:ID"></xs:attribute>
<xs:attribute name="coldim" type="xs:nonNegativeInteger"></xs:attribute>
<xs:attribute name="values" type="xs:string"></xs:attribute>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="IdentifiableThreeVectorType">
<xs:annotation>
<xs:documentation>Named (referenced), 3 dimensional, global scope, vector of doubles</xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="ThreeVectorType">
<xs:attribute name="name" type="xs:ID" use="required"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="QuantityVectorType">
<xs:annotation>
<xs:documentation>An anonymous, 3 dimensional, local scope, with a unit,
(possibly of a given type) quantity vector</xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="ThreeVectorType">
<!-- The unit attribute was originally required,
but set to optional and is recommended to provide
a default value in its derived type
-->
<xs:attribute name="unit" type="xs:string" use="optional"></xs:attribute>
<xs:attribute name="type" type="xs:string" use="optional"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="IdentifiableQuantityVectorType">
<xs:annotation>
<xs:documentation>Named (referenced), 3 dimensional, global scope, with a unit,
(possibly of a given type) quantity vector</xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="QuantityVectorType">
<xs:attribute name="name" type="xs:ID" use="required"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="ReferenceType">
<xs:annotation>
<xs:documentation>Local reference to an element of a named type</xs:documentation>
</xs:annotation>
<xs:attribute name="ref" type="xs:IDREF" use="required"></xs:attribute>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="FileReferenceType">
<xs:annotation>
<xs:documentation>Reference to an external file containing sub-volume information</xs:documentation>
</xs:annotation>
<xs:attribute name="name" type="xs:anyURI" use="required"></xs:attribute>
<xs:attribute name="volname" type="xs:string" use="optional"></xs:attribute>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="ReferenceListType">
<xs:annotation>
<xs:documentation>List of local references to a set of element of a named type</xs:documentation>
</xs:annotation>
<xs:attribute name="refs" type="xs:IDREFS" use="required"></xs:attribute>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="AuxiliaryType">
<xs:annotation>
<xs:documentation>Auxiliary information like sensitive detector declaration, etc.</xs:documentation>
</xs:annotation>
<xs:attribute name="auxtype" type="xs:string" use="required"></xs:attribute>
<xs:attribute name="auxvalue" type="xs:string" use="required"></xs:attribute>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
</xs:schema>
+118
View File
@@ -0,0 +1,118 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xs:schema>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" version="1.0" xmlns:gdml="http://cern.ch/2001/Schemas/GDML" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="gdml_core.xsd"/>
<xs:include schemaLocation="gdml_extensions.xsd"/>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="define" type="defineType">
<xs:annotation>
<xs:documentation>Definition block of global named constants, quantitties, expressions,
positions and rotations which may be used by name or
by a reference in scope of the current document</xs:documentation>
</xs:annotation>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="defineType">
<xs:annotation>
<xs:documentation>The global complex type is defined in order to reuse this defintion
in derived schemas</xs:documentation>
</xs:annotation>
<!-- |||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -->
<xs:choice maxOccurs="unbounded">
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element maxOccurs="unbounded" minOccurs="0" ref="loop"/>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element maxOccurs="unbounded" minOccurs="0" name="constant" type="IdentifiableConstantType">
<xs:annotation>
<xs:documentation>Named constant</xs:documentation>
</xs:annotation>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element maxOccurs="unbounded" minOccurs="0" name="variable" type="IdentifiableVariableType">
<xs:annotation>
<xs:documentation>Named variable</xs:documentation>
</xs:annotation>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element maxOccurs="unbounded" minOccurs="0" name="matrix" type="MatrixType">
<xs:annotation>
<xs:documentation>Named matrix</xs:documentation>
</xs:annotation>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element maxOccurs="unbounded" minOccurs="0" name="quantity" type="IdentifiableQuantityType">
<xs:annotation>
<xs:documentation>Named quantity</xs:documentation>
</xs:annotation>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element maxOccurs="unbounded" minOccurs="0" name="expression" type="IdentifiableExpressionType">
<xs:annotation>
<xs:documentation>Named expression, may contain other named constants,
quantities and expressions</xs:documentation>
</xs:annotation>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element maxOccurs="unbounded" minOccurs="0" name="position" type="positionType">
<xs:annotation>
<xs:documentation>Named cartesian position, default unit mm</xs:documentation>
</xs:annotation>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element maxOccurs="unbounded" minOccurs="0" name="rotation" type="rotationType">
<xs:annotation>
<xs:documentation>Named cartesian rotation, default unit radian</xs:documentation>
</xs:annotation>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element maxOccurs="unbounded" minOccurs="0" name="scale" type="scaleType">
<xs:annotation>
<xs:documentation>Named cartesian rotation, default unit radian</xs:documentation>
</xs:annotation>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
</xs:choice>
<!-- |||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -->
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="positionType">
<xs:complexContent>
<xs:restriction base="IdentifiableQuantityVectorType">
<xs:attribute default="mm" type="xs:string" name="unit"/>
<xs:attribute default="cartesian" type="xs:string" name="type"/>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="rotationType">
<xs:complexContent>
<xs:restriction base="IdentifiableQuantityVectorType">
<xs:attribute default="radian" type="xs:string" name="unit"/>
<xs:attribute default="cartesian" type="xs:string" name="type"/>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="scaleType">
<xs:complexContent>
<xs:restriction base="IdentifiableQuantityVectorType">
</xs:restriction>
</xs:complexContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
</xs:schema>
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" version="1.0" xmlns:gdml="http://cern.ch/2001/Schemas/GDML" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="loop">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element maxOccurs="unbounded" ref="Solid"/>
<xs:element name="volume" type="VolumeType"/>
<xs:element name="physvol" type="SinglePlacementType"/>
<xs:element name="loop" maxOccurs="unbounded"/>
</xs:choice>
<xs:attribute name="for" type="xs:string">
<xs:annotation>
<xs:documentation>
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="from" type="xs:nonNegativeInteger">
<xs:annotation>
<xs:documentation>
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="to" type="ExpressionOrIDREFType">
<xs:annotation>
<xs:documentation>
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="step" type="xs:positiveInteger">
<xs:annotation>
<xs:documentation>
</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>
+390
View File
@@ -0,0 +1,390 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xs:schema []>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" version="0.1" xmlns:gdml="http://cern.ch/2001/Schemas/GDML" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:include schemaLocation="gdml_core.xsd"></xs:include>
<xs:include schemaLocation="gdml_define.xsd"></xs:include>
<xs:include schemaLocation="gdml_extensions.xsd"/>
<!-- Removed abstract="true" in AtomType -->
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="AtomType">
<xs:annotation>
<xs:documentation>Atomic mass, quantity type A, default unit g/mole</xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:restriction base="QuantityType">
<xs:attribute default="g/mole" type="xs:string" name="unit"></xs:attribute>
<xs:attribute fixed="A" type="xs:string" name="type"></xs:attribute>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="DensityType">
<xs:annotation>
<xs:documentation>Density</xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:restriction base="QuantityType">
<xs:attribute default="g/cm3" type="xs:string" name="unit"></xs:attribute>
<xs:attribute fixed="density" type="xs:string" name="type"></xs:attribute>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:group name="MaterialPropertiesGroup">
<xs:annotation>
<xs:documentation>General material properties</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:choice minOccurs="0">
<xs:element maxOccurs="unbounded" name="property">
<xs:annotation>
<xs:documentation>General material property (const or vector)</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="ReferenceType">
<xs:attribute name="name" type="xs:string" use="required"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:choice>
<xs:choice minOccurs="0">
<xs:element name="RL">
<xs:annotation>
<xs:documentation>Radiation length</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:restriction base="QuantityType">
<xs:attribute default="cm" type="xs:string" name="unit"></xs:attribute>
<xs:attribute fixed="X0" type="xs:string" name="type"></xs:attribute>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="RLref" type="ReferenceType">
<xs:annotation>
<xs:documentation>A reference to a previsouly defined named radiation length quantity value</xs:documentation>
</xs:annotation>
</xs:element>
</xs:choice>
<xs:choice minOccurs="0">
<xs:element name="AL">
<xs:annotation>
<xs:documentation>Absorption length</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:restriction base="QuantityType">
<xs:attribute default="cm" type="xs:string" name="unit"></xs:attribute>
<xs:attribute fixed="lambda" type="xs:string" name="type"></xs:attribute>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="ALref" type="ReferenceType">
<xs:annotation>
<xs:documentation>A reference to a previsouly defined named absorption length quantity value</xs:documentation>
</xs:annotation>
</xs:element>
</xs:choice>
<xs:choice minOccurs="0">
<xs:element name="T">
<xs:annotation>
<xs:documentation>Temperature</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:restriction base="QuantityType">
<xs:attribute default="K" type="xs:string" name="unit"></xs:attribute>
<xs:attribute fixed="temperature" type="xs:string" name="type"></xs:attribute>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="Tref" type="ReferenceType">
<xs:annotation>
<xs:documentation>A reference to previously defined named temperature quantity value</xs:documentation>
</xs:annotation>
</xs:element>
</xs:choice>
<xs:choice minOccurs="0">
<xs:element name="P">
<xs:annotation>
<xs:documentation>Pressure</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:restriction base="QuantityType">
<xs:attribute default="pascal" type="xs:string" name="unit"></xs:attribute>
<xs:attribute fixed="pressure" type="xs:string" name="type"></xs:attribute>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="Pref" type="ReferenceType">
<xs:annotation>
<xs:documentation>A reference to previously defined named pressure quantity value</xs:documentation>
</xs:annotation>
</xs:element>
</xs:choice>
</xs:sequence>
</xs:group>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:attributeGroup name="MaterialAttributeGroup">
<xs:annotation>
<xs:documentation>General material attributes</xs:documentation>
</xs:annotation>
<xs:attribute name="name" type="xs:ID" use="required">
<xs:annotation>
<xs:documentation>Material name</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="formula" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation>Material chemical formula</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute default="unknown" name="state">
<xs:annotation>
<xs:documentation>Material physical state</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:NMTOKEN">
<xs:enumeration value="gas"></xs:enumeration>
<xs:enumeration value="liquid"></xs:enumeration>
<xs:enumeration value="solid"></xs:enumeration>
<xs:enumeration value="unknown"></xs:enumeration>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:attributeGroup>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="MaterialType">
<xs:annotation>
<xs:documentation>Base type for materials</xs:documentation>
</xs:annotation>
<xs:group ref="MaterialPropertiesGroup"></xs:group>
<xs:attributeGroup ref="MaterialAttributeGroup"></xs:attributeGroup>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<!--
<xs:complexType name="ComplexMaterialType">
<xs:annotation>
<xs:documentation>
Base type for complex materials
</xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="MaterialType">
-->
<!-- <xs:group ref="MaterialPropertiesGroup"/> -->
<!--
Removed from referenced attribute group
<xs:attribute name="N" use="prohibited"/>
-->
<!--
<xs:attribute name="Z" type="xs:double" use="optional">
<xs:annotation>
<xs:documentation>Atomic number</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
-->
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="materials">
<xs:annotation>
<xs:documentation>Materials description</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element maxOccurs="unbounded" minOccurs="0" ref="loop"/>
<xs:element minOccurs="0" name="define" type="defineType">
<xs:annotation>
<xs:documentation>Material related definitons of constants and quantities
In this version of schema these become visible in global scope</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element maxOccurs="unbounded" minOccurs="0" name="isotope" type="MaterialIsotopeType">
<xs:annotation>
<xs:documentation>An isotope</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element maxOccurs="unbounded" minOccurs="0" name="element" type="MaterialElementType">
<xs:annotation>
<xs:documentation>A simple element or an element composed of isotopes</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element maxOccurs="unbounded" minOccurs="0" name="material" type="MaterialMixtureType">
<xs:annotation>
<xs:documentation>A composite or a mixture complex material</xs:documentation>
</xs:annotation>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="MaterialIsotopeType">
<xs:annotation>
<xs:documentation>Exported isotope type</xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="MaterialType">
<xs:sequence>
<xs:choice minOccurs="0">
<xs:element name="D" type="DensityType">
<xs:annotation>
<xs:documentation>Density quantity value</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="Dref" type="ReferenceType">
<xs:annotation>
<xs:documentation>A reference to a previsouly defined named density quantity value</xs:documentation>
</xs:annotation>
</xs:element>
</xs:choice>
<xs:element name="atom" type="AtomType"></xs:element>
</xs:sequence>
<xs:attribute name="N" type="xs:positiveInteger" use="required">
<xs:annotation>
<xs:documentation>Number of nucleons</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="Z" type="xs:double" use="required">
<xs:annotation>
<xs:documentation>Atomic number</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="MaterialElementType">
<xs:annotation>
<xs:documentation>Exported material element type</xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="MaterialType">
<xs:sequence>
<xs:choice minOccurs="0">
<xs:element name="D" type="DensityType">
<xs:annotation>
<xs:documentation>Density quantity value</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="Dref" type="ReferenceType">
<xs:annotation>
<xs:documentation>A reference to a previsouly defined named density quantity value</xs:documentation>
</xs:annotation>
</xs:element>
</xs:choice>
<xs:choice>
<xs:annotation>
<xs:documentation>An element can be defined either as a simple element or by a set
of isotopes fractions</xs:documentation>
</xs:annotation>
<xs:element name="atom" type="AtomType"></xs:element>
<xs:element maxOccurs="unbounded" name="fraction">
<xs:annotation>
<xs:documentation>An isotope fraction of an element where n is the actual amount
of the isotope in the element</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="ReferenceType">
<xs:attribute name="n" type="xs:double" use="required"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:sequence>
<xs:attribute name="N" type="xs:positiveInteger" use="optional">
<xs:annotation>
<xs:documentation>Number of nucleons</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="Z" type="xs:double" use="optional">
<xs:annotation>
<xs:documentation>Atomic number</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="MaterialMixtureType">
<xs:annotation>
<xs:documentation>Exported material composite or mixture type</xs:documentation>
</xs:annotation>
<xs:complexContent>
<!-- <xs:extension base="ComplexMaterialType"> -->
<xs:extension base="MaterialType">
<xs:sequence>
<xs:choice>
<xs:element name="D" type="DensityType">
<xs:annotation>
<xs:documentation>Density quantity value</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="Dref" type="ReferenceType">
<xs:annotation>
<xs:documentation>A reference to a previsouly defined named density quantity value</xs:documentation>
</xs:annotation>
</xs:element>
</xs:choice>
<xs:choice>
<xs:annotation>
<xs:documentation>A complex material can be defined as a simple mixture when
its material properties are known or as a composite material
or a mixture. A composite material is defined by a set of elements
by specifying the number of atoms.
The second way is by a set of material fractions where the fractions
can be either simple elements or other complex materials.
The restriction is that one can't mix composition by atoms and fractions
at the same time.</xs:documentation>
</xs:annotation>
<xs:element name="atom" type="AtomType"></xs:element>
<xs:element maxOccurs="unbounded" name="composite">
<xs:annotation>
<xs:documentation>Elements of this composite material specified as a set of local references
to already defined simple elements where value of n in each means the number of atoms</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="ReferenceType">
<xs:attribute name="n" type="xs:positiveInteger" use="required"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element maxOccurs="unbounded" name="fraction">
<xs:annotation>
<xs:documentation>Fractions of this mixture specified as a set of local references to already defined
elements or other mixtures where value of n in each means the fraction of the whole
material in the range 0.0 &lt; n &lt; 1.0</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="ReferenceType">
<xs:attribute name="n" type="xs:double" use="required"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:sequence>
<xs:attribute name="Z" type="xs:double" use="optional">
<xs:annotation>
<xs:documentation>Atomic number</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
</xs:schema>
+263
View File
@@ -0,0 +1,263 @@
<?xml version="1.0"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" version="1.0" xmlns:gdml="http://cern.ch/2001/Schemas/GDML" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="gdml_define.xsd"/>
<xs:include schemaLocation="gdml_extensions.xsd"/>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType abstract="false" name="DimensionsType">
<xs:annotation>
<xs:documentation>Abstract base for parametrised dimensions</xs:documentation>
</xs:annotation>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="Dimensions" abstract="true" type="DimensionsType">
<xs:annotation>
<xs:documentation>Abstract element for substitution group</xs:documentation>
</xs:annotation>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="BoxDimensionsType">
<xs:annotation>
<xs:documentation>Dimensions for parametrised Boxes. </xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="DimensionsType">
<xs:attribute default="1.0" name="x" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="y" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="z" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="mm" name="lunit" type="xs:string"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="box_dimensions" substitutionGroup="Dimensions" type="BoxDimensionsType"/>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="TrdDimensionsType">
<xs:annotation>
<xs:documentation>Dimensions for parametrised Trd. </xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="DimensionsType">
<xs:attribute default="1.0" name="x1" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="x2" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="y1" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="y2" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="z" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="mm" name="lunit" type="xs:string"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="trd_dimensions" substitutionGroup="Dimensions" type="TrdDimensionsType"/>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="TrapDimensionsType">
<xs:annotation>
<xs:documentation>Dimensions for parametrised Trap. </xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="DimensionsType">
<xs:attribute default="1.0" name="z" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="theta" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="phi" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="y1" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="x1" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="x2" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="alpha1" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="y2" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="x3" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="x4" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="alpha2" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="mm" name="lunit" type="xs:string"></xs:attribute>
<xs:attribute default="radian" name="aunit" type="xs:string"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="trap_dimensions" substitutionGroup="Dimensions" type="TrapDimensionsType"/>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="TubeDimensionsType">
<xs:annotation>
<xs:documentation>Dimensions for parametrised Tubes. </xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="DimensionsType">
<xs:attribute default="1.0" name="DeltaPhi" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="InR" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="OutR" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="0.0" name="StartPhi" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="hz" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="mm" name="lunit" type="xs:string"></xs:attribute>
<xs:attribute default="radian" name="aunit" type="xs:string"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="tube_dimensions" substitutionGroup="Dimensions" type="TubeDimensionsType"/>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="ConeDimensionsType">
<xs:annotation>
<xs:documentation>Dimensions for parametrised Cones. </xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="DimensionsType">
<xs:attribute default="1.0" name="rmin1" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="rmax1" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="rmin2" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="rmax2" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="z" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="0.0" name="startphi" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="deltaphi" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="mm" name="lunit" type="xs:string"></xs:attribute>
<xs:attribute default="radian" name="aunit" type="xs:string"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="cone_dimensions" substitutionGroup="Dimensions" type="ConeDimensionsType"/>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="SphereDimensionsType">
<xs:annotation>
<xs:documentation>Dimensions for parametrised Spheres. </xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="DimensionsType">
<xs:attribute default="1.0" name="rmin" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="rmax" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="0.0" name="starttheta" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="deltatheta" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="0.0" name="startphi" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="deltaphi" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="mm" name="lunit" type="xs:string"></xs:attribute>
<xs:attribute default="radian" name="aunit" type="xs:string"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="sphere_dimensions" substitutionGroup="Dimensions" type="SphereDimensionsType"/>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="OrbDimensionsType">
<xs:annotation>
<xs:documentation>Dimensions for parametrised Orbs. </xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="DimensionsType">
<xs:attribute default="1.0" name="r" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="mm" name="lunit" type="xs:string"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="orb_dimensions" substitutionGroup="Dimensions" type="OrbDimensionsType"/>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="TorusDimensionsType">
<xs:annotation>
<xs:documentation>Dimensions for parametrised Torus. </xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="DimensionsType">
<xs:attribute default="1.0" name="rmin" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="rmax" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="rtor" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="0.0" name="startphi" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="deltaphi" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="mm" name="lunit" type="xs:string"></xs:attribute>
<xs:attribute default="radian" name="aunit" type="xs:string"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="torus_dimensions" substitutionGroup="Dimensions" type="TorusDimensionsType"/>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="ParaDimensionsType">
<xs:annotation>
<xs:documentation>Dimensions for parametrised Paras. </xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="DimensionsType">
<xs:attribute default="1.0" name="x" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="y" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="z" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="alpha" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="theta" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="phi" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="mm" name="lunit" type="xs:string"></xs:attribute>
<xs:attribute default="radian" name="aunit" type="xs:string"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="para_dimensions" substitutionGroup="Dimensions" type="ParaDimensionsType"/>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="HypeDimensionsType">
<xs:annotation>
<xs:documentation>Dimensions for parametrised Hypes. </xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="DimensionsType">
<xs:attribute default="1.0" name="rmin" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="rmax" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="inst" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="outst" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="z" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="mm" name="lunit" type="xs:string"></xs:attribute>
<xs:attribute default="radian" name="aunit" type="xs:string"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="hype_dimensions" substitutionGroup="Dimensions" type="HypeDimensionsType"/>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType abstract="false" name="ParameterisationAlgorithmType">
<xs:annotation>
<xs:documentation>Abstract base for parameterised placement strategies</xs:documentation>
</xs:annotation>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="ParameterisationAlgorithm" abstract="true" type="ParameterisationAlgorithmType">
<xs:annotation>
<xs:documentation>Abstract element for substitution group</xs:documentation>
</xs:annotation>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="PositionSizeParameterisationAlgorithmType">
<xs:annotation>
<xs:documentation>Parameterised volumes get created using
the tabularized position and sizes. </xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="ParameterisationAlgorithmType">
<xs:sequence>
<xs:element maxOccurs="unbounded" name="parameters" type="ParametersType"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="parameterised_position_size" substitutionGroup="ParameterisationAlgorithm" type="PositionSizeParameterisationAlgorithmType"/>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="ParameterisedPlacementType">
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:annotation>
<xs:documentation>Base type for parameterised volumes</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="volumeref" type="ReferenceType"></xs:element>
<xs:element ref="ParameterisationAlgorithm"/>
</xs:sequence>
<xs:attribute name="ncopies" type="xs:positiveInteger" use="required"/>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="paramvol" type="ParameterisedPlacementType"/>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="ParametersType">
<xs:annotation>
<xs:documentation>
Holds parameteres for parameterised volumes.
</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element type="positionType" name="position"/>
<xs:element ref="Dimensions"/>
</xs:sequence>
<xs:attribute type="xs:positiveInteger" use="required" name="number"/>
</xs:complexType>
</xs:schema>
+80
View File
@@ -0,0 +1,80 @@
<?xml version="1.0"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" version="1.0" xmlns:gdml="http://cern.ch/2001/Schemas/GDML" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="gdml_define.xsd"/>
<xs:include schemaLocation="gdml_extensions.xsd"/>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType abstract="false" name="ReplicationAlgorithmType">
<xs:annotation>
<xs:documentation>Abstract base for replication placement strategies</xs:documentation>
</xs:annotation>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="ReplicationAlgorithm" abstract="true" type="ReplicationAlgorithmType">
<xs:annotation>
<xs:documentation>Abstract element for substitution group</xs:documentation>
</xs:annotation>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="AxisReplicationAlgorithmType">
<xs:annotation>
<xs:documentation>Replica volumes get created along the specified direction
starting with the first replica placed at the given position and rotated
according to the given rotation and others placed using the given distance;
If position and/or rotation is omitted the defaults will be applied, e.g.
position at the mother volume center and identity rotation;
NOTE: THE ROTATION IS APPLIED TO ALL REPLICATED VOLUMES!</xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="ReplicationAlgorithmType">
<xs:sequence>
<xs:choice minOccurs="0">
<xs:element name="position" type="positionType"/>
<xs:element name="positionref" type="ReferenceType"/>
</xs:choice>
<xs:choice minOccurs="0">
<xs:element name="rotation" type="rotationType"/>
<xs:element name="rotationref" type="ReferenceType"/>
</xs:choice>
<xs:choice>
<xs:element ref="direction"/>
<xs:element name="directionref" type="ReferenceType"/>
</xs:choice>
<xs:element ref="width"/>
<xs:element ref="offset"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="replicate_along_axis" substitutionGroup="ReplicationAlgorithm" type="AxisReplicationAlgorithmType"/>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="ReplicaPlacementType">
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:annotation>
<xs:documentation>Base type for replicated volumes</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="volumeref" type="ReferenceType"></xs:element>
<xs:element ref="ReplicationAlgorithm"/>
</xs:sequence>
<xs:attribute name="number" type="xs:positiveInteger" use="required"/>
<xs:attribute name="copy_num_start" type="xs:positiveInteger" use="optional" default="1"/>
<xs:attribute name="copy_num_step" type="xs:positiveInteger" use="optional" default="1"/>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="directionType">
<xs:complexContent>
<xs:restriction base="QuantityVectorType">
<xs:attribute default="mm" type="xs:string" name="unit"/>
<xs:attribute default="cartesian" type="xs:string" name="type"/>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="direction" type="directionType"/>
<xs:element name="width" type="QuantityType"/>
<xs:element name="offset" type="QuantityType"/>
<xs:element name="replicavol" type="ReplicaPlacementType"/>
</xs:schema>
+855
View File
@@ -0,0 +1,855 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xs:schema>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" version="1.0" xmlns:gdml="http://cern.ch/2001/Schemas/GDML" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="gdml_core.xsd"></xs:include>
<xs:include schemaLocation="gdml_define.xsd"></xs:include>
<xs:include schemaLocation="gdml_extensions.xsd"/>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="SolidType">
<xs:annotation>
<xs:documentation>Base solid type</xs:documentation>
</xs:annotation>
<xs:attribute default="mm" name="lunit" type="xs:string">
<xs:annotation>
<xs:documentation>Length unit of all dimensions used for this instance of solid</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute default="radian" name="aunit" type="xs:string">
<xs:annotation>
<xs:documentation>Angle unit of angles used in definition of this solid</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="name" type="xs:ID" use="required"></xs:attribute>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="BooleanSolidType">
<xs:annotation>
<xs:documentation>Base type for boolean solids</xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="SolidType">
<xs:sequence>
<xs:element name="first" type="ReferenceType"></xs:element>
<xs:element name="second" type="ReferenceType"></xs:element>
<xs:choice minOccurs="0">
<xs:element name="position" type="positionType"></xs:element>
<xs:element name="positionref" type="ReferenceType"></xs:element>
</xs:choice>
<xs:choice minOccurs="0">
<xs:element name="rotation" type="rotationType"></xs:element>
<xs:element name="rotationref" type="ReferenceType"></xs:element>
</xs:choice>
<xs:choice minOccurs="0">
<xs:element name="firstposition" type="positionType"></xs:element>
<xs:element name="firstpositionref" type="ReferenceType"></xs:element>
</xs:choice>
<xs:choice minOccurs="0">
<xs:element name="firstrotation" type="rotationType"></xs:element>
<xs:element name="firstrotationref" type="ReferenceType"></xs:element>
</xs:choice>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="reflectedSolid" substitutionGroup="Solid">
<xs:annotation>
<xs:documentation>Reflected solid:
sx, sy, sz are scale components (containing reflection),
rx, ry, rz are rotation angles around given axes and
dx, dy, dz is the translation.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="SolidType">
<xs:attribute name="solid" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute default="1.0" name="sx" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="sy" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="sz" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="0.0" name="rx" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="0.0" name="ry" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="0.0" name="rz" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="0.0" name="dx" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="0.0" name="dy" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="0.0" name="dz" type="ExpressionOrIDREFType"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="SurfacePropertyType">
<xs:annotation>
<xs:documentation>Base surface type</xs:documentation>
</xs:annotation>
<xs:attribute name="name" type="xs:ID" use="required"></xs:attribute>
<xs:attribute name="type" type="xs:string" default="dielectric_dielectric"></xs:attribute>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element abstract="true" name="Solid" type="SolidType">
<xs:annotation>
<xs:documentation>Abstract element for all solids substitution group</xs:documentation>
</xs:annotation>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element abstract="true" name="SurfaceProperty" type="SurfacePropertyType">
<xs:annotation>
<xs:documentation>Abstract element for surfaces substitution</xs:documentation>
</xs:annotation>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="solids">
<xs:annotation>
<xs:documentation>Solids definitions block</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element minOccurs="0" name="define" type="defineType">
<xs:annotation>
<xs:documentation>Definitions of constants and expressions to be used for solids'
dimensions and transformations
In this version these become part of the global scope.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element maxOccurs="unbounded" ref="Solid"></xs:element>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="SurfaceProperty"></xs:element>
<xs:element maxOccurs="unbounded" minOccurs="0" ref="loop"/>
</xs:choice>
</xs:complexType>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="union" substitutionGroup="Solid" type="BooleanSolidType">
<xs:annotation>
<xs:documentation>Exported boolean union of two solids</xs:documentation>
</xs:annotation>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="subtraction" substitutionGroup="Solid" type="BooleanSolidType">
<xs:annotation>
<xs:documentation>Exported boolean subtraction of two solids</xs:documentation>
</xs:annotation>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="intersection" substitutionGroup="Solid" type="BooleanSolidType">
<xs:annotation>
<xs:documentation>Exported boolean intersectioin of two solids</xs:documentation>
</xs:annotation>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="box" substitutionGroup="Solid">
<xs:annotation>
<xs:documentation>CSG box solid described by 3 dimensions of x, y, and z</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="SolidType">
<xs:attribute name="x" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="y" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="z" type="ExpressionOrIDREFType" use="required"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="twistedbox" substitutionGroup="Solid">
<xs:annotation>
<xs:documentation>CSG twisted box solid described by 4 dimensions of
x length along x axis
y length along y axis
z length along z axis
PhiTwist twist angle </xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="SolidType">
<xs:attribute name="x" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="y" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="z" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="PhiTwist" type="ExpressionOrIDREFType" use="required"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="twistedtrap" substitutionGroup="Solid">
<xs:annotation>
<xs:documentation>general twisted trapezoid. faces perpendicular to the z planes are trapezia, and their centres are
not necessarily on a line paralell to the z axis.
PhiTwist Twist Angle
z length along the z-axis
Theta Polar angle of the line joining the centres of the faces at -/+z
Phi Azimuthal angle of the line joing the centre of the face at -z to the centre of the face at +z
y1 length along y of the face at -z
x1 length along x of the side at y=-y1 of the face at -z
x2 length along x of the side at y=+y1 of the face at -z
y2 length along y of the face at +z
x3 length along x of the side at y=-y2 of the face at +z
x4 length along x of the side at y=+y2 of the face at +z
Alph Angle with respect to the y axis from the centre of the side </xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="SolidType">
<xs:attribute name="PhiTwist" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="z" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="Theta" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="Phi" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="y1" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="x1" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="y2" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="x2" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="x3" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="x4" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="Alph" type="ExpressionOrIDREFType" use="required"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="twistedtrd" substitutionGroup="Solid">
<xs:annotation>
<xs:documentation>different length axis twistable trapezoid. faces perpendicular to the z planes are trapezia, and their centres are
not necessarily on a line paralell to the z axis.
PhiTwist Twist Angle
z length along the z-axis
y1 length along y of the face at -z
x1 length along x of the side at y=-y1 of the face at -z
x2 length along x of the side at y=+y1 of the face at -z
y2 length along y of the face at +z </xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="SolidType">
<xs:attribute name="PhiTwist" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="z" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="y1" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="x1" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="y2" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="x2" type="ExpressionOrIDREFType" use="required"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="paraboloid" substitutionGroup="Solid">
<xs:annotation>
<xs:documentation>CSG paraboloid defined by
rlo radius at -dz
rhi radius at +dz
dz half z length
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="SolidType">
<xs:attribute name="rlo" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="rhi" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="dz" type="ExpressionOrIDREFType" use="required"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="sphere" substitutionGroup="Solid">
<xs:annotation>
<xs:documentation>CSG sphere or spherical shell segment solid described by
rmin inner radius
rmax outer radius
startphi starting angle of the segment in radians(0 &lt;= phi &lt;= 2*PI)
deltaphi delta angle of the segment in radians
starttheta starting angle of the segment in radians(0 &lt;= theta &lt;= PI)
deltatheta delta angle of the segment in radians
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="SolidType">
<xs:attribute default="0.0" name="rmin" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute name="rmax" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute default="0.0" name="startphi" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute name="deltaphi" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute default="0.0" name="starttheta" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute name="deltatheta" type="ExpressionOrIDREFType" use="required"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="ellipsoid" substitutionGroup="Solid">
<xs:annotation>
<xs:documentation>CSG ellispoid or ellipsoidal shell segment solid described by
ax x semiaxis
by y semiaxis
cz z semiaxis
zcut1 bottom plane cutting ellipsoid
zcut2 top plane cutting ellispoid
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="SolidType">
<xs:attribute name="ax" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="by" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="cz" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute default="-1000000.0" name="zcut1" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1000000.0" name="zcut2" type="ExpressionOrIDREFType"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="tube" substitutionGroup="Solid">
<xs:annotation>
<xs:documentation>CSG tube or tube segement solid described by
rmin Inner radius
rmax Outer radius
z length in z
startphi The starting phi angle in radians, adjusted such that
(startphi+deltaphi &lt;= 2PI, startphi &gt; -2PI)
deltaphi Delta angle of the segment in radians</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="SolidType">
<xs:attribute name="z" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="0.0" name="rmin" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute name="rmax" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute default="0.0" name="startphi" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute name="deltaphi" type="ExpressionOrIDREFType" use="required"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="twistedtubs" substitutionGroup="Solid">
<xs:annotation>
<xs:documentation>CSG twisted tube segement solid described by
twistedangle twist angle
endinnerrad inside radius at end of segment
endouterrad outside radius at end of segment
zlen z length of segment
phi phi angle of a segment </xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="SolidType">
<xs:attribute name="twistedangle" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="endinnerrad" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="endouterrad" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="zlen" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="phi" type="ExpressionOrIDREFType" use="required"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="cutTube" substitutionGroup="Solid">
<xs:annotation>
<xs:documentation>CSG cut tube or cut tube segment solid described by
rmin Inner radius
rmax Outer radius
z length in z
startphi The starting phi angle in radians, adjusted such that (startphi+deltaphi &lt;= 2PI, startphi &gt; -2PI)
deltaphi Delta angle of the segment in radians
lowX, lowY, lowZ Normal at lower Z plane
highX, highY, highZ Normal at higher Z plane
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="SolidType">
<xs:attribute name="z" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="0.0" name="rmin" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute name="rmax" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute default="0.0" name="startphi" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute name="deltaphi" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="lowX" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="lowY" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="lowZ" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="highX" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="highY" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="highZ" type="ExpressionOrIDREFType" use="required"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="cone" substitutionGroup="Solid">
<xs:annotation>
<xs:documentation>CSG cone or cone segment described by
rmin1 inside radius at z/2
rmin2 inside radius at z/2
rmax1 outside radius at z/2
rmax2 outside radius at z/2
z length in z
startphi starting angle of the segment in radians
deltaphi delta angle of the segment in radians</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="SolidType">
<xs:attribute name="z" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute default="0.0" name="rmin1" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="0.0" name="rmin2" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute name="rmax1" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="rmax2" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute default="0.0" name="startphi" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute name="deltaphi" type="ExpressionOrIDREFType" use="required"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="elcone" substitutionGroup="Solid">
<xs:annotation>
<xs:documentation>CSG cone with elliptical cross section
dx semiaxis in X
dy semiaxis in Y
zmax height of elliptical cone
zcut upper cut plane level
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="SolidType">
<xs:attribute name="dx" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute name="dy" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute name="zmax" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="zcut" type="ExpressionOrIDREFType" use="required"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="polycone" substitutionGroup="Solid">
<xs:annotation>
<xs:documentation>CSG polycone or polycone segment described by
startphi starting angle of the segment in radians
deltaphi delta angle of the segment in radians
and a set of z-planes each described by
rmin inside radius at z/2
rmax outside radius at z/2
z length in z
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="SolidType">
<xs:sequence>
<xs:element name="zplane" minOccurs="1" maxOccurs="unbounded" type="ZPlaneType"/>
</xs:sequence>
<xs:attribute name="deltaphi" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute default="0.0" name="startphi" type="ExpressionOrIDREFType"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<!-- +++++++++++++ -->
<xs:complexType name="ZPlaneType">
<xs:attribute name="z" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute default="0.0" name="rmin" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute name="rmax" type="ExpressionOrIDREFType" use="required"></xs:attribute>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="para" substitutionGroup="Solid">
<xs:annotation>
<xs:documentation>CSG parallelepiped solid is described by
x, y, z length in x,y,z
alpha Angle formed by the y axis and by the plane joining the centre of the faces
G4Parallel to the z-x plane at -y and +y
theta Polar angle of the line joining the centres of the faces at -z and +z in z
phi Azimuthal angle of the line joining the centres of the faces at -z and +z in z</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="SolidType">
<xs:attribute name="x" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="y" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="z" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="alpha" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="theta" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="phi" type="ExpressionOrIDREFType" use="required"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="trd" substitutionGroup="Solid">
<xs:annotation>
<xs:documentation>CSG trapezoid solid with varying x and y dimensions along z axis
x1 Length along x at the surface positioned at -z
x2 Length along x at the surface positioned at +z
y1 Length along y at the surface positioned at -z
y2 Length along y at the surface positioned at +z
z Length along z axis</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="SolidType">
<xs:attribute name="x1" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="x2" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="y1" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="y2" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="z" type="ExpressionOrIDREFType" use="required"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="trap" substitutionGroup="Solid">
<xs:annotation>
<xs:documentation>CSG general trapezoid solid is described by
z Length along the z-axis
theta Polar angle of the line joining the centres of the faces at -/+z
phi Azimuthal angle of the line joing the centre of the face at -z to the centre of the face at +z
y1 Length along y of the face at -z
x1 Length along x of the side at y = -y1 of the face at -z
x2 Length along x of the side at y = +y1 of the face at -z
alp1 Angle with respect to the y axis from the centre of the side at y =- y1 to the centre at y = +y1 of the face at -z
y2 Length along y of the face at +z
x3 Length along x of the side at y = -y2 of the face at +z
x4 Length along x of the side at y = +y2 of the face at +z
alp2 Angle with respect to the y axis from the centre of the side at y = -y2 to the centre at y = +y2 of the face at +z</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="SolidType">
<xs:attribute name="z" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="theta" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="phi" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="y1" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="x1" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="x2" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="alpha1" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="y2" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="x3" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="x4" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="alpha2" type="ExpressionOrIDREFType" use="required"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="torus" substitutionGroup="Solid">
<xs:annotation>
<xs:documentation>CSG torus solid is described by
rmin Inside radius
rmax Outside radius
rtor swept radius of torus
startphi The starting phi angle in radians adjusted such that sphi+dphi lt 2PI, sphi gt -2PI
deltaphi Delta angle of the segment in radians
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="SolidType">
<xs:attribute name="rmin" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="rmax" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="rtor" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="startphi" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="deltaphi" type="ExpressionOrIDREFType" use="required"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="orb" substitutionGroup="Solid">
<xs:annotation>
<xs:documentation>CSG orb solid (simplified sphere with only rmax) is described by
r Outside radius</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="SolidType">
<xs:attribute name="r" type="ExpressionOrIDREFType" use="required"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="polyhedra" substitutionGroup="Solid">
<xs:annotation>
<xs:documentation>Polyhedra is described by
startphi initial phi starting angle
totalphi total phi angle
numsides number sides
and a set of zplanes.</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="SolidType">
<xs:sequence>
<xs:element name="zplane" minOccurs="1" maxOccurs="unbounded" type="ZPlaneType"/>
</xs:sequence>
<xs:attribute name="startphi" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="deltaphi" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="numsides" type="ExpressionOrIDREFType" use="required"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="TwoDimVertexType">
<xs:attribute name="x" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="y" type="ExpressionOrIDREFType" use="required"></xs:attribute>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="SectionType">
<xs:attribute name="zOrder" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="zPosition" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="xOffset" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="yOffset" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="scalingFactor" type="ExpressionOrIDREFType" use="required"></xs:attribute>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="xtru" substitutionGroup="Solid">
<xs:annotation>
<xs:documentation>Poligonal extrusion is described by
an unbounded (min. 3) number of vertices of the blueprint polygon
and an unbounded number of Z sections.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="SolidType">
<xs:sequence>
<xs:sequence>
<xs:element name="twoDimVertex" minOccurs="3" maxOccurs="unbounded" type="TwoDimVertexType"/>
</xs:sequence>
<xs:sequence>
<xs:element name="section" minOccurs="2" maxOccurs="unbounded" type="SectionType"/>
</xs:sequence>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="hype" substitutionGroup="Solid">
<xs:annotation>
<xs:documentation>Tube with hyperbolic profile described by
rmin innerRadius
rmax outerRadius
inst innerStereo
outst outerStereo
z z length
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="SolidType">
<xs:attribute name="rmin" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="rmax" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="inst" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="outst" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="z" type="ExpressionOrIDREFType" use="required"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="eltube" substitutionGroup="Solid">
<xs:annotation>
<xs:documentation>
Volume representing a tube with elliptical
cross section.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="SolidType">
<xs:attribute name="dx" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="dy" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="dz" type="ExpressionOrIDREFType" use="required"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="tet" substitutionGroup="Solid">
<xs:annotation>
<xs:documentation>
Volume representing a tetrahedron.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="SolidType">
<xs:attribute name="vertex1" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="vertex2" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="vertex3" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="vertex4" type="ExpressionOrIDREFType" use="required"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="arb8" substitutionGroup="Solid">
<xs:annotation>
<xs:documentation>
Volume representing an (almost)arbitrary 8 vertices solid.
The solid is defined by two quadrilaterals sitting on parallel planes,
the distance between these two planes is dz*2.
The base quadrilateral contained within the plane located at -dz is defined by
the first 4 vertices (v1,v2,v3,v4 each one with the x and y coordinates).
The other parallel quadrilateral contained within the plane at +dz is defined by
the other 4 vertices (v5,v6,v7,v8 each one with the x and y coordinates).
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="SolidType">
<xs:attribute name="v1x" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="v1y" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="v2x" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="v2y" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="v3x" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="v3y" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="v4x" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="v4y" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="v5x" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="v5y" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="v6x" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="v6y" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="v7x" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="v7y" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="v8x" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="v8y" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="dz" type="ExpressionOrIDREFType" use="required"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<!-- Tessellated solid elements -->
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="FacetType">
<xs:annotation>
<xs:documentation>Base facet type</xs:documentation>
</xs:annotation>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element abstract="true" name="Facet" type="FacetType">
<xs:annotation>
<xs:documentation>Abstract element for all facets substitution group</xs:documentation>
</xs:annotation>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="triangular" substitutionGroup="Facet">
<xs:annotation>
<xs:documentation>
Triangular facet.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="FacetType">
<xs:attribute name="vertex1" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="vertex2" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="vertex3" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="type" type="xs:string" default="ABSOLUTE"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="quadrangular" substitutionGroup="Facet">
<xs:annotation>
<xs:documentation>
Quadrangular facet.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="FacetType">
<xs:attribute name="vertex1" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="vertex2" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="vertex3" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="vertex4" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="type" type="xs:string" default="ABSOLUTE"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="tessellated" substitutionGroup="Solid">
<xs:annotation>
<xs:documentation>Tessellated solid
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="SolidType">
<xs:sequence>
<xs:element name="Facet" minOccurs="1" maxOccurs="unbounded" type="FacetType"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="opticalsurface" substitutionGroup="SurfaceProperty">
<xs:annotation>
<xs:documentation>Optical surface used by Geant4 optical processes</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="SurfacePropertyType">
<xs:attribute name="model" type="xs:string" default="glisur"></xs:attribute>
<xs:attribute name="finish" type="xs:string" default="polished"></xs:attribute>
<xs:attribute name="value" type="xs:string" default="1.0"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
</xs:schema>
-158
View File
@@ -1,158 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4GDMLBase.cc,v 1.3 2007/11/30 11:58:46 ztorzsok Exp $
// GEANT4 tag $Name: geant4-09-01 $
//
//
// class G4GDMLBase
//
// Class description:
//
// History:
// - Created. Zoltan Torzsok, November 2007
// -------------------------------------------------------------------------
#include "G4GDMLBase.hh"
G4GDMLBase::G4GDMLBase() {
try {
xercesc::XMLPlatformUtils::Initialize();
}
catch(xercesc::XMLException& e) {
char* message = xercesc::XMLString::transcode(e.getMessage());
G4cerr << "XML toolkit initialization error: " << message << G4endl;
xercesc::XMLString::release(&message);
}
parser = new xercesc::XercesDOMParser;
parser->setValidationScheme(xercesc::XercesDOMParser::Val_Always);
parser->setDoNamespaces(true);
parser->setDoSchema(true);
parser->setValidationSchemaFullChecking(true);
}
G4GDMLBase::~G4GDMLBase() {
if (parser) delete parser;
try {
xercesc::XMLPlatformUtils::Terminate();
}
catch(xercesc::XMLException& e) {
char* message = xercesc::XMLString::transcode(e.getMessage());
G4cerr << "XML toolkit termination error: " << message << G4endl;
xercesc::XMLString::release(&message);
}
}
G4String G4GDMLBase::GenerateName(const G4String& in) {
std::string out(prename);
std::string::size_type open = in.find("[",0);
out.append(in,0,open);
while (open != std::string::npos) {
std::string::size_type close = in.find("]",open);
if (close == std::string::npos) G4Exception("Bracket mismatch in loop!");
std::string expr = in.substr(open+1,close-open-1);
std::stringstream stream;
stream << "[" << eval.EvaluateInteger(expr) << "]";
out.append(stream.str());
open = in.find("[",close);
}
return out;
}
void G4GDMLBase::Parse(const G4String& fileName) {
prename = fileName + "_";
try {
parser->parse(fileName.c_str());
}
catch (const xercesc::XMLException &e) {
char* message = xercesc::XMLString::transcode(e.getMessage());
G4cout << "XML: " << message << G4endl;
xercesc::XMLString::release(&message);
}
catch (const xercesc::DOMException &e) {
char* message = xercesc::XMLString::transcode(e.getMessage());
G4cout << "DOM: " << message << G4endl;
xercesc::XMLString::release(&message);
}
xercesc::DOMDocument* doc = parser->getDocument();
if (!doc) G4Exception("GDML: Unable to open document: "+fileName);
xercesc::DOMElement* element = doc->getDocumentElement();
if (!element) G4Exception("GDML: Empty document!");
for (xercesc::DOMNode* iter = element->getFirstChild();iter != 0;iter = iter->getNextSibling()) {
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) continue;
const xercesc::DOMElement* const child = dynamic_cast<xercesc::DOMElement*>(iter);
const G4String tag = xercesc::XMLString::transcode(child->getTagName());
if (tag=="define" ) defineRead(child); else
if (tag=="materials") materialsRead(child); else
if (tag=="solids" ) solidsRead(child); else
if (tag=="setup" ) setupRead(child); else
if (tag=="structure") structureRead(child);
}
}
G4PVPlacement* G4GDMLBase::getTopVolume(const G4String& setupName) {
G4LogicalVolume* volume = getVolume(getSetup(setupName));
volume->SetVisAttributes(G4VisAttributes::Invisible);
return new G4PVPlacement(0,G4ThreeVector(),volume,"",0,0,0);
}
-244
View File
@@ -1,244 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4GDMLDefine.cc,v 1.14 2007/11/30 13:27:24 ztorzsok Exp $
// GEANT4 tag $ Name:$
//
// class G4GDMLDefine Implementation
//
// Original author: Zoltan Torzsok, November 2007
//
// --------------------------------------------------------------------
#include "G4GDMLDefine.hh"
void G4GDMLDefine::constantRead(const xercesc::DOMElement* const element) {
G4String name;
G4String value;
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;attribute_index<attributeCount;attribute_index++) {
xercesc::DOMNode* node = attributes->item(attribute_index);
if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue;
const xercesc::DOMAttr* const attribute = dynamic_cast<xercesc::DOMAttr*>(node);
const G4String attribute_name = xercesc::XMLString::transcode(attribute->getName());
const G4String attribute_value = xercesc::XMLString::transcode(attribute->getValue());
if (attribute_name=="name") name = attribute_value; else
if (attribute_name=="value") value = attribute_value;
}
eval.defineConstant(name,eval.Evaluate(value));
}
void G4GDMLDefine::positionRead(const xercesc::DOMElement* const element) {
G4String name;
G4String unit("1");
G4String x;
G4String y;
G4String z;
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;attribute_index<attributeCount;attribute_index++) {
xercesc::DOMNode* node = attributes->item(attribute_index);
if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue;
const xercesc::DOMAttr* const attribute = dynamic_cast<xercesc::DOMAttr*>(node);
const G4String attribute_name = xercesc::XMLString::transcode(attribute->getName());
const G4String attribute_value = xercesc::XMLString::transcode(attribute->getValue());
if (attribute_name=="name") name = attribute_value; else
if (attribute_name=="unit") unit = attribute_value; else
if (attribute_name=="x") x = attribute_value; else
if (attribute_name=="y") y = attribute_value; else
if (attribute_name=="z") z = attribute_value;
}
G4double _unit = eval.Evaluate(unit);
G4double _x = eval.Evaluate(x)*_unit;
G4double _y = eval.Evaluate(y)*_unit;
G4double _z = eval.Evaluate(z)*_unit;
positionMap[GenerateName(name)] = new G4ThreeVector(_x,_y,_z);
}
void G4GDMLDefine::rotationRead(const xercesc::DOMElement* const element) {
G4String name;
G4String unit("1");
G4String x;
G4String y;
G4String z;
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;attribute_index<attributeCount;attribute_index++) {
xercesc::DOMNode* node = attributes->item(attribute_index);
if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue;
const xercesc::DOMAttr* const attribute = dynamic_cast<xercesc::DOMAttr*>(node);
const G4String attribute_name = xercesc::XMLString::transcode(attribute->getName());
const G4String attribute_value = xercesc::XMLString::transcode(attribute->getValue());
if (attribute_name=="name") name = attribute_value; else
if (attribute_name=="unit") unit = attribute_value; else
if (attribute_name=="x") x = attribute_value; else
if (attribute_name=="y") y = attribute_value; else
if (attribute_name=="z") z = attribute_value;
}
G4double _unit = eval.Evaluate(unit);
G4double _x = eval.Evaluate(x)*_unit;
G4double _y = eval.Evaluate(y)*_unit;
G4double _z = eval.Evaluate(z)*_unit;
rotationMap[GenerateName(name)] = new G4ThreeVector(_x,_y,_z);
}
void G4GDMLDefine::scaleRead(const xercesc::DOMElement* const element) {
G4String name;
G4String x;
G4String y;
G4String z;
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;attribute_index<attributeCount;attribute_index++) {
xercesc::DOMNode* node = attributes->item(attribute_index);
if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue;
const xercesc::DOMAttr* const attribute = dynamic_cast<xercesc::DOMAttr*>(node);
const G4String attribute_name = xercesc::XMLString::transcode(attribute->getName());
const G4String attribute_value = xercesc::XMLString::transcode(attribute->getValue());
if (attribute_name=="name") name = attribute_value; else
if (attribute_name=="x") x = attribute_value; else
if (attribute_name=="y") y = attribute_value; else
if (attribute_name=="z") z = attribute_value;
}
G4double _x = eval.Evaluate(x);
G4double _y = eval.Evaluate(y);
G4double _z = eval.Evaluate(z);
scaleMap[GenerateName(name)] = new G4ThreeVector(_x,_y,_z);
}
void G4GDMLDefine::variableRead(const xercesc::DOMElement* const element) {
G4String name;
G4String value;
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;attribute_index<attributeCount;attribute_index++) {
xercesc::DOMNode* node = attributes->item(attribute_index);
if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue;
const xercesc::DOMAttr* const attribute = dynamic_cast<xercesc::DOMAttr*>(node);
const G4String attribute_name = xercesc::XMLString::transcode(attribute->getName());
const G4String attribute_value = xercesc::XMLString::transcode(attribute->getValue());
if (attribute_name=="name") name = attribute_value; else
if (attribute_name=="value") value = attribute_value;
}
eval.defineVariable(name,eval.Evaluate(value));
}
void G4GDMLDefine::defineRead(const xercesc::DOMElement* const element) {
for (xercesc::DOMNode* iter = element->getFirstChild();iter != 0;iter = iter->getNextSibling()) {
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) continue;
const xercesc::DOMElement* const child = dynamic_cast<xercesc::DOMElement*>(iter);
const G4String tag = xercesc::XMLString::transcode(child->getTagName());
if (tag=="constant") constantRead(child); else
if (tag=="position") positionRead(child); else
if (tag=="rotation") rotationRead(child); else
if (tag=="scale") scaleRead(child); else
if (tag=="variable") variableRead(child); else
G4Exception("GDML: Unknown tag in define: "+tag);
}
}
G4ThreeVector* G4GDMLDefine::getPosition(const G4String& ref) {
if (positionMap.find(ref) != positionMap.end()) return positionMap[ref];
G4Exception("GDML: Referenced position '"+ref+"' was not found!");
return 0;
}
G4ThreeVector* G4GDMLDefine::getRotation(const G4String& ref) {
if (rotationMap.find(ref) != rotationMap.end()) return rotationMap[ref];
G4Exception("GDML: Referenced rotation '"+ref+"' was not found!");
return 0;
}
G4ThreeVector* G4GDMLDefine::getScale(const G4String& ref) {
if (scaleMap.find(ref) != scaleMap.end()) return scaleMap[ref];
G4Exception("GDML: Referenced scale '"+ref+"' was not found!");
return 0;
}
+175 -29
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4GDMLEvaluator.cc,v 1.11 2007/11/28 10:27:18 ztorzsok Exp $
// $Id: G4GDMLEvaluator.cc,v 1.20 2008/07/16 15:46:34 gcosmo Exp $
// GEANT4 tag $ Name:$
//
// class G4GDMLEvaluator Implementation
@@ -33,73 +33,219 @@
//
// --------------------------------------------------------------------
#include <sstream>
#include "G4GDMLEvaluator.hh"
G4GDMLEvaluator::G4GDMLEvaluator() {
G4GDMLEvaluator::G4GDMLEvaluator()
{
eval.clear();
eval.setStdMath();
eval.setSystemOfUnits(1.e+3,1./1.60217733e-25,1.e+9,1./1.60217733e-10,1.0,1.0,1.0);
eval.setSystemOfUnits(meter,kilogram,second,ampere,kelvin,mole,candela);
}
void G4GDMLEvaluator::defineConstant(const G4String& name,G4double value) {
if (eval.findVariable(name)) G4Exception("GDML: Constant or variable '"+name+"' is already defined!");
void G4GDMLEvaluator::DefineConstant(const G4String& name, G4double value)
{
if (eval.findVariable(name))
{
G4String error_msg = "Redefinition of constant or variable: "+name;
G4Exception("G4GDMLEvaluator::DefineConstant()", "InvalidExpression",
FatalException, error_msg);
}
eval.setVariable(name.c_str(),value);
}
void G4GDMLEvaluator::defineVariable(const G4String& name,G4double value) {
if (eval.findVariable(name)) G4Exception("GDML: Constant or variable '"+name+"' is already defined!");
void G4GDMLEvaluator::DefineVariable(const G4String& name,G4double value)
{
if (eval.findVariable(name))
{
G4String error_msg = "Redefinition of constant or variable: "+name;
G4Exception("G4GDMLEvaluator::DefineVariable()", "InvalidExpression",
FatalException, error_msg);
}
eval.setVariable(name.c_str(),value);
variableList.push_back(name);
}
void G4GDMLEvaluator::setVariable(const G4String& name,G4double value) {
void G4GDMLEvaluator::DefineMatrix(const G4String& name,
G4int coldim,
std::vector<G4double> valueList)
{
const G4int size = valueList.size();
checkVariable(name);
if (size == 0)
{
G4String error_msg = "Matrix '"+name+"' is empty!";
G4Exception("G4GDMLEvaluator::DefineMatrix()", "InvalidSize",
FatalException, error_msg);
}
if (size == 1)
{
G4String error_msg = "Matrix '" + name
+ "' has only one element! "
+ "Define a constant instead!!";
G4Exception("G4GDMLEvaluator::DefineMatrix()", "InvalidSize",
FatalException, error_msg);
}
if (size % coldim != 0)
{
G4String error_msg = "Matrix '" + name + "' is not filled correctly!";
G4Exception("G4GDMLEvaluator::DefineMatrix()", "InvalidSize",
FatalException, error_msg);
}
if ((size == coldim) || (coldim == 1)) // Row- or column matrix
{
for (G4int i=0;i<size;i++)
{
std::stringstream MatrixElementNameStream;
MatrixElementNameStream << name << "_" << i;
DefineConstant(MatrixElementNameStream.str(),valueList[i]);
}
}
else // Normal matrix
{
const G4int rowdim = size/coldim;
for (G4int i=0;i<rowdim;i++)
{
for (G4int j=0;j<coldim;j++)
{
std::stringstream MatrixElementNameStream;
MatrixElementNameStream << name << "_" << i << "_" << j;
DefineConstant(MatrixElementNameStream.str(),valueList[coldim*i+j]);
}
}
}
}
void G4GDMLEvaluator::SetVariable(const G4String& name, G4double value)
{
if (!IsVariable(name))
{
G4String error_msg = "Variable '" + name + "' is not defined!";
G4Exception("G4GDMLEvaluator::SetVariable()", "InvalidSetup",
FatalException, error_msg);
}
eval.setVariable(name.c_str(),value);
}
void G4GDMLEvaluator::checkVariable(const G4String& name) {
G4bool G4GDMLEvaluator::IsVariable(const G4String& name) const
{
const size_t variableCount = variableList.size();
for (std::vector<G4String>::iterator iter = variableList.begin(); iter != variableList.end(); iter++) {
if (name == *iter) return;
for (size_t i=0;i<variableCount;i++)
{
if (variableList[i] == name) { return true; }
}
G4Exception("GDML: Variable '"+name+"' is not defined!");
return false;
}
G4double G4GDMLEvaluator::Evaluate(const G4String& expression) {
G4String G4GDMLEvaluator::SolveBrackets(const G4String& in)
{
const std::string::size_type open = in.find("[",0);
const std::string::size_type close = in.find("]",0);
if (open==close) { return in; }
if (open>close)
{
G4String error_msg = "Bracket mismatch: " + in;
G4Exception("G4GDMLEvaluator::SolveBrackets()", "InvalidExpression",
FatalException, error_msg);
}
std::string::size_type begin = open;
std::string::size_type end = 0;
std::string out;
out.append(in,0,open);
do
{
end = in.find(",",begin+1);
if (end==std::string::npos) { end = close; }
std::stringstream indexStream;
indexStream << "_" << EvaluateInteger(in.substr(begin+1,end-begin-1));
out.append(indexStream.str());
begin = end;
} while (end<close);
return out;
}
G4double G4GDMLEvaluator::Evaluate(const G4String& in)
{
G4String expression = SolveBrackets(in);
G4double value = 0.0;
if (!expression.empty()) {
if (!expression.empty())
{
value = eval.evaluate(expression.c_str());
if (eval.status() != HepTool::Evaluator::OK) {
if (eval.status() != HepTool::Evaluator::OK)
{
eval.print_error();
G4Exception("Error in evaluator!");
G4String error_msg = "Error in expression: " + expression;
G4Exception("G4GDMLEvaluator::Evaluate()", "InvalidExpression",
FatalException, error_msg);
}
}
return value;
}
G4int G4GDMLEvaluator::EvaluateInteger(const G4String& expression) {
G4int G4GDMLEvaluator::EvaluateInteger(const G4String& expression)
{
// This function is for evaluating integer expressions,
// like loop variables and matrix indices.
// Complains if the evaluated expression has a fractional
// part different from zero
G4double value = Evaluate(expression);
G4int whole = (G4int)value;
G4double frac = value - (G4double)whole;
if (frac != 0.0) G4Exception("GDML: Expression '"+expression+"' is expected to have an integer value!");
if (frac != 0.0)
{
G4String error_msg = "Expression '" + expression
+ "' is expected to have an integer value!";
G4Exception("G4GDMLEvaluator::EvaluateInteger()", "InvalidExpression",
FatalException, error_msg);
}
return whole;
}
G4double G4GDMLEvaluator::GetConstant(const G4String& name)
{
if (IsVariable(name))
{
G4String error_msg = "Constant '" + name
+ "' is not defined! It is a variable!";
G4Exception("G4GDMLEvaluator::GetConstant()", "InvalidSetup",
FatalException, error_msg);
}
if (!eval.findVariable(name))
{
G4String error_msg = "Constant '" + name + "' is not defined!";
G4Exception("G4GDMLEvaluator::GetConstant()", "InvalidSetup",
FatalException, error_msg);
}
return Evaluate(name);
}
G4double G4GDMLEvaluator::GetVariable(const G4String& name)
{
if (!IsVariable(name))
{
G4String error_msg = "Variable '" + name + "' is not a defined!";
G4Exception("G4GDMLEvaluator::GetVariable()", "InvalidSetup",
FatalException, error_msg);
}
return Evaluate(name);
}
@@ -1,332 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4GDMLMaterials.cc,v 1.12 2007/11/30 15:20:00 gcosmo Exp $
// GEANT4 tag $ Name:$
//
// class G4GDMLMaterials Implementation
//
// Original author: Zoltan Torzsok, November 2007
//
// --------------------------------------------------------------------
#include "G4GDMLMaterials.hh"
G4double G4GDMLMaterials::atomRead(const xercesc::DOMElement* const element) {
G4String value;
G4String unit("g/mole");
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;attribute_index<attributeCount;attribute_index++) {
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue;
const xercesc::DOMAttr* const attribute = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attribute_name = xercesc::XMLString::transcode(attribute->getName());
const G4String attribute_value = xercesc::XMLString::transcode(attribute->getValue());
if (attribute_name=="value") value = attribute_value; else
if (attribute_name=="unit") unit = attribute_value;
}
return eval.Evaluate(value)*eval.Evaluate(unit);
}
G4double G4GDMLMaterials::DRead(const xercesc::DOMElement* const element) {
G4String value;
G4String unit("g/cm3");
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;attribute_index<attributeCount;attribute_index++) {
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue;
const xercesc::DOMAttr* const attribute = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attribute_name = xercesc::XMLString::transcode(attribute->getName());
const G4String attribute_value = xercesc::XMLString::transcode(attribute->getValue());
if (attribute_name=="value") value = attribute_value; else
if (attribute_name=="unit") unit = attribute_value;
}
return eval.Evaluate(value)*eval.Evaluate(unit);
}
void G4GDMLMaterials::elementRead(const xercesc::DOMElement* const element) {
G4String name;
G4String formula;
G4String Z;
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;attribute_index<attributeCount;attribute_index++) {
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue;
const xercesc::DOMAttr* const attribute = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attribute_name = xercesc::XMLString::transcode(attribute->getName());
const G4String attribute_value = xercesc::XMLString::transcode(attribute->getValue());
if (attribute_name=="name") name = attribute_value; else
if (attribute_name=="formula") formula = attribute_value; else
if (attribute_name=="Z") Z = attribute_value;
}
G4double _Z = eval.Evaluate(Z);
G4double _a = 0;
G4int nComponents = 0;
for (xercesc::DOMNode* iter = element->getFirstChild();iter != 0;iter = iter->getNextSibling()) {
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) continue;
const xercesc::DOMElement* const child = dynamic_cast<xercesc::DOMElement*>(iter);
const G4String tag = xercesc::XMLString::transcode(child->getTagName());
if (tag=="atom") _a = atomRead(child); else
if (tag=="fraction") nComponents++; else
G4Exception("GDML: Unknown tag in element: "+tag);
}
if (nComponents>0) mixtureRead(element,new G4Element(GenerateName(name),formula,nComponents));
else new G4Element(GenerateName(name),formula,_Z,_a);
}
G4double G4GDMLMaterials::fractionRead(const xercesc::DOMElement* const element,G4String& ref) {
G4String n;
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;attribute_index<attributeCount;attribute_index++) {
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue;
const xercesc::DOMAttr* const attribute = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attribute_name = xercesc::XMLString::transcode(attribute->getName());
const G4String attribute_value = xercesc::XMLString::transcode(attribute->getValue());
if (attribute_name=="n") n = attribute_value; else
if (attribute_name=="ref") ref = attribute_value;
}
return eval.Evaluate(n);
}
void G4GDMLMaterials::isotopeRead(const xercesc::DOMElement* const element) {
G4String name;
G4String Z;
G4String N;
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;attribute_index<attributeCount;attribute_index++) {
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue;
const xercesc::DOMAttr* const attribute = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attribute_name = xercesc::XMLString::transcode(attribute->getName());
const G4String attribute_value = xercesc::XMLString::transcode(attribute->getValue());
if (attribute_name=="name") name = attribute_value; else
if (attribute_name=="Z") Z = attribute_value; else
if (attribute_name=="N") N = attribute_value;
}
G4double __Z = eval.Evaluate(Z);
G4double __N = eval.Evaluate(N);
G4double __a = 0;
for (xercesc::DOMNode* iter = element->getFirstChild();iter != 0;iter = iter->getNextSibling()) {
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) continue;
const xercesc::DOMElement* const child = dynamic_cast<xercesc::DOMElement*>(iter);
const G4String tag = xercesc::XMLString::transcode(child->getTagName());
if (tag=="atom") __a = atomRead(child);
}
new G4Isotope(GenerateName(name),(G4int)__Z,(G4int)__N,__a);
}
void G4GDMLMaterials::materialRead(const xercesc::DOMElement* const element) {
G4String name;
G4String Z;
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;attribute_index<attributeCount;attribute_index++) {
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue;
const xercesc::DOMAttr* const attribute = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attribute_name = xercesc::XMLString::transcode(attribute->getName());
const G4String attribute_value = xercesc::XMLString::transcode(attribute->getValue());
if (attribute_name=="name") name = attribute_value; else
if (attribute_name=="Z") Z = attribute_value;
}
G4double _Z = eval.Evaluate(Z);
G4double _D = 0.0;
G4double _a = 0.0;
G4int nComponents = 0;
for (xercesc::DOMNode* iter = element->getFirstChild();iter != 0;iter = iter->getNextSibling()) {
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) continue;
const xercesc::DOMElement* const child = dynamic_cast<xercesc::DOMElement*>(iter);
const G4String tag = xercesc::XMLString::transcode(child->getTagName());
if (tag=="D") _D = DRead(child); else
if (tag=="atom") _a = atomRead(child); else
if (tag=="fraction") nComponents++; else
G4Exception("GDML: Unknown tag in material: "+tag);
}
if (nComponents>0) mixtureRead(element,new G4Material(GenerateName(name),_D,nComponents));
else new G4Material(GenerateName(name),_Z,_a,_D);
}
void G4GDMLMaterials::mixtureRead(const xercesc::DOMElement *const element,G4Element *ele) {
for (xercesc::DOMNode* iter = element->getFirstChild();iter != 0;iter = iter->getNextSibling()) {
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) continue;
const xercesc::DOMElement* const child = dynamic_cast<xercesc::DOMElement*>(iter);
const G4String tag = xercesc::XMLString::transcode(child->getTagName());
if (tag=="fraction") {
G4String ref;
G4double _n = fractionRead(child,ref);
ele->AddIsotope(getIsotope(GenerateName(ref)),_n);
} else G4Exception("GDML: Unknown tag in mixture element: "+tag);
}
}
void G4GDMLMaterials::mixtureRead(const xercesc::DOMElement *const element,G4Material *material) {
for (xercesc::DOMNode* iter = element->getFirstChild();iter != 0;iter = iter->getNextSibling()) {
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) continue;
const xercesc::DOMElement* const child = dynamic_cast<xercesc::DOMElement*>(iter);
const G4String tag = xercesc::XMLString::transcode(child->getTagName());
if (tag=="D") { /*already processed*/ } else
if (tag=="fraction") {
G4String ref;
G4double _n = fractionRead(child,ref);
G4Material *materialPtr = G4Material::GetMaterial(GenerateName(ref),false);
G4Element *elementPtr = G4Element::GetElement(GenerateName(ref),false);
if (materialPtr != 0) material->AddMaterial(materialPtr,_n); else
if (elementPtr != 0) material->AddElement(elementPtr,_n);
if ((materialPtr == 0) && (elementPtr == 0)) G4Exception("GDML: Referenced material/element '"+GenerateName(ref)+"' was not found!");
} else G4Exception("GDML: Unknown tag in mixture material: "+tag);
}
}
void G4GDMLMaterials::materialsRead(const xercesc::DOMElement* const element) {
for (xercesc::DOMNode* iter = element->getFirstChild();iter != 0;iter = iter->getNextSibling()) {
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) continue;
const xercesc::DOMElement* const child = dynamic_cast<xercesc::DOMElement*>(iter);
const G4String tag = xercesc::XMLString::transcode(child->getTagName());
if (tag=="element") elementRead(child); else
if (tag=="isotope") isotopeRead(child); else
if (tag=="material") materialRead(child); else
G4Exception("GDML: Unknown tag in materials: "+tag);
}
}
G4Isotope* G4GDMLMaterials::getIsotope(const G4String& ref) const {
G4Isotope* isotopePtr = G4Isotope::GetIsotope(ref,false);
if (!isotopePtr) G4Exception("GDML: Referenced isotope '"+ref+"' was not found!");
return isotopePtr;
}
G4Material* G4GDMLMaterials::getMaterial(const G4String& ref) const {
G4Material *materialPtr = G4Material::GetMaterial(ref,false);
if (!materialPtr) G4Exception("GDML: Referenced material '"+ref+"' was not found!");
return materialPtr;
}
@@ -0,0 +1,172 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4GDMLParameterisation.cc,v 1.11 2008/07/16 15:46:34 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
// class G4GDMLParameterisation Implementation
//
// History:
// - Created. Zoltan Torzsok, November 2007
// -------------------------------------------------------------------------
#include "G4GDMLParameterisation.hh"
G4int G4GDMLParameterisation::GetSize() const
{
return (G4int)parameterList.size();
}
void G4GDMLParameterisation::AddParameter(const PARAMETER& newParameter)
{
parameterList.push_back(newParameter);
}
void G4GDMLParameterisation::
ComputeTransformation(const G4int index,G4VPhysicalVolume* physvol) const
{
physvol->SetTranslation(parameterList[index].position);
physvol->SetRotation(parameterList[index].pRot);
}
void G4GDMLParameterisation::
ComputeDimensions(G4Box& box,const G4int index,const G4VPhysicalVolume*) const
{
box.SetXHalfLength(parameterList[index].dimension[0]);
box.SetYHalfLength(parameterList[index].dimension[1]);
box.SetZHalfLength(parameterList[index].dimension[2]);
}
void G4GDMLParameterisation::
ComputeDimensions(G4Trd& trd,const G4int index,const G4VPhysicalVolume*) const
{
trd.SetXHalfLength1(parameterList[index].dimension[0]);
trd.SetXHalfLength2(parameterList[index].dimension[1]);
trd.SetYHalfLength1(parameterList[index].dimension[2]);
trd.SetYHalfLength2(parameterList[index].dimension[3]);
trd.SetZHalfLength(parameterList[index].dimension[4]);
}
void G4GDMLParameterisation::
ComputeDimensions(G4Trap& trap,const G4int index,const G4VPhysicalVolume*) const
{
trap.SetAllParameters(parameterList[index].dimension[0], // Dz
parameterList[index].dimension[1], // Theta
parameterList[index].dimension[2], // Phi
parameterList[index].dimension[3], // Dy1
parameterList[index].dimension[4], // Dx1
parameterList[index].dimension[5], // Dx2
parameterList[index].dimension[6], // pAlp1,
parameterList[index].dimension[7], // pDy2,
parameterList[index].dimension[8], // pDx3,
parameterList[index].dimension[9], // pDx4,
parameterList[index].dimension[10]); // pAlp2
}
void G4GDMLParameterisation::
ComputeDimensions(G4Tubs& tubs,const G4int index,const G4VPhysicalVolume*) const
{
tubs.SetInnerRadius(parameterList[index].dimension[0]);
tubs.SetOuterRadius(parameterList[index].dimension[1]);
tubs.SetZHalfLength(parameterList[index].dimension[2]);
tubs.SetStartPhiAngle(parameterList[index].dimension[3]);
tubs.SetDeltaPhiAngle(parameterList[index].dimension[4]);
}
void G4GDMLParameterisation::
ComputeDimensions(G4Cons& cons,const G4int index,const G4VPhysicalVolume*) const
{
cons.SetInnerRadiusMinusZ(parameterList[index].dimension[0]);
cons.SetOuterRadiusMinusZ(parameterList[index].dimension[1]);
cons.SetInnerRadiusPlusZ(parameterList[index].dimension[2]);
cons.SetOuterRadiusPlusZ(parameterList[index].dimension[3]);
cons.SetZHalfLength(parameterList[index].dimension[4]);
cons.SetStartPhiAngle(parameterList[index].dimension[5]);
cons.SetDeltaPhiAngle(parameterList[index].dimension[6]);
}
void G4GDMLParameterisation::
ComputeDimensions(G4Sphere& sphere,const G4int index,const G4VPhysicalVolume*) const
{
sphere.SetInsideRadius(parameterList[index].dimension[0]);
sphere.SetOuterRadius(parameterList[index].dimension[1]);
sphere.SetStartPhiAngle(parameterList[index].dimension[2]);
sphere.SetDeltaPhiAngle(parameterList[index].dimension[3]);
sphere.SetStartThetaAngle(parameterList[index].dimension[4]);
sphere.SetDeltaThetaAngle(parameterList[index].dimension[5]);
}
void G4GDMLParameterisation::
ComputeDimensions(G4Orb& orb,const G4int index,const G4VPhysicalVolume*) const
{
orb.SetRadius(parameterList[index].dimension[0]);
}
void G4GDMLParameterisation::
ComputeDimensions(G4Torus& torus,const G4int index,const G4VPhysicalVolume*) const
{
torus.SetAllParameters(parameterList[index].dimension[0], // pRmin
parameterList[index].dimension[1], // pRmax
parameterList[index].dimension[2], // pRtor
parameterList[index].dimension[3], // pSPhi
parameterList[index].dimension[4]); // pDPhi
}
void G4GDMLParameterisation::
ComputeDimensions(G4Para& para,const G4int index,const G4VPhysicalVolume*) const
{
para.SetXHalfLength(parameterList[index].dimension[0]);
para.SetYHalfLength(parameterList[index].dimension[1]);
para.SetZHalfLength(parameterList[index].dimension[2]);
para.SetAlpha(parameterList[index].dimension[3]);
para.SetTanAlpha(std::tan(parameterList[index].dimension[3]));
para.SetThetaAndPhi(parameterList[index].dimension[4],parameterList[index].dimension[5]);
}
void G4GDMLParameterisation::
ComputeDimensions(G4Hype& hype,const G4int index,const G4VPhysicalVolume*) const
{
hype.SetInnerRadius(parameterList[index].dimension[0]);
hype.SetOuterRadius(parameterList[index].dimension[1]);
hype.SetZHalfLength(parameterList[index].dimension[4]);
hype.SetInnerStereo(parameterList[index].dimension[2]);
hype.SetOuterStereo(parameterList[index].dimension[3]);
}
void G4GDMLParameterisation::
ComputeDimensions(G4Polycone&,const G4int,const G4VPhysicalVolume*) const
{
G4Exception("G4GDMLParameterisation::ComputeDimensions()",
"InvalidSetup", FatalException,
"Parameterisation of G4Polycone not implemented yet. Sorry!");
}
void G4GDMLParameterisation::
ComputeDimensions(G4Polyhedra&,const G4int,const G4VPhysicalVolume*) const
{
G4Exception("G4GDMLParameterisation::ComputeDimensions()",
"InvalidSetup", FatalException,
"Parameterisation of G4Polyhedra not implemented yet. Sorry!");
}
@@ -23,4 +23,36 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4GDMLParser.cc,v 1.13 2008/11/20 15:33:52 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
//
// class G4GDMLParser Implementation
//
// -------------------------------------------------------------------------
#include "G4GDMLParser.hh"
G4GDMLParser::G4GDMLParser()
: ucode(false)
{
reader = new G4GDMLReadStructure;
writer = new G4GDMLWriteStructure;
xercesc::XMLPlatformUtils::Initialize();
}
G4GDMLParser::G4GDMLParser(G4GDMLReadStructure* ext)
: ucode(true)
{
reader = ext;
writer = new G4GDMLWriteStructure;
xercesc::XMLPlatformUtils::Initialize();
}
G4GDMLParser::~G4GDMLParser()
{
xercesc::XMLPlatformUtils::Terminate();
delete writer;
if (!ucode) { delete reader; }
}
+325
View File
@@ -0,0 +1,325 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4GDMLRead.cc,v 1.40 2008/11/21 10:33:17 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
// class G4GDMLRead Implementation
//
// History:
// - Created. Zoltan Torzsok, November 2007
// -------------------------------------------------------------------------
#include "G4GDMLRead.hh"
#include "G4Element.hh"
#include "G4Material.hh"
#include "G4SolidStore.hh"
#include "G4LogicalVolumeStore.hh"
#include "G4PhysicalVolumeStore.hh"
G4String G4GDMLRead::Transcode(const XMLCh* const toTranscode)
{
char* char_str = xercesc::XMLString::transcode(toTranscode);
G4String my_str(char_str);
xercesc::XMLString::release(&char_str);
return my_str;
}
G4String G4GDMLRead::GenerateName(const G4String& nameIn, G4bool strip)
{
G4String nameOut(nameIn);
if (InLoop>0) { nameOut = eval.SolveBrackets(nameOut); }
if (strip) { StripName(nameOut); }
return nameOut;
}
void G4GDMLRead::GeneratePhysvolName(const G4String& nameIn,
G4VPhysicalVolume* physvol)
{
G4String nameOut(nameIn);
if (nameIn.empty())
{
std::stringstream stream;
stream << physvol->GetLogicalVolume()->GetName() << "_PV";
nameOut = stream.str();
}
nameOut = eval.SolveBrackets(nameOut);
physvol->SetName(nameOut);
}
G4String G4GDMLRead::Strip(const G4String& name) const
{
G4String sname(name);
return sname.remove(sname.find("0x"));
}
void G4GDMLRead::StripName(G4String& name) const
{
name.remove(name.find("0x"));
}
void G4GDMLRead::StripNames() const
{
// Strips off names of volumes, solids elements and materials from possible
// reference pointers or IDs attached to their original identifiers.
G4PhysicalVolumeStore* pvols = G4PhysicalVolumeStore::GetInstance();
G4LogicalVolumeStore* lvols = G4LogicalVolumeStore::GetInstance();
G4SolidStore* solids = G4SolidStore::GetInstance();
const G4ElementTable* elements = G4Element::GetElementTable();
const G4MaterialTable* materials = G4Material::GetMaterialTable();
G4cout << "Stripping off GDML names of materials, solids and volumes ..."
<< G4endl;
G4String sname;
register size_t i;
// Solids...
//
for (i=0; i<solids->size(); i++)
{
G4VSolid* psol = (*solids)[i];
sname = psol->GetName();
StripName(sname);
psol->SetName(sname);
}
// Logical volumes...
//
for (i=0; i<lvols->size(); i++)
{
G4LogicalVolume* lvol = (*lvols)[i];
sname = lvol->GetName();
StripName(sname);
lvol->SetName(sname);
}
// Physical volumes...
//
for (i=0; i<pvols->size(); i++)
{
G4VPhysicalVolume* pvol = (*pvols)[i];
sname = pvol->GetName();
StripName(sname);
pvol->SetName(sname);
}
// Materials...
//
for (i=0; i<materials->size(); i++)
{
G4Material* pmat = (*materials)[i];
sname = pmat->GetName();
StripName(sname);
pmat->SetName(sname);
}
// Elements...
//
for (i=0; i<elements->size(); i++)
{
G4Element* pelm = (*elements)[i];
sname = pelm->GetName();
StripName(sname);
pelm->SetName(sname);
}
}
void G4GDMLRead::LoopRead(const xercesc::DOMElement* const element,
void(G4GDMLRead::*func)(const xercesc::DOMElement* const))
{
G4String var;
G4String from;
G4String to;
G4String step;
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;
attribute_index<attributeCount;attribute_index++)
{
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
{ continue; }
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attribute_name = Transcode(attribute->getName());
const G4String attribute_value = Transcode(attribute->getValue());
if (attribute_name=="for") { var = attribute_value; } else
if (attribute_name=="from") { from = attribute_value; } else
if (attribute_name=="to") { to = attribute_value; } else
if (attribute_name=="step") { step = attribute_value; }
}
if (var.empty())
{
G4Exception("G4GDMLRead::loopRead()", "InvalidRead",
FatalException, "No variable is determined for loop!");
}
if (!eval.IsVariable(var))
{
G4Exception("G4GDMLRead::loopRead()", "InvalidRead",
FatalException, "Variable is not defined in loop!");
}
G4int _var = eval.EvaluateInteger(var);
G4int _from = eval.EvaluateInteger(from);
G4int _to = eval.EvaluateInteger(to);
G4int _step = eval.EvaluateInteger(step);
if (!from.empty()) { _var = _from; }
if (_from == _to)
{
G4Exception("G4GDMLRead::loopRead()", "InvalidRead",
FatalException, "Empty loop!");
}
if (_from < _to && _step <= 0)
{
G4Exception("G4GDMLRead::loopRead()", "InvalidRead",
FatalException, "Infinite loop!");
}
if (_from > _to && _step >= 0)
{
G4Exception("G4GDMLRead::loopRead()", "InvalidRead",
FatalException, "Infinite loop!");
}
InLoop++;
while (_var <= _to)
{
eval.SetVariable(var,_var);
(this->*func)(element);
_var += _step;
}
InLoop--;
}
void G4GDMLRead::ExtensionRead(const xercesc::DOMElement* const)
{
G4String error_msg = "No handle to user-code for parsing extensions!";
G4Exception("G4GDMLRead::ExtensionRead()",
"NotImplemented", JustWarning, error_msg);
}
void G4GDMLRead::Read(const G4String& fileName,
G4bool SetValidate,
G4bool IsModule)
{
if (IsModule)
{
G4cout << "G4GDML: Reading module '" << fileName << "'..." << G4endl;
}
else
{
G4cout << "G4GDML: Reading '" << fileName << "'..." << G4endl;
}
InLoop = 0;
Validate = SetValidate;
xercesc::ErrorHandler* handler = new G4GDMLErrorHandler(!Validate);
xercesc::XercesDOMParser* parser = new xercesc::XercesDOMParser;
parser->setValidationScheme(xercesc::XercesDOMParser::Val_Always);
parser->setValidationSchemaFullChecking(true);
parser->setCreateEntityReferenceNodes(false);
// Entities will be automatically resolved by Xerces
parser->setDoNamespaces(true);
parser->setDoSchema(true);
parser->setErrorHandler(handler);
try { parser->parse(fileName.c_str()); }
catch (const xercesc::XMLException &e)
{ G4cout << "G4GDML: " << Transcode(e.getMessage()) << G4endl; }
catch (const xercesc::DOMException &e)
{ G4cout << "G4GDML: " << Transcode(e.getMessage()) << G4endl; }
xercesc::DOMDocument* doc = parser->getDocument();
if (!doc)
{
G4String error_msg = "Unable to open document: " + fileName;
G4Exception("G4GDMLRead::Read()", "InvalidRead",
FatalException, error_msg);
}
xercesc::DOMElement* element = doc->getDocumentElement();
if (!element)
{
G4Exception("G4GDMLRead::Read()", "InvalidRead",
FatalException, "Empty document!");
}
for (xercesc::DOMNode* iter = element->getFirstChild();
iter != 0; iter = iter->getNextSibling())
{
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
const xercesc::DOMElement* const child
= dynamic_cast<xercesc::DOMElement*>(iter);
const G4String tag = Transcode(child->getTagName());
if (tag=="define") { DefineRead(child); } else
if (tag=="materials") { MaterialsRead(child); } else
if (tag=="solids") { SolidsRead(child); } else
if (tag=="setup") { SetupRead(child); } else
if (tag=="structure") { StructureRead(child); } else
if (tag=="extension") { ExtensionRead(child); }
else
{
G4String error_msg = "Unknown tag in gdml: " + tag;
G4Exception("G4GDMLRead::Read()", "InvalidRead",
FatalException, error_msg);
}
}
if (parser) { delete parser; }
if (handler) { delete handler; }
if (IsModule)
{
G4cout << "G4GDML: Reading module '" << fileName << "' done!" << G4endl;
}
else
{
G4cout << "G4GDML: Reading '" << fileName << "' done!" << G4endl;
StripNames();
}
}
@@ -0,0 +1,483 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4GDMLReadDefine.cc,v 1.20 2008/07/16 15:46:34 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
// class G4GDMLReadDefine Implementation
//
// Original author: Zoltan Torzsok, November 2007
//
// --------------------------------------------------------------------
#include "G4GDMLReadDefine.hh"
G4GDMLMatrix::G4GDMLMatrix()
{
rows = 0;
cols = 0;
m = 0;
}
G4GDMLMatrix::G4GDMLMatrix(size_t rows0,size_t cols0)
{
rows = rows0;
cols = cols0;
m = new G4double[rows*cols];
}
G4GDMLMatrix::~G4GDMLMatrix()
{
if (m) { delete [] m; }
}
void G4GDMLMatrix::Set(size_t r,size_t c,G4double a)
{
if (r>=rows || c>=cols)
{
G4Exception("G4GDMLMatrix::set()", "InvalidSetup",
FatalException, "Index out of range!");
}
m[cols*r+c] = a;
}
G4double G4GDMLMatrix::Get(size_t r,size_t c) const
{
if (r>=rows || c>=cols)
{
G4Exception("G4GDMLMatrix::get()", "InvalidSetup",
FatalException, "Index out of range!");
}
return m[cols*r+c];
}
size_t G4GDMLMatrix::GetRows() const
{
return rows;
}
size_t G4GDMLMatrix::GetCols() const
{
return cols;
}
G4RotationMatrix
G4GDMLReadDefine::GetRotationMatrix(const G4ThreeVector& angles)
{
G4RotationMatrix rot;
rot.rotateX(angles.x());
rot.rotateY(angles.y());
rot.rotateZ(angles.z());
return rot;
}
void
G4GDMLReadDefine::ConstantRead(const xercesc::DOMElement* const constantElement)
{
G4String name = "";
G4double value = 0.0;
const xercesc::DOMNamedNodeMap* const attributes
= constantElement->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;
attribute_index<attributeCount; attribute_index++)
{
xercesc::DOMNode* node = attributes->item(attribute_index);
if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) { continue; }
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(node);
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="name") { name = attValue; } else
if (attName=="value") { value = eval.Evaluate(attValue); }
}
eval.DefineConstant(name,value);
}
void
G4GDMLReadDefine::MatrixRead(const xercesc::DOMElement* const matrixElement)
{
G4String name = "";
G4int coldim = 0;
G4String values = "";
const xercesc::DOMNamedNodeMap* const attributes
= matrixElement->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;
attribute_index<attributeCount; attribute_index++)
{
xercesc::DOMNode* node = attributes->item(attribute_index);
if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) { continue; }
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(node);
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="name") { name = GenerateName(attValue); } else
if (attName=="coldim") { coldim = eval.EvaluateInteger(attValue); } else
if (attName=="values") { values = attValue; }
}
std::stringstream MatrixValueStream(values);
std::vector<G4double> valueList;
while (!MatrixValueStream.eof())
{
G4String MatrixValue;
MatrixValueStream >> MatrixValue;
valueList.push_back(eval.Evaluate(MatrixValue));
}
eval.DefineMatrix(name,coldim,valueList);
G4GDMLMatrix matrix(valueList.size()/coldim,coldim);
for (size_t i=0;i<valueList.size();i++)
{
matrix.Set(i/coldim,i%coldim,valueList[i]);
}
matrixMap[name] = matrix;
}
void
G4GDMLReadDefine::PositionRead(const xercesc::DOMElement* const positionElement)
{
G4String name = "";
G4double unit = 1.0;
G4ThreeVector position(0.,0.,0.);
const xercesc::DOMNamedNodeMap* const attributes
= positionElement->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;
attribute_index<attributeCount; attribute_index++)
{
xercesc::DOMNode* node = attributes->item(attribute_index);
if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) { continue; }
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(node);
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="name") { name = GenerateName(attValue); } else
if (attName=="unit") { unit = eval.Evaluate(attValue); } else
if (attName=="x") { position.setX(eval.Evaluate(attValue)); } else
if (attName=="y") { position.setY(eval.Evaluate(attValue)); } else
if (attName=="z") { position.setZ(eval.Evaluate(attValue)); }
}
positionMap[name] = position*unit;
}
void
G4GDMLReadDefine::RotationRead(const xercesc::DOMElement* const rotationElement)
{
G4String name = "";
G4double unit = 1.0;
G4ThreeVector rotation(0.,0.,0.);
const xercesc::DOMNamedNodeMap* const attributes
= rotationElement->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;
attribute_index<attributeCount; attribute_index++)
{
xercesc::DOMNode* node = attributes->item(attribute_index);
if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) { continue; }
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(node);
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="name") { name = GenerateName(attValue); } else
if (attName=="unit") { unit = eval.Evaluate(attValue); } else
if (attName=="x") { rotation.setX(eval.Evaluate(attValue)); } else
if (attName=="y") { rotation.setY(eval.Evaluate(attValue)); } else
if (attName=="z") { rotation.setZ(eval.Evaluate(attValue)); }
}
rotationMap[name] = rotation*unit;
}
void G4GDMLReadDefine::ScaleRead(const xercesc::DOMElement* const scaleElement)
{
G4String name = "";
G4ThreeVector scale(1.0,1.0,1.0);
const xercesc::DOMNamedNodeMap* const attributes
= scaleElement->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;
attribute_index<attributeCount; attribute_index++)
{
xercesc::DOMNode* node = attributes->item(attribute_index);
if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) { continue; }
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(node);
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="name") { name = GenerateName(attValue); } else
if (attName=="x") { scale.setX(eval.Evaluate(attValue)); } else
if (attName=="y") { scale.setY(eval.Evaluate(attValue)); } else
if (attName=="z") { scale.setZ(eval.Evaluate(attValue)); }
}
scaleMap[name] = scale;
}
void
G4GDMLReadDefine::VariableRead(const xercesc::DOMElement* const variableElement)
{
G4String name = "";
G4double value = 0.0;
const xercesc::DOMNamedNodeMap* const attributes
= variableElement->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;
attribute_index<attributeCount; attribute_index++)
{
xercesc::DOMNode* node = attributes->item(attribute_index);
if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) { continue; }
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(node);
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="name") { name = attValue; } else
if (attName=="value") { value = eval.Evaluate(attValue); }
}
eval.DefineVariable(name,value);
}
void G4GDMLReadDefine::QuantityRead(const xercesc::DOMElement* const element)
{
G4String name = "";
G4double unit = 1.0;
G4double value = 0.0;
const xercesc::DOMNamedNodeMap* const attributes
= element->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;
attribute_index<attributeCount; attribute_index++)
{
xercesc::DOMNode* node = attributes->item(attribute_index);
if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) { continue; }
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(node);
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="name") { name = attValue; } else
if (attName=="value") { value = eval.Evaluate(attValue); } else
if (attName=="unit") { unit = eval.Evaluate(attValue); }
}
quantityMap[name] = value*unit;
}
void
G4GDMLReadDefine::DefineRead(const xercesc::DOMElement* const defineElement)
{
G4cout << "G4GDML: Reading definitions..." << G4endl;
for (xercesc::DOMNode* iter = defineElement->getFirstChild();
iter != 0;iter = iter->getNextSibling())
{
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
const xercesc::DOMElement* const child
= dynamic_cast<xercesc::DOMElement*>(iter);
const G4String tag = Transcode(child->getTagName());
if (tag=="constant") { ConstantRead(child); } else
if (tag=="matrix") { MatrixRead(child); } else
if (tag=="position") { PositionRead(child); } else
if (tag=="rotation") { RotationRead(child); } else
if (tag=="scale") { ScaleRead(child); } else
if (tag=="variable") { VariableRead(child); } else
if (tag=="quantity") { QuantityRead(child); }
else
{
G4String error_msg = "Unknown tag in define: "+tag;
G4Exception("G4GDMLReadDefine::defineRead()", "ReadError",
FatalException, error_msg);
}
}
}
void
G4GDMLReadDefine::VectorRead(const xercesc::DOMElement* const vectorElement,
G4ThreeVector& vec)
{
G4double unit = 1.0;
const xercesc::DOMNamedNodeMap* const attributes
= vectorElement->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;
attribute_index<attributeCount; attribute_index++)
{
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
{ continue; }
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="unit") { unit = eval.Evaluate(attValue); } else
if (attName=="x") { vec.setX(eval.Evaluate(attValue)); } else
if (attName=="y") { vec.setY(eval.Evaluate(attValue)); } else
if (attName=="z") { vec.setZ(eval.Evaluate(attValue)); }
}
vec *= unit;
}
G4String G4GDMLReadDefine::RefRead(const xercesc::DOMElement* const element)
{
G4String ref;
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;
attribute_index<attributeCount; attribute_index++)
{
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
{ continue; }
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="ref") { ref = attValue; }
}
return ref;
}
G4double G4GDMLReadDefine::GetConstant(const G4String& ref)
{
return eval.GetConstant(ref);
}
G4double G4GDMLReadDefine::GetVariable(const G4String& ref)
{
return eval.GetVariable(ref);
}
G4double G4GDMLReadDefine::GetQuantity(const G4String& ref)
{
if (quantityMap.find(ref) == quantityMap.end())
{
G4String error_msg = "Quantity '"+ref+"' was not found!";
G4Exception("G4GDMLReadDefine::getQuantity()", "ReadError",
FatalException, error_msg);
}
return quantityMap[ref];
}
G4ThreeVector G4GDMLReadDefine::GetPosition(const G4String& ref)
{
if (positionMap.find(ref) == positionMap.end())
{
G4String error_msg = "Position '"+ref+"' was not found!";
G4Exception("G4GDMLReadDefine::getPosition()", "ReadError",
FatalException, error_msg);
}
return positionMap[ref];
}
G4ThreeVector G4GDMLReadDefine::GetRotation(const G4String& ref)
{
if (rotationMap.find(ref) == rotationMap.end())
{
G4String error_msg = "Rotation '"+ref+"' was not found!";
G4Exception("G4GDMLReadDefine::getRotation()", "ReadError",
FatalException, error_msg);
}
return rotationMap[ref];
}
G4ThreeVector G4GDMLReadDefine::GetScale(const G4String& ref)
{
if (scaleMap.find(ref) == scaleMap.end())
{
G4String error_msg = "Scale '"+ref+"' was not found!";
G4Exception("G4GDMLReadDefine::getScale()", "ReadError",
FatalException, error_msg);
}
return scaleMap[ref];
}
G4GDMLMatrix G4GDMLReadDefine::GetMatrix(const G4String& ref)
{
if (matrixMap.find(ref) == matrixMap.end())
{
G4String error_msg = "Matrix '"+ref+"' was not found!";
G4Exception("G4GDMLReadDefine::getMatrix()", "ReadError",
FatalException, error_msg);
}
return matrixMap[ref];
}
@@ -0,0 +1,592 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4GDMLReadMaterials.cc,v 1.16 2008/08/22 10:00:20 gcosmo Exp $
// GEANT4 tag $ Name:$
//
// class G4GDMLReadMaterials Implementation
//
// Original author: Zoltan Torzsok, November 2007
//
// --------------------------------------------------------------------
#include "G4GDMLReadMaterials.hh"
G4double
G4GDMLReadMaterials::AtomRead(const xercesc::DOMElement* const atomElement)
{
G4double value = 0.0;
G4double unit = g/mole;
const xercesc::DOMNamedNodeMap* const attributes
= atomElement->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;
attribute_index<attributeCount; attribute_index++)
{
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
{ continue; }
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="value") { value = eval.Evaluate(attValue); } else
if (attName=="unit") { unit = eval.Evaluate(attValue); }
}
return value*unit;
}
G4int G4GDMLReadMaterials::
CompositeRead(const xercesc::DOMElement* const compositeElement,G4String& ref)
{
G4int n = 0;
const xercesc::DOMNamedNodeMap* const attributes
= compositeElement->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;
attribute_index<attributeCount; attribute_index++)
{
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
{ continue; }
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="n") { n = eval.EvaluateInteger(attValue); } else
if (attName=="ref") { ref = attValue; }
}
return n;
}
G4double G4GDMLReadMaterials::DRead(const xercesc::DOMElement* const DElement)
{
G4double value = 0.0;
G4double unit = g/cm3;
const xercesc::DOMNamedNodeMap* const attributes
= DElement->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;
attribute_index<attributeCount; attribute_index++)
{
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
{ continue; }
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="value") { value = eval.Evaluate(attValue); } else
if (attName=="unit") { unit = eval.Evaluate(attValue); }
}
return value*unit;
}
G4double G4GDMLReadMaterials::PRead(const xercesc::DOMElement* const PElement)
{
G4double value = STP_Pressure;
G4double unit = pascal;
const xercesc::DOMNamedNodeMap* const attributes = PElement->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;
attribute_index<attributeCount; attribute_index++)
{
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
{ continue; }
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="value") { value = eval.Evaluate(attValue); } else
if (attName=="unit") { unit = eval.Evaluate(attValue); }
}
return value*unit;
}
G4double G4GDMLReadMaterials::TRead(const xercesc::DOMElement* const TElement)
{
G4double value = STP_Temperature;
G4double unit = kelvin;
const xercesc::DOMNamedNodeMap* const attributes = TElement->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;
attribute_index<attributeCount; attribute_index++)
{
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
{ continue; }
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="value") { value = eval.Evaluate(attValue); } else
if (attName=="unit") { unit = eval.Evaluate(attValue); }
}
return value*unit;
}
void G4GDMLReadMaterials::
ElementRead(const xercesc::DOMElement* const elementElement)
{
G4String name;
G4String formula;
G4double a = 0.0;
G4double Z = 0.0;
const xercesc::DOMNamedNodeMap* const attributes
= elementElement->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;
attribute_index<attributeCount; attribute_index++)
{
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
{ continue; }
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="name") { name = GenerateName(attValue); } else
if (attName=="formula") { formula = attValue; } else
if (attName=="Z") { Z = eval.Evaluate(attValue); }
}
G4int nComponents = 0;
for (xercesc::DOMNode* iter = elementElement->getFirstChild();
iter != 0; iter = iter->getNextSibling())
{
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
const xercesc::DOMElement* const child
= dynamic_cast<xercesc::DOMElement*>(iter);
const G4String tag = Transcode(child->getTagName());
if (tag=="atom") { a = AtomRead(child); } else
if (tag=="fraction") { nComponents++; }
}
if (nComponents>0)
{
MixtureRead(elementElement,
new G4Element(Strip(name),formula,nComponents));
}
else
{
new G4Element(Strip(name),formula,Z,a);
}
}
G4double G4GDMLReadMaterials::
FractionRead(const xercesc::DOMElement* const fractionElement, G4String& ref)
{
G4double n = 0.0;
const xercesc::DOMNamedNodeMap* const attributes
= fractionElement->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;
attribute_index<attributeCount; attribute_index++)
{
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
{ continue; }
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="n") { n = eval.Evaluate(attValue); } else
if (attName=="ref") { ref = attValue; }
}
return n;
}
void G4GDMLReadMaterials::
IsotopeRead(const xercesc::DOMElement* const isotopeElement)
{
G4String name;
G4int Z = 0;
G4int N = 0;
G4double a = 0.0;
const xercesc::DOMNamedNodeMap* const attributes
= isotopeElement->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;
attribute_index<attributeCount;attribute_index++)
{
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
{ continue; }
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="name") { name = GenerateName(attValue); } else
if (attName=="Z") { Z = eval.EvaluateInteger(attValue); } else
if (attName=="N") { N = eval.EvaluateInteger(attValue); }
}
for (xercesc::DOMNode* iter = isotopeElement->getFirstChild();
iter != 0; iter = iter->getNextSibling())
{
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
const xercesc::DOMElement* const child
= dynamic_cast<xercesc::DOMElement*>(iter);
const G4String tag = Transcode(child->getTagName());
if (tag=="atom") { a = AtomRead(child); }
}
new G4Isotope(Strip(name),Z,N,a);
}
void G4GDMLReadMaterials::
MaterialRead(const xercesc::DOMElement* const materialElement)
{
G4String name;
G4double Z = 0.0;
G4double a = 0.0;
G4double D = 0.0;
G4State state = kStateUndefined;
G4double T = STP_Temperature;
G4double P = STP_Pressure;
const xercesc::DOMNamedNodeMap* const attributes
= materialElement->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;
attribute_index<attributeCount; attribute_index++)
{
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
{ continue; }
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="name") { name = GenerateName(attValue); } else
if (attName=="Z") { Z = eval.Evaluate(attValue); } else
if (attName=="state")
{
if (attValue=="solid") { state = kStateSolid; } else
if (attValue=="liquid") { state = kStateLiquid; } else
if (attValue=="gas") { state = kStateGas; }
}
}
size_t nComponents = 0;
for (xercesc::DOMNode* iter = materialElement->getFirstChild();
iter != 0; iter = iter->getNextSibling())
{
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
const xercesc::DOMElement* const child
= dynamic_cast<xercesc::DOMElement*>(iter);
const G4String tag = Transcode(child->getTagName());
if (tag=="atom") { a = AtomRead(child); } else
if (tag=="Dref") { D = GetQuantity(GenerateName(RefRead(child))); } else
if (tag=="Pref") { P = GetQuantity(GenerateName(RefRead(child))); } else
if (tag=="Tref") { T = GetQuantity(GenerateName(RefRead(child))); } else
if (tag=="D") { D = DRead(child); } else
if (tag=="P") { P = PRead(child); } else
if (tag=="T") { T = TRead(child); } else
if (tag=="fraction" || tag=="composite") { nComponents++; }
}
G4Material* material = 0;
if (nComponents==0)
{
material = new G4Material(Strip(name),Z,a,D,state,T,P);
}
else
{
material = new G4Material(Strip(name),D,nComponents,state,T,P);
MixtureRead(materialElement, material);
}
for (xercesc::DOMNode* iter = materialElement->getFirstChild();
iter != 0; iter = iter->getNextSibling())
{
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
const xercesc::DOMElement* const child
= dynamic_cast<xercesc::DOMElement*>(iter);
const G4String tag = Transcode(child->getTagName());
if (tag=="property") { PropertyRead(child,material); }
}
}
void G4GDMLReadMaterials::
MixtureRead(const xercesc::DOMElement *const mixtureElement, G4Element *element)
{
for (xercesc::DOMNode* iter = mixtureElement->getFirstChild();
iter != 0; iter = iter->getNextSibling())
{
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
const xercesc::DOMElement* const child
= dynamic_cast<xercesc::DOMElement*>(iter);
const G4String tag = Transcode(child->getTagName());
if (tag=="fraction")
{
G4String ref;
G4double n = FractionRead(child,ref);
element->AddIsotope(GetIsotope(GenerateName(ref,true)),n);
}
}
}
void G4GDMLReadMaterials::
MixtureRead(const xercesc::DOMElement *const mixtureElement,
G4Material *material)
{
for (xercesc::DOMNode* iter = mixtureElement->getFirstChild();
iter != 0; iter = iter->getNextSibling())
{
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
const xercesc::DOMElement* const child
= dynamic_cast<xercesc::DOMElement*>(iter);
const G4String tag = Transcode(child->getTagName());
if (tag=="fraction")
{
G4String ref;
G4double n = FractionRead(child,ref);
G4Material *materialPtr = GetMaterial(GenerateName(ref,true), false);
G4Element *elementPtr = GetElement(GenerateName(ref,true), false);
if (materialPtr != 0) { material->AddMaterial(materialPtr,n); } else
if (elementPtr != 0) { material->AddElement(elementPtr,n); }
if ((materialPtr == 0) && (elementPtr == 0))
{
G4String error_msg = "Referenced material/element '"
+ GenerateName(ref,true) + "' was not found!";
G4Exception("G4GDMLReadMaterials::MixtureRead()", "InvalidSetup",
FatalException, error_msg);
}
}
else if (tag=="composite")
{
G4String ref;
G4int n = CompositeRead(child,ref);
G4Element *elementPtr = GetElement(GenerateName(ref,true));
material->AddElement(elementPtr,n);
}
}
}
void G4GDMLReadMaterials::
PropertyRead(const xercesc::DOMElement* const propertyElement,
G4Material* material)
{
G4String name;
G4String ref;
G4GDMLMatrix matrix;
const xercesc::DOMNamedNodeMap* const attributes
= propertyElement->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;
attribute_index<attributeCount; attribute_index++)
{
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
{ continue; }
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="name") { name = GenerateName(attValue); } else
if (attName=="ref") { matrix = GetMatrix(ref=attValue); }
}
if (matrix.GetCols() != 2)
{
G4String error_msg = "Referenced matrix '" + ref
+ "' should have \n two columns as a property table for material: "
+ material->GetName();
G4Exception("G4GDMLReadMaterials::PropertyRead()", "InvalidRead",
FatalException, error_msg);
}
if (matrix.GetRows() == 0) { return; }
G4MaterialPropertiesTable* matprop = material->GetMaterialPropertiesTable();
if (!matprop)
{
material->SetMaterialPropertiesTable(
matprop = new G4MaterialPropertiesTable());
}
G4MaterialPropertyVector* propvect = new G4MaterialPropertyVector(0,0,0);
for (size_t i=0; i<matrix.GetRows(); i++)
{
propvect->AddElement(matrix.Get(i,0),matrix.Get(i,1));
}
matprop->AddProperty(Strip(name),propvect);
}
void G4GDMLReadMaterials::
MaterialsRead(const xercesc::DOMElement* const materialsElement)
{
G4cout << "G4GDML: Reading materials..." << G4endl;
for (xercesc::DOMNode* iter = materialsElement->getFirstChild();
iter != 0; iter = iter->getNextSibling())
{
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
const xercesc::DOMElement* const child
= dynamic_cast<xercesc::DOMElement*>(iter);
const G4String tag = Transcode(child->getTagName());
if (tag=="element") { ElementRead(child); } else
if (tag=="isotope") { IsotopeRead(child); } else
if (tag=="material") { MaterialRead(child); }
else
{
G4String error_msg = "Unknown tag in materials: " + tag;
G4Exception("G4GDMLReadMaterials::MaterialsRead()", "InvalidSetup",
FatalException, error_msg);
}
}
}
G4Element* G4GDMLReadMaterials::
GetElement(const G4String& ref, G4bool verbose) const
{
G4Element* elementPtr = G4Element::GetElement(ref,false);
if (!elementPtr)
{
elementPtr = G4NistManager::Instance()->FindOrBuildElement(ref);
}
if (verbose && !elementPtr)
{
G4String error_msg = "Referenced element '" + ref + "' was not found!";
G4Exception("G4GDMLReadMaterials::GetElement()", "InvalidRead",
FatalException, error_msg);
}
return elementPtr;
}
G4Isotope* G4GDMLReadMaterials::GetIsotope(const G4String& ref,
G4bool verbose) const
{
G4Isotope* isotopePtr = G4Isotope::GetIsotope(ref,false);
if (verbose && !isotopePtr)
{
G4String error_msg = "Referenced isotope '" + ref + "' was not found!";
G4Exception("G4GDMLReadMaterials::GetIsotope()", "InvalidRead",
FatalException, error_msg);
}
return isotopePtr;
}
G4Material* G4GDMLReadMaterials::GetMaterial(const G4String& ref,
G4bool verbose) const
{
G4Material *materialPtr = G4Material::GetMaterial(ref,false);
if (!materialPtr)
{
materialPtr = G4NistManager::Instance()->FindOrBuildMaterial(ref);
}
if (verbose && !materialPtr)
{
G4String error_msg = "Referenced material '" + ref + "' was not found!";
G4Exception("G4GDMLReadMaterials::GetMaterial()", "InvalidRead",
FatalException, error_msg);
}
return materialPtr;
}
@@ -0,0 +1,630 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4GDMLReadParamvol.cc,v 1.10 2008/08/13 13:58:53 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
// class G4GDMLReadParamvol Implementation
//
// History:
// - Created. Zoltan Torzsok, November 2007
// -------------------------------------------------------------------------
#include "G4GDMLReadParamvol.hh"
void G4GDMLReadParamvol::
Box_dimensionsRead( const xercesc::DOMElement* const element,
G4GDMLParameterisation::PARAMETER& parameter )
{
G4double lunit = 1.0;
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;
attribute_index<attributeCount; attribute_index++)
{
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
{ continue; }
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
if (attName=="x") { parameter.dimension[0] = eval.Evaluate(attValue); } else
if (attName=="y") { parameter.dimension[1] = eval.Evaluate(attValue); } else
if (attName=="z") { parameter.dimension[2] = eval.Evaluate(attValue); }
}
parameter.dimension[0] *= 0.5*lunit;
parameter.dimension[1] *= 0.5*lunit;
parameter.dimension[2] *= 0.5*lunit;
}
void G4GDMLReadParamvol::
Trd_dimensionsRead( const xercesc::DOMElement* const element,
G4GDMLParameterisation::PARAMETER& parameter )
{
G4double lunit = 1.0;
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;
attribute_index<attributeCount; attribute_index++)
{
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
{ continue; }
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
if (attName=="x1") { parameter.dimension[0]=eval.Evaluate(attValue); } else
if (attName=="x2") { parameter.dimension[1]=eval.Evaluate(attValue); } else
if (attName=="y1") { parameter.dimension[2]=eval.Evaluate(attValue); } else
if (attName=="y2") { parameter.dimension[3]=eval.Evaluate(attValue); } else
if (attName=="z") { parameter.dimension[4]=eval.Evaluate(attValue); }
}
parameter.dimension[0] *= 0.5*lunit;
parameter.dimension[1] *= 0.5*lunit;
parameter.dimension[2] *= 0.5*lunit;
parameter.dimension[3] *= 0.5*lunit;
parameter.dimension[4] *= 0.5*lunit;
}
void G4GDMLReadParamvol::
Trap_dimensionsRead( const xercesc::DOMElement* const element,
G4GDMLParameterisation::PARAMETER& parameter )
{
G4double lunit = 1.0;
G4double aunit = 1.0;
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;
attribute_index<attributeCount; attribute_index++)
{
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
{ continue; }
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="lunit")
{ lunit = eval.Evaluate(attValue); } else
if (attName=="aunit")
{ aunit = eval.Evaluate(attValue); } else
if (attName=="z")
{ parameter.dimension[0] = eval.Evaluate(attValue); } else
if (attName=="theta")
{ parameter.dimension[1] = eval.Evaluate(attValue); } else
if (attName=="phi")
{ parameter.dimension[2] = eval.Evaluate(attValue); } else
if (attName=="y1")
{ parameter.dimension[3] = eval.Evaluate(attValue); } else
if (attName=="x1")
{ parameter.dimension[4] = eval.Evaluate(attValue); } else
if (attName=="x2")
{ parameter.dimension[5] = eval.Evaluate(attValue); } else
if (attName=="alpha1")
{ parameter.dimension[6] = eval.Evaluate(attValue); } else
if (attName=="y2")
{ parameter.dimension[7] = eval.Evaluate(attValue); } else
if (attName=="x3")
{ parameter.dimension[8] = eval.Evaluate(attValue); } else
if (attName=="x4")
{ parameter.dimension[9] = eval.Evaluate(attValue); } else
if (attName=="alpha2")
{ parameter.dimension[10] = eval.Evaluate(attValue); }
}
parameter.dimension[0] *= 0.5*lunit;
parameter.dimension[1] *= aunit;
parameter.dimension[2] *= aunit;
parameter.dimension[3] *= 0.5*lunit;
parameter.dimension[4] *= 0.5*lunit;
parameter.dimension[5] *= 0.5*lunit;
parameter.dimension[6] *= aunit;
parameter.dimension[7] *= 0.5*lunit;
parameter.dimension[8] *= 0.5*lunit;
parameter.dimension[9] *= 0.5*lunit;
parameter.dimension[10] *= aunit;
}
void G4GDMLReadParamvol::
Tube_dimensionsRead( const xercesc::DOMElement* const element,
G4GDMLParameterisation::PARAMETER& parameter )
{
G4double lunit = 1.0;
G4double aunit = 1.0;
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;
attribute_index<attributeCount; attribute_index++)
{
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
{ continue; }
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="lunit")
{ lunit = eval.Evaluate(attValue); } else
if (attName=="aunit")
{ aunit = eval.Evaluate(attValue); } else
if (attName=="InR")
{ parameter.dimension[0] = eval.Evaluate(attValue); } else
if (attName=="OutR")
{ parameter.dimension[1] = eval.Evaluate(attValue); } else
if (attName=="hz")
{ parameter.dimension[2] = eval.Evaluate(attValue); } else
if (attName=="StartPhi")
{ parameter.dimension[3] = eval.Evaluate(attValue); } else
if (attName=="DeltaPhi")
{ parameter.dimension[4] = eval.Evaluate(attValue); }
}
parameter.dimension[0] *= lunit;
parameter.dimension[1] *= lunit;
parameter.dimension[2] *= 0.5*lunit;
parameter.dimension[3] *= aunit;
parameter.dimension[4] *= aunit;
}
void G4GDMLReadParamvol::
Cone_dimensionsRead( const xercesc::DOMElement* const element,
G4GDMLParameterisation::PARAMETER& parameter )
{
G4double lunit = 1.0;
G4double aunit = 1.0;
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;
attribute_index<attributeCount; attribute_index++)
{
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
{ continue; }
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="lunit")
{ lunit = eval.Evaluate(attValue); } else
if (attName=="aunit")
{ aunit = eval.Evaluate(attValue); } else
if (attName=="rmin1")
{ parameter.dimension[0] = eval.Evaluate(attValue); } else
if (attName=="rmax1")
{ parameter.dimension[1] = eval.Evaluate(attValue); } else
if (attName=="rmin2")
{ parameter.dimension[2] = eval.Evaluate(attValue); } else
if (attName=="rmax2")
{ parameter.dimension[3] = eval.Evaluate(attValue); } else
if (attName=="z")
{ parameter.dimension[4] = eval.Evaluate(attValue); } else
if (attName=="startphi")
{ parameter.dimension[5] = eval.Evaluate(attValue); } else
if (attName=="deltaphi")
{ parameter.dimension[6] = eval.Evaluate(attValue); }
}
parameter.dimension[0] *= lunit;
parameter.dimension[1] *= lunit;
parameter.dimension[2] *= lunit;
parameter.dimension[3] *= lunit;
parameter.dimension[4] *= 0.5*lunit;
parameter.dimension[5] *= aunit;
parameter.dimension[6] *= aunit;
}
void G4GDMLReadParamvol::
Sphere_dimensionsRead( const xercesc::DOMElement* const element,
G4GDMLParameterisation::PARAMETER& parameter )
{
G4double lunit = 1.0;
G4double aunit = 1.0;
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;
attribute_index<attributeCount; attribute_index++)
{
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
{ continue; }
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="lunit")
{ lunit = eval.Evaluate(attValue); } else
if (attName=="aunit")
{ aunit = eval.Evaluate(attValue); } else
if (attName=="rmin")
{ parameter.dimension[0] = eval.Evaluate(attValue); } else
if (attName=="rmax")
{ parameter.dimension[1] = eval.Evaluate(attValue); } else
if (attName=="startphi")
{ parameter.dimension[2] = eval.Evaluate(attValue); } else
if (attName=="deltaphi")
{ parameter.dimension[3] = eval.Evaluate(attValue); } else
if (attName=="starttheta")
{ parameter.dimension[4] = eval.Evaluate(attValue); } else
if (attName=="deltatheta")
{ parameter.dimension[5] = eval.Evaluate(attValue); }
}
parameter.dimension[0] *= lunit;
parameter.dimension[1] *= lunit;
parameter.dimension[2] *= aunit;
parameter.dimension[3] *= aunit;
parameter.dimension[4] *= aunit;
parameter.dimension[5] *= aunit;
}
void G4GDMLReadParamvol::
Orb_dimensionsRead( const xercesc::DOMElement* const element,
G4GDMLParameterisation::PARAMETER& parameter )
{
G4double lunit = 1.0;
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;
attribute_index<attributeCount; attribute_index++)
{
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
{ continue; }
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
if (attName=="r") { parameter.dimension[0] = eval.Evaluate(attValue); }
}
parameter.dimension[0] *= lunit;
}
void G4GDMLReadParamvol::
Torus_dimensionsRead( const xercesc::DOMElement* const element,
G4GDMLParameterisation::PARAMETER& parameter )
{
G4double lunit = 1.0;
G4double aunit = 1.0;
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;
attribute_index<attributeCount; attribute_index++)
{
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
{ continue; }
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="lunit")
{ lunit = eval.Evaluate(attValue); } else
if (attName=="aunit")
{ aunit = eval.Evaluate(attValue); } else
if (attName=="rmin")
{ parameter.dimension[0] = eval.Evaluate(attValue); } else
if (attName=="rmax")
{ parameter.dimension[1] = eval.Evaluate(attValue); } else
if (attName=="rtor")
{ parameter.dimension[2] = eval.Evaluate(attValue); } else
if (attName=="startphi")
{ parameter.dimension[3] = eval.Evaluate(attValue); } else
if (attName=="deltaphi")
{ parameter.dimension[4] = eval.Evaluate(attValue); }
}
parameter.dimension[0] *= lunit;
parameter.dimension[1] *= lunit;
parameter.dimension[2] *= lunit;
parameter.dimension[3] *= aunit;
parameter.dimension[4] *= aunit;
}
void G4GDMLReadParamvol::
Para_dimensionsRead( const xercesc::DOMElement* const element,
G4GDMLParameterisation::PARAMETER& parameter )
{
G4double lunit = 1.0;
G4double aunit = 1.0;
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;
attribute_index<attributeCount; attribute_index++)
{
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
{ continue; }
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="lunit")
{ lunit = eval.Evaluate(attValue); } else
if (attName=="aunit")
{ aunit = eval.Evaluate(attValue); } else
if (attName=="x")
{ parameter.dimension[0] = eval.Evaluate(attValue); } else
if (attName=="y")
{ parameter.dimension[1] = eval.Evaluate(attValue); } else
if (attName=="z")
{ parameter.dimension[2] = eval.Evaluate(attValue); } else
if (attName=="alpha")
{ parameter.dimension[3] = eval.Evaluate(attValue); } else
if (attName=="theta")
{ parameter.dimension[4] = eval.Evaluate(attValue); } else
if (attName=="phi")
{ parameter.dimension[5] = eval.Evaluate(attValue); }
}
parameter.dimension[0] = 0.5*lunit;
parameter.dimension[1] = 0.5*lunit;
parameter.dimension[2] = 0.5*lunit;
parameter.dimension[3] = aunit;
parameter.dimension[4] = aunit;
parameter.dimension[5] = aunit;
}
void G4GDMLReadParamvol::
Hype_dimensionsRead( const xercesc::DOMElement* const element,
G4GDMLParameterisation::PARAMETER& parameter )
{
G4double lunit = 1.0;
G4double aunit = 1.0;
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;
attribute_index<attributeCount; attribute_index++)
{
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
{ continue; }
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="lunit")
{ lunit = eval.Evaluate(attValue); } else
if (attName=="aunit")
{ aunit = eval.Evaluate(attValue); } else
if (attName=="rmin")
{ parameter.dimension[0] = eval.Evaluate(attValue); } else
if (attName=="rmax")
{ parameter.dimension[1] = eval.Evaluate(attValue); } else
if (attName=="inst")
{ parameter.dimension[2] = eval.Evaluate(attValue); } else
if (attName=="outst")
{ parameter.dimension[3] = eval.Evaluate(attValue); } else
if (attName=="z")
{ parameter.dimension[4] = eval.Evaluate(attValue); }
}
parameter.dimension[0] = lunit;
parameter.dimension[1] = lunit;
parameter.dimension[2] = aunit;
parameter.dimension[3] = aunit;
parameter.dimension[4] = 0.5*lunit;
}
void G4GDMLReadParamvol::
ParametersRead(const xercesc::DOMElement* const element) {
G4ThreeVector rotation(0.0,0.0,0.0);
G4ThreeVector position(0.0,0.0,0.0);
G4GDMLParameterisation::PARAMETER parameter;
for (xercesc::DOMNode* iter = element->getFirstChild();
iter != 0; iter = iter->getNextSibling())
{
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
const xercesc::DOMElement* const child
= dynamic_cast<xercesc::DOMElement*>(iter);
const G4String tag = Transcode(child->getTagName());
if (tag=="rotation") { VectorRead(child,rotation); } else
if (tag=="position") { VectorRead(child,position); } else
if (tag=="positionref")
{ position = GetPosition(GenerateName(RefRead(child))); } else
if (tag=="rotationref")
{ rotation = GetRotation(GenerateName(RefRead(child))); } else
if (tag=="box_dimensions") { Box_dimensionsRead(child,parameter); } else
if (tag=="trd_dimensions") { Trd_dimensionsRead(child,parameter); } else
if (tag=="trap_dimensions") { Trap_dimensionsRead(child,parameter); } else
if (tag=="tube_dimensions") { Tube_dimensionsRead(child,parameter); } else
if (tag=="cone_dimensions") { Cone_dimensionsRead(child,parameter); } else
if (tag=="sphere_dimensions") { Cone_dimensionsRead(child,parameter); } else
if (tag=="orb_dimensions") { Cone_dimensionsRead(child,parameter); } else
if (tag=="torus_dimensions") { Cone_dimensionsRead(child,parameter); } else
if (tag=="para_dimensions") { Cone_dimensionsRead(child,parameter); } else
if (tag=="hype_dimensions") { Hype_dimensionsRead(child,parameter); }
else
{
G4String error_msg = "Unknown tag in parameters: " + tag;
G4Exception("G4GDMLReadParamvol::ParametersRead()", "ReadError",
FatalException, error_msg);
}
}
parameter.pRot = new G4RotationMatrix();
parameter.pRot->rotateX(rotation.x());
parameter.pRot->rotateY(rotation.y());
parameter.pRot->rotateZ(rotation.z());
parameter.position = position;
parameterisation->AddParameter(parameter);
}
void G4GDMLReadParamvol::
ParameterisedRead(const xercesc::DOMElement* const element)
{
for (xercesc::DOMNode* iter = element->getFirstChild();
iter != 0; iter = iter->getNextSibling())
{
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
const xercesc::DOMElement* const child
= dynamic_cast<xercesc::DOMElement*>(iter);
const G4String tag = Transcode(child->getTagName());
if (tag=="parameters")
{
G4double number = 1;
const xercesc::DOMNamedNodeMap* const attributes
= element->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;
attribute_index<attributeCount; attribute_index++)
{
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
{ continue; }
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="number") { number = eval.Evaluate(attValue); }
}
ParametersRead(child);
}
else
{
if (tag=="loop") { LoopRead(child,&G4GDMLRead::Paramvol_contentRead); }
}
}
}
void G4GDMLReadParamvol::
Paramvol_contentRead(const xercesc::DOMElement* const element)
{
for (xercesc::DOMNode* iter = element->getFirstChild();
iter != 0; iter = iter->getNextSibling())
{
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
const xercesc::DOMElement* const child
= dynamic_cast<xercesc::DOMElement*>(iter);
const G4String tag = Transcode(child->getTagName());
if (tag=="parameterised_position_size") { ParameterisedRead(child); }else
if (tag=="loop") { LoopRead(child,&G4GDMLRead::Paramvol_contentRead); }
}
}
void G4GDMLReadParamvol::
ParamvolRead(const xercesc::DOMElement* const element, G4LogicalVolume* mother)
{
G4String volumeref;
parameterisation = new G4GDMLParameterisation();
for (xercesc::DOMNode* iter = element->getFirstChild();
iter != 0; iter = iter->getNextSibling())
{
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
const xercesc::DOMElement* const child
= dynamic_cast<xercesc::DOMElement*>(iter);
const G4String tag = Transcode(child->getTagName());
if (tag=="volumeref") { volumeref = RefRead(child); }
}
Paramvol_contentRead(element);
G4LogicalVolume* logvol = GetVolume(GenerateName(volumeref));
if (parameterisation->GetSize()==0)
{
G4Exception("G4GDMLReadParamvol::ParamvolRead()",
"ReadError", FatalException,
"No parameters are defined in parameterised volume!");
}
G4String pv_name = logvol->GetName() + "_param";
new G4PVParameterised(pv_name, logvol, mother, kUndefined,
parameterisation->GetSize(), parameterisation);
}
@@ -23,61 +23,68 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4GDMLReadSetup.cc,v 1.9 2008/07/16 15:46:34 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
// $Id: G4GDMLSetup.cc,v 1.11 2007/11/29 13:13:06 ztorzsok Exp $
// GEANT4 tag $ Name:$
//
// class G4GDMLSetup Implementation
// class G4GDMLReadSetup Implementation
//
// Original author: Zoltan Torzsok, November 2007
//
// --------------------------------------------------------------------
#include "G4GDMLSetup.hh"
#include "G4GDMLReadSetup.hh"
G4String G4GDMLSetup::getSetup(const G4String& ref) {
G4String G4GDMLReadSetup::GetSetup(const G4String& ref)
{
if (setupMap.size() == 1) // If there is only one setup defined,
{ // no matter how it is named
return setupMap.begin()->second;
}
if (setupMap.find(ref) == setupMap.end())
G4Exception("GDML: Referenced setup '"+ref+"' was not found!");
{
G4String error_msg = "Referenced setup '" + ref + "' was not found!";
G4Exception("G4GDMLReadSetup::getSetup()", "ReadError",
FatalException, error_msg);
}
return setupMap[ref];
}
void G4GDMLSetup::setupRead(const xercesc::DOMElement* const element) {
void G4GDMLReadSetup::SetupRead(const xercesc::DOMElement* const element)
{
G4cout << "G4GDML: Reading setup..." << G4endl;
G4String name;
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;attribute_index<attributeCount;attribute_index++) {
for (XMLSize_t attribute_index=0;
attribute_index<attributeCount; attribute_index++)
{
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue;
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
{ continue; }
const xercesc::DOMAttr* const attribute = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
const G4String attribute_name = xercesc::XMLString::transcode(attribute->getName());
const G4String attribute_value = xercesc::XMLString::transcode(attribute->getValue());
if (attribute_name=="name") name = attribute_value;
if (attName=="name") { name = attValue; }
}
for (xercesc::DOMNode* iter = element->getFirstChild();iter != 0;iter = iter->getNextSibling()) {
for (xercesc::DOMNode* iter = element->getFirstChild();
iter != 0; iter = iter->getNextSibling())
{
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) continue;
const xercesc::DOMElement* const child
= dynamic_cast<xercesc::DOMElement*>(iter);
const G4String tag = Transcode(child->getTagName());
const xercesc::DOMElement* const child = dynamic_cast<xercesc::DOMElement*>(iter);
const G4String tag = xercesc::XMLString::transcode(child->getTagName());
if (tag != "world") continue;
XMLCh *ref_attr = xercesc::XMLString::transcode("ref");
G4String ref = xercesc::XMLString::transcode(child->getAttribute(ref_attr));
xercesc::XMLString::release(&ref_attr);
setupMap[name] = GenerateName(ref);
if (tag == "world") { setupMap[name] = GenerateName(RefRead(child)); }
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,691 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4GDMLReadStructure.cc,v 1.52 2008/11/20 15:37:46 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
// class G4GDMLReadStructure Implementation
//
// Original author: Zoltan Torzsok, November 2007
//
// --------------------------------------------------------------------
#include "G4GDMLReadStructure.hh"
G4GDMLAuxPairType G4GDMLReadStructure::
AuxiliaryRead(const xercesc::DOMElement* const auxiliaryElement)
{
G4GDMLAuxPairType auxpair;
const xercesc::DOMNamedNodeMap* const attributes
= auxiliaryElement->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;
attribute_index<attributeCount; attribute_index++)
{
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
{ continue; }
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="auxtype") { auxpair.type = attValue; } else
if (attName=="auxvalue") { auxpair.value = eval.Evaluate(attValue); }
}
return auxpair;
}
void G4GDMLReadStructure::
BordersurfaceRead(const xercesc::DOMElement* const bordersurfaceElement)
{
G4String name;
G4VPhysicalVolume* pv1 = 0;
G4VPhysicalVolume* pv2 = 0;
G4SurfaceProperty* prop = 0;
G4int index = 0;
const xercesc::DOMNamedNodeMap* const attributes
= bordersurfaceElement->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;
attribute_index<attributeCount; attribute_index++)
{
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
{ continue; }
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="name")
{ name = GenerateName(attValue); } else
if (attName=="surfaceproperty")
{ prop = GetSurfaceProperty(GenerateName(attValue)); }
}
for (xercesc::DOMNode* iter = bordersurfaceElement->getFirstChild();
iter != 0; iter = iter->getNextSibling())
{
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
const xercesc::DOMElement* const child
= dynamic_cast<xercesc::DOMElement*>(iter);
const G4String tag = Transcode(child->getTagName());
if (tag != "physvolref") { continue; }
if (index==0)
{ pv1 = GetPhysvol(GenerateName(RefRead(child))); index++; } else
if (index==1)
{ pv2 = GetPhysvol(GenerateName(RefRead(child))); index++; } else
break;
}
new G4LogicalBorderSurface(Strip(name),pv1,pv2,prop);
}
void G4GDMLReadStructure::
DivisionvolRead(const xercesc::DOMElement* const divisionvolElement)
{
G4String name;
G4double unit = 1.0;
G4double width = 0.0;
G4double offset = 0.0;
G4int number = 0;
EAxis axis = kUndefined;
G4LogicalVolume* logvol = 0;
const xercesc::DOMNamedNodeMap* const attributes
= divisionvolElement->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;
attribute_index<attributeCount; attribute_index++)
{
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
{ continue; }
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="name") { name = attValue; } else
if (attName=="unit") { unit = eval.Evaluate(attValue); } else
if (attName=="width") { width = eval.Evaluate(attValue); } else
if (attName=="offset") { offset = eval.Evaluate(attValue); } else
if (attName=="number") { number = eval.EvaluateInteger(attValue); } else
if (attName=="axis")
{
if (attValue=="kXAxis") { axis = kXAxis; } else
if (attValue=="kYAxis") { axis = kYAxis; } else
if (attValue=="kZAxis") { axis = kZAxis; } else
if (attValue=="kRho") { axis = kRho; } else
if (attValue=="kPhi") { axis = kPhi; }
}
}
width *= unit;
offset *= unit;
for (xercesc::DOMNode* iter = divisionvolElement->getFirstChild();
iter != 0;iter = iter->getNextSibling())
{
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
const xercesc::DOMElement* const child
= dynamic_cast<xercesc::DOMElement*>(iter);
const G4String tag = Transcode(child->getTagName());
if (tag=="volumeref") { logvol = GetVolume(GenerateName(RefRead(child))); }
}
G4PVDivisionFactory::GetInstance();
G4PhysicalVolumesPair pair;
G4String pv_name = logvol->GetName() + "_div";
if ((number != 0) && (width == 0.0))
{
pair = G4ReflectionFactory::Instance()
->Divide(pv_name,logvol,pMotherLogical,axis,number,offset);
}
else if ((number == 0) && (width != 0.0))
{
pair = G4ReflectionFactory::Instance()
->Divide(pv_name,logvol,pMotherLogical,axis,width,offset);
}
else
{
pair = G4ReflectionFactory::Instance()
->Divide(pv_name,logvol,pMotherLogical,axis,number,width,offset);
}
if (pair.first != 0) { GeneratePhysvolName(name,pair.first); }
if (pair.second != 0) { GeneratePhysvolName(name,pair.second); }
}
G4LogicalVolume* G4GDMLReadStructure::
FileRead(const xercesc::DOMElement* const fileElement)
{
G4String name;
G4String volname;
const xercesc::DOMNamedNodeMap* const attributes
= fileElement->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;
attribute_index<attributeCount; attribute_index++)
{
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
{ continue; }
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="name") { name = attValue; } else
if (attName=="volname") { volname = attValue; }
}
const G4bool IsModule = true;
G4GDMLReadStructure structure;
structure.Read(name,Validate,IsModule);
if (volname.empty())
{
return structure.GetVolume(structure.GetSetup("Default"));
}
else
{
return structure.GetVolume(structure.GenerateName(volname));
}
}
void G4GDMLReadStructure::
PhysvolRead(const xercesc::DOMElement* const physvolElement)
{
G4String name;
G4LogicalVolume* logvol = 0;
G4ThreeVector position(0.0,0.0,0.0);
G4ThreeVector rotation(0.0,0.0,0.0);
G4ThreeVector scale(1.0,1.0,1.0);
const xercesc::DOMNamedNodeMap* const attributes
= physvolElement->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;
attribute_index<attributeCount; attribute_index++)
{
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
{ continue; }
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="name") { name = attValue; }
}
for (xercesc::DOMNode* iter = physvolElement->getFirstChild();
iter != 0; iter = iter->getNextSibling())
{
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
const xercesc::DOMElement* const child
= dynamic_cast<xercesc::DOMElement*>(iter);
const G4String tag = Transcode(child->getTagName());
if (tag=="file")
{ logvol = FileRead(child); } else
if (tag=="volumeref")
{ logvol = GetVolume(GenerateName(RefRead(child))); } else
if (tag=="position")
{ VectorRead(child,position); } else
if (tag=="rotation")
{ VectorRead(child,rotation); } else
if (tag=="scale")
{ VectorRead(child,scale); } else
if (tag=="positionref")
{ position = GetPosition(GenerateName(RefRead(child))); } else
if (tag=="rotationref")
{ rotation = GetRotation(GenerateName(RefRead(child))); } else
if (tag=="scaleref")
{ scale = GetScale(GenerateName(RefRead(child))); }
else
{
G4String error_msg = "Unknown tag in physvol: " + tag;
G4Exception("G4GDMLReadStructure::PhysvolRead()", "ReadError",
FatalException, error_msg);
}
}
G4Transform3D transform(GetRotationMatrix(rotation).inverse(),position);
transform = transform*G4Scale3D(scale.x(),scale.y(),scale.z());
G4String pv_name = logvol->GetName() + "_refl";
G4PhysicalVolumesPair pair = G4ReflectionFactory::Instance()
->Place(transform,pv_name,logvol,pMotherLogical,false,0,false);
if (pair.first != 0) { GeneratePhysvolName(name,pair.first); }
if (pair.second != 0) { GeneratePhysvolName(name,pair.second); }
}
void G4GDMLReadStructure::
ReplicavolRead(const xercesc::DOMElement* const replicavolElement, G4int number)
{
G4LogicalVolume* logvol = 0;
for (xercesc::DOMNode* iter = replicavolElement->getFirstChild();
iter != 0; iter = iter->getNextSibling())
{
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
const xercesc::DOMElement* const child
= dynamic_cast<xercesc::DOMElement*>(iter);
const G4String tag = Transcode(child->getTagName());
if (tag=="volumeref")
{
logvol = GetVolume(GenerateName(RefRead(child)));
}
else if (tag=="replicate_along_axis")
{
ReplicaRead(child,logvol,number);
}
else
{
G4String error_msg = "Unknown tag in ReplicavolRead: " + tag;
G4Exception("G4GDMLReadStructure::ReplicavolRead()",
"ReadError", FatalException, error_msg);
}
}
}
void G4GDMLReadStructure::
ReplicaRead(const xercesc::DOMElement* const replicaElement,
G4LogicalVolume* logvol, G4int number)
{
G4double width = 0.0;
G4double offset = 0.0;
G4ThreeVector position(0.0,0.0,0.0);
G4ThreeVector rotation(0.0,0.0,0.0);
EAxis axis = kUndefined;
G4String name;
for (xercesc::DOMNode* iter = replicaElement->getFirstChild();
iter != 0; iter = iter->getNextSibling())
{
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
const xercesc::DOMElement* const child
= dynamic_cast<xercesc::DOMElement*>(iter);
const G4String tag = Transcode(child->getTagName());
if (tag=="position")
{ VectorRead(child,position); } else
if (tag=="rotation")
{ VectorRead(child,rotation); } else
if (tag=="positionref")
{ position = GetPosition(GenerateName(RefRead(child))); } else
if (tag=="rotationref")
{ rotation = GetRotation(GenerateName(RefRead(child))); } else
if (tag=="direction")
{ axis=AxisRead(child); } else
if (tag=="width")
{ width=QuantityRead(child); } else
if (tag=="offset")
{ offset=QuantityRead(child); }
else
{
G4String error_msg = "Unknown tag in ReplicaRead: " + tag;
G4Exception("G4GDMLReadStructure::ReplicaRead()", "ReadError",
FatalException, error_msg);
}
}
G4String pv_name = logvol->GetName() + "_refl";
G4PhysicalVolumesPair pair = G4ReflectionFactory::Instance()
->Replicate(pv_name,logvol,pMotherLogical,axis,number,width,offset);
if (pair.first != 0) { GeneratePhysvolName(name,pair.first); }
if (pair.second != 0) { GeneratePhysvolName(name,pair.second); }
}
EAxis G4GDMLReadStructure::
AxisRead(const xercesc::DOMElement* const axisElement)
{
EAxis axis = kUndefined;
const xercesc::DOMNamedNodeMap* const attributes
= axisElement->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;
attribute_index<attributeCount; attribute_index++)
{
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
{ continue; }
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="x")
{ if( eval.Evaluate(attValue)==1.) {axis=kXAxis;} }
else if (attName=="y")
{ if( eval.Evaluate(attValue)==1.) {axis=kYAxis;} }
else if (attName=="z")
{ if( eval.Evaluate(attValue)==1.) {axis=kZAxis;} }
else if (attName=="rho")
{ if( eval.Evaluate(attValue)==1.) {axis=kRho;} }
else if (attName=="phi")
{ if( eval.Evaluate(attValue)==1.) {axis=kPhi;} }
}
return axis;
}
G4double G4GDMLReadStructure::
QuantityRead(const xercesc::DOMElement* const readElement)
{
G4double value = 0.0;
G4double unit = 0.0;
const xercesc::DOMNamedNodeMap* const attributes
= readElement->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;
attribute_index<attributeCount; attribute_index++)
{
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
{ continue; }
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="unit") { unit = eval.Evaluate(attValue); } else
if (attName=="value"){ value= eval.Evaluate(attValue); }
}
return value*unit;
}
void G4GDMLReadStructure::
VolumeRead(const xercesc::DOMElement* const volumeElement)
{
G4VSolid* solidPtr = 0;
G4Material* materialPtr = 0;
G4GDMLAuxListType auxList;
XMLCh *name_attr = xercesc::XMLString::transcode("name");
const G4String name = Transcode(volumeElement->getAttribute(name_attr));
xercesc::XMLString::release(&name_attr);
for (xercesc::DOMNode* iter = volumeElement->getFirstChild();
iter != 0; iter = iter->getNextSibling())
{
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
const xercesc::DOMElement* const child
= dynamic_cast<xercesc::DOMElement*>(iter);
const G4String tag = Transcode(child->getTagName());
if (tag=="auxiliary")
{ auxList.push_back(AuxiliaryRead(child)); } else
if (tag=="materialref")
{ materialPtr = GetMaterial(GenerateName(RefRead(child),true)); } else
if (tag=="solidref")
{ solidPtr = GetSolid(GenerateName(RefRead(child))); }
}
pMotherLogical = new G4LogicalVolume(solidPtr,materialPtr,
GenerateName(name),0,0,0);
if (!auxList.empty()) { auxMap[pMotherLogical] = auxList; }
Volume_contentRead(volumeElement);
}
void G4GDMLReadStructure::
SkinsurfaceRead(const xercesc::DOMElement* const skinsurfaceElement)
{
G4String name;
G4LogicalVolume* logvol = 0;
G4SurfaceProperty* prop = 0;
const xercesc::DOMNamedNodeMap* const attributes
= skinsurfaceElement->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;
attribute_index<attributeCount; attribute_index++)
{
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
{ continue; }
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="name")
{ name = GenerateName(attValue); } else
if (attName=="surfaceproperty")
{ prop = GetSurfaceProperty(GenerateName(attValue)); }
}
for (xercesc::DOMNode* iter = skinsurfaceElement->getFirstChild();
iter != 0; iter = iter->getNextSibling())
{
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
const xercesc::DOMElement* const child
= dynamic_cast<xercesc::DOMElement*>(iter);
const G4String tag = Transcode(child->getTagName());
if (tag=="volumeref")
{
logvol = GetVolume(GenerateName(RefRead(child)));
}
else
{
G4String error_msg = "Unknown tag in skinsurface: " + tag;
G4Exception("G4GDMLReadStructure::SkinsurfaceRead()", "ReadError",
FatalException, error_msg);
}
}
new G4LogicalSkinSurface(Strip(name),logvol,prop);
}
void G4GDMLReadStructure::
Volume_contentRead(const xercesc::DOMElement* const volumeElement)
{
for (xercesc::DOMNode* iter = volumeElement->getFirstChild();
iter != 0; iter = iter->getNextSibling())
{
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
const xercesc::DOMElement* const child
= dynamic_cast<xercesc::DOMElement*>(iter);
const G4String tag = Transcode(child->getTagName());
if ((tag=="auxiliary") || (tag=="materialref") || (tag=="solidref"))
{
// These are already processed in VolumeRead()
}
else if (tag=="paramvol")
{
ParamvolRead(child,pMotherLogical);
}
else if (tag=="physvol")
{
PhysvolRead(child);
}
else if (tag=="replicavol")
{
G4int number = 1;
const xercesc::DOMNamedNodeMap* const attributes
= child->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;
attribute_index<attributeCount; attribute_index++)
{
xercesc::DOMNode* attribute_node
= attributes->item(attribute_index);
if (attribute_node->getNodeType()!=xercesc::DOMNode::ATTRIBUTE_NODE)
{
continue;
}
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="number")
{
number = eval.EvaluateInteger(attValue);
}
}
ReplicavolRead(child,number);
}
else if (tag=="divisionvol")
{
DivisionvolRead(child);
}
else if (tag=="loop")
{
LoopRead(child,&G4GDMLRead::Volume_contentRead);
}
else
{
G4cout << "Treating unknown GDML tag in volume '" << tag
<< "' as GDML extension..." << G4endl;
}
}
}
void G4GDMLReadStructure::
StructureRead(const xercesc::DOMElement* const structureElement)
{
G4cout << "G4GDML: Reading structure..." << G4endl;
for (xercesc::DOMNode* iter = structureElement->getFirstChild();
iter != 0; iter = iter->getNextSibling())
{
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
const xercesc::DOMElement* const child
= dynamic_cast<xercesc::DOMElement*>(iter);
const G4String tag = Transcode(child->getTagName());
if (tag=="bordersurface") { BordersurfaceRead(child); } else
if (tag=="skinsurface") { SkinsurfaceRead(child); } else
if (tag=="volume") { VolumeRead(child); } else
if (tag=="loop") { LoopRead(child,&G4GDMLRead::StructureRead); }
else
{
G4String error_msg = "Unknown tag in structure: " + tag;
G4Exception("G4GDMLReadStructure::StructureRead()",
"ReadError", FatalException, error_msg);
}
}
}
G4VPhysicalVolume* G4GDMLReadStructure::
GetPhysvol(const G4String& ref) const
{
G4VPhysicalVolume* physvolPtr =
G4PhysicalVolumeStore::GetInstance()->GetVolume(ref,false);
if (!physvolPtr)
{
G4String error_msg = "Referenced physvol '" + ref + "' was not found!";
G4Exception("G4GDMLReadStructure::GetPhysvol()", "ReadError",
FatalException, error_msg);
}
return physvolPtr;
}
G4LogicalVolume* G4GDMLReadStructure::
GetVolume(const G4String& ref) const
{
G4LogicalVolume *volumePtr
= G4LogicalVolumeStore::GetInstance()->GetVolume(ref,false);
if (!volumePtr)
{
G4String error_msg = "Referenced volume '" + ref + "' was not found!";
G4Exception("G4GDMLReadStructure::GetVolume()", "ReadError",
FatalException, error_msg);
}
return volumePtr;
}
G4GDMLAuxListType G4GDMLReadStructure::
GetVolumeAuxiliaryInformation(const G4LogicalVolume* const logvol)
{
if (auxMap.find(logvol) != auxMap.end()) { return auxMap[logvol]; }
else { return G4GDMLAuxListType(); }
}
G4VPhysicalVolume* G4GDMLReadStructure::
GetWorldVolume(const G4String& setupName)
{
G4LogicalVolume* volume = GetVolume(Strip(GetSetup(setupName)));
volume->SetVisAttributes(G4VisAttributes::Invisible);
G4VPhysicalVolume* pvWorld =
new G4PVPlacement(0,G4ThreeVector(0,0,0),volume,setupName,0,0,0);
return pvWorld;
}
File diff suppressed because it is too large Load Diff
@@ -1,504 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4GDMLStructure.cc,v 1.25 2007/11/30 14:51:20 ztorzsok Exp $
// GEANT4 tag $ Name:$
//
// class G4GDMLStructure Implementation
//
// Original author: Zoltan Torzsok, November 2007
//
// --------------------------------------------------------------------
#include "G4GDMLStructure.hh"
EAxis G4GDMLStructure::directionRead(const xercesc::DOMElement* const element) {
G4String x;
G4String y;
G4String z;
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;attribute_index<attributeCount;attribute_index++) {
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue;
const xercesc::DOMAttr* const attribute = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attribute_name = xercesc::XMLString::transcode(attribute->getName());
const G4String attribute_value = xercesc::XMLString::transcode(attribute->getValue());
if (attribute_name=="x") x = attribute_value; else
if (attribute_name=="y") y = attribute_value; else
if (attribute_name=="z") z = attribute_value;
}
G4double _x = eval.Evaluate(x);
G4double _y = eval.Evaluate(y);
G4double _z = eval.Evaluate(z);
if (_x == 1.0 && _y == 0.0 && _z == 0.0) return kXAxis; else
if (_x == 0.0 && _y == 1.0 && _z == 0.0) return kYAxis; else
if (_x == 0.0 && _y == 0.0 && _z == 1.0) return kZAxis;
G4Exception("GDML: Only directions along axes are supported!");
return kZAxis;
}
void G4GDMLStructure::divisionvolRead(const xercesc::DOMElement* const element,G4LogicalVolume* pMother) {
G4String unit("1");
G4String axis;
G4String width;
G4String offset;
G4String number;
G4String volumeref;
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;attribute_index<attributeCount;attribute_index++) {
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue;
const xercesc::DOMAttr* const attribute = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attribute_name = xercesc::XMLString::transcode(attribute->getName());
const G4String attribute_value = xercesc::XMLString::transcode(attribute->getValue());
if (attribute_name=="unit") unit = attribute_value; else
if (attribute_name=="axis") axis = attribute_value; else
if (attribute_name=="width") width = attribute_value; else
if (attribute_name=="offset") offset = attribute_value; else
if (attribute_name=="number") number = attribute_value;
}
for (xercesc::DOMNode* iter = element->getFirstChild();iter != 0;iter = iter->getNextSibling()) {
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) continue;
const xercesc::DOMElement* const child = dynamic_cast<xercesc::DOMElement*>(iter);
const G4String tag = xercesc::XMLString::transcode(child->getTagName());
if (tag=="volumeref") volumeref = refRead(child);
}
G4LogicalVolume* pLogical = getVolume(GenerateName(volumeref));
G4double _unit = eval.Evaluate(unit);
G4double _width = eval.Evaluate(width)*_unit;
G4double _offset = eval.Evaluate(offset)*_unit;
G4double _number = eval.Evaluate(number);
EAxis _axis = kZAxis;
if (axis=="kXAxis") _axis = kXAxis; else
if (axis=="kYAxis") _axis = kYAxis; else
if (axis=="kZAxis") _axis = kZAxis; else
if (axis=="kRho") _axis = kRho; else
if (axis=="kPhi") _axis = kPhi;
new G4PVDivision("",pLogical,pMother,_axis,(G4int)_number,_width,_offset);
}
G4LogicalVolume* G4GDMLStructure::fileRead(const xercesc::DOMElement* const element) {
G4String name;
G4String volname;
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;attribute_index<attributeCount;attribute_index++) {
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue;
const xercesc::DOMAttr* const attribute = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attribute_name = xercesc::XMLString::transcode(attribute->getName());
const G4String attribute_value = xercesc::XMLString::transcode(attribute->getValue());
if (attribute_name=="name") name = attribute_value; else
if (attribute_name=="volname") volname = attribute_value;
}
G4GDMLStructure structure; // We create a new structure with a new evaluator
structure.Parse(name);
return structure.getVolume(structure.GenerateName(volname));
}
void G4GDMLStructure::loopRead(const xercesc::DOMElement* const element) {
G4String var;
G4String from;
G4String to;
G4String step;
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;attribute_index<attributeCount;attribute_index++) {
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue;
const xercesc::DOMAttr* const attribute = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attribute_name = xercesc::XMLString::transcode(attribute->getName());
const G4String attribute_value = xercesc::XMLString::transcode(attribute->getValue());
if (attribute_name=="var") var = attribute_value; else
if (attribute_name=="from") from = attribute_value; else
if (attribute_name=="to") to = attribute_value; else
if (attribute_name=="step") step = attribute_value;
}
eval.checkVariable(var);
G4int _var = eval.EvaluateInteger(var );
G4int _from = eval.EvaluateInteger(from);
G4int _to = eval.EvaluateInteger(to );
G4int _step = eval.EvaluateInteger(step);
if (!from.empty()) _var = _from;
while (_var <= _to) {
eval.setVariable(var,_var);
structureRead(element);
_var += _step;
}
}
void G4GDMLStructure::paramvolRead(const xercesc::DOMElement* const element,G4LogicalVolume *pMotherLogical) {
pMotherLogical = 0;
G4String volumeref;
G4String parameterised_position_size;
for (xercesc::DOMNode* iter = element->getFirstChild();iter != 0;iter = iter->getNextSibling()) {
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) continue;
const xercesc::DOMElement* const child = dynamic_cast<xercesc::DOMElement*>(iter);
const G4String tag = xercesc::XMLString::transcode(child->getTagName());
if (tag=="parameterised_position_size") { ; } else
if (tag=="volumeref") volumeref = refRead(child);
}
}
void G4GDMLStructure::physvolRead(const xercesc::DOMElement* const element,G4LogicalVolume *mother) {
G4String volumeref;
G4String positionref;
G4String rotationref;
G4String scaleref;
G4LogicalVolume* logvol = 0;
G4ThreeVector position;
G4ThreeVector rotation;
G4ThreeVector scale(1.0,1.0,1.0);
for (xercesc::DOMNode* iter = element->getFirstChild();iter != 0;iter = iter->getNextSibling()) {
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) continue;
const xercesc::DOMElement* const child = dynamic_cast<xercesc::DOMElement*>(iter);
const G4String tag = xercesc::XMLString::transcode(child->getTagName());
if (tag=="file") logvol = fileRead(child); else
if (tag=="volumeref") volumeref = refRead(child); else
if (tag=="position") position = positionRead(child); else
if (tag=="rotation") rotation = rotationRead(child); else
if (tag=="scale") scale = scaleRead(child); else
if (tag=="positionref") positionref = refRead(child); else
if (tag=="rotationref") rotationref = refRead(child); else
if (tag=="scaleref") scaleref = refRead(child);
}
if (!volumeref.empty()) logvol = getVolume(GenerateName(volumeref));
if (!positionref.empty()) position = *getPosition(GenerateName(positionref));
if (!rotationref.empty()) rotation = *getRotation(GenerateName(rotationref));
if (!scaleref.empty()) scale = *getScale(GenerateName(scaleref));
G4RotationMatrix Rot;
Rot.rotateX(rotation.x());
Rot.rotateY(rotation.y());
Rot.rotateZ(rotation.z());
G4Transform3D transform(Rot.inverse(),position);
transform = transform*G4Scale3D(scale.x(),scale.y(),scale.z());
G4ReflectionFactory::Instance()->Place(transform,"",logvol,mother,false,0);
}
G4double G4GDMLStructure::quantityRead(const xercesc::DOMElement* const element) {
G4String value;
G4String unit("1");
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;attribute_index<attributeCount;attribute_index++) {
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue;
const xercesc::DOMAttr* const attribute = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attribute_name = xercesc::XMLString::transcode(attribute->getName());
const G4String attribute_value = xercesc::XMLString::transcode(attribute->getValue());
if (attribute_name=="value") value = attribute_value;
if (attribute_name=="unit") unit = attribute_value;
}
return eval.Evaluate(value)*eval.Evaluate(unit);
}
G4String G4GDMLStructure::refRead(const xercesc::DOMElement* const element) {
G4String ref;
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;attribute_index<attributeCount;attribute_index++) {
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue;
const xercesc::DOMAttr* const attribute = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attribute_name = xercesc::XMLString::transcode(attribute->getName());
const G4String attribute_value = xercesc::XMLString::transcode(attribute->getValue());
if (attribute_name=="ref") ref = attribute_value;
}
return ref;
}
void G4GDMLStructure::replicate_along_axisRead(const xercesc::DOMElement* const element,G4double& _width,G4double& _offset,EAxis& _axis) {
for (xercesc::DOMNode* iter = element->getFirstChild();iter != 0;iter = iter->getNextSibling()) {
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) continue;
const xercesc::DOMElement* const child = dynamic_cast<xercesc::DOMElement*>(iter);
const G4String tag = xercesc::XMLString::transcode(child->getTagName());
if (tag=="width") _width = quantityRead(child); else
if (tag=="offset") _offset = quantityRead(child); else
if (tag=="direction") _axis = directionRead(child);
}
}
void G4GDMLStructure::replicavolRead(const xercesc::DOMElement* const element,G4LogicalVolume* pMother) {
G4String volumeref;
G4String numb;
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;attribute_index<attributeCount;attribute_index++) {
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue;
const xercesc::DOMAttr* const attribute = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attribute_name = xercesc::XMLString::transcode(attribute->getName());
const G4String attribute_value = xercesc::XMLString::transcode(attribute->getValue());
if (attribute_name=="numb") numb = attribute_value;
}
G4double _numb = eval.Evaluate(numb);
G4double _width = 0.0;
G4double _offset = 0.0;
EAxis _axis;
for (xercesc::DOMNode* iter = element->getFirstChild();iter != 0;iter = iter->getNextSibling()) {
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) continue;
const xercesc::DOMElement* const child = dynamic_cast<xercesc::DOMElement*>(iter);
const G4String tag = xercesc::XMLString::transcode(child->getTagName());
if (tag=="volumeref") volumeref = refRead(child); else
if (tag=="replicate_along_axis") replicate_along_axisRead(child,_width,_offset,_axis);
}
G4LogicalVolume* pLogical = getVolume(GenerateName(volumeref));
new G4PVReplica("",pLogical,pMother,_axis,(G4int)_numb,_width,_offset);
}
void G4GDMLStructure::volumeRead(const xercesc::DOMElement* const element) {
G4String name;
G4String solidref;
G4String materialref;
XMLCh *name_attr = xercesc::XMLString::transcode("name");
name = xercesc::XMLString::transcode(element->getAttribute(name_attr));
xercesc::XMLString::release(&name_attr);
for (xercesc::DOMNode* iter = element->getFirstChild();iter != 0;iter = iter->getNextSibling()) {
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) continue;
const xercesc::DOMElement* const child = dynamic_cast<xercesc::DOMElement*>(iter);
const G4String tag = xercesc::XMLString::transcode(child->getTagName());
if (tag=="materialref") materialref = refRead(child); else
if (tag=="solidref") solidref = refRead(child);
}
G4Material* materialPtr = getMaterial(GenerateName(materialref));
G4VSolid* solidPtr = getSolid(GenerateName(solidref));
volume_contentRead(element,new G4LogicalVolume(solidPtr,materialPtr,GenerateName(name),0,0,0));
}
void G4GDMLStructure::volume_contentRead(const xercesc::DOMElement* const element,G4LogicalVolume* volumePtr) {
for (xercesc::DOMNode* iter = element->getFirstChild();iter != 0;iter = iter->getNextSibling()) {
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) continue;
const xercesc::DOMElement* const child = dynamic_cast<xercesc::DOMElement*>(iter);
const G4String tag = xercesc::XMLString::transcode(child->getTagName());
if (tag=="loop") volume_loopRead(child,volumePtr); else
if (tag=="paramvol") paramvolRead(child,volumePtr); else
if (tag=="physvol") physvolRead(child,volumePtr); else
if (tag=="replicavol") replicavolRead(child,volumePtr); else
if (tag=="divisionvol") divisionvolRead(child,volumePtr);
}
}
void G4GDMLStructure::volume_loopRead(const xercesc::DOMElement* const element,G4LogicalVolume* volumePtr) {
G4String var;
G4String from;
G4String to;
G4String step;
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
XMLSize_t attributeCount = attributes->getLength();
for (XMLSize_t attribute_index=0;attribute_index<attributeCount;attribute_index++) {
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue;
const xercesc::DOMAttr* const attribute = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
const G4String attribute_name = xercesc::XMLString::transcode(attribute->getName());
const G4String attribute_value = xercesc::XMLString::transcode(attribute->getValue());
if (attribute_name=="var") var = attribute_value; else
if (attribute_name=="from") from = attribute_value; else
if (attribute_name=="to") to = attribute_value; else
if (attribute_name=="step") step = attribute_value;
}
eval.checkVariable(var);
G4int _var = eval.EvaluateInteger(var);
G4int _from = eval.EvaluateInteger(from);
G4int _to = eval.EvaluateInteger(to);
G4int _step = eval.EvaluateInteger(step);
if (!from.empty()) _var = _from;
while (_var <= _to) {
eval.setVariable(var,_var);
volume_contentRead(element,volumePtr);
_var += _step;
}
}
void G4GDMLStructure::structureRead(const xercesc::DOMElement* const element) {
for (xercesc::DOMNode* iter = element->getFirstChild();iter != 0;iter = iter->getNextSibling()) {
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) continue;
const xercesc::DOMElement* const child = dynamic_cast<xercesc::DOMElement*>(iter);
const G4String tag = xercesc::XMLString::transcode(child->getTagName());
if (tag=="loop") loopRead(child); else
if (tag=="volume") volumeRead(child); else
G4Exception("GDML: Unknown tag in structure: "+tag);
}
}
G4LogicalVolume* G4GDMLStructure::getVolume(const G4String& ref) const {
G4LogicalVolume *volumePtr = G4LogicalVolumeStore::GetInstance()->GetVolume(ref,false);
if (!volumePtr) G4Exception("GDML: Referenced volume '"+ref+"' was not found!");
return volumePtr;
}
+280
View File
@@ -0,0 +1,280 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4GDMLWrite.cc,v 1.50 2008/11/13 17:00:50 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
// class G4GDMLWrite Implementation
//
// Original author: Zoltan Torzsok, November 2007
//
// --------------------------------------------------------------------
#include "G4GDMLWrite.hh"
G4bool G4GDMLWrite::addPointerToName = true;
G4bool G4GDMLWrite::FileExists(const G4String& fname) const
{
struct stat FileInfo;
return (stat(fname.c_str(),&FileInfo) == 0);
}
G4GDMLWrite::VolumeMapType& G4GDMLWrite::VolumeMap()
{
static VolumeMapType instance;
return instance;
}
G4GDMLWrite::PhysVolumeMapType& G4GDMLWrite::PvolumeMap()
{
static PhysVolumeMapType instance;
return instance;
}
G4GDMLWrite::DepthMapType& G4GDMLWrite::DepthMap()
{
static DepthMapType instance;
return instance;
}
G4String G4GDMLWrite::GenerateName(const G4String& name, const void* const ptr)
{
std::stringstream stream; stream << name;
if (addPointerToName) { stream << ptr; }
return G4String(stream.str());
}
xercesc::DOMAttr* G4GDMLWrite::NewAttribute(const G4String& name,
const G4String& value)
{
xercesc::XMLString::transcode(name,tempStr,99);
xercesc::DOMAttr* att = doc->createAttribute(tempStr);
xercesc::XMLString::transcode(value,tempStr,99);
att->setValue(tempStr);
return att;
}
xercesc::DOMAttr* G4GDMLWrite::NewAttribute(const G4String& name,
const G4double& value)
{
xercesc::XMLString::transcode(name,tempStr,99);
xercesc::DOMAttr* att = doc->createAttribute(tempStr);
std::ostringstream ostream;
ostream.precision(15);
ostream << value;
G4String str = ostream.str();
xercesc::XMLString::transcode(str,tempStr,99);
att->setValue(tempStr);
return att;
}
xercesc::DOMElement* G4GDMLWrite::NewElement(const G4String& name)
{
xercesc::XMLString::transcode(name,tempStr,99);
return doc->createElement(tempStr);
}
G4Transform3D G4GDMLWrite::Write(const G4String& fname,
const G4LogicalVolume* const logvol,
const G4String& setSchemaLocation,
const G4int depth,
G4bool refs)
{
SchemaLocation = setSchemaLocation;
addPointerToName = refs;
if (depth==0) { G4cout << "G4GDML: Writing '" << fname << "'..." << G4endl; }
else { G4cout << "G4GDML: Writing module '" << fname << "'..." << G4endl; }
if (FileExists(fname))
{
G4String ErrorMessage = "File '"+fname+"' already exists!";
G4Exception("G4GDMLWrite::Write()", "InvalidSetup",
FatalException, ErrorMessage);
}
VolumeMap().clear(); // The module map is global for all modules,
// so clear it only at once!
xercesc::XMLString::transcode("LS", tempStr, 99);
xercesc::DOMImplementation* impl =
xercesc::DOMImplementationRegistry::getDOMImplementation(tempStr);
xercesc::XMLString::transcode("Range", tempStr, 99);
impl = xercesc::DOMImplementationRegistry::getDOMImplementation(tempStr);
xercesc::XMLString::transcode("gdml", tempStr, 99);
doc = impl->createDocument(0,tempStr,0);
xercesc::DOMElement* gdml = doc->getDocumentElement();
#if XERCES_VERSION_MAJOR >= 3
// DOM L3 as per Xerces 3.0 API
xercesc::DOMLSSerializer* writer =
((xercesc::DOMImplementationLS*)impl)->createLSSerializer();
xercesc::DOMConfiguration *dc = writer->getDomConfig();
dc->setParameter(xercesc::XMLUni::fgDOMWRTFormatPrettyPrint, true);
#else
xercesc::DOMWriter* writer =
((xercesc::DOMImplementationLS*)impl)->createDOMWriter();
if (writer->canSetFeature(xercesc::XMLUni::fgDOMWRTFormatPrettyPrint, true))
writer->setFeature(xercesc::XMLUni::fgDOMWRTFormatPrettyPrint, true);
#endif
gdml->setAttributeNode(NewAttribute("xmlns:xsi",
"http://www.w3.org/2001/XMLSchema-instance"));
gdml->setAttributeNode(NewAttribute("xsi:noNamespaceSchemaLocation",
SchemaLocation));
DefineWrite(gdml);
MaterialsWrite(gdml);
SolidsWrite(gdml);
StructureWrite(gdml);
SetupWrite(gdml,logvol);
G4Transform3D R = TraverseVolumeTree(logvol,depth);
xercesc::XMLFormatTarget *myFormTarget =
new xercesc::LocalFileFormatTarget(fname.c_str());
try
{
#if XERCES_VERSION_MAJOR >= 3
// DOM L3 as per Xerces 3.0 API
xercesc::DOMLSOutput *theOutput =
((xercesc::DOMImplementationLS*)impl)->createLSOutput();
theOutput->setByteStream(myFormTarget);
writer->write(doc, theOutput);
#else
writer->writeNode(myFormTarget, *doc);
#endif
}
catch (const xercesc::XMLException& toCatch)
{
char* message = xercesc::XMLString::transcode(toCatch.getMessage());
G4cout << "G4GDML: Exception message is: " << message << G4endl;
xercesc::XMLString::release(&message);
return G4Transform3D::Identity;
}
catch (const xercesc::DOMException& toCatch)
{
char* message = xercesc::XMLString::transcode(toCatch.msg);
G4cout << "G4GDML: Exception message is: " << message << G4endl;
xercesc::XMLString::release(&message);
return G4Transform3D::Identity;
}
catch (...)
{
G4cout << "G4GDML: Unexpected Exception!" << G4endl;
return G4Transform3D::Identity;
}
delete myFormTarget;
writer->release();
if (depth==0)
{
G4cout << "G4GDML: Writing '" << fname << "' done !" << G4endl;
}
else
{
G4cout << "G4GDML: Writing module '" << fname << "' done !" << G4endl;
}
return R;
}
void G4GDMLWrite::AddModule(const G4VPhysicalVolume* const physvol)
{
G4String fname = GenerateName(physvol->GetName(),physvol);
G4cout << "G4GDML: Adding module '" << fname << "'..." << G4endl;
if (physvol == 0)
{
G4Exception("G4GDMLWrite::AddModule()", "InvalidSetup", FatalException,
"Invalid NULL pointer is specified for modularization!");
}
if (dynamic_cast<const G4PVDivision*>(physvol))
{
G4Exception("G4GDMLWrite::AddModule()", "InvalidSetup", FatalException,
"It is not possible to modularize by divisionvol!");
}
if (physvol->IsParameterised())
{
G4Exception("G4GDMLWrite::AddModule()", "InvalidSetup", FatalException,
"It is not possible to modularize by parameterised volume!");
}
if (physvol->IsReplicated())
{
G4Exception("G4GDMLWrite::AddModule()", "InvalidSetup", FatalException,
"It is not possible to modularize by replicated volume!");
}
PvolumeMap()[physvol] = fname;
}
void G4GDMLWrite::AddModule(const G4int depth)
{
if (depth<0)
{
G4Exception("G4GDMLWrite::AddModule()", "InvalidSetup", FatalException,
"Depth must be a positive number!");
}
if (DepthMap().find(depth) != DepthMap().end())
{
G4Exception("G4GDMLWrite::AddModule()", "InvalidSetup", FatalException,
"Adding module(s) at this depth is already requested!");
}
DepthMap()[depth] = 0;
}
G4String G4GDMLWrite::Modularize( const G4VPhysicalVolume* const physvol,
const G4int depth )
{
if (PvolumeMap().find(physvol) != PvolumeMap().end())
{
return PvolumeMap()[physvol]; // Modularize via physvol
}
if (DepthMap().find(depth) != DepthMap().end()) // Modularize via depth
{
std::stringstream stream;
stream << "depth" << depth << "_module" << DepthMap()[depth] << ".gdml";
DepthMap()[depth]++; // There can be more modules at this depth!
return G4String(stream.str());
}
return G4String(""); // Empty string for module name = no modularization
// was requested at that level/physvol!
}
void G4GDMLWrite::SetAddPointerToName(G4bool set)
{
addPointerToName = set;
}
@@ -0,0 +1,123 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4GDMLWriteDefine.cc,v 1.18 2008/07/16 15:46:34 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
// class G4GDMLWriteDefine Implementation
//
// Original author: Zoltan Torzsok, November 2007
//
// --------------------------------------------------------------------
#include "G4GDMLWriteDefine.hh"
const G4double G4GDMLWriteDefine::kRelativePrecision = DBL_EPSILON;
const G4double G4GDMLWriteDefine::kAngularPrecision = DBL_EPSILON;
const G4double G4GDMLWriteDefine::kLinearPrecision = DBL_EPSILON;
G4ThreeVector G4GDMLWriteDefine::GetAngles(const G4RotationMatrix& mat)
{
G4double x,y,z;
const G4double cosb = std::sqrt(mat.xx()*mat.xx()+mat.yx()*mat.yx());
if (cosb > kRelativePrecision)
{
x = std::atan2(mat.zy(),mat.zz());
y = std::atan2(-mat.zx(),cosb);
z = std::atan2(mat.yx(),mat.xx());
}
else
{
x = std::atan2(-mat.yz(),mat.yy());
y = std::atan2(-mat.zx(),cosb);
z = 0.0;
}
return G4ThreeVector(x,y,z);
}
void G4GDMLWriteDefine::
Scale_vectorWrite(xercesc::DOMElement* element, const G4String& tag,
const G4String& name, const G4ThreeVector& scl)
{
const G4double x = (std::fabs(scl.x()-1.0) < kRelativePrecision)
? 1.0 : scl.x();
const G4double y = (std::fabs(scl.y()-1.0) < kRelativePrecision)
? 1.0 : scl.y();
const G4double z = (std::fabs(scl.z()-1.0) < kRelativePrecision)
? 1.0 : scl.z();
xercesc::DOMElement* scaleElement = NewElement(tag);
scaleElement->setAttributeNode(NewAttribute("name",name));
scaleElement->setAttributeNode(NewAttribute("x",x));
scaleElement->setAttributeNode(NewAttribute("y",y));
scaleElement->setAttributeNode(NewAttribute("z",z));
element->appendChild(scaleElement);
}
void G4GDMLWriteDefine::
Rotation_vectorWrite(xercesc::DOMElement* element, const G4String& tag,
const G4String& name, const G4ThreeVector& rot)
{
const G4double x = (std::fabs(rot.x()) < kAngularPrecision) ? 0.0 : rot.x();
const G4double y = (std::fabs(rot.y()) < kAngularPrecision) ? 0.0 : rot.y();
const G4double z = (std::fabs(rot.z()) < kAngularPrecision) ? 0.0 : rot.z();
xercesc::DOMElement* rotationElement = NewElement(tag);
rotationElement->setAttributeNode(NewAttribute("name",name));
rotationElement->setAttributeNode(NewAttribute("x",x/degree));
rotationElement->setAttributeNode(NewAttribute("y",y/degree));
rotationElement->setAttributeNode(NewAttribute("z",z/degree));
rotationElement->setAttributeNode(NewAttribute("unit","deg"));
element->appendChild(rotationElement);
}
void G4GDMLWriteDefine::
Position_vectorWrite(xercesc::DOMElement* element, const G4String& tag,
const G4String& name, const G4ThreeVector& pos)
{
const G4double x = (std::fabs(pos.x()) < kLinearPrecision) ? 0.0 : pos.x();
const G4double y = (std::fabs(pos.y()) < kLinearPrecision) ? 0.0 : pos.y();
const G4double z = (std::fabs(pos.z()) < kLinearPrecision) ? 0.0 : pos.z();
xercesc::DOMElement* positionElement = NewElement(tag);
positionElement->setAttributeNode(NewAttribute("name",name));
positionElement->setAttributeNode(NewAttribute("x",x/mm));
positionElement->setAttributeNode(NewAttribute("y",y/mm));
positionElement->setAttributeNode(NewAttribute("z",z/mm));
positionElement->setAttributeNode(NewAttribute("unit","mm"));
element->appendChild(positionElement);
}
void G4GDMLWriteDefine::DefineWrite(xercesc::DOMElement* element)
{
G4cout << "G4GDML: Writing definitions..." << G4endl;
defineElement = NewElement("define");
element->appendChild(defineElement);
}
@@ -0,0 +1,211 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4GDMLWriteMaterials.cc,v 1.20 2008/07/16 15:46:34 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
// class G4GDMLWriteMaterials Implementation
//
// Original author: Zoltan Torzsok, November 2007
//
// --------------------------------------------------------------------
#include "G4GDMLWriteMaterials.hh"
void G4GDMLWriteMaterials::
AtomWrite(xercesc::DOMElement* element,const G4double& a)
{
xercesc::DOMElement* atomElement = NewElement("atom");
atomElement->setAttributeNode(NewAttribute("unit","g/mole"));
atomElement->setAttributeNode(NewAttribute("value",a*mole/g));
element->appendChild(atomElement);
}
void G4GDMLWriteMaterials::
DWrite(xercesc::DOMElement* element,const G4double& d)
{
xercesc::DOMElement* DElement = NewElement("D");
DElement->setAttributeNode(NewAttribute("unit","g/cm3"));
DElement->setAttributeNode(NewAttribute("value",d*cm3/g));
element->appendChild(DElement);
}
void G4GDMLWriteMaterials::
PWrite(xercesc::DOMElement* element,const G4double& P)
{
xercesc::DOMElement* PElement = NewElement("P");
PElement->setAttributeNode(NewAttribute("unit","pascal"));
PElement->setAttributeNode(NewAttribute("value",P/pascal));
element->appendChild(PElement);
}
void G4GDMLWriteMaterials::
TWrite(xercesc::DOMElement* element,const G4double& T)
{
xercesc::DOMElement* TElement = NewElement("T");
TElement->setAttributeNode(NewAttribute("unit","K"));
TElement->setAttributeNode(NewAttribute("value",T/kelvin));
element->appendChild(TElement);
}
void G4GDMLWriteMaterials::
IsotopeWrite(const G4Isotope* const isotopePtr)
{
const G4String name = GenerateName(isotopePtr->GetName(),isotopePtr);
xercesc::DOMElement* isotopeElement = NewElement("isotope");
isotopeElement->setAttributeNode(NewAttribute("name",name));
isotopeElement->setAttributeNode(NewAttribute("N",isotopePtr->GetN()));
isotopeElement->setAttributeNode(NewAttribute("Z",isotopePtr->GetZ()));
materialsElement->appendChild(isotopeElement);
AtomWrite(isotopeElement,isotopePtr->GetA());
}
void G4GDMLWriteMaterials::ElementWrite(const G4Element* const elementPtr)
{
const G4String name = GenerateName(elementPtr->GetName(),elementPtr);
xercesc::DOMElement* elementElement = NewElement("element");
elementElement->setAttributeNode(NewAttribute("name",name));
const size_t NumberOfIsotopes = elementPtr->GetNumberOfIsotopes();
if (NumberOfIsotopes>0)
{
const G4double* RelativeAbundanceVector =
elementPtr->GetRelativeAbundanceVector();
for (size_t i=0;i<NumberOfIsotopes;i++)
{
G4String fractionref = GenerateName(elementPtr->GetIsotope(i)->GetName(),
elementPtr->GetIsotope(i));
xercesc::DOMElement* fractionElement = NewElement("fraction");
fractionElement->setAttributeNode(NewAttribute("n",
RelativeAbundanceVector[i]));
fractionElement->setAttributeNode(NewAttribute("ref",fractionref));
elementElement->appendChild(fractionElement);
AddIsotope(elementPtr->GetIsotope(i));
}
}
else
{
elementElement->setAttributeNode(NewAttribute("Z",elementPtr->GetZ()));
AtomWrite(elementElement,elementPtr->GetA());
}
materialsElement->appendChild(elementElement);
// Append the element AFTER all the possible components are appended!
}
void G4GDMLWriteMaterials::MaterialWrite(const G4Material* const materialPtr)
{
G4String state_str("undefined");
const G4State state = materialPtr->GetState();
if (state==kStateSolid) { state_str = "solid"; } else
if (state==kStateLiquid) { state_str = "liquid"; } else
if (state==kStateGas) { state_str = "gas"; }
const G4String name = GenerateName(materialPtr->GetName(), materialPtr);
xercesc::DOMElement* materialElement = NewElement("material");
materialElement->setAttributeNode(NewAttribute("name",name));
materialElement->setAttributeNode(NewAttribute("state",state_str));
if (materialPtr->GetTemperature() != STP_Temperature)
{ TWrite(materialElement,materialPtr->GetTemperature()); }
if (materialPtr->GetPressure() != STP_Pressure)
{ PWrite(materialElement,materialPtr->GetPressure()); }
DWrite(materialElement,materialPtr->GetDensity());
const size_t NumberOfElements = materialPtr->GetNumberOfElements();
if (NumberOfElements>1)
{
const G4double* MassFractionVector = materialPtr->GetFractionVector();
for (size_t i=0;i<NumberOfElements;i++)
{
const G4String fractionref =
GenerateName(materialPtr->GetElement(i)->GetName(),
materialPtr->GetElement(i));
xercesc::DOMElement* fractionElement = NewElement("fraction");
fractionElement->setAttributeNode(NewAttribute("n",
MassFractionVector[i]));
fractionElement->setAttributeNode(NewAttribute("ref",fractionref));
materialElement->appendChild(fractionElement);
AddElement(materialPtr->GetElement(i));
}
}
else
{
materialElement->setAttributeNode(NewAttribute("Z",materialPtr->GetZ()));
AtomWrite(materialElement,materialPtr->GetA());
}
materialsElement->appendChild(materialElement);
// Append the material AFTER all the possible components are appended!
}
void G4GDMLWriteMaterials::MaterialsWrite(xercesc::DOMElement* element)
{
G4cout << "G4GDML: Writing materials..." << G4endl;
materialsElement = NewElement("materials");
element->appendChild(materialsElement);
isotopeList.clear();
elementList.clear();
materialList.clear();
}
void G4GDMLWriteMaterials::AddIsotope(const G4Isotope* const isotopePtr)
{
for (size_t i=0; i<isotopeList.size(); i++) // Check if isotope is
{ // already in the list!
if (isotopeList[i] == isotopePtr) { return; }
}
isotopeList.push_back(isotopePtr);
IsotopeWrite(isotopePtr);
}
void G4GDMLWriteMaterials::AddElement(const G4Element* const elementPtr)
{
for (size_t i=0;i<elementList.size();i++) // Check if element is
{ // already in the list!
if (elementList[i] == elementPtr) { return; }
}
elementList.push_back(elementPtr);
ElementWrite(elementPtr);
}
void G4GDMLWriteMaterials::AddMaterial(const G4Material* const materialPtr)
{
for (size_t i=0;i<materialList.size();i++) // Check if material is
{ // already in the list!
if (materialList[i] == materialPtr) { return; }
}
materialList.push_back(materialPtr);
MaterialWrite(materialPtr);
}
@@ -0,0 +1,406 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4GDMLWriteParamvol.cc,v 1.23 2008/08/20 08:56:32 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
// class G4GDMLParamVol Implementation
//
// Original author: Zoltan Torzsok, November 2007
//
// --------------------------------------------------------------------
#include "G4GDMLWriteParamvol.hh"
#include <sstream>
void G4GDMLWriteParamvol::
Box_dimensionsWrite(xercesc::DOMElement* parametersElement,
const G4Box* const box)
{
xercesc::DOMElement* box_dimensionsElement = NewElement("box_dimensions");
box_dimensionsElement->
setAttributeNode(NewAttribute("x",2.0*box->GetXHalfLength()/mm));
box_dimensionsElement->
setAttributeNode(NewAttribute("y",2.0*box->GetYHalfLength()/mm));
box_dimensionsElement->
setAttributeNode(NewAttribute("z",2.0*box->GetZHalfLength()/mm));
box_dimensionsElement->
setAttributeNode(NewAttribute("lunit","mm"));
parametersElement->appendChild(box_dimensionsElement);
}
void G4GDMLWriteParamvol::
Trd_dimensionsWrite(xercesc::DOMElement* parametersElement,
const G4Trd* const trd)
{
xercesc::DOMElement* trd_dimensionsElement = NewElement("trd_dimensions");
trd_dimensionsElement->
setAttributeNode(NewAttribute("x1",2.0*trd->GetXHalfLength1()/mm));
trd_dimensionsElement->
setAttributeNode(NewAttribute("x2",2.0*trd->GetXHalfLength2()/mm));
trd_dimensionsElement->
setAttributeNode(NewAttribute("y1",2.0*trd->GetYHalfLength1()/mm));
trd_dimensionsElement->
setAttributeNode(NewAttribute("y2",2.0*trd->GetYHalfLength2()/mm));
trd_dimensionsElement->
setAttributeNode(NewAttribute("z",2.0*trd->GetZHalfLength()/mm));
trd_dimensionsElement->
setAttributeNode(NewAttribute("lunit","mm"));
parametersElement->appendChild(trd_dimensionsElement);
}
void G4GDMLWriteParamvol::
Trap_dimensionsWrite(xercesc::DOMElement* parametersElement,
const G4Trap* const trap)
{
const G4ThreeVector simaxis = trap->GetSymAxis();
const G4double phi = (simaxis.z() != 1.0)
? (std::atan(simaxis.y()/simaxis.x())) : (0.0);
const G4double theta = std::acos(simaxis.z());
const G4double alpha1 = std::atan(trap->GetTanAlpha1());
const G4double alpha2 = std::atan(trap->GetTanAlpha2());
xercesc::DOMElement* trap_dimensionsElement = NewElement("trap");
trap_dimensionsElement->
setAttributeNode(NewAttribute("z",2.0*trap->GetZHalfLength()/mm));
trap_dimensionsElement->
setAttributeNode(NewAttribute("theta",theta/degree));
trap_dimensionsElement->
setAttributeNode(NewAttribute("phi",phi/degree));
trap_dimensionsElement->
setAttributeNode(NewAttribute("y1",2.0*trap->GetYHalfLength1()/mm));
trap_dimensionsElement->
setAttributeNode(NewAttribute("x1",2.0*trap->GetXHalfLength1()/mm));
trap_dimensionsElement->
setAttributeNode(NewAttribute("x2",2.0*trap->GetXHalfLength2()/mm));
trap_dimensionsElement->
setAttributeNode(NewAttribute("alpha1",alpha1/degree));
trap_dimensionsElement->
setAttributeNode(NewAttribute("y2",2.0*trap->GetYHalfLength2()/mm));
trap_dimensionsElement->
setAttributeNode(NewAttribute("x3",2.0*trap->GetXHalfLength3()/mm));
trap_dimensionsElement->
setAttributeNode(NewAttribute("x4",2.0*trap->GetXHalfLength4()/mm));
trap_dimensionsElement->
setAttributeNode(NewAttribute("alpha2",alpha2/degree));
trap_dimensionsElement->
setAttributeNode(NewAttribute("aunit","deg"));
trap_dimensionsElement->
setAttributeNode(NewAttribute("lunit","mm"));
parametersElement->appendChild(trap_dimensionsElement);
}
void G4GDMLWriteParamvol::
Tube_dimensionsWrite(xercesc::DOMElement* parametersElement,
const G4Tubs* const tube)
{
xercesc::DOMElement* tube_dimensionsElement = NewElement("tube_dimensions");
tube_dimensionsElement->
setAttributeNode(NewAttribute("InR",tube->GetInnerRadius()/mm));
tube_dimensionsElement->
setAttributeNode(NewAttribute("OutR",tube->GetOuterRadius()/mm));
tube_dimensionsElement->
setAttributeNode(NewAttribute("hz",2.0*tube->GetZHalfLength()/mm));
tube_dimensionsElement->
setAttributeNode(NewAttribute("StartPhi",tube->GetStartPhiAngle()/degree));
tube_dimensionsElement->
setAttributeNode(NewAttribute("DeltaPhi",tube->GetDeltaPhiAngle()/degree));
tube_dimensionsElement->
setAttributeNode(NewAttribute("aunit","deg"));
tube_dimensionsElement->
setAttributeNode(NewAttribute("lunit","mm"));
parametersElement->appendChild(tube_dimensionsElement);
}
void G4GDMLWriteParamvol::
Cone_dimensionsWrite(xercesc::DOMElement* parametersElement,
const G4Cons* const cone)
{
xercesc::DOMElement* cone_dimensionsElement = NewElement("cone_dimensions");
cone_dimensionsElement->
setAttributeNode(NewAttribute("rmin1",cone->GetInnerRadiusMinusZ()/mm));
cone_dimensionsElement->
setAttributeNode(NewAttribute("rmax1",cone->GetOuterRadiusMinusZ()/mm));
cone_dimensionsElement->
setAttributeNode(NewAttribute("rmin2",cone->GetInnerRadiusPlusZ()/mm));
cone_dimensionsElement->
setAttributeNode(NewAttribute("rmax2",cone->GetOuterRadiusPlusZ()/mm));
cone_dimensionsElement->
setAttributeNode(NewAttribute("z",2.0*cone->GetZHalfLength()/mm));
cone_dimensionsElement->
setAttributeNode(NewAttribute("startphi",cone->GetStartPhiAngle()/degree));
cone_dimensionsElement->
setAttributeNode(NewAttribute("deltaphi",cone->GetDeltaPhiAngle()/degree));
cone_dimensionsElement->
setAttributeNode(NewAttribute("aunit","deg"));
cone_dimensionsElement->
setAttributeNode(NewAttribute("lunit","mm"));
parametersElement->appendChild(cone_dimensionsElement);
}
void G4GDMLWriteParamvol::
Sphere_dimensionsWrite(xercesc::DOMElement* parametersElement,
const G4Sphere* const sphere)
{
xercesc::DOMElement* sphere_dimensionsElement =
NewElement("sphere_dimensions");
sphere_dimensionsElement->setAttributeNode(NewAttribute("rmin",
sphere->GetInsideRadius()/mm));
sphere_dimensionsElement->setAttributeNode(NewAttribute("rmax",
sphere->GetOuterRadius()/mm));
sphere_dimensionsElement->setAttributeNode(NewAttribute("startphi",
sphere->GetStartPhiAngle()/degree));
sphere_dimensionsElement->setAttributeNode(NewAttribute("deltaphi",
sphere->GetDeltaPhiAngle()/degree));
sphere_dimensionsElement->setAttributeNode(NewAttribute("starttheta",
sphere->GetStartThetaAngle()/degree));
sphere_dimensionsElement->setAttributeNode(NewAttribute("deltatheta",
sphere->GetDeltaThetaAngle()/degree));
sphere_dimensionsElement->setAttributeNode(NewAttribute("aunit","deg"));
sphere_dimensionsElement->setAttributeNode(NewAttribute("lunit","mm"));
parametersElement->appendChild(sphere_dimensionsElement);
}
void G4GDMLWriteParamvol::
Orb_dimensionsWrite(xercesc::DOMElement* parametersElement,
const G4Orb* const orb)
{
xercesc::DOMElement* orb_dimensionsElement = NewElement("orb_dimensions");
orb_dimensionsElement->setAttributeNode(NewAttribute("r",
orb->GetRadius()/mm));
orb_dimensionsElement->setAttributeNode(NewAttribute("lunit","mm"));
parametersElement->appendChild(orb_dimensionsElement);
}
void G4GDMLWriteParamvol::
Torus_dimensionsWrite(xercesc::DOMElement* parametersElement,
const G4Torus* const torus)
{
xercesc::DOMElement* torus_dimensionsElement =
NewElement("torus_dimensions");
torus_dimensionsElement->
setAttributeNode(NewAttribute("rmin",torus->GetRmin()/mm));
torus_dimensionsElement->
setAttributeNode(NewAttribute("rmax",torus->GetRmax()/mm));
torus_dimensionsElement->
setAttributeNode(NewAttribute("rtor",torus->GetRtor()/mm));
torus_dimensionsElement->
setAttributeNode(NewAttribute("startphi",torus->GetSPhi()/degree));
torus_dimensionsElement->
setAttributeNode(NewAttribute("deltaphi",torus->GetDPhi()/degree));
torus_dimensionsElement->
setAttributeNode(NewAttribute("aunit","deg"));
torus_dimensionsElement->
setAttributeNode(NewAttribute("lunit","mm"));
parametersElement->appendChild(torus_dimensionsElement);
}
void G4GDMLWriteParamvol::
Para_dimensionsWrite(xercesc::DOMElement* parametersElement,
const G4Para* const para)
{
const G4ThreeVector simaxis = para->GetSymAxis();
const G4double alpha = std::atan(para->GetTanAlpha());
const G4double theta = std::acos(simaxis.z());
const G4double phi = (simaxis.z() != 1.0)
? (std::atan(simaxis.y()/simaxis.x())) : (0.0);
xercesc::DOMElement* para_dimensionsElement = NewElement("para_dimensions");
para_dimensionsElement->
setAttributeNode(NewAttribute("x",2.0*para->GetXHalfLength()/mm));
para_dimensionsElement->
setAttributeNode(NewAttribute("y",2.0*para->GetYHalfLength()/mm));
para_dimensionsElement->
setAttributeNode(NewAttribute("z",2.0*para->GetZHalfLength()/mm));
para_dimensionsElement->
setAttributeNode(NewAttribute("alpha",alpha/degree));
para_dimensionsElement->
setAttributeNode(NewAttribute("theta",theta/degree));
para_dimensionsElement->
setAttributeNode(NewAttribute("phi",phi/degree));
para_dimensionsElement->
setAttributeNode(NewAttribute("aunit","deg"));
para_dimensionsElement->
setAttributeNode(NewAttribute("lunit","mm"));
parametersElement->appendChild(para_dimensionsElement);
}
void G4GDMLWriteParamvol::
Hype_dimensionsWrite(xercesc::DOMElement* parametersElement,
const G4Hype* const hype)
{
xercesc::DOMElement* hype_dimensionsElement = NewElement("hype_dimensions");
hype_dimensionsElement->
setAttributeNode(NewAttribute("rmin",hype->GetInnerRadius()/mm));
hype_dimensionsElement->
setAttributeNode(NewAttribute("rmax",hype->GetOuterRadius()/mm));
hype_dimensionsElement->
setAttributeNode(NewAttribute("inst",hype->GetInnerStereo()/degree));
hype_dimensionsElement->
setAttributeNode(NewAttribute("outst",hype->GetOuterStereo()/degree));
hype_dimensionsElement->
setAttributeNode(NewAttribute("z",2.0*hype->GetZHalfLength()/mm));
hype_dimensionsElement->
setAttributeNode(NewAttribute("aunit","deg"));
hype_dimensionsElement->
setAttributeNode(NewAttribute("lunit","mm"));
parametersElement->appendChild(hype_dimensionsElement);
}
void G4GDMLWriteParamvol::
ParametersWrite(xercesc::DOMElement* paramvolElement,
const G4VPhysicalVolume* const paramvol,const G4int& index)
{
paramvol->GetParameterisation()
->ComputeTransformation(index, const_cast<G4VPhysicalVolume*>(paramvol));
G4ThreeVector Angles;
G4String name = GenerateName(paramvol->GetName(),paramvol);
std::stringstream os;
os.precision(15);
os << index;
G4String sncopie = os.str();
xercesc::DOMElement* parametersElement = NewElement("parameters");
parametersElement->setAttributeNode(NewAttribute("number",index+1));
PositionWrite(parametersElement, name+sncopie+"_pos",
paramvol->GetObjectTranslation());
Angles=GetAngles(paramvol->GetObjectRotationValue());
if (Angles.mag2()>DBL_EPSILON)
{
RotationWrite(parametersElement, name+sncopie+"_rot",
GetAngles(paramvol->GetObjectRotationValue()));
}
paramvolElement->appendChild(parametersElement);
G4VSolid* solid = paramvol->GetLogicalVolume()->GetSolid();
if (G4Box* box = dynamic_cast<G4Box*>(solid))
{
paramvol->GetParameterisation()->ComputeDimensions(*box,index,
const_cast<G4VPhysicalVolume*>(paramvol));
Box_dimensionsWrite(parametersElement,box);
} else
if (G4Trd* trd = dynamic_cast<G4Trd*>(solid))
{
paramvol->GetParameterisation()->ComputeDimensions(*trd,index,
const_cast<G4VPhysicalVolume*>(paramvol));
Trd_dimensionsWrite(parametersElement,trd);
} else
if (G4Trap* trap = dynamic_cast<G4Trap*>(solid))
{
paramvol->GetParameterisation()->ComputeDimensions(*trap,index,
const_cast<G4VPhysicalVolume*>(paramvol));
Trap_dimensionsWrite(parametersElement,trap);
} else
if (G4Tubs* tube = dynamic_cast<G4Tubs*>(solid))
{
paramvol->GetParameterisation()->ComputeDimensions(*tube,index,
const_cast<G4VPhysicalVolume*>(paramvol));
Tube_dimensionsWrite(parametersElement,tube);
} else
if (G4Cons* cone = dynamic_cast<G4Cons*>(solid))
{
paramvol->GetParameterisation()->ComputeDimensions(*cone,index,
const_cast<G4VPhysicalVolume*>(paramvol));
Cone_dimensionsWrite(parametersElement,cone);
} else
if (G4Sphere* sphere = dynamic_cast<G4Sphere*>(solid))
{
paramvol->GetParameterisation()->ComputeDimensions(*sphere,index,
const_cast<G4VPhysicalVolume*>(paramvol));
Sphere_dimensionsWrite(parametersElement,sphere);
} else
if (G4Orb* orb = dynamic_cast<G4Orb*>(solid))
{
paramvol->GetParameterisation()->ComputeDimensions(*orb,index,
const_cast<G4VPhysicalVolume*>(paramvol));
Orb_dimensionsWrite(parametersElement,orb);
} else
if (G4Torus* torus = dynamic_cast<G4Torus*>(solid))
{
paramvol->GetParameterisation()->ComputeDimensions(*torus,index,
const_cast<G4VPhysicalVolume*>(paramvol));
Torus_dimensionsWrite(parametersElement,torus);
} else
if (G4Para* para = dynamic_cast<G4Para*>(solid))
{
paramvol->GetParameterisation()->ComputeDimensions(*para,index,
const_cast<G4VPhysicalVolume*>(paramvol));
Para_dimensionsWrite(parametersElement,para);
} else
if (G4Hype* hype = dynamic_cast<G4Hype*>(solid))
{
paramvol->GetParameterisation()->ComputeDimensions(*hype,index,
const_cast<G4VPhysicalVolume*>(paramvol));
Hype_dimensionsWrite(parametersElement,hype);
}
else
{
G4String error_msg = "Solid '" + solid->GetName()
+ "' cannot be used in parameterised volume!";
G4Exception("G4GDMLWriteParamvol::ParametersWrite()",
"InvalidSetup", FatalException, error_msg);
}
}
void G4GDMLWriteParamvol::
ParamvolWrite(xercesc::DOMElement* volumeElement,
const G4VPhysicalVolume* const paramvol)
{
const G4String volumeref =
GenerateName(paramvol->GetLogicalVolume()->GetName(),
paramvol->GetLogicalVolume());
xercesc::DOMElement* paramvolElement = NewElement("paramvol");
paramvolElement->setAttributeNode(NewAttribute("ncopies",
paramvol->GetMultiplicity()));
xercesc::DOMElement* volumerefElement = NewElement("volumeref");
volumerefElement->setAttributeNode(NewAttribute("ref",volumeref));
xercesc::DOMElement* algorithmElement =
NewElement("parameterised_position_size");
paramvolElement->appendChild(volumerefElement);
paramvolElement->appendChild(algorithmElement);
ParamvolAlgorithmWrite(algorithmElement,paramvol);
volumeElement->appendChild(paramvolElement);
}
void G4GDMLWriteParamvol::
ParamvolAlgorithmWrite(xercesc::DOMElement* paramvolElement,
const G4VPhysicalVolume* const paramvol)
{
const G4String volumeref =
GenerateName(paramvol->GetLogicalVolume()->GetName(),
paramvol->GetLogicalVolume());
const G4int parameterCount = paramvol->GetMultiplicity();
for (G4int i=0; i<parameterCount; i++)
{
ParametersWrite(paramvolElement,paramvol,i);
}
}
@@ -0,0 +1,52 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4GDMLWriteSetup.cc,v 1.11 2008/07/16 15:46:34 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
// class G4GDMLWriteSetup Implementation
//
// Original author: Zoltan Torzsok, November 2007
//
// --------------------------------------------------------------------
#include "G4GDMLWriteSetup.hh"
void G4GDMLWriteSetup::SetupWrite(xercesc::DOMElement* gdmlElement,
const G4LogicalVolume* const logvol)
{
G4cout << "G4GDML: Writing setup..." << G4endl;
const G4String worldref = GenerateName(logvol->GetName(),logvol);
xercesc::DOMElement* setupElement = NewElement("setup");
setupElement->setAttributeNode(NewAttribute("version","1.0"));
setupElement->setAttributeNode(NewAttribute("name","Default"));
xercesc::DOMElement* worldElement = NewElement("world");
worldElement->setAttributeNode(NewAttribute("ref",worldref));
setupElement->appendChild(worldElement);
gdmlElement->appendChild(setupElement);
}
@@ -0,0 +1,828 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4GDMLWriteSolids.cc,v 1.59 2008/11/21 09:32:46 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
// class G4GDMLWriteSolids Implementation
//
// Original author: Zoltan Torzsok, November 2007
//
// --------------------------------------------------------------------
#include "G4GDMLWriteSolids.hh"
void G4GDMLWriteSolids::
BooleanWrite(xercesc::DOMElement* solidsElement,
const G4BooleanSolid* const boolean)
{
G4String tag("undefined");
if (dynamic_cast<const G4IntersectionSolid*>(boolean))
{ tag = "intersection"; } else
if (dynamic_cast<const G4SubtractionSolid*>(boolean))
{ tag = "subtraction"; } else
if (dynamic_cast<const G4UnionSolid*>(boolean))
{ tag = "union"; }
G4VSolid* firstPtr = const_cast<G4VSolid*>(boolean->GetConstituentSolid(0));
G4VSolid* secondPtr = const_cast<G4VSolid*>(boolean->GetConstituentSolid(1));
G4ThreeVector firstpos,firstrot,pos,rot;
if (const G4DisplacedSolid* disp
= dynamic_cast<const G4DisplacedSolid*>(firstPtr))
{
firstpos = disp->GetObjectTranslation();
firstrot = GetAngles(disp->GetObjectRotation());
firstPtr = disp->GetConstituentMovedSolid();
}
if (const G4DisplacedSolid* disp
= dynamic_cast<const G4DisplacedSolid*>(secondPtr))
{
pos = disp->GetObjectTranslation();
rot = GetAngles(disp->GetObjectRotation());
secondPtr = disp->GetConstituentMovedSolid();
}
AddSolid(firstPtr); // At first add the constituent solids!
AddSolid(secondPtr);
const G4String& name = GenerateName(boolean->GetName(),boolean);
const G4String& firstref = GenerateName(firstPtr->GetName(),firstPtr);
const G4String& secondref = GenerateName(secondPtr->GetName(),secondPtr);
xercesc::DOMElement* booleanElement = NewElement(tag);
booleanElement->setAttributeNode(NewAttribute("name",name));
xercesc::DOMElement* firstElement = NewElement("first");
firstElement->setAttributeNode(NewAttribute("ref",firstref));
booleanElement->appendChild(firstElement);
xercesc::DOMElement* secondElement = NewElement("second");
secondElement->setAttributeNode(NewAttribute("ref",secondref));
booleanElement->appendChild(secondElement);
solidsElement->appendChild(booleanElement);
// Add the boolean solid AFTER the constituent solids!
if ( (std::fabs(pos.x()) > kLinearPrecision)
|| (std::fabs(pos.y()) > kLinearPrecision)
|| (std::fabs(pos.z()) > kLinearPrecision) )
{
PositionWrite(booleanElement,name+"_pos",pos);
}
if ( (std::fabs(rot.x()) > kAngularPrecision)
|| (std::fabs(rot.y()) > kAngularPrecision)
|| (std::fabs(rot.z()) > kAngularPrecision) )
{
RotationWrite(booleanElement,name+"_rot",rot);
}
if ( (std::fabs(firstpos.x()) > kLinearPrecision)
|| (std::fabs(firstpos.y()) > kLinearPrecision)
|| (std::fabs(firstpos.z()) > kLinearPrecision) )
{
FirstpositionWrite(booleanElement,name+"_fpos",firstpos);
}
if ( (std::fabs(firstrot.x()) > kAngularPrecision)
|| (std::fabs(firstrot.y()) > kAngularPrecision)
|| (std::fabs(firstrot.z()) > kAngularPrecision) )
{
FirstrotationWrite(booleanElement,name+"_frot",firstrot);
}
}
void G4GDMLWriteSolids::
BoxWrite(xercesc::DOMElement* solidsElement, const G4Box* const box)
{
const G4String& name = GenerateName(box->GetName(),box);
xercesc::DOMElement* boxElement = NewElement("box");
boxElement->setAttributeNode(NewAttribute("name",name));
boxElement->setAttributeNode(NewAttribute("x",2.0*box->GetXHalfLength()/mm));
boxElement->setAttributeNode(NewAttribute("y",2.0*box->GetYHalfLength()/mm));
boxElement->setAttributeNode(NewAttribute("z",2.0*box->GetZHalfLength()/mm));
boxElement->setAttributeNode(NewAttribute("lunit","mm"));
solidsElement->appendChild(boxElement);
}
void G4GDMLWriteSolids::
ConeWrite(xercesc::DOMElement* solidsElement, const G4Cons* const cone)
{
const G4String& name = GenerateName(cone->GetName(),cone);
xercesc::DOMElement* coneElement = NewElement("cone");
coneElement->setAttributeNode(NewAttribute("name",name));
coneElement->
setAttributeNode(NewAttribute("rmin1",cone->GetInnerRadiusMinusZ()/mm));
coneElement->
setAttributeNode(NewAttribute("rmax1",cone->GetOuterRadiusMinusZ()/mm));
coneElement->
setAttributeNode(NewAttribute("rmin2",cone->GetInnerRadiusPlusZ()/mm));
coneElement->
setAttributeNode(NewAttribute("rmax2",cone->GetOuterRadiusPlusZ()/mm));
coneElement->
setAttributeNode(NewAttribute("z",2.0*cone->GetZHalfLength()/mm));
coneElement->
setAttributeNode(NewAttribute("startphi",cone->GetStartPhiAngle()/degree));
coneElement->
setAttributeNode(NewAttribute("deltaphi",cone->GetDeltaPhiAngle()/degree));
coneElement->setAttributeNode(NewAttribute("aunit","deg"));
coneElement->setAttributeNode(NewAttribute("lunit","mm"));
solidsElement->appendChild(coneElement);
}
void G4GDMLWriteSolids::
ElconeWrite(xercesc::DOMElement* solidsElement,
const G4EllipticalCone* const elcone)
{
const G4String& name = GenerateName(elcone->GetName(),elcone);
xercesc::DOMElement* elconeElement = NewElement("elcone");
elconeElement->setAttributeNode(NewAttribute("name",name));
elconeElement->setAttributeNode(NewAttribute("dx",elcone->GetSemiAxisX()/mm));
elconeElement->setAttributeNode(NewAttribute("dy",elcone->GetSemiAxisY()/mm));
elconeElement->setAttributeNode(NewAttribute("zmax",elcone->GetZMax()/mm));
elconeElement->setAttributeNode(NewAttribute("zcut",elcone->GetZTopCut()/mm));
elconeElement->setAttributeNode(NewAttribute("lunit","mm"));
solidsElement->appendChild(elconeElement);
}
void G4GDMLWriteSolids::
EllipsoidWrite(xercesc::DOMElement* solidsElement,
const G4Ellipsoid* const ellipsoid)
{
const G4String& name = GenerateName(ellipsoid->GetName(),ellipsoid);
xercesc::DOMElement* ellipsoidElement = NewElement("ellipsoid");
ellipsoidElement->setAttributeNode(NewAttribute("name",name));
ellipsoidElement->
setAttributeNode(NewAttribute("ax",ellipsoid->GetSemiAxisMax(0)/mm));
ellipsoidElement->
setAttributeNode(NewAttribute("by",ellipsoid->GetSemiAxisMax(1)/mm));
ellipsoidElement->
setAttributeNode(NewAttribute("cz",ellipsoid->GetSemiAxisMax(2)/mm));
ellipsoidElement->
setAttributeNode(NewAttribute("zcut1",ellipsoid->GetZBottomCut()/mm));
ellipsoidElement->
setAttributeNode(NewAttribute("zcut2",ellipsoid->GetZTopCut()/mm));
ellipsoidElement->
setAttributeNode(NewAttribute("lunit","mm"));
solidsElement->appendChild(ellipsoidElement);
}
void G4GDMLWriteSolids::
EltubeWrite(xercesc::DOMElement* solidsElement,
const G4EllipticalTube* const eltube)
{
const G4String& name = GenerateName(eltube->GetName(),eltube);
xercesc::DOMElement* eltubeElement = NewElement("eltube");
eltubeElement->setAttributeNode(NewAttribute("name",name));
eltubeElement->setAttributeNode(NewAttribute("dx",eltube->GetDx()/mm));
eltubeElement->setAttributeNode(NewAttribute("dy",eltube->GetDy()/mm));
eltubeElement->setAttributeNode(NewAttribute("dz",eltube->GetDz()/mm));
eltubeElement->setAttributeNode(NewAttribute("lunit","mm"));
solidsElement->appendChild(eltubeElement);
}
void G4GDMLWriteSolids::
XtruWrite(xercesc::DOMElement* solidsElement,
const G4ExtrudedSolid* const xtru)
{
const G4String& name = GenerateName(xtru->GetName(),xtru);
xercesc::DOMElement* xtruElement = NewElement("xtru");
xtruElement->setAttributeNode(NewAttribute("name",name));
xtruElement->setAttributeNode(NewAttribute("lunit","mm"));
solidsElement->appendChild(xtruElement);
const G4int NumVertex = xtru->GetNofVertices();
for (G4int i=0;i<NumVertex;i++)
{
xercesc::DOMElement* twoDimVertexElement = NewElement("twoDimVertex");
xtruElement->appendChild(twoDimVertexElement);
const G4TwoVector& vertex = xtru->GetVertex(i);
twoDimVertexElement->setAttributeNode(NewAttribute("x",vertex.x()/mm));
twoDimVertexElement->setAttributeNode(NewAttribute("y",vertex.y()/mm));
}
const G4int NumSection = xtru->GetNofZSections();
for (G4int i=0;i<NumSection;i++)
{
xercesc::DOMElement* sectionElement = NewElement("section");
xtruElement->appendChild(sectionElement);
const G4ExtrudedSolid::ZSection section = xtru->GetZSection(i);
sectionElement->setAttributeNode(NewAttribute("zOrder",i));
sectionElement->setAttributeNode(NewAttribute("zPosition",section.fZ/mm));
sectionElement->
setAttributeNode(NewAttribute("xOffset",section.fOffset.x()/mm));
sectionElement->
setAttributeNode(NewAttribute("yOffset",section.fOffset.y()/mm));
sectionElement->
setAttributeNode(NewAttribute("scalingFactor",section.fScale));
}
}
void G4GDMLWriteSolids::
HypeWrite(xercesc::DOMElement* solidsElement, const G4Hype* const hype)
{
const G4String& name = GenerateName(hype->GetName(),hype);
xercesc::DOMElement* hypeElement = NewElement("hype");
hypeElement->setAttributeNode(NewAttribute("name",name));
hypeElement->setAttributeNode(NewAttribute("rmin",
hype->GetInnerRadius()/mm));
hypeElement->setAttributeNode(NewAttribute("rmax",
hype->GetOuterRadius()/mm));
hypeElement->setAttributeNode(NewAttribute("inst",
hype->GetInnerStereo()/degree));
hypeElement->setAttributeNode(NewAttribute("outst",
hype->GetOuterStereo()/degree));
hypeElement->setAttributeNode(NewAttribute("z",
2.0*hype->GetZHalfLength()/mm));
hypeElement->setAttributeNode(NewAttribute("aunit","deg"));
hypeElement->setAttributeNode(NewAttribute("lunit","mm"));
solidsElement->appendChild(hypeElement);
}
void G4GDMLWriteSolids::
OrbWrite(xercesc::DOMElement* solidsElement, const G4Orb* const orb)
{
const G4String& name = GenerateName(orb->GetName(),orb);
xercesc::DOMElement* orbElement = NewElement("orb");
orbElement->setAttributeNode(NewAttribute("name",name));
orbElement->setAttributeNode(NewAttribute("r",orb->GetRadius()/mm));
orbElement->setAttributeNode(NewAttribute("lunit","mm"));
solidsElement->appendChild(orbElement);
}
void G4GDMLWriteSolids::
ParaWrite(xercesc::DOMElement* solidsElement, const G4Para* const para)
{
const G4String& name = GenerateName(para->GetName(),para);
const G4ThreeVector simaxis = para->GetSymAxis();
const G4double alpha = std::atan(para->GetTanAlpha());
const G4double theta = std::acos(simaxis.z());
const G4double phi = (simaxis.z() != 1.0)
? (std::atan(simaxis.y()/simaxis.x())) : (0.0);
xercesc::DOMElement* paraElement = NewElement("para");
paraElement->setAttributeNode(NewAttribute("name",name));
paraElement->setAttributeNode(NewAttribute("x",
2.0*para->GetXHalfLength()/mm));
paraElement->setAttributeNode(NewAttribute("y",
2.0*para->GetYHalfLength()/mm));
paraElement->setAttributeNode(NewAttribute("z",
2.0*para->GetZHalfLength()/mm));
paraElement->setAttributeNode(NewAttribute("alpha",alpha/degree));
paraElement->setAttributeNode(NewAttribute("theta",theta/degree));
paraElement->setAttributeNode(NewAttribute("phi",phi/degree));
paraElement->setAttributeNode(NewAttribute("aunit","deg"));
paraElement->setAttributeNode(NewAttribute("lunit","mm"));
solidsElement->appendChild(paraElement);
}
void G4GDMLWriteSolids::
ParaboloidWrite(xercesc::DOMElement* solidsElement,
const G4Paraboloid* const paraboloid)
{
const G4String& name = GenerateName(paraboloid->GetName(),paraboloid);
xercesc::DOMElement* paraboloidElement = NewElement("paraboloid");
paraboloidElement->setAttributeNode(NewAttribute("name",name));
paraboloidElement->setAttributeNode(NewAttribute("rlo",
paraboloid->GetRadiusMinusZ()/mm));
paraboloidElement->setAttributeNode(NewAttribute("rhi",
paraboloid->GetRadiusPlusZ()/mm));
paraboloidElement->setAttributeNode(NewAttribute("dz",
paraboloid->GetZHalfLength()/mm));
paraboloidElement->setAttributeNode(NewAttribute("lunit","mm"));
solidsElement->appendChild(paraboloidElement);
}
void G4GDMLWriteSolids::
PolyconeWrite(xercesc::DOMElement* solidsElement,
const G4Polycone* const polycone)
{
const G4String& name = GenerateName(polycone->GetName(),polycone);
xercesc::DOMElement* polyconeElement = NewElement("polycone");
polyconeElement->setAttributeNode(NewAttribute("name",name));
polyconeElement->setAttributeNode(NewAttribute("startphi",
polycone->GetOriginalParameters()->Start_angle/degree));
polyconeElement->setAttributeNode(NewAttribute("deltaphi",
polycone->GetOriginalParameters()->Opening_angle/degree));
polyconeElement->setAttributeNode(NewAttribute("aunit","deg"));
polyconeElement->setAttributeNode(NewAttribute("lunit","mm"));
solidsElement->appendChild(polyconeElement);
const size_t num_zplanes = polycone->GetOriginalParameters()->Num_z_planes;
const G4double* z_array = polycone->GetOriginalParameters()->Z_values;
const G4double* rmin_array = polycone->GetOriginalParameters()->Rmin;
const G4double* rmax_array = polycone->GetOriginalParameters()->Rmax;
for (size_t i=0; i<num_zplanes; i++)
{
ZplaneWrite(polyconeElement,z_array[i],rmin_array[i],rmax_array[i]);
}
}
void G4GDMLWriteSolids::
PolyhedraWrite(xercesc::DOMElement* solidsElement,
const G4Polyhedra* const polyhedra)
{
const G4String& name = GenerateName(polyhedra->GetName(),polyhedra);
xercesc::DOMElement* polyhedraElement = NewElement("polyhedra");
polyhedraElement->setAttributeNode(NewAttribute("name",name));
polyhedraElement->setAttributeNode(NewAttribute("startphi",
polyhedra->GetOriginalParameters()->Start_angle/degree));
polyhedraElement->setAttributeNode(NewAttribute("deltaphi",
polyhedra->GetOriginalParameters()->Opening_angle/degree));
polyhedraElement->setAttributeNode(NewAttribute("numsides",
polyhedra->GetOriginalParameters()->numSide));
polyhedraElement->setAttributeNode(NewAttribute("aunit","deg"));
polyhedraElement->setAttributeNode(NewAttribute("lunit","mm"));
solidsElement->appendChild(polyhedraElement);
const size_t num_zplanes = polyhedra->GetOriginalParameters()->Num_z_planes;
const G4double* z_array = polyhedra->GetOriginalParameters()->Z_values;
const G4double* rmin_array = polyhedra->GetOriginalParameters()->Rmin;
const G4double* rmax_array = polyhedra->GetOriginalParameters()->Rmax;
const G4double convertRad =
std::cos(0.5*polyhedra->GetOriginalParameters()->Opening_angle
/ polyhedra->GetOriginalParameters()->numSide);
for (size_t i=0;i<num_zplanes;i++)
{
ZplaneWrite(polyhedraElement,z_array[i],
rmin_array[i]*convertRad, rmax_array[i]*convertRad);
}
}
void G4GDMLWriteSolids::
SphereWrite(xercesc::DOMElement* solidsElement, const G4Sphere* const sphere)
{
const G4String& name = GenerateName(sphere->GetName(),sphere);
xercesc::DOMElement* sphereElement = NewElement("sphere");
sphereElement->setAttributeNode(NewAttribute("name",name));
sphereElement->setAttributeNode(NewAttribute("rmin",
sphere->GetInsideRadius()/mm));
sphereElement->setAttributeNode(NewAttribute("rmax",
sphere->GetOuterRadius()/mm));
sphereElement->setAttributeNode(NewAttribute("startphi",
sphere->GetStartPhiAngle()/degree));
sphereElement->setAttributeNode(NewAttribute("deltaphi",
sphere->GetDeltaPhiAngle()/degree));
sphereElement->setAttributeNode(NewAttribute("starttheta",
sphere->GetStartThetaAngle()/degree));
sphereElement->setAttributeNode(NewAttribute("deltatheta",
sphere->GetDeltaThetaAngle()/degree));
sphereElement->setAttributeNode(NewAttribute("aunit","deg"));
sphereElement->setAttributeNode(NewAttribute("lunit","mm"));
solidsElement->appendChild(sphereElement);
}
void G4GDMLWriteSolids::
TessellatedWrite(xercesc::DOMElement* solidsElement,
const G4TessellatedSolid* const tessellated)
{
const G4String& solid_name = tessellated->GetName();
const G4String& name = GenerateName(solid_name, tessellated);
xercesc::DOMElement* tessellatedElement = NewElement("tessellated");
tessellatedElement->setAttributeNode(NewAttribute("name",name));
tessellatedElement->setAttributeNode(NewAttribute("aunit","deg"));
tessellatedElement->setAttributeNode(NewAttribute("lunit","mm"));
solidsElement->appendChild(tessellatedElement);
std::map<G4ThreeVector, G4String> vertexMap;
const size_t NumFacets = tessellated->GetNumberOfFacets();
size_t NumVertex = 0;
for (size_t i=0;i<NumFacets;i++)
{
const G4VFacet* facet = tessellated->GetFacet(i);
const size_t NumVertexPerFacet = facet->GetNumberOfVertices();
G4String FacetTag;
if (NumVertexPerFacet==3) { FacetTag="triangular"; } else
if (NumVertexPerFacet==4) { FacetTag="quadrangular"; }
else
{
G4Exception("G4GDMLWriteSolids::TessellatedWrite()", "InvalidSetup",
FatalException, "Facet should contain 3 or 4 vertices!");
}
xercesc::DOMElement* facetElement = NewElement(FacetTag);
tessellatedElement->appendChild(facetElement);
for (size_t j=0; j<NumVertexPerFacet; j++)
{
std::stringstream name_stream;
std::stringstream ref_stream;
name_stream << "vertex" << (j+1);
ref_stream << solid_name << "_v" << NumVertex;
const G4String& name = name_stream.str(); // facet's tag variable
G4String ref = ref_stream.str(); // vertex tag to be associated
// Now search for the existance of the current vertex in the
// map of cached vertices. If existing, do NOT store it as
// position in the GDML file, so avoiding duplication; otherwise
// cache it in the local map and add it as position in the
// "define" section of the GDML file.
const G4ThreeVector& vertex = facet->GetVertex(j);
if(vertexMap.find(vertex) != vertexMap.end()) // Vertex is cached
{
ref = vertexMap[vertex]; // Set the proper tag for it
}
else // Vertex not found
{
vertexMap.insert(std::make_pair(vertex,ref)); // Cache vertex and ...
AddPosition(ref, vertex); // ... add it to define section!
NumVertex++;
}
// Now create association of the vertex with its facet
//
facetElement->setAttributeNode(NewAttribute(name,ref));
}
}
}
void G4GDMLWriteSolids::
TetWrite(xercesc::DOMElement* solidsElement, const G4Tet* const tet)
{
const G4String& solid_name = tet->GetName();
const G4String& name = GenerateName(solid_name, tet);
std::vector<G4ThreeVector> vertexList = tet->GetVertices();
xercesc::DOMElement* tetElement = NewElement("tet");
tetElement->setAttributeNode(NewAttribute("name",name));
tetElement->setAttributeNode(NewAttribute("vertex1",solid_name+"_v1"));
tetElement->setAttributeNode(NewAttribute("vertex2",solid_name+"_v2"));
tetElement->setAttributeNode(NewAttribute("vertex3",solid_name+"_v3"));
tetElement->setAttributeNode(NewAttribute("vertex4",solid_name+"_v4"));
tetElement->setAttributeNode(NewAttribute("lunit","mm"));
solidsElement->appendChild(tetElement);
AddPosition(solid_name+"_v1",vertexList[0]);
AddPosition(solid_name+"_v2",vertexList[1]);
AddPosition(solid_name+"_v3",vertexList[2]);
AddPosition(solid_name+"_v4",vertexList[3]);
}
void G4GDMLWriteSolids::
TorusWrite(xercesc::DOMElement* solidsElement, const G4Torus* const torus)
{
const G4String& name = GenerateName(torus->GetName(),torus);
xercesc::DOMElement* torusElement = NewElement("torus");
torusElement->setAttributeNode(NewAttribute("name",name));
torusElement->setAttributeNode(NewAttribute("rmin",torus->GetRmin()/mm));
torusElement->setAttributeNode(NewAttribute("rmax",torus->GetRmax()/mm));
torusElement->setAttributeNode(NewAttribute("rtor",torus->GetRtor()/mm));
torusElement->
setAttributeNode(NewAttribute("startphi",torus->GetSPhi()/degree));
torusElement->
setAttributeNode(NewAttribute("deltaphi",torus->GetDPhi()/degree));
torusElement->setAttributeNode(NewAttribute("aunit","deg"));
torusElement->setAttributeNode(NewAttribute("lunit","mm"));
solidsElement->appendChild(torusElement);
}
void G4GDMLWriteSolids::
TrapWrite(xercesc::DOMElement* solidsElement, const G4Trap* const trap)
{
const G4String& name = GenerateName(trap->GetName(),trap);
const G4ThreeVector& simaxis = trap->GetSymAxis();
const G4double phi = (simaxis.z() != 1.0)
? (std::atan(simaxis.y()/simaxis.x())) : (0.0);
const G4double theta = std::acos(simaxis.z());
const G4double alpha1 = std::atan(trap->GetTanAlpha1());
const G4double alpha2 = std::atan(trap->GetTanAlpha2());
xercesc::DOMElement* trapElement = NewElement("trap");
trapElement->setAttributeNode(NewAttribute("name",name));
trapElement->setAttributeNode(NewAttribute("z",
2.0*trap->GetZHalfLength()/mm));
trapElement->setAttributeNode(NewAttribute("theta",theta/degree));
trapElement->setAttributeNode(NewAttribute("phi",phi/degree));
trapElement->setAttributeNode(NewAttribute("y1",
2.0*trap->GetYHalfLength1()/mm));
trapElement->setAttributeNode(NewAttribute("x1",
2.0*trap->GetXHalfLength1()/mm));
trapElement->setAttributeNode(NewAttribute("x2",
2.0*trap->GetXHalfLength2()/mm));
trapElement->setAttributeNode(NewAttribute("alpha1",alpha1/degree));
trapElement->setAttributeNode(NewAttribute("y2",
2.0*trap->GetYHalfLength2()/mm));
trapElement->setAttributeNode(NewAttribute("x3",
2.0*trap->GetXHalfLength3()/mm));
trapElement->setAttributeNode(NewAttribute("x4",
2.0*trap->GetXHalfLength4()/mm));
trapElement->setAttributeNode(NewAttribute("alpha2",alpha2/degree));
trapElement->setAttributeNode(NewAttribute("aunit","deg"));
trapElement->setAttributeNode(NewAttribute("lunit","mm"));
solidsElement->appendChild(trapElement);
}
void G4GDMLWriteSolids::
TrdWrite(xercesc::DOMElement* solidsElement, const G4Trd* const trd)
{
const G4String& name = GenerateName(trd->GetName(),trd);
xercesc::DOMElement* trdElement = NewElement("trd");
trdElement->setAttributeNode(NewAttribute("name",name));
trdElement->setAttributeNode(NewAttribute("x1",
2.0*trd->GetXHalfLength1()/mm));
trdElement->setAttributeNode(NewAttribute("x2",
2.0*trd->GetXHalfLength2()/mm));
trdElement->setAttributeNode(NewAttribute("y1",
2.0*trd->GetYHalfLength1()/mm));
trdElement->setAttributeNode(NewAttribute("y2",
2.0*trd->GetYHalfLength2()/mm));
trdElement->setAttributeNode(NewAttribute("z",
2.0*trd->GetZHalfLength()/mm));
trdElement->setAttributeNode(NewAttribute("lunit","mm"));
solidsElement->appendChild(trdElement);
}
void G4GDMLWriteSolids::
TubeWrite(xercesc::DOMElement* solidsElement, const G4Tubs* const tube)
{
const G4String& name = GenerateName(tube->GetName(),tube);
xercesc::DOMElement* tubeElement = NewElement("tube");
tubeElement->setAttributeNode(NewAttribute("name",name));
tubeElement->setAttributeNode(NewAttribute("rmin",
tube->GetInnerRadius()/mm));
tubeElement->setAttributeNode(NewAttribute("rmax",
tube->GetOuterRadius()/mm));
tubeElement->setAttributeNode(NewAttribute("z",
2.0*tube->GetZHalfLength()/mm));
tubeElement->setAttributeNode(NewAttribute("startphi",
tube->GetStartPhiAngle()/degree));
tubeElement->setAttributeNode(NewAttribute("deltaphi",
tube->GetDeltaPhiAngle()/degree));
tubeElement->setAttributeNode(NewAttribute("aunit","deg"));
tubeElement->setAttributeNode(NewAttribute("lunit","mm"));
solidsElement->appendChild(tubeElement);
}
void G4GDMLWriteSolids::
TwistedboxWrite(xercesc::DOMElement* solidsElement,
const G4TwistedBox* const twistedbox)
{
const G4String& name = GenerateName(twistedbox->GetName(),twistedbox);
xercesc::DOMElement* twistedboxElement = NewElement("twistedbox");
twistedboxElement->setAttributeNode(NewAttribute("name",name));
twistedboxElement->setAttributeNode(NewAttribute("x",
2.0*twistedbox->GetXHalfLength()/mm));
twistedboxElement->setAttributeNode(NewAttribute("y",
2.0*twistedbox->GetYHalfLength()/mm));
twistedboxElement->setAttributeNode(NewAttribute("z",
2.0*twistedbox->GetZHalfLength()/mm));
twistedboxElement->setAttributeNode(NewAttribute("PhiTwist",
twistedbox->GetPhiTwist()/degree));
twistedboxElement->setAttributeNode(NewAttribute("aunit","deg"));
twistedboxElement->setAttributeNode(NewAttribute("lunit","mm"));
solidsElement->appendChild(twistedboxElement);
}
void G4GDMLWriteSolids::
TwistedtrapWrite(xercesc::DOMElement* solidsElement,
const G4TwistedTrap* const twistedtrap)
{
const G4String& name = GenerateName(twistedtrap->GetName(),twistedtrap);
xercesc::DOMElement* twistedtrapElement = NewElement("twistedtrap");
twistedtrapElement->setAttributeNode(NewAttribute("name",name));
twistedtrapElement->setAttributeNode(NewAttribute("y1",
2.0*twistedtrap->GetY1HalfLength()/mm));
twistedtrapElement->setAttributeNode(NewAttribute("x1",
2.0*twistedtrap->GetX1HalfLength()/mm));
twistedtrapElement->setAttributeNode(NewAttribute("x2",
2.0*twistedtrap->GetX2HalfLength()/mm));
twistedtrapElement->setAttributeNode(NewAttribute("y2",
2.0*twistedtrap->GetY2HalfLength()/mm));
twistedtrapElement->setAttributeNode(NewAttribute("x3",
2.0*twistedtrap->GetX3HalfLength()/mm));
twistedtrapElement->setAttributeNode(NewAttribute("x4",
2.0*twistedtrap->GetX4HalfLength()/mm));
twistedtrapElement->setAttributeNode(NewAttribute("z",
2.0*twistedtrap->GetZHalfLength()/mm));
twistedtrapElement->setAttributeNode(NewAttribute("Alph",
twistedtrap->GetTiltAngleAlpha()/degree));
twistedtrapElement->setAttributeNode(NewAttribute("Theta",
twistedtrap->GetPolarAngleTheta()/degree));
twistedtrapElement->setAttributeNode(NewAttribute("Phi",
twistedtrap->GetAzimuthalAnglePhi()/degree));
twistedtrapElement->setAttributeNode(NewAttribute("PhiTwist",
twistedtrap->GetPhiTwist()/degree));
twistedtrapElement->setAttributeNode(NewAttribute("aunit","deg"));
twistedtrapElement->setAttributeNode(NewAttribute("lunit","mm"));
solidsElement->appendChild(twistedtrapElement);
}
void G4GDMLWriteSolids::
TwistedtrdWrite(xercesc::DOMElement* solidsElement,
const G4TwistedTrd* const twistedtrd)
{
const G4String& name = GenerateName(twistedtrd->GetName(),twistedtrd);
xercesc::DOMElement* twistedtrdElement = NewElement("twistedtrd");
twistedtrdElement->setAttributeNode(NewAttribute("name",name));
twistedtrdElement->setAttributeNode(NewAttribute("x1",
2.0*twistedtrd->GetX1HalfLength()/mm));
twistedtrdElement->setAttributeNode(NewAttribute("x2",
2.0*twistedtrd->GetX2HalfLength()/mm));
twistedtrdElement->setAttributeNode(NewAttribute("y1",
2.0*twistedtrd->GetY1HalfLength()/mm));
twistedtrdElement->setAttributeNode(NewAttribute("y2",
2.0*twistedtrd->GetY2HalfLength()/mm));
twistedtrdElement->setAttributeNode(NewAttribute("z",
2.0*twistedtrd->GetZHalfLength()/mm));
twistedtrdElement->setAttributeNode(NewAttribute("PhiTwist",
twistedtrd->GetPhiTwist()/degree));
twistedtrdElement->setAttributeNode(NewAttribute("aunit","deg"));
twistedtrdElement->setAttributeNode(NewAttribute("lunit","mm"));
solidsElement->appendChild(twistedtrdElement);
}
void G4GDMLWriteSolids::
TwistedtubsWrite(xercesc::DOMElement* solidsElement,
const G4TwistedTubs* const twistedtubs)
{
const G4String& name = GenerateName(twistedtubs->GetName(),twistedtubs);
xercesc::DOMElement* twistedtubsElement = NewElement("twistedtubs");
twistedtubsElement->setAttributeNode(NewAttribute("name",name));
twistedtubsElement->setAttributeNode(NewAttribute("twistedangle",
twistedtubs->GetPhiTwist()/degree));
twistedtubsElement->setAttributeNode(NewAttribute("endinnerrad",
twistedtubs->GetInnerRadius()/mm));
twistedtubsElement->setAttributeNode(NewAttribute("endouterrad",
twistedtubs->GetOuterRadius()/mm));
twistedtubsElement->setAttributeNode(NewAttribute("zlen",
2.0*twistedtubs->GetZHalfLength()/mm));
twistedtubsElement->setAttributeNode(NewAttribute("phi",
twistedtubs->GetDPhi()/degree));
twistedtubsElement->setAttributeNode(NewAttribute("aunit","deg"));
twistedtubsElement->setAttributeNode(NewAttribute("lunit","mm"));
solidsElement->appendChild(twistedtubsElement);
}
void G4GDMLWriteSolids::
ZplaneWrite(xercesc::DOMElement* element, const G4double& z,
const G4double& rmin, const G4double& rmax)
{
xercesc::DOMElement* zplaneElement = NewElement("zplane");
zplaneElement->setAttributeNode(NewAttribute("z",z/mm));
zplaneElement->setAttributeNode(NewAttribute("rmin",rmin/mm));
zplaneElement->setAttributeNode(NewAttribute("rmax",rmax/mm));
element->appendChild(zplaneElement);
}
void G4GDMLWriteSolids::SolidsWrite(xercesc::DOMElement* gdmlElement)
{
G4cout << "G4GDML: Writing solids..." << G4endl;
solidsElement = NewElement("solids");
gdmlElement->appendChild(solidsElement);
solidList.clear();
}
void G4GDMLWriteSolids::AddSolid(const G4VSolid* const solidPtr)
{
for (size_t i=0; i<solidList.size(); i++) // Check if solid is
{ // already in the list!
if (solidList[i] == solidPtr) { return; }
}
solidList.push_back(solidPtr);
if (const G4BooleanSolid* const booleanPtr
= dynamic_cast<const G4BooleanSolid*>(solidPtr))
{ BooleanWrite(solidsElement,booleanPtr); } else
if (const G4Box* const boxPtr
= dynamic_cast<const G4Box*>(solidPtr))
{ BoxWrite(solidsElement,boxPtr); } else
if (const G4Cons* const conePtr
= dynamic_cast<const G4Cons*>(solidPtr))
{ ConeWrite(solidsElement,conePtr); } else
if (const G4EllipticalCone* const elconePtr
= dynamic_cast<const G4EllipticalCone*>(solidPtr))
{ ElconeWrite(solidsElement,elconePtr); } else
if (const G4Ellipsoid* const ellipsoidPtr
= dynamic_cast<const G4Ellipsoid*>(solidPtr))
{ EllipsoidWrite(solidsElement,ellipsoidPtr); } else
if (const G4EllipticalTube* const eltubePtr
= dynamic_cast<const G4EllipticalTube*>(solidPtr))
{ EltubeWrite(solidsElement,eltubePtr); } else
if (const G4ExtrudedSolid* const xtruPtr
= dynamic_cast<const G4ExtrudedSolid*>(solidPtr))
{ XtruWrite(solidsElement,xtruPtr); } else
if (const G4Hype* const hypePtr
= dynamic_cast<const G4Hype*>(solidPtr))
{ HypeWrite(solidsElement,hypePtr); } else
if (const G4Orb* const orbPtr
= dynamic_cast<const G4Orb*>(solidPtr))
{ OrbWrite(solidsElement,orbPtr); } else
if (const G4Para* const paraPtr
= dynamic_cast<const G4Para*>(solidPtr))
{ ParaWrite(solidsElement,paraPtr); } else
if (const G4Paraboloid* const paraboloidPtr
= dynamic_cast<const G4Paraboloid*>(solidPtr))
{ ParaboloidWrite(solidsElement,paraboloidPtr); } else
if (const G4Polycone* const polyconePtr
= dynamic_cast<const G4Polycone*>(solidPtr))
{ PolyconeWrite(solidsElement,polyconePtr); } else
if (const G4Polyhedra* const polyhedraPtr
= dynamic_cast<const G4Polyhedra*>(solidPtr))
{ PolyhedraWrite(solidsElement,polyhedraPtr); } else
if (const G4Sphere* const spherePtr
= dynamic_cast<const G4Sphere*>(solidPtr))
{ SphereWrite(solidsElement,spherePtr); } else
if (const G4TessellatedSolid* const tessellatedPtr
= dynamic_cast<const G4TessellatedSolid*>(solidPtr))
{ TessellatedWrite(solidsElement,tessellatedPtr); } else
if (const G4Tet* const tetPtr
= dynamic_cast<const G4Tet*>(solidPtr))
{ TetWrite(solidsElement,tetPtr); } else
if (const G4Torus* const torusPtr
= dynamic_cast<const G4Torus*>(solidPtr))
{ TorusWrite(solidsElement,torusPtr); } else
if (const G4Trap* const trapPtr
= dynamic_cast<const G4Trap*>(solidPtr))
{ TrapWrite(solidsElement,trapPtr); } else
if (const G4Trd* const trdPtr
= dynamic_cast<const G4Trd*>(solidPtr))
{ TrdWrite(solidsElement,trdPtr); } else
if (const G4Tubs* const tubePtr
= dynamic_cast<const G4Tubs*>(solidPtr))
{ TubeWrite(solidsElement,tubePtr); } else
if (const G4TwistedBox* const twistedboxPtr
= dynamic_cast<const G4TwistedBox*>(solidPtr))
{ TwistedboxWrite(solidsElement,twistedboxPtr); } else
if (const G4TwistedTrap* const twistedtrapPtr
= dynamic_cast<const G4TwistedTrap*>(solidPtr))
{ TwistedtrapWrite(solidsElement,twistedtrapPtr); } else
if (const G4TwistedTrd* const twistedtrdPtr
= dynamic_cast<const G4TwistedTrd*>(solidPtr))
{ TwistedtrdWrite(solidsElement,twistedtrdPtr); } else
if (const G4TwistedTubs* const twistedtubsPtr
= dynamic_cast<const G4TwistedTubs*>(solidPtr))
{ TwistedtubsWrite(solidsElement,twistedtubsPtr); }
else
{
G4String error_msg = "Unknown solid: " + solidPtr->GetName();
G4Exception("G4GDMLWriteSolids::AddSolid()", "ReadError",
FatalException, error_msg);
}
}
@@ -0,0 +1,334 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4GDMLWriteStructure.cc,v 1.74 2008/11/13 16:48:19 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
// class G4GDMLWriteStructure Implementation
//
// Original author: Zoltan Torzsok, November 2007
//
// --------------------------------------------------------------------
#include "G4GDMLWriteStructure.hh"
void
G4GDMLWriteStructure::DivisionvolWrite(xercesc::DOMElement* volumeElement,
const G4PVDivision* const divisionvol)
{
EAxis axis = kUndefined;
G4int number = 0;
G4double width = 0.0;
G4double offset = 0.0;
G4bool consuming = false;
divisionvol->GetReplicationData(axis,number,width,offset,consuming);
G4String unitString("mm");
G4String axisString("kUndefined");
if (axis==kXAxis) { axisString = "kXAxis"; } else
if (axis==kYAxis) { axisString = "kYAxis"; } else
if (axis==kZAxis) { axisString = "kZAxis"; } else
if (axis==kRho) { axisString = "kRho"; } else
if (axis==kPhi) { axisString = "kPhi"; unitString = "degree"; }
const G4String name
= GenerateName(divisionvol->GetName(),divisionvol);
const G4String volumeref
= GenerateName(divisionvol->GetLogicalVolume()->GetName(),
divisionvol->GetLogicalVolume());
xercesc::DOMElement* divisionvolElement = NewElement("divisionvol");
divisionvolElement->setAttributeNode(NewAttribute("axis",axisString));
divisionvolElement->setAttributeNode(NewAttribute("number",number));
divisionvolElement->setAttributeNode(NewAttribute("width",width));
divisionvolElement->setAttributeNode(NewAttribute("offset",offset));
divisionvolElement->setAttributeNode(NewAttribute("unit",unitString));
xercesc::DOMElement* volumerefElement = NewElement("volumeref");
volumerefElement->setAttributeNode(NewAttribute("ref",volumeref));
divisionvolElement->appendChild(volumerefElement);
volumeElement->appendChild(divisionvolElement);
}
void G4GDMLWriteStructure::PhysvolWrite(xercesc::DOMElement* volumeElement,
const G4VPhysicalVolume* const physvol,
const G4Transform3D& T,
const G4String& ModuleName)
{
HepGeom::Scale3D scale;
HepGeom::Rotate3D rotate;
HepGeom::Translate3D translate;
T.getDecomposition(scale,rotate,translate);
const G4ThreeVector scl(scale(0,0),scale(1,1),scale(2,2));
const G4ThreeVector rot = GetAngles(rotate.getRotation());
const G4ThreeVector pos = T.getTranslation();
const G4String name = GenerateName(physvol->GetName(),physvol);
xercesc::DOMElement* physvolElement = NewElement("physvol");
physvolElement->setAttributeNode(NewAttribute("name",name));
volumeElement->appendChild(physvolElement);
const G4String volumeref
= GenerateName(physvol->GetLogicalVolume()->GetName(),
physvol->GetLogicalVolume());
if (ModuleName.empty())
{
xercesc::DOMElement* volumerefElement = NewElement("volumeref");
volumerefElement->setAttributeNode(NewAttribute("ref",volumeref));
physvolElement->appendChild(volumerefElement);
}
else
{
xercesc::DOMElement* fileElement = NewElement("file");
fileElement->setAttributeNode(NewAttribute("name",ModuleName));
fileElement->setAttributeNode(NewAttribute("volname",volumeref));
physvolElement->appendChild(fileElement);
}
if (std::fabs(pos.x()) > kLinearPrecision
|| std::fabs(pos.y()) > kLinearPrecision
|| std::fabs(pos.z()) > kLinearPrecision)
{
PositionWrite(physvolElement,name+"_pos",pos);
}
if (std::fabs(rot.x()) > kAngularPrecision
|| std::fabs(rot.y()) > kAngularPrecision
|| std::fabs(rot.z()) > kAngularPrecision)
{
RotationWrite(physvolElement,name+"_rot",rot);
}
if (std::fabs(scl.x()-1.0) > kRelativePrecision
|| std::fabs(scl.y()-1.0) > kRelativePrecision
|| std::fabs(scl.z()-1.0) > kRelativePrecision)
{
ScaleWrite(physvolElement,name+"_scl",scl);
}
}
void G4GDMLWriteStructure::ReplicavolWrite(xercesc::DOMElement* volumeElement,
const G4VPhysicalVolume* const replicavol)
{
EAxis axis = kUndefined;
G4int number = 0;
G4double width = 0.0;
G4double offset = 0.0;
G4bool consuming = false;
G4String unitString("mm");
replicavol->GetReplicationData(axis,number,width,offset,consuming);
const G4String volumeref
= GenerateName(replicavol->GetLogicalVolume()->GetName(),
replicavol->GetLogicalVolume());
xercesc::DOMElement* replicavolElement = NewElement("replicavol");
replicavolElement->setAttributeNode(NewAttribute("number",number));
xercesc::DOMElement* volumerefElement = NewElement("volumeref");
volumerefElement->setAttributeNode(NewAttribute("ref",volumeref));
replicavolElement->appendChild(volumerefElement);
xercesc::DOMElement* replicateElement = NewElement("replicate_along_axis");
replicavolElement->appendChild(replicateElement);
xercesc::DOMElement* dirElement = NewElement("direction");
if(axis==kXAxis)dirElement->setAttributeNode(NewAttribute("x","1"));
if(axis==kYAxis)dirElement->setAttributeNode(NewAttribute("y","1"));
if(axis==kZAxis)dirElement->setAttributeNode(NewAttribute("z","1"));
if(axis==kRho)dirElement->setAttributeNode(NewAttribute("rho","1"));
if(axis==kPhi)dirElement->setAttributeNode(NewAttribute("phi","1"));
replicateElement->appendChild(dirElement);
xercesc::DOMElement* widthElement = NewElement("width");
widthElement->setAttributeNode(NewAttribute("value",width));
widthElement->setAttributeNode(NewAttribute("unit",unitString));
replicateElement->appendChild(widthElement);
xercesc::DOMElement* offsetElement = NewElement("offset");
offsetElement->setAttributeNode(NewAttribute("value",offset));
offsetElement->setAttributeNode(NewAttribute("unit",unitString));
replicateElement->appendChild(offsetElement);
volumeElement->appendChild(replicavolElement);
}
void G4GDMLWriteStructure::StructureWrite(xercesc::DOMElement* gdmlElement)
{
G4cout << "G4GDML: Writing structure..." << G4endl;
structureElement = NewElement("structure");
gdmlElement->appendChild(structureElement);
}
G4Transform3D G4GDMLWriteStructure::
TraverseVolumeTree(const G4LogicalVolume* const volumePtr, const G4int depth)
{
if (VolumeMap().find(volumePtr) != VolumeMap().end())
{
return VolumeMap()[volumePtr]; // Volume is already processed
}
G4VSolid* solidPtr = volumePtr->GetSolid();
G4Transform3D R,invR;
G4int reflected = 0;
while (true) // Solve possible displacement/reflection
{ // of the referenced solid!
if (reflected>maxReflections)
{
G4String ErrorMessage = "Referenced solid in volume '"
+ volumePtr->GetName()
+ "' was displaced/reflected too many times!";
G4Exception("G4GDMLWriteStructure::TraverseVolumeTree()",
"InvalidSetup", FatalException, ErrorMessage);
}
if (G4ReflectedSolid* refl = dynamic_cast<G4ReflectedSolid*>(solidPtr))
{
R = R*refl->GetTransform3D();
solidPtr = refl->GetConstituentMovedSolid();
reflected++;
continue;
}
if (G4DisplacedSolid* disp = dynamic_cast<G4DisplacedSolid*>(solidPtr))
{
R = R*G4Transform3D(disp->GetObjectRotation(),
disp->GetObjectTranslation());
solidPtr = disp->GetConstituentMovedSolid();
reflected++;
continue;
}
break;
}
if (reflected>0) { invR = R.inverse(); }
// Only compute the inverse when necessary!
const G4String name
= GenerateName(volumePtr->GetName(),volumePtr);
const G4String materialref
= GenerateName(volumePtr->GetMaterial()->GetName(),
volumePtr->GetMaterial());
const G4String solidref
= GenerateName(solidPtr->GetName(),solidPtr);
xercesc::DOMElement* volumeElement = NewElement("volume");
volumeElement->setAttributeNode(NewAttribute("name",name));
xercesc::DOMElement* materialrefElement = NewElement("materialref");
materialrefElement->setAttributeNode(NewAttribute("ref",materialref));
volumeElement->appendChild(materialrefElement);
xercesc::DOMElement* solidrefElement = NewElement("solidref");
solidrefElement->setAttributeNode(NewAttribute("ref",solidref));
volumeElement->appendChild(solidrefElement);
const G4int daughterCount = volumePtr->GetNoDaughters();
for (G4int i=0;i<daughterCount;i++) // Traverse all the children!
{
const G4VPhysicalVolume* const physvol = volumePtr->GetDaughter(i);
const G4String ModuleName = Modularize(physvol,depth);
G4Transform3D daughterR;
if (ModuleName.empty()) // Check if subtree requested to be
{ // a separate module!
daughterR = TraverseVolumeTree(physvol->GetLogicalVolume(),depth+1);
}
else
{
G4GDMLWriteStructure writer;
daughterR = writer.Write(ModuleName,physvol->GetLogicalVolume(),
SchemaLocation,depth+1);
}
if (const G4PVDivision* const divisionvol
= dynamic_cast<const G4PVDivision*>(physvol)) // Is it division?
{
if (!G4Transform3D::Identity.isNear(invR*daughterR,kRelativePrecision))
{
G4String ErrorMessage = "Division volume in '"
+ name
+ "' can not be related to reflected solid!";
G4Exception("G4GDMLWriteStructure::TraverseVolumeTree()",
"InvalidSetup", FatalException, ErrorMessage);
}
DivisionvolWrite(volumeElement,divisionvol);
} else
if (physvol->IsParameterised()) // Is it a paramvol?
{
if (!G4Transform3D::Identity.isNear(invR*daughterR,kRelativePrecision))
{
G4String ErrorMessage = "Parameterised volume in '"
+ name
+ "' can not be related to reflected solid!";
G4Exception("G4GDMLWriteStructure::TraverseVolumeTree()",
"InvalidSetup", FatalException, ErrorMessage);
}
ParamvolWrite(volumeElement,physvol);
} else
if (physvol->IsReplicated()) // Is it a replicavol?
{
if (!G4Transform3D::Identity.isNear(invR*daughterR,kRelativePrecision))
{
G4String ErrorMessage = "Replica volume in '"
+ name
+ "' can not be related to reflected solid!";
G4Exception("G4GDMLWriteStructure::TraverseVolumeTree()",
"InvalidSetup", FatalException, ErrorMessage);
}
ReplicavolWrite(volumeElement,physvol);
}
else // Is it a physvol?
{
G4RotationMatrix rot;
if (physvol->GetFrameRotation() != 0)
{
rot = *(physvol->GetFrameRotation());
}
G4Transform3D P(rot,physvol->GetObjectTranslation());
PhysvolWrite(volumeElement,physvol,invR*P*daughterR,ModuleName);
}
}
structureElement->appendChild(volumeElement);
// Append the volume AFTER traversing the children so that
// the order of volumes will be correct!
VolumeMap()[volumePtr] = R;
G4GDMLWriteMaterials::AddMaterial(volumePtr->GetMaterial());
// Add the involved materials and solids!
G4GDMLWriteSolids::AddSolid(solidPtr);
return R;
}
+268
View File
@@ -0,0 +1,268 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4STRead.cc,v 1.3 2008/07/17 14:05:50 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
// class G4STRead Implementation
//
// History:
// - Created. Zoltan Torzsok, November 2007
// -------------------------------------------------------------------------
#include "G4STRead.hh"
void G4STRead::TessellatedRead(const std::string& line)
{
if (tessellatedList.size()>0)
{
tessellatedList.back()->SetSolidClosed(true);
// Finish the previous solid at first!
}
std::istringstream stream(line.substr(2));
G4String name;
stream >> name;
G4TessellatedSolid* tessellated = new G4TessellatedSolid(name);
volumeMap[tessellated] =
new G4LogicalVolume(tessellated, solid_material, name+"_LV" , 0, 0, 0);
tessellatedList.push_back(tessellated);
G4cout << "G4STRead: Reading solid: " << name << G4endl;
}
void G4STRead::FacetRead(const std::string& line)
{
if (tessellatedList.size()==0)
{
G4Exception("G4STRead::FacetRead()", "ReadError", FatalException,
"A solid must be defined before defining a facet!");
}
if (line[2]=='3') // Triangular facet
{
G4double x1,y1,z1;
G4double x2,y2,z2;
G4double x3,y3,z3;
std::istringstream stream(line.substr(4));
stream >> x1 >> y1 >> z1 >> x2 >> y2 >> z2 >> x3 >> y3 >> z3;
tessellatedList.back()->
AddFacet(new G4TriangularFacet(G4ThreeVector(x1,y1,z1),
G4ThreeVector(x2,y2,z2),
G4ThreeVector(x3,y3,z3), ABSOLUTE));
}
else if (line[2]=='4') // Quadrangular facet
{
G4double x1,y1,z1;
G4double x2,y2,z2;
G4double x3,y3,z3;
G4double x4,y4,z4;
std::istringstream stream(line.substr(4));
stream >> x1 >> y1 >> z1 >> x2 >> y2 >> z2
>> x3 >> y3 >> z3 >> x4 >> y4 >> z4;
tessellatedList.back()->
AddFacet(new G4QuadrangularFacet(G4ThreeVector(x1,y1,z1),
G4ThreeVector(x2,y2,z2),
G4ThreeVector(x3,y3,z3),
G4ThreeVector(x4,y4,z4), ABSOLUTE));
}
else
{
G4Exception("G4STRead::FacetRead()", "ReadError", FatalException,
"Number of vertices per facet should be either 3 or 4!");
}
}
void G4STRead::PhysvolRead(const std::string& line)
{
G4int level;
G4String name;
G4double r1,r2,r3;
G4double r4,r5,r6;
G4double r7,r8,r9;
G4double pX,pY,pZ;
G4double n1,n2,n3,n4,n5;
std::istringstream stream(line.substr(2));
stream >> level >> name >> r1 >> r2 >> r3 >> n1 >> r4 >> r5 >> r6
>> n2 >> r7 >> r8 >> r9 >> n3 >> pX >> pY >> pZ >> n4 >> n5;
name.resize(name.rfind("_"));
G4cout << "G4STRead: Placing tessellated solid: " << name << G4endl;
G4TessellatedSolid* tessellated = 0;
for (size_t i=0; i<tessellatedList.size(); i++)
{ // Find the volume for this physvol!
if (tessellatedList[i]->GetName() == G4String(name))
{
tessellated = tessellatedList[i];
break;
}
}
if (tessellated == 0)
{
G4String error_msg = "Referenced solid '" + name + "' not found!";
G4Exception("G4STRead::PhysvolRead()", "ReadError",
FatalException, error_msg);
}
if (volumeMap.find(tessellated) == volumeMap.end())
{
G4String error_msg = "Referenced solid '" + name
+ "' is not associated with a logical volume!";
G4Exception("G4STRead::PhysvolRead()", "InvalidSetup",
FatalException, error_msg);
}
const G4RotationMatrix rot(G4ThreeVector(r1,r2,r3),
G4ThreeVector(r4,r5,r6),
G4ThreeVector(r7,r8,r9));
const G4ThreeVector pos(pX,pY,pZ);
new G4PVPlacement(G4Transform3D(rot.inverse(),pos),
volumeMap[tessellated], name+"_PV", world_volume, 0, 0);
// Note: INVERSE of rotation is needed!!!
G4double minx,miny,minz;
G4double maxx,maxy,maxz;
const G4VoxelLimits limits;
tessellated->CalculateExtent(kXAxis,limits,
G4AffineTransform(rot,pos),minx,maxx);
tessellated->CalculateExtent(kYAxis,limits,
G4AffineTransform(rot,pos),miny,maxy);
tessellated->CalculateExtent(kZAxis,limits,
G4AffineTransform(rot,pos),minz,maxz);
if (world_extent.x() < std::fabs(minx))
{ world_extent.setX(std::fabs(minx)); }
if (world_extent.y() < std::fabs(miny))
{ world_extent.setY(std::fabs(miny)); }
if (world_extent.z() < std::fabs(minz))
{ world_extent.setZ(std::fabs(minz)); }
if (world_extent.x() < std::fabs(maxx))
{ world_extent.setX(std::fabs(maxx)); }
if (world_extent.y() < std::fabs(maxy))
{ world_extent.setY(std::fabs(maxy)); }
if (world_extent.z() < std::fabs(maxz))
{ world_extent.setZ(std::fabs(maxz)); }
}
void G4STRead::ReadGeom(const G4String& name)
{
G4cout << "G4STRead: Reading '" << name << "'..." << G4endl;
std::ifstream GeomFile(name);
if (!GeomFile)
{
G4String error_msg = "Cannot open file: " + name;
G4Exception("G4STRead::ReadGeom()", "ReadError",
FatalException, error_msg);
}
tessellatedList.clear();
volumeMap.clear();
std::string line;
while (getline(GeomFile,line))
{
if (line[0] == 'f') { TessellatedRead(line); } else
if (line[0] == 'p') { FacetRead(line); }
}
if (tessellatedList.size()>0) // Finish the last solid!
{
tessellatedList.back()->SetSolidClosed(true);
}
G4cout << "G4STRead: Reading '" << name << "' done." << G4endl;
}
void G4STRead::ReadTree(const G4String& name)
{
G4cout << "G4STRead: Reading '" << name << "'..." << G4endl;
std::ifstream TreeFile(name);
if (!TreeFile)
{
G4String error_msg = "Cannot open file: " + name;
G4Exception("G4STRead::ReadTree()", "ReadError",
FatalException, error_msg);
}
std::string line;
while (getline(TreeFile,line))
{
if (line[0] == 'g') { PhysvolRead(line); }
}
G4cout << "G4STRead: Reading '" << name << "' done." << G4endl;
}
G4LogicalVolume*
G4STRead::Read(const G4String& name, G4Material* mediumMaterial,
G4Material* solidMaterial)
{
if (mediumMaterial == 0)
{
G4Exception("G4STRead::Read()", "InvalidSetup", FatalException,
"Pointer to medium material is not valid!");
}
if (solidMaterial == 0)
{
G4Exception("G4STRead::Read()", "InvalidSetup", FatalException,
"Pointer to solid material is not valid!");
}
solid_material = solidMaterial;
world_box = new G4Box("TessellatedWorldBox",kInfinity,kInfinity,kInfinity);
// We don't know the extent of the world yet!
world_volume = new G4LogicalVolume(world_box, mediumMaterial,
"TessellatedWorldLV", 0, 0, 0);
world_extent = G4ThreeVector(0,0,0);
ReadGeom(name+".geom");
ReadTree(name+".tree");
// Now setting the world extent ...
//
if (world_box->GetXHalfLength() > world_extent.x())
{ world_box->SetXHalfLength(world_extent.x()); }
if (world_box->GetYHalfLength() > world_extent.y())
{ world_box->SetYHalfLength(world_extent.y()); }
if (world_box->GetZHalfLength() > world_extent.z())
{ world_box->SetZHalfLength(world_extent.z()); }
return world_volume;
}