Dasha
May 17, 2011, 1:28pm
1
Dear people,
I have one very strange problem, that looks totally crazy.
I do the following in interpreter:
h=new TH1F(“h”,“h”,100,0,0.1);
h->Fill(0.016);
h->Fill(0.017);
h->Draw();
And what I see? 0.016 comes to the bin 16 (0.015-0.016), and 0.017 comes to the bin 18 (0.017-0.018).
How can it be and what is wrong?
I use 528-00 version.
I tried it on 527 and 523 as well. Result is the same.
On 529 there is no such problem.
Thank you in advance!
[quote=“Dasha”]Dear people,
I have one very strange problem, that looks totally crazy.
I do the following in interpreter:
h=new TH1F(“h”,“h”,100,0,0.1);
h->Fill(0.016);
h->Fill(0.017);
h->Draw();
And what I see? 0.016 comes to the bin 16 (0.015-0.016), and 0.017 comes to the bin 18 (0.017-0.018).
How can it be and what is wrong?
[/quote]
My guess is that you are are just being hit by the floating point precision.
root [5] 0.016
(const double)1.60000000000000003e-02
root [6] 0.017
(const double)1.70000000000000012e-02
If you really need to make sure that 0.016 and 0.017 fall in sequential bins, then I suggest you rebin your histogram so that these values fall in the middle of the bins instead of the edges.
h=new TH1F("h","h",100,0.005,0.105);
Good luck,
Charles