Message: Re: Generating a geometry GDML file Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

News Re: Generating a geometry GDML file 

Forum: Geometry
Re: Question Generating a geometry GDML file (Luis Alejandro Perez Perez)
Date: 17 Jul, 2015
From: Michael H. Kelsey <Michael H. Kelsey>

On Fri, 17 Jul 2015 15:44:53 GMT, Luis Alejandro Perez Perez wrote:
> I am writing an application for simulating beam test setups with silicon detector telescopes. I would 
> already wrote a code for doing this but would like to generate a gdml file with the geometry description 
> to visualize it later with root. Is there a systematic way of doing this in Geant4?

Yes, it's quite easy to both write and read GDML files with Geant4. You will have to the external XercesC library installed on your system (see the Geant4 Installation Guide), and set the following CMake flags:

    cmake -DGEANT4_USE_GDML=ON -DXERCESC_INCLUDE_DIR=<whatever> -DXERCESC_LIBRARY=<whatever>/libxerces-c.so <other-cmake-stuff>

(or .dylib on MacOSX). You can use |ccmake| interactively; the XercesC stuff is in the Advanced options.

Once your geometry has been built (i.e., after |/run/initialize|), use the command

  /persistency/gdml/write <filename>

to dump your geometry to a GDML file.

Note that the geometry file produced this way is not particularly friendly to humans. All of the names (of materials, of solids, and of volumes) have the hexadecimal pointer from your G4 job appended:

    <isotope N="54" Z="26" name="Fe540xb9b7ef0">
      <atom unit="g/mole" value="53.9396"/>
    </isotope>

    <subtraction name="Shield-OuterPoly0xd643bc0">
      <first ref="Tube10xd643a60"/>
      <second ref="Tube20xd643b20"/>
      <position name="Shield-OuterPoly0xd643bc0_pos" unit="mm" x="0" y="0" z="25.4"/>
    </subtraction>

    <volume name="Shield-InnerLead0xd643160">
      <materialref ref="G4_Pb0xb9b6970"/>
      <solidref ref="Shield-InnerLead0xd643010"/>
    </volume>

I wrote myself a script to process the GDML file and strip out all this cruft, but it's kind of annoying.

There is an external library you might want to try. VGM (http://ivana.home.cern.ch/ivana/VGM.html), written by one of our Geant4 collaborators, Ivan Hrivnacova, provides interconversion between a few different geometry formats, including G4, ROOT, and GDML. The GDML output from VGM is more human friendly.

  -- Michael Kelsey

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 None: Re: Generating a geometry GDML file   (Luis Alejandro Perez Perez - 20 Jul, 2015)
1 None: Re: Generating a geometry GDML file   (Ivana Hrivnacova - 12 Aug, 2015)
2 None: Re: Generating a geometry GDML file   (Ivana Hrivnacova - 12 Aug, 2015)
3 None: Re: Generating a geometry GDML file   (Ivana Hrivnacova - 12 Aug, 2015)
1 Question: Re: Generating a geometry GDML file   (Leonardo Ghizoni - 20 Sep, 2015)
... 1 Message(s)
 Add Message Add Message
to: "Re: Generating a geometry GDML file"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]