# Question for 1d histogram in root

**URL:** <https://root-forum.cern.ch/t/question-for-1d-histogram-in-root/45637>\
**Category:** Newbie\
**Created:** [July 1, 2021, 8:26pm UTC](https://root-forum.cern.ch/t/question-for-1d-histogram-in-root/45637 "2021-07-01T20:26:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Saradindu](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/saradindu/32/26687_2.png) [@Saradindu](https://root-forum.cern.ch/u/Saradindu)\
**Post date:** [July 1, 2021, 8:26pm UTC](https://root-forum.cern.ch/t/question-for-1d-histogram-in-root/45637/1 "2021-07-01T20:26:59Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [July 2, 2021, 6:23am UTC](https://root-forum.cern.ch/t/question-for-1d-histogram-in-root/45637/2 "2021-07-02T06:23:43Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Saradindu](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/saradindu/32/26687_2.png) [@Saradindu](https://root-forum.cern.ch/u/Saradindu)\
**Post date:** [July 2, 2021, 6:48am UTC](https://root-forum.cern.ch/t/question-for-1d-histogram-in-root/45637/3 "2021-07-02T06:48:51Z")

</div>

Hi,

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

```auto
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!

---

<div class="post-metadata">

**Author:** ![Saradindu](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/saradindu/32/26687_2.png) [@Saradindu](https://root-forum.cern.ch/u/Saradindu)\
**Post date:** [July 2, 2021, 6:52am UTC](https://root-forum.cern.ch/t/question-for-1d-histogram-in-root/45637/4 "2021-07-02T06:52:37Z")

</div>

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

Thanks!

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [July 2, 2021, 6:56am UTC](https://root-forum.cern.ch/t/question-for-1d-histogram-in-root/45637/5 "2021-07-02T06:56:07Z")

</div>

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

```

---

<div class="post-metadata">

**Author:** ![Saradindu](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/saradindu/32/26687_2.png) [@Saradindu](https://root-forum.cern.ch/u/Saradindu)\
**Post date:** [July 2, 2021, 7:03am UTC](https://root-forum.cern.ch/t/question-for-1d-histogram-in-root/45637/6 "2021-07-02T07:03:27Z")

</div>

Hi bellenot ,  
Many many thanks. It works.
