Draw option change after Normalization

Hi Everyone,
I have some histograms in my root file That I can retrieve and draw it by for instance:

TFile* f2 = new TFile("../summary_20_175_signal.root");
 TH1F *hM4l_20_175= (TH1F*)f2->Get("hM1234");
 hM4l_20_175->Draw("L") //or just  hM4l_20_175->Draw("");

It works well, but if I tried to normalize it by adding:

 Double_t scale2 = 1/hM4l_20_175->Integral();
   hM4l_20_175->Scale(scale2);

it will just draw the histogram using dots as if I use the option Draw(“P”), and whatever option I use it will not be taken into account.
Could someone tell me please why it behaves like that ?
Cheers,
Thanks in advance.
Diallo.

When Scale is called on an histogram it set some flag saying it has error bars and in such case an histogram is drawn with error bars. That’s what you see. The HIST option allows to bypass this:

{
   auto *h = new TH1F("","",100,-4.,4);
   h->FillRandom("gaus");
   h->Scale(0.5);
   h->Draw("HIST L");
}

Hi Couet,
Thanks very much, it works.
Cheers
Diallo.

Hi Couet,
I don’t if this need to open another topic, but do you know why my legend as well doesn’t draw as well?

 TLegend lg1(0.1,0.7,0.48,0.9);
   lg1.SetFillColor(0);
   lg1.SetBorderSize(0);
  lg1.AddEntry(hM4l_smzz, "SMZZ bkg", "p");
  lg1.AddEntry(hM4l_ggfh, "ggFH bkg", "p");
 lg1.Draw();

Like that always works for me, but I don’t it doesn’t work now.
Thanks in advance.
cheers
Diallo.

Try:

   auto *lg1 = new TLegend (0.1,0.7,0.48,0.9);
   lg1->SetFillColor(0);
   lg1->SetBorderSize(0);
   lg1->AddEntry(hM4l_smzz, "SMZZ bkg", "p");
   lg1->AddEntry(hM4l_ggfh, "ggFH bkg", "p");
   lg1->Draw();

Hi Couet,
Thanks, it works now, I really appreciate :slight_smile:
Could you tell me please why this works and not the first one, just to know.
Chanks

void named() {
   TText ti(.05, .5, "text is invisible because the text is deleted at the end of the macro");
   ti.Draw();
   auto *tv = new TText(.05, .6, "text is visible because the pointer remains after the macro execution");
   tv->Draw();
}

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.