Draw a GDML geometry projection on a TCanvas


I have a hit distribution stored in a 2D histogram drawn in a TCanvas.
I would like to superimpose the outline of a GDML imported geometry.
Basically my goal is to draw on canvas above a XY projection of this GDML geometry.
Do you have any advice for that ?
NB: Histogram and GDML are positioned in the same reference frame.

Thank you very much and cheers,

It would be good to have a small example reproducing what you are a doing.
But my first idea would be to create a Pad on top of the GDML geometry and draw the histogram into it.

Hi Olivier

I am going to prepare this, although TGeoManager is still a bit obscur for me.
I am not sure what I can do except importing the geometry :joy:

Is there any function able to project or draw a 2D figure from TGeoManager? I was expecting to have some saving option like for histograms where you can save it in C. (And generating TLine objects in the case of TGeoManager)

This geometry would be something that I will store in a root file and reuse many times. I might also to superimpose 2 of them

I think @agheata can brings some light there :slight_smile:

Hi Marco,

You can only have orthographic projections of geometry using the OpenGL viewer. If you do:
gGeoManager->GetTopVolume()->Draw(“ogl”) and in the viewer select Camera/Ortographic you get this. In a TCanvas the viewer does not do projections, the closest you can get is to do TView3D::SetParallel() from the context menu of the viewer, then use Front/Side/Top from the same context menu. On the other hand, overlaying a histogram in the same pad as the geometry I don’t think it is possible (would be a nice feature though). An alternative is to make sub-pads of the same canvas and draw separately.
For more geometry functionality that you are still unaware, I suggest having a look in the geometry section of the user guide.

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