Importing GDML and CAD models in gemc¶

gemc can import models in GDML [1] format or directly from CAD models [2].

For example, to import three detectors:

• one in the usual TEXT format, named “drift_chambers”
• one in GDML, named “target” (filename is target.gdml)
• one in CAD, named “beamline” (filename is target.stl or target.ply)

you would add the following lines in the gcard:

<detector name="drift_chambers" factory="TEXT" variation="lH2"/>
<detector name="target" factory="GDML"/>


Notice you do not need the variation tag for the GDML and CAD detector factories. If you import the models in this way, you will not be able to assign attributes to them.

Importing CAD models from a directory¶

A single directory can be specified in the gcard. GEMC will look for and load all valid CAD files inside that directory. For example:

<detector name="beamline/" factory="CAD"/>


will load all CAD files inside “beamline”. Only files with these extensions will be loaded: “.stl” or “.ply” or “.obj”. Any other format will be ignored.

GEMC attributes to models¶

Attributes can be assigned when models are imported from a directory. This includes:

• material
• visualization attributes (color, surface style)
• sensitivity

Attributes are assigned by using an XML file “cad.gxml” inside the directory dedicated to the models. For example the following line in a cad.gxml inside the directory “beamline” will change the color, material of an imported volume named “vacuumLine” and assign flux sensitivity so that hits can be recorded:

<volume name="vacuumLine" color="99ff00" material="G4_Pb" sensitivity="flux" identifiers="id manual 1"/>


• A GDML file can contain many volumes. Their attributes are assigned by a .gxml file with the same name as the system. For example, to set the attributes of the target of the gcard above, a filename “target.gxml” can be used:

<gxml>
<volume name="inner_target_vol" color="8899dd" material="lH2"/>
</gxml>

• A CAD file contains only one volume. Many cad files can be imported and the attributes of all of them can be set by filename “cad.gxml””:

<gxml>
<volume name="beamline" color="8899dd" material="G4_Al"/>
</gxml>


You can find many autocad examples here.