Noor1
June 7, 2019, 6:27pm
1
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
Pnine
June 8, 2019, 11:20am
2
Hi,
what do you mean with “as point”?
Did you try to re-draw it with the “HIST” option?
myHisto->Draw("HIST");
Cheers
Noor1
June 8, 2019, 11:38am
3
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)
Pnine
June 9, 2019, 2:27pm
4
Hi,
I think I do not get this. Could you share a reproducer?
P
couet
June 11, 2019, 9:10am
5
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.
Noor1
June 11, 2019, 11:11am
6
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)
Noor1
June 11, 2019, 11:25am
8
Yes, this works perfectly
Thank you
system
Closed
June 25, 2019, 11:25am
9
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.