# Two directories with different number of entries

**URL:** <https://root-forum.cern.ch/t/two-directories-with-different-number-of-entries/15096>\
**Category:** ROOT\
**Created:** [October 17, 2012, 7:42am UTC](https://root-forum.cern.ch/t/two-directories-with-different-number-of-entries/15096 "2012-10-17T07:42:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![magistros](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/ba8739/32.png) [@magistros](https://root-forum.cern.ch/u/magistros)\
**Post date:** [October 17, 2012, 7:42am UTC](https://root-forum.cern.ch/t/two-directories-with-different-number-of-entries/15096/1 "2012-10-17T07:42:36Z")

</div>

Dear rooters,  
I have 1573 root files, and I wanted to merge them, so I used the hadd tool, to do the job. When I opened the produced root file, I found two directories:  
[ul]  
events;1 (Number of Entries: 136965)  
events;2 (Number of Entries: 93882)  
[/ul]  
I have seen this before, but the problem now is that these directories have not the same number of events.  
Is this a problem of ROOT or I have to check my code?

Also, is there any way, to have only one directory?

Thank you in advance.

EDIT 1: I write a script which will print the number of events:

```auto
void test_entries(TString Filename)
{
        TFile *inf = new TFile(Filename);
        TTree *t1 = (TTree*)inf->Get("multijets/events");

        cout<<t1->GetEntries()<<endl;
}
```

In line  
Tree _t1 = (TTree_)inf-\>Get(“multijets/events”);  
I tried also “events;1” and next I tried “events;2” and it prints always the same:  
93882  
So… Could I say that this is the real number of entries?

---

<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:** [October 17, 2012, 8:13am UTC](https://root-forum.cern.ch/t/two-directories-with-different-number-of-entries/15096/2 "2012-10-17T08:13:18Z")

</div>

[url][Aux;1 aux;2 aux3;](https://root-forum.cern.ch/t/aux-1-aux-2-aux3/13345/2)

---

<div class="post-metadata">

**Author:** ![magistros](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/ba8739/32.png) [@magistros](https://root-forum.cern.ch/u/magistros)\
**Post date:** [October 17, 2012, 10:45am UTC](https://root-forum.cern.ch/t/two-directories-with-different-number-of-entries/15096/3 "2012-10-17T10:45:48Z")

</div>

Thank you Coyote!

I checked the links and I found out that I have to run this code

```auto
   TIter nextkey(f.GetListOfKeys());
   TKey *key;
   while (key = (TKey*)nextkey()) {
      Event *event = (Event*)key->ReadObj();
      event->Process();
   }
```

I am getting these errors:

`Error: Symbol Event is not defined in current scope test_entries.C:17:
Error: class,struct,union or type Event not defined test_entries.C:17:
Warning: Automatic variable Event*event is allocated test_entries.C:17:
Error: Undeclared variable Event*event test_entries.C:17:
***Interpreter error recovered*** `

I search for Event.h but no results… Any ideas?

---

<div class="post-metadata">

**Author:** ![Pepe\_Le\_Pew](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pepe_le_pew/32/12365_2.png) [@Pepe\_Le\_Pew](https://root-forum.cern.ch/u/Pepe_Le_Pew)\
**Post date:** [October 17, 2012, 11:27am UTC](https://root-forum.cern.ch/t/two-directories-with-different-number-of-entries/15096/4 "2012-10-17T11:27:07Z")

</div>

You should try something like this: `TFile *file = TFile::Open("MyRootFile.root");
file->ls();
TTree *tree; file->GetObject("MyRootTree", tree);
if (tree) { tree->Print(); } else { std::cout << "Warning: MyRootTree NOT found!" << std::endl; }`

---

<div class="post-metadata">

**Author:** ![magistros](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/ba8739/32.png) [@magistros](https://root-forum.cern.ch/u/magistros)\
**Post date:** [October 22, 2012, 4:58pm UTC](https://root-forum.cern.ch/t/two-directories-with-different-number-of-entries/15096/5 "2012-10-22T16:58:23Z")

</div>

Thank you Pepe and Coyote.  
Finally, I solved the problem, doing the follow:  
As I said in my first post, I add 1537 histograms, using hadd.  
So, I tried to each 400 histograms each time(1537 / 400 ~ 4 files) and finally I added the 4 files.  
It seems that the hadd has a limit.

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [October 23, 2012, 3:17pm UTC](https://root-forum.cern.ch/t/two-directories-with-different-number-of-entries/15096/6 "2012-10-23T15:17:09Z")

</div>

Hi,

In order version of ROOT hadd was limited to the number of allowed open descriptor (OS limit, usually around 1024). This should be fixed in the lastest version of ROOT.

Cheers,  
Philippe.

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [October 23, 2012, 5:43pm UTC](https://root-forum.cern.ch/t/two-directories-with-different-number-of-entries/15096/7 "2012-10-23T17:43:37Z")

</div>

Hi,

It could also be the same problem as in [Hadd with Trees in Root 5.32 with a large number of files](https://root-forum.cern.ch/t/hadd-with-trees-in-root-5-32-with-a-large-number-of-files/14024/1)  
which has also been solved (in v5.32 patch branch and any later release).

Cheers,  
Philippe.
