# Dealing with Tree's with identical Labels

**URL:** <https://root-forum.cern.ch/t/dealing-with-trees-with-identical-labels/15961>\
**Category:** ROOT\
**Created:** [April 23, 2013, 11:27am UTC](https://root-forum.cern.ch/t/dealing-with-trees-with-identical-labels/15961 "2013-04-23T11:27:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![y33t](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/y/50afbb/32.png) [@y33t](https://root-forum.cern.ch/u/y33t)\
**Post date:** [April 23, 2013, 11:27am UTC](https://root-forum.cern.ch/t/dealing-with-trees-with-identical-labels/15961/1 "2013-04-23T11:27:57Z")

</div>

I import some trees using ;

test = TChain(t\_name)

and it works flawlessly. The only problem is that if I got more than 1 trees with identical names/labels in the same root file, I get to export them all with the above tchain. As in structure these trees differ as following ;

t\_name;1  
t\_name;2  
.  
.  
and so on…

but I can not indexize/arrayize neither TChain nor the t\_name. I am not after a one-liner, any pythonic solution suits me.

---

<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:** [April 23, 2013, 11:30am UTC](https://root-forum.cern.ch/t/dealing-with-trees-with-identical-labels/15961/2 "2013-04-23T11:30:48Z")

</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:** ![y33t](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/y/50afbb/32.png) [@y33t](https://root-forum.cern.ch/u/y33t)\
**Post date:** [April 23, 2013, 2:35pm UTC](https://root-forum.cern.ch/t/dealing-with-trees-with-identical-labels/15961/3 "2013-04-23T14:35:51Z")

</div>

The only section it mentiones cycle/namecycle is about deleting it. I am trying to get it as ;

test = TChain(t\_name)[0]  
test2 = TChain(t\_name)[1]

and so on.

---

<div class="post-metadata">

**Author:** ![jfcaron](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/7c8e57/32.png) [@jfcaron](https://root-forum.cern.ch/u/jfcaron)\
**Post date:** [April 23, 2013, 4:09pm UTC](https://root-forum.cern.ch/t/dealing-with-trees-with-identical-labels/15961/4 "2013-04-23T16:09:38Z")

</div>

I might recommend using the TFile.Get method. Something like:

```auto
trees = {}
f = ROOT.TFile("myfile.root")
for i in range(ncycles):
    trees[i] = f.Get("t_name;%d" % i)
```

Then you can put them together in a TChain yourself if you need.

---

<div class="post-metadata">

**Author:** ![y33t](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/y/50afbb/32.png) [@y33t](https://root-forum.cern.ch/u/y33t)\
**Post date:** [April 24, 2013, 11:34am UTC](https://root-forum.cern.ch/t/dealing-with-trees-with-identical-labels/15961/5 "2013-04-24T11:34:04Z")

</div>

I get ;

\<ROOT.TObject object at 0x(nil)\>

for each iteration of tree[i]. Why?

---

<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:** [April 24, 2013, 12:25pm UTC](https://root-forum.cern.ch/t/dealing-with-trees-with-identical-labels/15961/6 "2013-04-24T12:25:42Z")

</div>

[url][Plotting Multiple Histograms with Same Title](https://root-forum.cern.ch/t/plotting-multiple-histograms-with-same-title/14792/2)

---

<div class="post-metadata">

**Author:** ![y33t](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/y/50afbb/32.png) [@y33t](https://root-forum.cern.ch/u/y33t)\
**Post date:** [April 25, 2013, 10:20pm UTC](https://root-forum.cern.ch/t/dealing-with-trees-with-identical-labels/15961/7 "2013-04-25T22:20:49Z")

</div>

Thanks.
