Re: [ROOT] AddBinContent doesn't show on TH2 scatterplot

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed Jun 25 2003 - 09:28:23 MEST


Hi Chris,

Because, TH2 are often used to draw a pad frame, the TH2 Paint functions
with options like "colz", "cont" return immediatly once the axes are drawn
if the number of entries is null. There is no need to loop on the cell contents.
If you use AddBinContent to fill your histogram, the number of entries is not
incremented. Only the Fill functions increment the number of entries.
In your case, simply add one statement before drawing your histogram:
  f->SetEntries(1);

Rene Brun

Chris Roat wrote:
> 
> Hi all,
> 
> I didn't see mention of this bug in a search of
> this newsgroup, so I hope I'm not rehashing
> something already known.
> 
> On RedHat 7.2 with gcc-2.95.3, the following macro
> produces two difference behaviours in ROOT 3.03/09
> and ROOT 3.05/05.  In the earlier version, the
> right-side plot is a scatterplot with some points
> indicating one of the bins was filled.  In the
> later version, the same plot comes up empty even
> though the LEGO version (left-side plot) clearly
> shows the bin is non-empty.
> 
>   // fill particular bin of TH2F with weight 2
>   TH2F *f= new TH2F("f","f",10,0,1,10,0,1);
>   f->SetMarkerStyle(8);
>   f->AddBinContent(55,2);
> 
>   // display the TH2F in lego and scatter fashions
>   TCanvas *c1= new TCanvas;
>   c1->Divide(2,1);
>   c1->cd(1);
>   f->Draw("LEGO");
>   c1->cd(2);
>   f->Draw("");
> 
> Cheers,
> Chris



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:12 MET