Hi everyone,
I am trying to create a geometry using loops in gdml.
You can find here a simple example of what I’m trying to do:
<!DOCTYPE gdml [
<!ENTITY materials SYSTEM "https://rest-for-physics.github.io/materials/materials.xml">
]>
<gdml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://service-spi.web.cern.ch/service-spi/app/releases/GDML/schema/gdml.xsd">
<define>
<variable name="world_size" value="700" />
<!-- The vessel definitions -->
<constant name="vesselThickness" value="10" /> <!--in mm's -->
<constant name="vesselXSize" value="100" />
<constant name="vesselYSize" value="100" />
<constant name="vesselZSize" value="100"/>
<position name="vesselPosition" unit="mm" x="0" y="0" z="0"/>
<matrix name="m" coldim="5" values="0 100 200 300 400"/>
<variable name="i" value="0" />
<variable name="num" value="5" />
</define>
&materials;
<solids>
<box name="WorldSolid" x="world_size" y="world_size" z="world_size" lunit="mm"/>
<loop for="i" from="1" to="num" step="1">
<box name="vesselSolid[i]" x="vesselXSize" y="vesselYSize" z="vesselZSize" lunit="mm"/>
</loop>
<box name="gasSolid" x="vesselXSize-2*vesselThickness" y="vesselYSize-2*vesselThickness" z="vesselZSize-2*vesselThickness" lunit="mm" />
<!-- <subtraction name="vesselSolid"> -->
<!-- <first ref="solidBox"/> -->
<!-- <second ref="gasSolid"/> -->
<!-- </subtraction> -->
</solids>
<structure>
<!-- {{{ Volumes definition (material and solid assignment) -->
<loop for="i" from="1" to="num" step="1">
<volume name="vesselVolume[i]">
<materialref ref="G4_Cu" />
<solidref ref="vesselSolid[i]" />
</volume>
</loop>
<volume name="gasVolume">
<materialref ref="G4_GLASS_PLATE"/>
<solidref ref="gasSolid"/>
</volume>
<!-- {{{ Physical volume definition (volume and position assignment) -->
<volume name="World">
<materialref ref="G4_AIR"/>
<solidref ref="WorldSolid"/>
<loop for="i" from="1" to="num" step="1">
<physvol>
<volumeref ref="vesselVolume[i]" />
<position name="pos[i]" x="0" y="0" z="m[1,i]"/>
</physvol>
</loop>
<physvol name="gas">
<volumeref ref="gasVolume"/>
<position name="gasPosition" x="0" y="0" z="0"/>
</physvol>
</volume>
</structure>
<setup name="Default" version="1.0">
<world ref="World"/>
</setup>
</gdml>
In a new root
session, I use the TGeoManager()
class to visualize the geometry and here is the output:
Filename : box.gdml
TRestGDMLParser: Initializing variables
TRestGDMLParser: Replacing expressions in GDML
TRestGDMLParser: Replacing entity: materials, file: https://rest-for-physics.github.io/materials/materials.xml
TRestGDMLParser: Creating temporary file at: "/uni-mainz.de/homes/cgirardc/.rest/gdml/PID655383_box.gdml"
Info in <TGeoManager::Import>: Reading geometry from file: /uni-mainz.de/homes/cgirardc/.rest/gdml/PID655383_box.gdml
Info in <TGeoManager::TGeoManager>: Geometry GDMLImport, Geometry imported from GDML created
Error: Unsupported GDML Tag Used :loop. Please Check Geometry/Schema.
Error: Unsupported GDML Tag Used :loop. Please Check Geometry/Schema.
Info in <TGeoManager::SetTopVolume>: Top volume is World. Master volume is World
Info in <TGeoNavigator::BuildCache>: --- Maximum geometry depth set to 100
Info in <TGeoManager::CheckGeometry>: Fixing runtime shapes...
Info in <TGeoManager::CheckGeometry>: ...Nothing to fix
Info in <TGeoManager::CloseGeometry>: Counting nodes...
Info in <TGeoManager::Voxelize>: Voxelizing...
Info in <TGeoManager::CloseGeometry>: Building cache...
Info in <TGeoManager::CountLevels>: max level = 1, max placements = 1
Info in <TGeoManager::CloseGeometry>: 2 nodes/ 3 volume UID's in Geometry imported from GDML
Info in <TGeoManager::CloseGeometry>: ----------------modeler ready----------------
Info in <TCanvas::MakeDefCanvas>: created default TCanvas with name c1
(int) 0
and the vessels do not appear in the visualization.
Loops are definitely supported by GDML (see documentation section 3.5.1 Loops).
Am I missing something?
Thank you for your help
ROOT Version: 6.26/10
Platform: Debian GNU/Linux 11
Compiler: g++ 10.4.0