# Accessing Variables from a Complex TTree

**URL:** <https://root-forum.cern.ch/t/accessing-variables-from-a-complex-ttree/46073>\
**Category:** Newbie\
**Created:** [July 29, 2021, 9:27am UTC](https://root-forum.cern.ch/t/accessing-variables-from-a-complex-ttree/46073 "2021-07-29T09:27:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Omar\_Ibna\_Nazim](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/o/f0a364/32.png) [@Omar\_Ibna\_Nazim](https://root-forum.cern.ch/u/Omar_Ibna_Nazim)\
**Post date:** [July 29, 2021, 9:27am UTC](https://root-forum.cern.ch/t/accessing-variables-from-a-complex-ttree/46073/1 "2021-07-29T09:27:36Z")

</div>

ROOT Version: 6.22/08  
Platform: CentOS  
Compiler: 4.8.5

* * *

I am using the MakeClass method to obtain the skeleton of a TTree with multiple Branches and the Branches having multiple TLeafs. I can print the event variables using the code below.

I want to access multiple TLeafs from different branches of each entry for calculation.  
How can I access certain variables of each entry?

```auto
 for (Long64_t jentry=0; jentry<nentries;jentry++) {
      Long64_t ientry = LoadTree(jentry);
      if (ientry < 0) break;
      cout<< ientry <<endl;
      nb = fChain->GetEntry(jentry); nbytes += nb;
      // if (Cut(ientry) < 0) continue;
   }

```

---

<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:** [July 29, 2021, 9:44am UTC](https://root-forum.cern.ch/t/accessing-variables-from-a-complex-ttree/46073/2 "2021-07-29T09:44:24Z")

</div>

[“ROOT User’s Guide” → “Trees” → “Using TTree::MakeClass”](http://root.cern.ch/root/html534/guides/users-guide/Trees.html#using-ttreemakeclass)

---

<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:** [July 29, 2021, 8:46pm UTC](https://root-forum.cern.ch/t/accessing-variables-from-a-complex-ttree/46073/3 "2021-07-29T20:46:59Z")

</div>

…and really, save your time and nerves and just advance to [`RDataFrame`](https://root.cern/doc/master/classROOT_1_1RDataFrame.html) directly. You can run in all kinds of weird issues with accessing `TLeaf`s directly, and your analysis will be much faster (multithreaded).
