How to cut a slice from a TH3D histogram

I have a TH3D with min and max x,y,z bins as follows x=(-1500,1500), y=(-1500,1500),z=(-1000,1000)
I want to take a slice of the TH3D histogram to create a TH2D histogram (not a projection but a slice) at x =0 (or any value for that matter) with thickness of one bin
I am unable to find anything that does so.

This is what I am doing

TH3D *h1 = (TH3D*) _file0->Get("hist_name")
h1->Project3D("zy")->Draw("colz")

But this gives a projection. How do I get a slice?

Hi,

That’s still a projection - but only of one bin! :slight_smile: please use h1->GetXaxis()->SetRange(1,1) to select only the first x bin before doing the projection.

Does that do it?

Cheers, Axel.

Thanks!!

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