Question for 1d histogram in root

Hii all,

I am new in root… Could you please tell me how do I can save 1d histogram using TH1D class… I know how to save pdf files, and histograms using TH1F class.

But i need histogram of TH1D class… Please tell me the command to save it.

Welcome to the ROOT Forum!
I’m not sure to understand your question. The difference between a TH1D and a TH1F histogram is that TH1D is filled with double precision floating point values. Do you have a concrete example of what you’re trying to achieve?

Hi,

First thing I have a root file containing one tree. Now I do the following.

root [2] outTree->StartViewer()
File name : run-0170-00.root
root [3] Info in <TCanvas::MakeDefCanvas>:  created default TCanvas with name c1

root [3] 
root [3] tv__tree->Draw("SeGAenergy[0]>>h1(1000,100,10000)","","", 7908188, 0);
root [4] h1->GetXaxis()->SetRangeUser(1000,10000)
root [5] h1->Draw()
root [6] h1->SaveAs("ss.root")
Info in <TH1F::SaveAs>: ROOT file ss.root has been created

Now when I open ss.root I found the histogram is saved as TH1F .

But I require h1 to be saved as TH1D. I can’t do that .
Please help.

Thanks!

Or simply please tell me how do I save one histogram which is of TH1D class.

Thanks!

TH1D *h1 = new TH1D("h1", "h1", 1000, 100, 10000);
tv__tree->Draw("SeGAenergy[0]>>h1", "", "", 7908188, 0);

Hi bellenot ,
Many many thanks. It works.

1 Like