Gdml multiple files error with define

I am trying to define a geometry with gdml using multiple files, using the gdml manual as a reference (https://gdml.web.cern.ch/GDML/doc/GDMLmanual.pdf) but I am having a problem when using the tesselated solid geometry.

In this case (a simple cube) it works fine:

child.gdml

<?xml version="1.0" encoding="UTF-8"?>
<gdml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://service-spi.web.cern.ch/service-spi/app/releases/GDML/schema/gdml.xsd">
   <define>
      <constant name="size" value="50" />
   </define>
   <solids>
      <box name="world_solid" x="100" y="100" z="100" />
      <box name="child_solid" x="size" y="size" z="size" />
   </solids>
   <structure>
      <volume name="child">
         <materialref ref="child_material" />
         <solidref ref="child_solid" />
      </volume>
      <volume name="world">
         <physvol>
            <volumeref ref="child" />
         </physvol>
         <materialref ref="world_material" />
         <solidref ref="world_solid" />
      </volume>
   </structure>
   <setup name="Default" version="1.0">
      <world ref="world" />
   </setup>
</gdml>

mother.gdml

<?xml version="1.0" encoding="UTF-8"?>
<gdml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://service-spi.web.cern.ch/service-spi/app/releases/GDML/schema/gdml.xsd">
   <define />
   <solids>
      <box name="world_solid" x="100" y="100" z="100" />
   </solids>
   <structure>
      <volume name="world">
         <physvol>
            <file name="child.gdml" />
         </physvol>
         <materialref ref="world_material" />
         <solidref ref="world_solid" />
      </volume>
   </structure>
   <setup name="Default" version="1.0">
      <world ref="world" />
   </setup>
</gdml>

However when I use a tesselated solid on the child volume I get an error:

child.gdml (tesselated)

<?xml version="1.0" encoding="UTF-8"?>
<gdml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://service-spi.web.cern.ch/service-spi/app/releases/GDML/schema/gdml.xsd">
   <define>
      <position name="cube_v0" unit="mm" x="10.0" y="-10.0" z="10.0" />
      <position name="cube_v1" unit="mm" x="10.0" y="0.0" z="10.0" />
      <position name="cube_v2" unit="mm" x="0.0" y="-10.0" z="10.0" />
      <position name="cube_v3" unit="mm" x="0.0" y="0.0" z="10.0" />
      <position name="cube_v4" unit="mm" x="0.0" y="-10.0" z="0.0" />
      <position name="cube_v5" unit="mm" x="0.0" y="0.0" z="0.0" />
      <position name="cube_v6" unit="mm" x="10.0" y="-10.0" z="0.0" />
      <position name="cube_v7" unit="mm" x="10.0" y="0.0" z="0.0" />
   </define>
   <solids>
      <box name="world_solid" x="100" y="100" z="100" />
      <tessellated name="child_solid" aunit="deg" lunit="mm">
         <triangular vertex1="cube_v0" vertex2="cube_v1" vertex3="cube_v2" />
         <triangular vertex1="cube_v2" vertex2="cube_v1" vertex3="cube_v3" />
         <triangular vertex1="cube_v4" vertex2="cube_v5" vertex3="cube_v6" />
         <triangular vertex1="cube_v6" vertex2="cube_v5" vertex3="cube_v7" />
         <triangular vertex1="cube_v3" vertex2="cube_v5" vertex3="cube_v2" />
         <triangular vertex1="cube_v2" vertex2="cube_v5" vertex3="cube_v4" />
         <triangular vertex1="cube_v1" vertex2="cube_v7" vertex3="cube_v3" />
         <triangular vertex1="cube_v3" vertex2="cube_v7" vertex3="cube_v5" />
         <triangular vertex1="cube_v0" vertex2="cube_v6" vertex3="cube_v1" />
         <triangular vertex1="cube_v1" vertex2="cube_v6" vertex3="cube_v7" />
         <triangular vertex1="cube_v2" vertex2="cube_v4" vertex3="cube_v0" />
         <triangular vertex1="cube_v0" vertex2="cube_v4" vertex3="cube_v6" />
      </tessellated>
   </solids>
   <structure>
      <volume name="child">
         <materialref ref="child_material" />
         <solidref ref="child_solid" />
      </volume>
      <volume name="world">
         <physvol>
            <volumeref ref="child" />
         </physvol>
         <materialref ref="world_material" />
         <solidref ref="world_solid" />
      </volume>
   </structure>
   <setup name="Default" version="1.0">
      <world ref="world" />
   </setup>
</gdml>

To read the GDML I use TGeoManager::Import("mother.gdml").

I get the following error on the tesselated geometry:

Info in <TGeoManager::Import>: Reading geometry from file: mother.gdml
Info in <TGeoManager::TGeoManager>: Geometry GDMLImport, Geometry imported from GDML created
Medium: world_material, Not Yet Defined!
Fatal in <TGDMLParse::Tessellated>: Vertex cube_v0 not defined

It looks like the cube_v0 definition is not being carried over in the <file/> declaration. However this does not make sense to me because in the first example, I am using the size definition which is correctly processed.

What am I missing?

Thanks!

I have found a likely explanation in Reading GDML File in ROOT 6.25 - #4 by FFoll but I still don’t understand why the first case (using box) works and the tesselated solid does not work, perhaps @agheata can shine some light on this topic ^^. To me this looks like a bug in the parser.

My goal would be to have each of the gdml module files be readable on their own (thats why they have a world volume and so on) and also be able to be incorporated into a mother gdml. I thought this was possible since I can do it with the box example.

I have tried to name the vertices in the file as suggested in the linked reply (such as vertex1="cube_v0_Volumes/child.gdml") but it gives out the same error. I really don’t want to place all the definitions inside the mother file since that would defeat the purpose of splitting the file.

I wanted to check if the gdml was properly parsed by the Geant4 parser and after removing the “world” volume from the child gdml it looks like it can be read OK.

new child.gdml:

<?xml version="1.0" encoding="UTF-8"?>
<gdml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="https://service-spi.web.cern.ch/service-spi/app/releases/GDML/schema/gdml.xsd">
    <define>
        <position name="cube_v0" unit="mm" x="10.0" y="-10.0" z="10.0"/>
        <position name="cube_v1" unit="mm" x="10.0" y="0.0" z="10.0"/>
        <position name="cube_v2" unit="mm" x="0.0" y="-10.0" z="10.0"/>
        <position name="cube_v3" unit="mm" x="0.0" y="0.0" z="10.0"/>
        <position name="cube_v4" unit="mm" x="0.0" y="-10.0" z="0.0"/>
        <position name="cube_v5" unit="mm" x="0.0" y="0.0" z="0.0"/>
        <position name="cube_v6" unit="mm" x="10.0" y="-10.0" z="0.0"/>
        <position name="cube_v7" unit="mm" x="10.0" y="0.0" z="0.0"/>
    </define>
    <solids>
        <box name="world_solid" x="100" y="100" z="100"/>
        <tessellated name="child_solid" aunit="deg" lunit="mm">
            <triangular vertex1="cube_v0" vertex2="cube_v1" vertex3="cube_v2"/>
            <triangular vertex1="cube_v2" vertex2="cube_v1" vertex3="cube_v3"/>
            <triangular vertex1="cube_v4" vertex2="cube_v5" vertex3="cube_v6"/>
            <triangular vertex1="cube_v6" vertex2="cube_v5" vertex3="cube_v7"/>
            <triangular vertex1="cube_v3" vertex2="cube_v5" vertex3="cube_v2"/>
            <triangular vertex1="cube_v2" vertex2="cube_v5" vertex3="cube_v4"/>
            <triangular vertex1="cube_v1" vertex2="cube_v7" vertex3="cube_v3"/>
            <triangular vertex1="cube_v3" vertex2="cube_v7" vertex3="cube_v5"/>
            <triangular vertex1="cube_v0" vertex2="cube_v6" vertex3="cube_v1"/>
            <triangular vertex1="cube_v1" vertex2="cube_v6" vertex3="cube_v7"/>
            <triangular vertex1="cube_v2" vertex2="cube_v4" vertex3="cube_v0"/>
            <triangular vertex1="cube_v0" vertex2="cube_v4" vertex3="cube_v6"/>
        </tessellated>
    </solids>
    <structure>
        <volume name="child">
            <materialref ref="G4_Pb"/>
            <solidref ref="child_solid"/>
        </volume>
    </structure>
    <setup name="Default" version="1.0">
        <world ref="child"/>
    </setup>
</gdml>

So the Geant4 gdml parser works but the ROOT one doesn’t.

Hi @lobis ,
thank you for opening an issue at GDML module not working with Tessellated solid · Issue #9744 · root-project/root · GitHub – I think we need @agheata 's help.

Cheers,
Enrico

Hi,
The general problem here is that in the current parser implementation when there are children GDML files, all created object names in these files get appended _filename (in this case e.g. cube_v0_child.gdml). So whenever such objects are then referenced using the original name, they are obviously not found. If the tessellated vertex positions were for example defined in mother.gdml it would work. This is obviously a bug, AFAICT introduced to disambiguate possibly the same name defined in 2 different files. I’ll have to see how to fix this properly, not to create backward incompatibilities. As soon as I have a solution, I’l keep you posted via the issue 9744 you opened.

Thank you!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.