Integral function

Hi all,

I have a spectrum (a copy is attached) and I need t find the number of counts between -1 and 0 as well as 0 and -1. I was using the Integral function for each it return zero. Can anyone advise me as to what I am doing wrong?

In the code h_2 is TH1F *h_2 = new TH1F(“h_2”,"",1000,-2,2);

This is what I get when using the integral function

root [2] h_2->Integral(0,1)
(const Double_t)0.00000000000000000e+00
root [3] h_2->Integral(-1,0)
(const Double_t)0.00000000000000000e+00

Thanks in advance

Chloe

Try:
root [2] h_2->Integral(h_2->FindBin(-1), h_2->FindBin(0) - 1)
root [3] h_2->Integral(h_2->FindBin(0), h_2->FindBin(1))
If it helps, see http://root.cern.ch/root/html/TH1.html#TH1:Integral@1 and http://root.cern.ch/root/html/TH1.html#TH1:FindBin

Hi,

For: h_2->Integral(h_2->FindBin(0), h_2->FindBin(1))

I get this error:
Error: Symbol h_2 is not defined in current scope (tmpfile):1:
Error: Failed to evaluate h_c2->FindBin(0)
Error: Symbol h_2 is not defined in current scope (tmpfile):1:
Error: Failed to evaluate h_2->FindBin(1)
*** Interpreter error recovered ***

and for: h_2->Integral(h_2->FindBin(-1), h_2->FindBin(0) - 1)

I get this error:

Error: Symbol h_2 is not defined in current scope (tmpfile):1:
Error: Failed to evaluate h_2->FindBin(-1)
Error: Symbol h_2 is not defined in current scope (tmpfile):1:
Error: Failed to evaluate h_2->FindBin(0)
*** Interpreter error recovered ***

Chloe

Try:
root [2] TH1F *h = h_2
root [3] h->Integral(h->FindBin(-1), h->FindBin(0) - 1)
root [4] h->Integral(h->FindBin(0), h->FindBin(1))
If it helps, search for “Special Variables” in http://root.cern.ch/viewvc/trunk/cint/doc/limitati.txt

Hiya,

Success!! Thank you very much for you help.

Chloe