# How to put existing files in a THStack

**URL:** <https://root-forum.cern.ch/t/how-to-put-existing-files-in-a-thstack/29810>\
**Category:** ROOT\
**Created:** [July 16, 2018, 4:20pm UTC](https://root-forum.cern.ch/t/how-to-put-existing-files-in-a-thstack/29810 "2018-07-16T16:20:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![belle](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/b/a698b9/32.png) [@belle](https://root-forum.cern.ch/u/belle)\
**Post date:** [July 16, 2018, 4:20pm UTC](https://root-forum.cern.ch/t/how-to-put-existing-files-in-a-thstack/29810/1 "2018-07-16T16:20:14Z")

</div>

* * *

\_ROOT Version: 6.14.00  
_Platform:_ Linux Ubuntu 18.04  
_Compiler:_ Not Provided

* * *

Hi all,

Is it possible to put histograms (as existing files) into a THStack and how would one do that? Is there a general way to unpack a file and set it to a temporary variable name in the ROOT shell?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [July 16, 2018, 5:25pm UTC](https://root-forum.cern.ch/t/how-to-put-existing-files-in-a-thstack/29810/2 "2018-07-16T17:25:55Z")

</div>

[How to Read Objects from a File?](http://nbviewer.jupyter.org/urls/root.cern.ch/notebooks/HowTos/read-objects-from-a-file.ipynb)

> [@Aux;1 aux;2 aux3;](https://root-forum.cern.ch/t/aux-1-aux-2-aux3/13345/2):
>
> Search for “cycle” and/or “namecycle”, for example in: In a Nutshell: [Input and Output](https://root.cern.ch/d/input-and-output) . ROOT User’s Guide: [Input/Output](https://root.cern.ch/root/htmldoc/guides/users-guide/ROOTUsersGuide.html#inputoutput) : [Retrieving Objects from Disk](https://root.cern.ch/root/htmldoc/guides/users-guide/ROOTUsersGuide.html#retrieving-objects-from-disk) , [Subdirectories and Navigation](https://root.cern.ch/root/htmldoc/guides/users-guide/ROOTUsersGuide.html#subdirectories-and-navigation) . Just for reference: [some additional notes about GetObject, Get, FindObjectAny, FindKeyAny, ReadObj, ReadObjAny](https://root-forum.cern.ch/t/broken-tdirectoryfile-findobjectany-and-tdirectoryfile-findkeyany/20943/16) .

---

<div class="post-metadata">

**Author:** ![belle](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/b/a698b9/32.png) [@belle](https://root-forum.cern.ch/u/belle)\
**Post date:** [July 16, 2018, 5:39pm UTC](https://root-forum.cern.ch/t/how-to-put-existing-files-in-a-thstack/29810/3 "2018-07-16T17:39:09Z")

</div>

Is a histogram an object? I don’t think I understand what the link is trying to explain (sorry! I’m a super beginner). I’ve seen this:

```auto
TH1F *h = new TH1F("h1","title",100,0,3,3)

```

and I was wondering if there’s a way to take a .root or .c file and make it so that it can be called by a variable equivalent of the “h1” when you create a new histogram. I’m trying to put files into a THStack and I can’t seem to find anything that says how to do it with a .root or .C file.

---

<div class="post-metadata">

**Author:** ![belle](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/b/a698b9/32.png) [@belle](https://root-forum.cern.ch/u/belle)\
**Post date:** [July 16, 2018, 6:36pm UTC](https://root-forum.cern.ch/t/how-to-put-existing-files-in-a-thstack/29810/4 "2018-07-16T18:36:53Z")

</div>

Figured it out here!

> **[tomasz-trzcinski/sonata-cern](https://github.com/tomasz-trzcinski/sonata-cern/wiki/Extracting-data-from-ROOT-file)**
>
> sonata-cern - Repository for SONATA grant to work with CERN

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [July 30, 2018, 6:36pm UTC](https://root-forum.cern.ch/t/how-to-put-existing-files-in-a-thstack/29810/5 "2018-07-30T18:36:56Z")

</div>

Closed on July 30, 2018, 6:36pm UTC

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