# Add branches to TTree for a file opened with RDataFrame

**URL:** <https://root-forum.cern.ch/t/add-branches-to-ttree-for-a-file-opened-with-rdataframe/57423>\
**Category:** Newbie\
**Created:** [December 6, 2023, 5:40pm UTC](https://root-forum.cern.ch/t/add-branches-to-ttree-for-a-file-opened-with-rdataframe/57423 "2023-12-06T17:40:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![amishgog](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/amishgog/32/34940_2.png) [@amishgog](https://root-forum.cern.ch/u/amishgog)\
**Post date:** [December 6, 2023, 5:40pm UTC](https://root-forum.cern.ch/t/add-branches-to-ttree-for-a-file-opened-with-rdataframe/57423/1 "2023-12-06T17:40:11Z")

</div>

So I opened my file using RDataFrame because I found it easier to access the data in the branches and use the data for analysis, but I want to add some branches to my dataset for which I need the tree in the dataset as a TTree object which is not stored by RDataFrame. How to go about this?

Just to give some background to my problem, I am trying to set a cut on a variable in my root file and draw the histogram for another variable. TCut method is used for TTree objects hence I want to add some new branches to my tree and then apply the cuts.

Thanks in advance for the help.

---

<div class="post-metadata">

**Author:** ![dastudillo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dastudillo/32/17280_2.png) [@dastudillo](https://root-forum.cern.ch/u/dastudillo)\
**Post date:** [December 7, 2023, 5:16am UTC](https://root-forum.cern.ch/t/add-branches-to-ttree-for-a-file-opened-with-rdataframe/57423/2 "2023-12-07T05:16:28Z")

</div>

Check out the [DataFrame tutorials](https://root.cern/doc/master/group __tutorial__ dataframe.html); in particular, df007\_snapshot.C (or .py) is probably what you want.

---

<div class="post-metadata">

**Author:** ![amishgog](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/amishgog/32/34940_2.png) [@amishgog](https://root-forum.cern.ch/u/amishgog)\
**Post date:** [December 7, 2023, 11:54am UTC](https://root-forum.cern.ch/t/add-branches-to-ttree-for-a-file-opened-with-rdataframe/57423/3 "2023-12-07T11:54:01Z")

</div>

Thanks for the reply. I figured it out. So I opened my root file using TFile which would give me access to the tree and then I converted the Tree into a RDataFrame.
