# Easiest way to add entries of a TTree

**URL:** <https://root-forum.cern.ch/t/easiest-way-to-add-entries-of-a-ttree/35896>\
**Category:** Newbie\
**Tags:** tree\
**Created:** [September 5, 2019, 4:40pm UTC](https://root-forum.cern.ch/t/easiest-way-to-add-entries-of-a-ttree/35896 "2019-09-05T16:40:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nyx](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/dc4da7/32.png) [@Nyx](https://root-forum.cern.ch/u/Nyx)\
**Post date:** [September 5, 2019, 4:40pm UTC](https://root-forum.cern.ch/t/easiest-way-to-add-entries-of-a-ttree/35896/1 "2019-09-05T16:40:28Z")

</div>

What is the easiest way to add or make operations with the entries of a TTree? Specifically, I want to do something like \sqrt{entry(1) + entry(2) + … + entry(N)}. This can be easily done with a macro, but I wonder if there is an easier way, even from the TBrowser prompt.

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [September 5, 2019, 5:43pm UTC](https://root-forum.cern.ch/t/easiest-way-to-add-entries-of-a-ttree/35896/2 "2019-09-05T17:43:21Z")

</div>

Hi,  
assuming that you want the square root of the sum of the values of a branch, with [RDataFrame](https://root.cern.ch/doc/master/classROOT_1_1RDataFrame.html) (available since ROOT v6.16) this would be (in C++ and python alike):

```auto
sqrt(RDataFrame("treename", "filename.root").Sum("branch").GetValue())

```

Cheers,  
Enrico

---

<div class="post-metadata">

**Author:** ![Nyx](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/dc4da7/32.png) [@Nyx](https://root-forum.cern.ch/u/Nyx)\
**Post date:** [September 5, 2019, 6:05pm UTC](https://root-forum.cern.ch/t/easiest-way-to-add-entries-of-a-ttree/35896/3 "2019-09-05T18:05:58Z")

</div>

My ROOT version is 6.06/08, so it does not recognize RDataFrame. I can’t update ROOT since I am running it in an external cluster.

---

<div class="post-metadata">

**Author:** ![Axel](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/axel/32/11084_2.png) [@Axel](https://root-forum.cern.ch/u/Axel)\
**Post date:** [September 9, 2019, 6:22am UTC](https://root-forum.cern.ch/t/easiest-way-to-add-entries-of-a-ttree/35896/4 "2019-09-09T06:22:34Z")

</div>

Apart form `RDataFrame` the only other option I can think of is to write a macro.

You should suggest to whoever is maintaining your cluster to upgrade ROOT!
