Scaling Histogram

Hello everyone,
I am trying to scale a histogram (TH1F)
but after applying the scale , it write it as point not histogram

TH1F * h = new TH1F(“h0”,“h0”,6000, 0,6000);
h =(TH1F*)myfile->Get(“coin_time1”);
Double_t scale = 0.1;
h->Scale(scale);
h->Write();

scale.pdf (19.9 KB)

_
ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


Hi,

what do you mean with “as point”?
Did you try to re-draw it with the “HIST” option?

myHisto->Draw("HIST");

Cheers

thank you for replying,
yes I draw it but still gives me points, I attached for the scaled histogram
scale.pdfscale.pdf (19.9 KB)

Hi,

I think I do not get this. Could you share a reproducer?

P

I tried the same with some histogram I have. It works fine when using the HIST option as @Pnine suggested:

root [2] TH1F *h =(TH1F*)hsimple.Get("hpx");
root [3] Double_t scale = 0.1;
root [4] h->Scale(scale);
root [5] h->Draw(); /// produce a plot with error bars
root [6] h->Draw("HIST"); /// produce a normal histogram plot

Note that you do not need to book the histogram. You need only a pointer.

hello,
thank you for replying.
I tried
h->Draw(“HIST”);
and it work as new Pad, but in the root file where I use
h->Write("");
it is not working and plot as error bars.

I have two machines one with root5 (Ubuntu), and one with root6 (mac)
I ran the same code and input file on both machines (root 5 and 6).
I have this issue only with root 6 .
I have attached both spectra before and after scaling

scale6.pdf (21.3 KB)
scale5.pdf (16.5 KB)

After Scale try:

h->Sumw2(0);

Yes, this works perfectly
Thank you

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