# Read a root file containing directrory

**URL:** <https://root-forum.cern.ch/t/read-a-root-file-containing-directrory/51649>\
**Category:** ROOT\
**Created:** [September 22, 2022, 12:15am UTC](https://root-forum.cern.ch/t/read-a-root-file-containing-directrory/51649 "2022-09-22T00:15:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marouane](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/7feea3/32.png) [@Marouane](https://root-forum.cern.ch/u/Marouane)\
**Post date:** [September 22, 2022, 12:15am UTC](https://root-forum.cern.ch/t/read-a-root-file-containing-directrory/51649/1 "2022-09-22T00:15:47Z")

</div>

Hello 👋,  
I need your help please 🙏 🙏 🙏.  
I have a root file called **ntuple\_array.root** containing a directory (file) called **ntupleProducer;1**. This **ntupleProducer;1** contains two trees, the name of the first one is **tree;1** and the name of the second one is **tree;2**. Each tree contains some histograms of course.  
How can I read this root file please?

I used the following methods but when I draw histograms, I get empty plots (nothing appears on my figures, they are white!):

// --------  
//first method to read the root file  
TFile \*f = TFile::Open(“ntuple\_array.root”);  
// …  
// --------

// -------  
//second method to read the root file  
TFile \*f;  
f = new TFile(“ntuple\_array.root”);  
f-\>ls();  
TDirectoryFile _dir1 = (TDirectoryFile_)f-\>Get(“ntupleProducer;1”);  
TTree _tree = (TTree_)dir1-\>FindObject(“tree;1”);  
// -------

// -------  
//third method to read the root file  
TFile \*f = new TFile(“ntuple\_array.root”);  
TTree _tree = (TTree_)f-\>Get(“ntupleProducer/tree;1”);  
// -------

---

<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:** [September 22, 2022, 6:49am UTC](https://root-forum.cern.ch/t/read-a-root-file-containing-directrory/51649/2 "2022-09-22T06:49:52Z")

</div>

> [@Aux;1 aux;2 aux3;](https://root-forum.cern.ch/t/aux-1-aux-2-aux3/13345):
>
> Hello! I’m filling a tree and after I, sometimes, get this funny behavior AUX;1 AUX;2 with the same histograms inside but with different events in each ;1 and ;2… Can somebody please tell me why this is happening? Many thanks, Stefanos

---

<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:** [October 6, 2022, 6:50am UTC](https://root-forum.cern.ch/t/read-a-root-file-containing-directrory/51649/3 "2022-10-06T06:50:47Z")

</div>

Closed on October 6, 2022, 6:50am UTC

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