# tree.CloneTree(0) not working

**URL:** <https://root-forum.cern.ch/t/tree-clonetree-0-not-working/60299>\
**Category:** Newbie\
**Tags:** python, root\
**Created:** [July 23, 2024, 1:47pm UTC](https://root-forum.cern.ch/t/tree-clonetree-0-not-working/60299 "2024-07-23T13:47:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![greentree](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/greentree/32/30929_2.png) [@greentree](https://root-forum.cern.ch/u/greentree)\
**Post date:** [July 23, 2024, 1:47pm UTC](https://root-forum.cern.ch/t/tree-clonetree-0-not-working/60299/1 "2024-07-23T13:47:30Z")

</div>

**The problem:**  
I clone my tree so that I don’t mess up the previous root file:

```auto
cloned_tree = tree.CloneTree(0)

```

When I type `tree.GetEntries()` I see that it prints a **large number**. But when I do

```auto
output_file = ROOT.TFile("with_weights.root", "RECREATE")

cloned_tree.GetEntries() 

```

that **returns 0.** So how does the cloned tree is empty?

**My ultimate goal:** I have a tree where I want to add a new branch (weights) to it . The values (weights) I want to add are already stored in a different .root file. I started by cloning the tree, then I loop over the weights and save them as a list. Then I try to create a new branch and fill the branch with this new list.

---

<div class="post-metadata">

**Author:** ![devajith](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/devajith/32/37165_2.png) [@devajith](https://root-forum.cern.ch/u/devajith)\
**Post date:** [July 23, 2024, 2:31pm UTC](https://root-forum.cern.ch/t/tree-clonetree-0-not-working/60299/2 "2024-07-23T14:31:18Z")

</div>

Hi @greentree, thanks for the question. I’m not an expert. But from what I see, you tried to

```auto
CloneTree(0) // which means 0 entries will be copied

```

So it makes sense that there are 0 entries in the cloned\_tree. You can have a look at the documentation and tutorials mentioned here: [ROOT: TTree Class Reference](https://root.cern/doc/master/classTTree.html#a76927d17a94d091d4ef1ed0ba7ef3383)

Maybe @couet can confirm.

---

<div class="post-metadata">

**Author:** ![greentree](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/greentree/32/30929_2.png) [@greentree](https://root-forum.cern.ch/u/greentree)\
**Post date:** [July 25, 2024, 4:04pm UTC](https://root-forum.cern.ch/t/tree-clonetree-0-not-working/60299/3 "2024-07-25T16:04:28Z")

</div>

Thanks this resolved the issue
