Raytracing through gdml and get material information

Is there a way to do raytracing in a gdml geometry model and get as an output for each ray:

  1. their direction (theta, phi coordinates)
  2. their vertex
  3. the list of materials (and corresponding thicknesses) transversed by the ray?

Thank you!

Welcome to the ROOT Forum!

I think @agheata or @matevz can have an answer to this question

Attached is a macro for viewing gdml files.

The Class member geoEveViewer::Start_Track should give what you need.

geoEveViewer.cc (8.22 KB)

You can also have a look at the ROOT stressGeometry test that transport random rays through several detector geometry files (load from ROOT files, but it is the same for GDML). I pointed the link to the method FindRad that actually does the ray-tracing part and queries material properties.

Thank you for the macro. It does the viewing of the gdml file but I don’t understand how is executed. From the macro I see the definition of different classes but I don’t know how to to “activate” the geoEveViewer::Start_Track. Sorry, I’m a new user of ROOT.

The macro creates a class, “geoEveViewer”.

At the root promt:

.L geoEveViewer.cc

geoEveViewer g(“filename.gdml”);

g.Draw();

g.Start_Track(TVector3(0., 0., 0.),TVector3(0., 0., 1.));

This would shot a vector from (0 0 0) in the Z direction.

1 Like

Thank you very much. It gives the output now as expected. For my problem I need to shot minimum 2000 vectors (spread uniformly) to have 4pi coverage of the full geometry. How could that be possible? I was looking at the documentation and one possibility might be to use the rotation, do you recommend to proceed this way? It will be important to know the point where all the rays are heading to so I can be flexible if I want to consider another point in the geometry.

Looking at stressGeometry by @agheata looks close to give a solution for my problem but I’m having difficulties to open my .gdml file because it gives me the following error:
error: expected unqualified-id

<?xml version="1.0" encoding="UTF-8"?>

^

How do you open your .gdml? Does TGeoManager::Import(gdmlfile) work? Can you share it?

In the member, geoEveViewer.Start_Track(TVector(0.,0.,0.),TVector(0.,0.,1.) the first TVector points to the starting point of the track. The second TVector is the direction cosines (In this case pointing in the Z direction). You can place this member call in a nested for loop which steps the direction cosines to point vectors in all directions about the starting point. This will produce a lot of output. You may want to modify the macro to redirect this output to a file.

Thanks for your suggestions @wattsjw. Actually I used the logic of FindRad from @agheata and the geoEveViewer so I finally get what I was looking for.
I had some problems with the gdml file in the beginning because I had a set of wrong gdml (that’s why I had a strange error).
At the moment I got the list of materials in this order: from the center to the edges of the model. I wanted the other way round so I just reversed this list but I was wondering if there is a command out of the box that provides me this info in the desired order. If not, it’s not the end of the world :slight_smile:.
Thank you @agheata and @wattsjw for your precious help. Without you I wouln’t have made it.

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