Wrong Event Count in ROOT 6.02.10

Dear all,

I am seeing some issues when plotting the contents of a TTree using the Draw functions and assigning it weights. I have attached the TTree in question.

Using ROOT 6.00.02, I plot the value 1 with weight event_weight and look at its integral. There are 125 (non-zero weight) entries and the integral is 1663. The histogram is attached as rootgood.pdf.

root [1] tree->Draw("1","event_weight")
(Long64_t) 125
root [2] htemp->Integral()
(Double_t) 1.663450e+03

Then I do the exact same thing using ROOT 6.02.10 (also tried 6.04.00) . Now the event count is 250 and the integral is 3327. The histogram is attached as rootbad.pdf.

root [1] tree->Draw("1","event_weight")
(Long64_t) 125
root [2] htemp->Integral()
(Double_t) 3.326900e+03

Any idea why I see this difference? The tests were done on lxplus using ROOT from AFS.
rootbad.pdf (13.4 KB)
rootgood.pdf (13.5 KB)
test.root (5.59 KB)

Thanks for reporting this.
Actually we can even see a difference with the ntuple generated by hsimple.C

Root 5.34 gives:

root [0]  ntuple->Draw("1","0.5") ; htemp->Integral()
(const Double_t)1.25000000000000000e+04

And the number of entries on the plot is 25000

Root >6 give:

root [0]  ntuple->Draw("1","0.5") ; htemp->Integral()
(Double_t) 1.300000e+04

And the number of entries on the plot is 26000

We will look at this.

I made a small macro which reproduces this issue without using ntuple or tree.

{
   TH1F *h1 = new TH1F("h1","h1", 100, -1., 1.); h1->SetBuffer(1000);
   TH1F *h2 = new TH1F("h2","h2", 100, -1., 1.); h2->SetBuffer(1000);
   for (int i=0; i<10000; i++) {
      h1->Fill(0.);
      h2->Fill(0.,0.5);
   }
   h2->Draw();
   printf("Entries  for h1 = %f Entries  for h2 = %f \n",h1->GetEntries(),h2->GetEntries());
   printf("Integral for h1 = %f Integral for h2 = %f \n",h1->Integral(),h2->Integral());
}

ROOT version < 6 give:

Entries  for h1 = 10000.000000 Entries  for h2 = 10000.000000 
Integral for h1 = 10000.000000 Integral for h2 = 5000.000000 

ROOT version >= 6 give:

Entries  for h1 = 10000.000000 Entries  for h2 = 11000.000000
Integral for h1 = 10000.000000 Integral for h2 = 5500.000000

As you can see for W = 0.5 there is s difference. The problem shows up only if SetBuffer is called.

This problem, appearing only when the histogram buffer is used with histogram filled with weights different than one, has been fixed in 6.02, 6.04 patches and master.
See also comments and git commit links in sft.its.cern.ch/jira/browse/ROOT-7328

Lorenzo

Hi,
I’ve just installed ROOT 6.04 and still experience this issue…
It might be linked to [url=https://root-forum.cern.ch/t/histogram-created-by-ttree-draw-behaves-erroneously/19223/5 which is also supposedly fixed, but does’t seem to be.

I’m bumping this since I can’t remove the “SOLVED” tag…

Is the bugfix actually present in the 6.04 release available from root.cern.ch/drupal/content/pro … ersion-604, or do we have to wait for the next bugfix release?