Finding individual bin width

Hi everyone,

I am trying to calculate delta N/ delta t but having trouble using GetBinWidth to find values for delta N and delta t.

t = pt^2 (Plotted on X-axis)
N = number of events (Plotted on Y-axis)

In my code I used:

TH1F* tHist = new TH1F(“tPt”,“Histogram of t”,100,0.0, 0.04);
tHist->GetXaxis()->GetBinWidth();

I got a huge number but I by hand .04 -0/100 is rather small.

I don’t know how to correct this, can someone kindly help, please?

Instead of

you should do
tHist->GetXaxis()->GetBinWidth(bin);, where bin is your favorite bin number. Any bin would do, so you can put e.g. 1.

Thank you. I just need to add a number in the bracket.

Can I ask another simple question, How would I print out this value to be used in this formula delta N/delta t?

Regards

Yes, just do tHist->GetXaxis()->GetBinWidth(1); for example.

I didn’t understand this one. What value? The bin width?

Thank you Yus,

Yes I would like to print out the value for the binwidth.

I want to use the binwidth as small change delta t and delta N while calculating
delta sigma/dt = (1/N )* sigma * (delta n/ delta t)

Then just do
printf("Bin width is %f GeV^2\n", tHist->GetXaxis()->GetBinWidth(1));

Thank you Yus.

I used cout command.

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