# Plot branch with weight from other file

**URL:** <https://root-forum.cern.ch/t/plot-branch-with-weight-from-other-file/57877>\
**Category:** Newbie\
**Created:** [January 17, 2024, 2:46pm UTC](https://root-forum.cern.ch/t/plot-branch-with-weight-from-other-file/57877 "2024-01-17T14:46:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Annzm](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/annzm/32/34693_2.png) [@Annzm](https://root-forum.cern.ch/u/Annzm)\
**Post date:** [January 17, 2024, 2:46pm UTC](https://root-forum.cern.ch/t/plot-branch-with-weight-from-other-file/57877/1 "2024-01-17T14:46:29Z")

</div>

Hi,

i have file1.root, having a TTree. wants to plot a branch from this try and apply weight. but the weight is in the file2.root.  
im stuck how to do this. or is there any way to copy the weight branch from file2.root to file1.root?

Thanks

---

<div class="post-metadata">

**Author:** ![jonas](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jonas/32/24756_2.png) [@jonas](https://root-forum.cern.ch/u/jonas)\
**Post date:** [January 17, 2024, 4:47pm UTC](https://root-forum.cern.ch/t/plot-branch-with-weight-from-other-file/57877/2 "2024-01-17T16:47:44Z")

</div>

Hi! This looks like a usecase for friend trees, which you can register with [TTree::AddFriend()](https://root.cern.ch/doc/master/classTTree.html#a011d362261b694ee7dd780bad21f030b).

There is also a [tutorial about this](https://root.cern/doc/master/treefriend_8C.html).

I hope that helps, if not let me know!

---

<div class="post-metadata">

**Author:** ![Annzm](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/annzm/32/34693_2.png) [@Annzm](https://root-forum.cern.ch/u/Annzm)\
**Post date:** [January 18, 2024, 3:28am UTC](https://root-forum.cern.ch/t/plot-branch-with-weight-from-other-file/57877/3 "2024-01-18T03:28:18Z")

</div>

hi thanks but i didnt get it

---

<div class="post-metadata">

**Author:** ![jonas](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jonas/32/24756_2.png) [@jonas](https://root-forum.cern.ch/u/jonas)\
**Post date:** [January 22, 2024, 1:27pm UTC](https://root-forum.cern.ch/t/plot-branch-with-weight-from-other-file/57877/4 "2024-01-22T13:27:28Z")

</div>

Which part are you still struggling with? It would be good if you are more specific so I don’t have to tell you things that you already know. For example, do you already know how to plot a branch with a weight from the _same_ file? And how are you using that, e.g. with TTree::Draw() or RDataFrame? The answer will depend on how you are doing the plotting.

---

<div class="post-metadata">

**Author:** ![Annzm](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/annzm/32/34693_2.png) [@Annzm](https://root-forum.cern.ch/u/Annzm)\
**Post date:** [January 28, 2024, 6:55am UTC](https://root-forum.cern.ch/t/plot-branch-with-weight-from-other-file/57877/5 "2024-01-28T06:55:38Z")

</div>

Thanks, i know the method to plot a branch with weight i.e `TTree::Draw()`, where both branch and weight belongs to same TTree. but im unable to apply weight when weight belongs to other tree or other root file.
