Import Geant4 10.4.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2017-06-30 10:49:55 +02:00
parent 3a5407696b
commit 1a1316fea4
2180 changed files with 237880 additions and 59109 deletions
+21 -2
View File
@@ -1,4 +1,4 @@
$Id: History 101687 2016-11-21 09:43:18Z gcosmo $
$Id: History 104834 2017-06-21 08:42:45Z gcosmo $
-------------------------------------------------------------------
=========================================================
@@ -17,8 +17,27 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
20 June 2017 Witek Pokorski (gdml-V10-03-03)
- added optical surface properties to the schema
12 June 2017 Gabriele Cosmo (gdml-V10-03-02)
- Added ability to export limited number of levels in the geometry hierarchy,
by specifying this through the G4GDMLParser::SetMaxExportLevel(G4int) method.
7 April 2017 Gabriele Cosmo (gdml-V10-03-01)
- Enabled import/export of G4MultiUnion as a native type, no longer bound
to USolids module only. Requires co-working tags in geometry.
23 March 2017 Witek Pokorski (gdml-V10-03-00)
- Fixed schema for replicas along angular axis.
Changing the schema to GDML version 3.1.5.
Addressing problem report #1917.
- Added possibility to specify material properties tables for optical
surfaces (Wouter Deconinck). Addressing enhancement request #1947.
18 November 2016 Witek Pokorski (gdml-V10-02-09)
- Fixing check for correctness of the units for replicas in case of angular axis.
- Fixing check for correctness of the units for replicas in case of angular
axis.
13 September Gabriele Cosmo (gdml-V10-02-08)
- Replaced obsolete call to 'Invisible' with 'G4VisAttributes::GetInvisible()'
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4GDMLParser.hh 96673 2016-04-29 12:08:20Z gcosmo $
// $Id: G4GDMLParser.hh 104688 2017-06-12 12:16:28Z gcosmo $
//
//
// class G4GDMLParser
@@ -128,6 +128,9 @@ class G4GDMLParser
inline void SetEnergyCutsExport(G4bool);
inline void SetSDExport(G4bool);
inline G4int GetMaxExportLevel() const; // Manage max number of levels
inline void SetMaxExportLevel(G4int); // to export
inline void Clear(); // Clears the evaluator
// Methods for Writer
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4GDMLParser.icc 96673 2016-04-29 12:08:20Z gcosmo $
// $Id: G4GDMLParser.icc 104688 2017-06-12 12:16:28Z gcosmo $
//
//
// class G4GDMLParser inline methods
@@ -213,6 +213,16 @@ inline void G4GDMLParser::SetSDExport(G4bool flag)
writer->SetSDExport(flag);
}
inline G4int G4GDMLParser::GetMaxExportLevel() const
{
return writer->GetMaxExportLevel();
}
inline void G4GDMLParser::SetMaxExportLevel(G4int level)
{
writer->SetMaxExportLevel(level);
}
inline void G4GDMLParser::Clear()
{
reader->Clear();
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4GDMLReadSolids.hh 96133 2016-03-16 22:21:17Z gcosmo $
// $Id: G4GDMLReadSolids.hh 103265 2017-03-23 11:14:00Z gcosmo $
//
//
// class G4GDMLReadSolids
@@ -49,6 +49,7 @@ class G4VSolid;
class G4QuadrangularFacet;
class G4TriangularFacet;
class G4SurfaceProperty;
class G4OpticalSurface;
class G4GDMLReadSolids : public G4GDMLReadMaterials
{
@@ -107,6 +108,7 @@ class G4GDMLReadSolids : public G4GDMLReadMaterials
zplaneType ZplaneRead(const xercesc::DOMElement* const);
rzPointType RZPointRead(const xercesc::DOMElement* const);
void OpticalSurfaceRead(const xercesc::DOMElement* const);
void PropertyRead(const xercesc::DOMElement* const,G4OpticalSurface*);
};
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4GDMLWriteSolids.hh 96133 2016-03-16 22:21:17Z gcosmo $
// $Id: G4GDMLWriteSolids.hh 103265 2017-03-23 11:14:00Z gcosmo $
//
//
// class G4GDMLWriteSolids
@@ -141,6 +141,8 @@ class G4GDMLWriteSolids : public G4GDMLWriteMaterials
void RZPointWrite(xercesc::DOMElement*, const G4double&,const G4double&);
void OpticalSurfaceWrite(xercesc::DOMElement*,
const G4OpticalSurface* const);
void PropertyWrite(xercesc::DOMElement*, const G4OpticalSurface* const);
protected:
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4GDMLWriteStructure.hh 96677 2016-04-29 12:20:20Z gcosmo $
// $Id: G4GDMLWriteStructure.hh 104688 2017-06-12 12:16:28Z gcosmo $
//
//
// class G4GDMLWriteStructure
@@ -67,6 +67,9 @@ class G4GDMLWriteStructure : public G4GDMLWriteParamvol
void SetEnergyCutsExport(G4bool);
void SetSDExport(G4bool);
G4int GetMaxExportLevel() const;
void SetMaxExportLevel(G4int);
protected:
void DivisionvolWrite(xercesc::DOMElement*, const G4PVDivision* const);
@@ -96,7 +99,9 @@ class G4GDMLWriteStructure : public G4GDMLWriteParamvol
std::vector<const G4OpticalSurface*> opt_vec;
G4ReflectionFactory* reflFactory;
G4bool cexport; // Flag for optional export of energy cuts per volume
G4bool sdexport; // Flag for optional export of SD per volume
G4bool sdexport; // Flag for optional export of SD per volume
G4int maxLevel; // Maximum number of levels to export
static G4int levelNo; // Counter for level being exported
};
#endif
+1 -1
View File
@@ -198,7 +198,7 @@
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute fixed="3.1.4" name="version" type="xs:string">
<xs:attribute fixed="3.1.5" name="version" type="xs:string">
<xs:annotation>
<xs:documentation>The GDML Schema version consists of 3 digits X.Y.Z
where these mean:
@@ -65,12 +65,11 @@
</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: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:attribute default="0.0" name="phi" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="0.0" name="rho" type="ExpressionOrIDREFType"></xs:attribute>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="direction" type="directionType"/>
+27 -2
View File
@@ -145,10 +145,35 @@
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:group name="OpticalSurfacePropertiesGroup">
<xs:annotation>
<xs:documentation>General optical surface properties</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:choice minOccurs="0">
<xs:element maxOccurs="unbounded" name="property">
<xs:annotation>
<xs:documentation>General optical surface 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:sequence>
</xs:group>
<xs:complexType name="SurfacePropertyType">
<xs:annotation>
<xs:documentation>Base surface type</xs:documentation>
</xs:annotation>
<xs:group ref="OpticalSurfacePropertiesGroup"></xs:group>
<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>
@@ -950,8 +975,8 @@
</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>
+91 -25
View File
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4GDMLReadSolids.cc 96190 2016-03-29 08:07:36Z gcosmo $
// $Id: G4GDMLReadSolids.cc 103463 2017-04-11 07:22:55Z gcosmo $
//
// class G4GDMLReadSolids Implementation
//
@@ -69,6 +69,7 @@
#include "G4OpticalSurface.hh"
#include "G4UnitsTable.hh"
#include "G4SurfaceProperty.hh"
#include "G4MaterialPropertiesTable.hh"
G4GDMLReadSolids::G4GDMLReadSolids() : G4GDMLReadMaterials()
{
@@ -574,17 +575,6 @@ void G4GDMLReadSolids::HypeRead(const xercesc::DOMElement* const hypeElement)
new G4Hype(name,rmin,rmax,inst,outst,z);
}
#if !defined(G4GEOM_USE_USOLIDS)
void G4GDMLReadSolids::
MultiUnionNodeRead(const xercesc::DOMElement* const,
G4MultiUnion* const)
{
G4Exception("G4GDMLReadSolids::MultiUnionNodeRead()",
"InvalidSetup", FatalException,
"Installation with USolids primitives required!");
return;
}
#else
void G4GDMLReadSolids::
MultiUnionNodeRead(const xercesc::DOMElement* const unionNodeElement,
G4MultiUnion* const multiUnionSolid)
@@ -653,18 +643,7 @@ MultiUnionNodeRead(const xercesc::DOMElement* const unionNodeElement,
G4Transform3D transform(GetRotationMatrix(rotation),position);
multiUnionSolid->AddNode(*solidNode, transform);
}
#endif
#if !defined(G4GEOM_USE_USOLIDS)
void G4GDMLReadSolids::
MultiUnionRead(const xercesc::DOMElement* const)
{
G4Exception("G4GDMLReadSolids::MultiUnionRead()",
"InvalidSetup", FatalException,
"Installation with USolids primitives required!");
return;
}
#else
void G4GDMLReadSolids::
MultiUnionRead(const xercesc::DOMElement* const unionElement)
{
@@ -723,7 +702,6 @@ MultiUnionRead(const xercesc::DOMElement* const unionElement)
}
multiUnion->Voxelize();
}
#endif
void G4GDMLReadSolids::OrbRead(const xercesc::DOMElement* const orbElement)
{
@@ -2466,6 +2444,75 @@ RZPointRead(const xercesc::DOMElement* const zplaneElement)
}
void G4GDMLReadSolids::
PropertyRead(const xercesc::DOMElement* const propertyElement,
G4OpticalSurface* opticalsurface)
{
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);
if (!attribute)
{
G4Exception("G4GDMLReadSolids::PropertyRead()", "InvalidRead",
FatalException, "No attribute found!");
return;
}
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 opticalsurface: "
+ opticalsurface->GetName();
G4Exception("G4GDMLReadSolids::PropertyRead()", "InvalidRead",
FatalException, error_msg);
}
*/
if (matrix.GetRows() == 0) { return; }
G4MaterialPropertiesTable* matprop=opticalsurface->GetMaterialPropertiesTable();
if (!matprop)
{
matprop = new G4MaterialPropertiesTable();
opticalsurface->SetMaterialPropertiesTable(matprop);
}
if (matrix.GetCols() == 1) // constant property assumed
{
matprop->AddConstProperty(Strip(name), matrix.Get(0,0));
}
else // build the material properties vector
{
G4MaterialPropertyVector* propvect = new G4MaterialPropertyVector();
for (size_t i=0; i<matrix.GetRows(); i++)
{
propvect->InsertValues(matrix.Get(i,0),matrix.Get(i,1));
}
matprop->AddProperty(Strip(name),propvect);
}
}
void G4GDMLReadSolids::
OpticalSurfaceRead(const xercesc::DOMElement* const opticalsurfaceElement)
{
@@ -2586,7 +2633,26 @@ OpticalSurfaceRead(const xercesc::DOMElement* const opticalsurfaceElement)
{ type = firsov; }
else { type = x_ray; }
new G4OpticalSurface(name,model,finish,type,value);
G4OpticalSurface* opticalsurface
= new G4OpticalSurface(name,model,finish,type,value);
for (xercesc::DOMNode* iter = opticalsurfaceElement->getFirstChild();
iter != 0;iter = iter->getNextSibling())
{
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
const xercesc::DOMElement* const child
= dynamic_cast<xercesc::DOMElement*>(iter);
if (!child)
{
G4Exception("G4GDMLReadSolids::OpticalSurfaceRead()",
"InvalidRead", FatalException, "No child found!");
return;
}
const G4String tag = Transcode(child->getTagName());
if (tag=="property") { PropertyRead(child,opticalsurface); }
}
}
void G4GDMLReadSolids::SolidsRead(const xercesc::DOMElement* const solidsElement)
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4GDMLWriteSolids.cc 96133 2016-03-16 22:21:17Z gcosmo $
// $Id: G4GDMLWriteSolids.cc 103463 2017-04-11 07:22:55Z gcosmo $
//
// class G4GDMLWriteSolids Implementation
//
@@ -69,6 +69,7 @@
#include "G4UnionSolid.hh"
#include "G4OpticalSurface.hh"
#include "G4SurfaceProperty.hh"
#include "G4MaterialPropertiesTable.hh"
G4GDMLWriteSolids::G4GDMLWriteSolids()
: G4GDMLWriteMaterials(), solidsElement(0)
@@ -79,17 +80,6 @@ G4GDMLWriteSolids::~G4GDMLWriteSolids()
{
}
#if !defined(G4GEOM_USE_USOLIDS)
void G4GDMLWriteSolids::
MultiUnionWrite(xercesc::DOMElement*,
const G4MultiUnion* const)
{
G4Exception("G4GDMLWriteSolids::MultiUnionWrite()",
"InvalidSetup", FatalException,
"Installation with USolids primitives required!");
return;
}
#else
void G4GDMLWriteSolids::
MultiUnionWrite(xercesc::DOMElement* solElement,
const G4MultiUnion* const munionSolid)
@@ -98,7 +88,7 @@ MultiUnionWrite(xercesc::DOMElement* solElement,
G4String tag("multiUnion");
G4VSolid* solid;
G4Transform3D* transform;
G4Transform3D transform;
const G4String& name = GenerateName(munionSolid->GetName(),munionSolid);
xercesc::DOMElement* multiUnionElement = NewElement(tag);
@@ -112,7 +102,7 @@ MultiUnionWrite(xercesc::DOMElement* solElement,
HepGeom::Rotate3D rot3d;
HepGeom::Translate3D transl ;
HepGeom::Scale3D scale;
transform->getDecomposition(scale,rot3d,transl);
transform.getDecomposition(scale,rot3d,transl);
G4ThreeVector pos = transl.getTranslation();
G4RotationMatrix
@@ -148,7 +138,6 @@ MultiUnionWrite(xercesc::DOMElement* solElement,
solElement->appendChild(multiUnionElement);
// Add the multiUnion solid AFTER the constituent nodes!
}
#endif
void G4GDMLWriteSolids::
BooleanWrite(xercesc::DOMElement* solElement,
@@ -1050,9 +1039,62 @@ OpticalSurfaceWrite(xercesc::DOMElement* solElement,
optElement->setAttributeNode(NewAttribute("type", surf->GetType()));
optElement->setAttributeNode(NewAttribute("value", sval));
// Write any property attached to the optical surface...
//
if (surf->GetMaterialPropertiesTable())
{
PropertyWrite(optElement, surf);
}
solElement->appendChild(optElement);
}
void G4GDMLWriteSolids::PropertyWrite(xercesc::DOMElement* optElement,
const G4OpticalSurface* const surf)
{
xercesc::DOMElement* propElement;
G4MaterialPropertiesTable* ptable = surf->GetMaterialPropertiesTable();
const std::map< G4String, G4PhysicsOrderedFreeVector*,
std::less<G4String> >* pmap = ptable->GetPropertiesMap();
const std::map< G4String, G4double,
std::less<G4String> >* cmap = ptable->GetPropertiesCMap();
std::map< G4String, G4PhysicsOrderedFreeVector*,
std::less<G4String> >::const_iterator mpos;
std::map< G4String, G4double,
std::less<G4String> >::const_iterator cpos;
for (mpos=pmap->begin(); mpos!=pmap->end(); mpos++)
{
propElement = NewElement("property");
propElement->setAttributeNode(NewAttribute("name", mpos->first));
propElement->setAttributeNode(NewAttribute("ref",
GenerateName(mpos->first, mpos->second)));
if (mpos->second)
{
PropertyVectorWrite(mpos->first, mpos->second);
optElement->appendChild(propElement);
}
else
{
G4String warn_message = "Null pointer for material property -"
+ mpos->first + "- of optical surface -" + surf->GetName() + "- !";
G4Exception("G4GDMLWriteSolids::PropertyWrite()", "NullPointer",
JustWarning, warn_message);
continue;
}
}
for (cpos=cmap->begin(); cpos!=cmap->end(); cpos++)
{
propElement = NewElement("property");
propElement->setAttributeNode(NewAttribute("name", cpos->first));
propElement->setAttributeNode(NewAttribute("ref", cpos->first));
xercesc::DOMElement* constElement = NewElement("constant");
constElement->setAttributeNode(NewAttribute("name", cpos->first));
constElement->setAttributeNode(NewAttribute("value", cpos->second));
defineElement->appendChild(constElement);
optElement->appendChild(propElement);
}
}
void G4GDMLWriteSolids::SolidsWrite(xercesc::DOMElement* gdmlElement)
{
G4cout << "G4GDML: Writing solids..." << G4endl;
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4GDMLWriteStructure.cc 96677 2016-04-29 12:20:20Z gcosmo $
// $Id: G4GDMLWriteStructure.cc 104688 2017-06-12 12:16:28Z gcosmo $
//
// class G4GDMLWriteStructure Implementation
//
@@ -57,8 +57,10 @@
#include "G4VSensitiveDetector.hh"
G4int G4GDMLWriteStructure::levelNo = 0; // Counter for level being exported
G4GDMLWriteStructure::G4GDMLWriteStructure()
: G4GDMLWriteParamvol(), cexport(false)
: G4GDMLWriteParamvol(), cexport(false), maxLevel(INT_MAX)
{
reflFactory = G4ReflectionFactory::Instance();
}
@@ -395,6 +397,8 @@ TraverseVolumeTree(const G4LogicalVolume* const volumePtr, const G4int depth)
std::map<const G4LogicalVolume*, G4GDMLAuxListType>::iterator auxiter;
levelNo++;
while (true) // Solve possible displacement/reflection
{ // of the referenced solid!
if (trans>maxTransforms)
@@ -459,8 +463,13 @@ TraverseVolumeTree(const G4LogicalVolume* const volumePtr, const G4int depth)
solidrefElement->setAttributeNode(NewAttribute("ref",solidref));
volumeElement->appendChild(solidrefElement);
const G4int daughterCount = volumePtr->GetNoDaughters();
G4int daughterCount = volumePtr->GetNoDaughters();
if (levelNo == maxLevel) // Stop exporting if reached levels limit
{
daughterCount = 0;
}
for (G4int i=0;i<daughterCount;i++) // Traverse all the children!
{
const G4VPhysicalVolume* const physvol = volumePtr->GetDaughter(i);
@@ -542,9 +551,9 @@ TraverseVolumeTree(const G4LogicalVolume* const volumePtr, const G4int depth)
}
structureElement->appendChild(volumeElement);
// Append the volume AFTER traversing the children so that
// the order of volumes will be correct!
// Append the volume AFTER traversing the children so that
// the order of volumes will be correct!
VolumeMap()[tmplv] = R;
AddExtension(volumeElement, volumePtr);
@@ -633,3 +642,23 @@ G4GDMLWriteStructure::ExportSD(const G4LogicalVolume* const lvol)
AddVolumeAuxiliary(SDinfo, lvol);
}
}
G4int
G4GDMLWriteStructure::GetMaxExportLevel() const
{
return maxLevel;
}
void
G4GDMLWriteStructure::SetMaxExportLevel(G4int level)
{
if (level <= 0)
{
G4Exception("G4GDMLWriteStructure::TraverseVolumeTree()",
"InvalidSetup", FatalException,
"Levels to export must be greater than zero!");
return;
}
maxLevel = level;
levelNo = 0;
}