# From plotting to Ntuples

**URL:** <https://root-forum.cern.ch/t/from-plotting-to-ntuples/36984>\
**Category:** Newbie\
**Created:** [November 27, 2019, 6:53pm UTC](https://root-forum.cern.ch/t/from-plotting-to-ntuples/36984 "2019-11-27T18:53:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Newbie](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/dc4da7/32.png) [@Newbie](https://root-forum.cern.ch/u/Newbie)\
**Post date:** [November 27, 2019, 6:53pm UTC](https://root-forum.cern.ch/t/from-plotting-to-ntuples/36984/1 "2019-11-27T18:53:02Z")

</div>

Hi,

I have a plotting script which make and fills TH1’s, and I want to change the TH1’s to Ntuples, so I can analyse the data easily, Is there a straight forward way to link the TH1’s to a TTree?

Or are there any more efficient ways to tackle this problem?

Thanks!

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [November 28, 2019, 7:53am UTC](https://root-forum.cern.ch/t/from-plotting-to-ntuples/36984/2 "2019-11-28T07:53:19Z")

</div>

There is no direct “conversion” from a histograms oriented data store to a ntuple one. You need to define the variables you are looking for, create the corresponding ntuple, fill it and then you will be able to create histograms from it.

---

<div class="post-metadata">

**Author:** ![Newbie](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/dc4da7/32.png) [@Newbie](https://root-forum.cern.ch/u/Newbie)\
**Post date:** [November 28, 2019, 11:21am UTC](https://root-forum.cern.ch/t/from-plotting-to-ntuples/36984/3 "2019-11-28T11:21:25Z")

</div>

Hi Couet,

I’m not looking to convert a TH1’s to ntuples, I want to change the script to store ntuples instead of TH1’s, and I was wondering how you do that?

Thanks!

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [November 28, 2019, 1:34pm UTC](https://root-forum.cern.ch/t/from-plotting-to-ntuples/36984/4 "2019-11-28T13:34:04Z")

</div>

> [@Newbie](#):
>
> I was wondering how you do that?

Yes that’s what I explained:

_You need to define the variables you are looking for, create the corresponding ntuple, fill it and then you will be able to create histograms from it._

---

<div class="post-metadata">

**Author:** ![OSchaile](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/o/e495f1/32.png) [@OSchaile](https://root-forum.cern.ch/u/OSchaile)\
**Post date:** [November 28, 2019, 1:43pm UTC](https://root-forum.cern.ch/t/from-plotting-to-ntuples/36984/5 "2019-11-28T13:43:32Z")

</div>

look at:

[https://root.cern/doc/master/classTNtuple.html#af45dbed82038acc4acb1629cca37e7ab](https://root.cern/doc/master/classTNtuple.html#af45dbed82038acc4acb1629cca37e7ab)

and

```auto
$ROOTSYS/tutorials/hsimple.C

```

Otto
