Skip to content

Conversation

@AlvaroEzq
Copy link

@AlvaroEzq AlvaroEzq commented Feb 14, 2025

AlvaroEzq Ok: 15 Powered by Pull Request Badge

I am trying to use a gdml where the volumes are defined in child files. Both ROOT and Geant4 are capable of parsing this, but REST not and exits because of this. The problem lies on the TRestGeant4GeometryInfo::PopulateFromGdml where the list of physical and logical volume names is generated.

This PR tries to solve this by adding the physical and volume names to the list. The best way should be to open the child gdml file and search there the name of the volumes but this is more complex (any ideas here are welcome). An easier way is the approach taken in this PR of extracting the name of the child volume from the gdml file name.

Small gdml example to reproduce the issue:
mother.gdml

<?xml version="1.0" encoding="UTF-8" ?>
<gdml xmlns:gdml="../schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../schema/gdml.xsd" >
    <define>
        <position name="center" x="0" y="0" z="0"/>
        <rotation name="identity" x="0" y="0" z="0"/>
    </define>

    <materials>
        <element name="Vacuum_el"  formula="Hv" Z="1">
            <atom value="1.008"/>
        </element>
         
        <material name="Vacuum_ref">
            <D value="0.0000000000000000000001" unit="mg/cm3"/>
            <fraction n="1.0" ref="Vacuum_el"/>
        </material>
    </materials>

    <solids>
        <box name="WorldBox" x="10.0" y="10.0" z="10.0" lunit="m"/>
    </solids>

    <structure>
        <volume name="World">
            <materialref ref="Vacuum_ref"/>
            <solidref ref="WorldBox"/>

            <physvol>
                <file name="/home/aezquerro/simulations/tests/geometries/Volumes/Solid1.gdml"/>
                <positionref ref="center"/>
                <rotationref ref="identity"/>
            </physvol>
            
        </volume>
    </structure>

    <setup name="Default" version="1.0">
        <world ref="World"/>
    </setup>

</gdml>

Solid1.gdml (child file)

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<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>
        <position name="Solid1_v0" unit="mm" x="93.0" y="37.5" z="132.0"/>
        <position name="Solid1_v1" unit="mm" x="93.0" y="-37.5" z="152.0"/>
        <position name="Solid1_v2" unit="mm" x="93.0" y="37.5" z="152.0"/>
        <position name="Solid1_v3" unit="mm" x="93.0" y="-37.5" z="132.0"/>
        <position name="Solid1_v4" unit="mm" x="132.0" y="37.5" z="132.0"/>
        <position name="Solid1_v5" unit="mm" x="132.0" y="-37.5" z="132.0"/>
        <position name="Solid1_v6" unit="mm" x="150.0" y="-37.5" z="77.0"/>
        <position name="Solid1_v7" unit="mm" x="150.0" y="-37.5" z="118.0"/>
        <position name="Solid1_v8" unit="mm" x="132.0" y="-37.5" z="77.0"/>
        <position name="Solid1_v9" unit="mm" x="116.0" y="-37.5" z="152.0"/>
        <position name="Solid1_v10" unit="mm" x="116.0" y="37.5" z="152.0"/>
        <position name="Solid1_v11" unit="mm" x="150.0" y="37.5" z="118.0"/>
        <position name="Solid1_v12" unit="mm" x="150.0" y="37.5" z="77.0"/>
        <position name="Solid1_v13" unit="mm" x="132.0" y="37.5" z="77.0"/>
    </define>
    <materials>
        <element name="Vacuum_el"  formula="Hv" Z="1">
            <atom value="1.008"/>
        </element>
         
        <material name="Vacuum_ref">
            <D value="0.0000000000000000000001" unit="mg/cm3"/>
            <fraction n="1.0" ref="Vacuum_el"/>
        </material>
    </materials>

    <solids>
        <tessellated aunit="deg" lunit="mm" name="Solid1_solid">
            <triangular vertex1="Solid1_v0" vertex2="Solid1_v1" vertex3="Solid1_v2"/>
            <triangular vertex1="Solid1_v3" vertex2="Solid1_v1" vertex3="Solid1_v0"/>
            <triangular vertex1="Solid1_v4" vertex2="Solid1_v5" vertex3="Solid1_v3"/>
            <triangular vertex1="Solid1_v0" vertex2="Solid1_v4" vertex3="Solid1_v3"/>
            <triangular vertex1="Solid1_v6" vertex2="Solid1_v7" vertex3="Solid1_v8"/>
            <triangular vertex1="Solid1_v7" vertex2="Solid1_v5" vertex3="Solid1_v8"/>
            <triangular vertex1="Solid1_v9" vertex2="Solid1_v3" vertex3="Solid1_v5"/>
            <triangular vertex1="Solid1_v9" vertex2="Solid1_v1" vertex3="Solid1_v3"/>
            <triangular vertex1="Solid1_v7" vertex2="Solid1_v9" vertex3="Solid1_v5"/>
            <triangular vertex1="Solid1_v9" vertex2="Solid1_v10" vertex3="Solid1_v1"/>
            <triangular vertex1="Solid1_v10" vertex2="Solid1_v2" vertex3="Solid1_v1"/>
            <triangular vertex1="Solid1_v11" vertex2="Solid1_v12" vertex3="Solid1_v13"/>
            <triangular vertex1="Solid1_v4" vertex2="Solid1_v11" vertex3="Solid1_v13"/>
            <triangular vertex1="Solid1_v0" vertex2="Solid1_v10" vertex3="Solid1_v4"/>
            <triangular vertex1="Solid1_v2" vertex2="Solid1_v10" vertex3="Solid1_v0"/>
            <triangular vertex1="Solid1_v10" vertex2="Solid1_v11" vertex3="Solid1_v4"/>
            <triangular vertex1="Solid1_v4" vertex2="Solid1_v13" vertex3="Solid1_v8"/>
            <triangular vertex1="Solid1_v4" vertex2="Solid1_v8" vertex3="Solid1_v5"/>
            <triangular vertex1="Solid1_v13" vertex2="Solid1_v12" vertex3="Solid1_v8"/>
            <triangular vertex1="Solid1_v8" vertex2="Solid1_v12" vertex3="Solid1_v6"/>
            <triangular vertex1="Solid1_v12" vertex2="Solid1_v11" vertex3="Solid1_v6"/>
            <triangular vertex1="Solid1_v6" vertex2="Solid1_v11" vertex3="Solid1_v7"/>
            <triangular vertex1="Solid1_v7" vertex2="Solid1_v11" vertex3="Solid1_v9"/>
            <triangular vertex1="Solid1_v11" vertex2="Solid1_v10" vertex3="Solid1_v9"/>
        </tessellated>

        <box lunit="mm" name="worldsolid" x="1000" y="1000" z="1000"/>
    </solids>

    <structure>
        <volume name="Solid1">
            <materialref ref="G4_Si"/>
            <solidref ref="Solid1_solid"/>
        </volume>
    </structure>

   <setup name="Default" version="1.0">
      <world ref="Solid1" />
   </setup>
</gdml>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants