Gdml geometries in geant4

Can someone help me with CAD to GDML geometries? I have converted .stl file into .gdml using Cadmesh but am not able to understand how I can specify material and optical properties. Also, do I need to make multiple .gdml if I have different materials? Consider: if I have a scintillator detector, do I need multiple .gdml for the reflector, lightguide, or sensor?

Hello,

Do I need to make multiple .gdml if I have different materials?
Do I need multiple .gdml for the reflector, lightguide, or sensor?

No, a GDML file can contain multiple geometries and materials.

I recommend you take a look into
examples/extended/persistency/gdml/G02

It shows how you can read a GDML or STEP file to build your geometry and then export it to a GDML file. (Of course you can use CadMesh to read your STEP file into Geant)

The process would be:
-read STEP file into Geant
-assign materials
-export geometry from Geant to GDML

Regards
Max

G4GDML: Writing ‘wtest.gdml’…

-------- EEEE ------- G4Exception-START -------- EEEE -------
*** G4Exception : InvalidSetup
issued by : G4GDMLWrite::Write()
File ‘wtest.gdml’ already exists!
*** Fatal Exception *** core dump ***
**** Track information is not available at this moment
**** Step information is not available at this moment

-------- EEEE -------- G4Exception-END --------- EEEE -------

*** G4Exception: Aborting execution ***

Sir, I’m getting this error with your above example

Hello,

The problem is stated in the error message:

-------- EEEE ------- G4Exception-START -------- EEEE -------
*** G4Exception : InvalidSetup
issued by : G4GDMLWrite::Write()
File ‘wtest.gdml’ already exists!
*** Fatal Exception *** core dump ***
**** Track information is not available at this moment
**** Step information is not available at this moment

-------- EEEE -------- G4Exception-END --------- EEEE -------

*** G4Exception: Aborting execution ***

Trying to write the GDML into a file that does not exist should solve your problem.