Projections of TH2D Histograms

I am currently using root version 5.14 and seem to be having a problem with slicing. I have created a 2D histogram with eta and energy loss as the two variables and am filling of order 10,000 entries, when i slice i get the correct number of entries if i do a slice of of the whole range in either x or y. If i do small slices (eg x range split into 5) and i add up the number of events it falls short of the true total. I think it might have to do with

has anyone else had this problem?? is there any better solution than just increasing the number of bins?

Hi,

do your small slices take under- and overflow bins into account?

Axel.

[quote=“Axel”]Hi,

do your small slices take under- and overflow bins into account?

Axel.[/quote]

I believe so. I am going in the lowest one from 0, and in the final one i go to -1.

an example of this happening is i have lost 33 events in a 100x100 2D hist with originally 2996 events.

Hi,

can you post the code + the histogram (in a .root file)?

Still - the most probable way for that to fail is skipping of under/overflows. In x or in y! :slight_smile: You can check with the full stats box on the original 2D histogram, the one that shows under and overflow entries. Maybe those explain the counts you see?

Cheers, Axel.

[quote=“Axel”]Hi,

can you post the code + the histogram (in a .root file)?

Still - the most probable way for that to fail is skipping of under/overflows. In x or in y! :slight_smile: You can check with the full stats box on the original 2D histogram, the one that shows under and overflow entries. Maybe those explain the counts you see?

Cheers, Axel.[/quote]
By looking in the underflow or overflow in the Y (the plane i am not cutting) there is only 1 event underflow. I not sure how to add the histogram, but if you know the command to change the read write options of a file i can do that and give you the address.

The code is attached.

cheers

gareth
AnalysisMain4oGeV.cpp (32.2 KB)

Hi Gareth,

[quote=“browngj”]I not sure how to add the histogram, but if you know the command to change the read write options of a file i can do that and give you the address.[/quote]You can just save it to a .root file!

TFile* f = new TFile("foraxel.root", "RECREATE"); hist->Write(); delete f;.

…but it doesn’t call TH2::ProjectionX(“whatever”, bin, bin) anywhere. Do you slice by hand using that chain of "if"s? Could you compact your macro such that a) I can run it myself (no input files needed - you could e.g. use TH2::FillRandom()) and b) it only contains the code relevant for understanding the slicing problem?

Cheers, Axel.

[quote=“Axel”]Hi Gareth,

[quote=“browngj”]I not sure how to add the histogram, but if you know the command to change the read write options of a file i can do that and give you the address.[/quote]You can just save it to a .root file!

TFile* f = new TFile("foraxel.root", "RECREATE"); hist->Write(); delete f;.

…but it doesn’t call TH2::ProjectionX(“whatever”, bin, bin) anywhere. Do you slice by hand using that chain of "if"s? Could you compact your macro such that a) I can run it myself (no input files needed - you could e.g. use TH2::FillRandom()) and b) it only contains the code relevant for understanding the slicing problem?

Cheers, Axel.[/quote]

i am currently doing the cutting by hand interactively on the 2D histogram as i only need to do 5or 6 slices, The histogram is already in a root file. the only problem is getting the root file uploaded as i am not using SLC and openafs is not yet set up on my computer.

just to clarify if i use -1 as the upper boundary it will include the overflow, and 0 as the lower boundary will include the underflow?