Possible to plot Geometry on the Same Canvas as a TH3F Hist?

Hello everyone,

I am new to ROOT. I have been attempting to produce a TH3F 4D histogram using “glcolz” and overlaying a detector geometry using PYROOT.

The bins of the TH3F would represent the position of events. I want to overlay the detector geometry so I can view the location of these events within the detector system and the positional density of them.

I have been able to create the detector geometry using TGeoManager and MakeBoxes. I can plot the geometry successfully on its own.

I can also plot the TH3F on its own.

I have tried plotting them both on the same canvas using the “same” argument on the second draw function however I only see the one plot.

A section of the plotting section of code is below.

Any advice would be greatly appreciated.

Many thanks.

g.SetTopVolume(top)
h = ROOT.TH3F("TH3F", "TH3F", 10, -50, 50, 10, -50, 50, 10, -50, 50)

for ping in pings:
    h.Fill(ping[0], ping[1], ping[2])
    
c = ROOT.TCanvas("c", "c", 1000, 1000)

h.Draw("glcolz")
g.Draw("same")

c.Update()

c.Draw()

Welcome to the ROOT forum,

You cannot mixed histograms drawing and TGeo shape drawing.

1 Like

Hi Couet.

Thank you for your welcome and very quick advice.

That is however unfortunate to hear, although I appreciate the end to my futile efforts with it!

Might there any way that 3d objects/boxes whether TGeos or not could be drawn into the 3D space of a TH3F plot at all?

All the best,

*edit TH1F TH3F

@agheata may help

Hi,

It is not possible overlay histogram and geometry drawings in ROOT.

I could try to implement this in JSROOT - if this will be ok for you.

Regards,
Sergey

1 Like

Hi Sergey,

Thank you very much for your response.

I don’t think JSROOT would be a problem…
I don’t have experience in JS or C either and so I’ve been keeping to pyroot for now and I believe using JSROOT for plotting.

I have the “% jsroot on” magic in my Jupiter notebook. I don’t have any problems using it in that sense.

Then I will try.

My idea that TH2/TH3 will be used for axes drawing and content - if any.

And then using histograms coordinates geometry object will be drawn.

1 Like

Hi,

Can you provide canvas stored in ROOT file, where TH3 and geometry drawn together.
I have some prototype, but need to test it.

Regards,
Sergey

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