Hi,
I have a problem with histogramming using TH1D.
I am getting “-1” returned as a bin number when the value put into the histogram is less than the first bin edge or greater than the last bin edge. See example below:
double * edges = new double[3];
edges[0] = 0;
edges[1] = 10;
edges[2] = 20;
TH1D *hist= new TH1D(“hist”,“title”,2,edges);
int a;
a = hist->Fill(-10);
cout << "-10 -> bin " << a << endl;
a = hist->Fill(5);
cout << "5 -> bin " << a << endl;
a = hist->Fill(10);
cout << "10 -> bin " << a << endl;
a = hist->Fill(30);
cout << "30 -> bin " << a << endl;
The output is:
-10 -> bin -1
5 -> bin 1
10 -> bin 2
30 -> bin -1
I was expecting to get a=0 and a=3 for inputs of -10 and 30 respectively (as described in the documentation at root.cern.ch/root/html518/TH1D.html). Does anyone know why I am not getting this result?
Regards,
Ed