Dear rooters,
The draw options don’t work well with 1D histogram filled using weights.
Without weights everything works as expected.
Can anybody explain this behaviour? Thanks.
Please, see the examples below.
I am using root-6.06.02.
Working macro:
{
TCanvas *c1 = new TCanvas("c1","c1",600,600);
TH1F *h = new TH1F("h","",20,-4,4);
Float_t px, py;
for (Int_t i = 0; i < 100000; i++) {
gRandom->Rannor(px,py);
h->Fill(px);
h->Fill(py);
}
h->Scale(1./200000);
h->SetFillStyle(1001);
h->SetFillColor(kGray);
h->SetLineWidth(2);
h->Draw("LF2");
return c1;
}
This macro produces the desired output:
Not working macro:
The only difference is that we assign a weight when filling the histograms
{
TCanvas *c1 = new TCanvas("c1","c1",600,600);
TH1F *h = new TH1F("h","",20,-4,4);
Float_t px, py;
for (Int_t i = 0; i < 100000; i++) {
gRandom->Rannor(px,py);
h->Fill(px,1./200000);
h->Fill(py,1./200000);
}
h->SetFillStyle(1001);
h->SetFillColor(kGray);
h->SetLineWidth(2);
h->Draw("LF2");
return c1;
}
This is the wrong output: