# Analysis skeleton for a TChain

**URL:** <https://root-forum.cern.ch/t/analysis-skeleton-for-a-tchain/52777>\
**Category:** Newbie\
**Created:** [December 15, 2022, 3:29pm UTC](https://root-forum.cern.ch/t/analysis-skeleton-for-a-tchain/52777 "2022-12-15T15:29:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stefano\_John](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/cdc98d/32.png) [@Stefano\_John](https://root-forum.cern.ch/u/Stefano_John)\
**Post date:** [December 15, 2022, 3:29pm UTC](https://root-forum.cern.ch/t/analysis-skeleton-for-a-tchain/52777/1 "2022-12-15T15:29:38Z")

</div>

Hi again guys,  
sorry for my naive questions. I’m still trying to understand the logic of ROOT.  
Following my previous topic [How to read array variable in a Tree](https://root-forum.cern.ch/t/how-to-read-array-variable-in-a-tree/52673) , I create the .h and .C (and modify it) files but I cannot understand how to generalize this to more root file. I followed the indication provided me by one answer of @Wile_E_Coyote and I understood that I need to use TChain and I read on the Manual on how to use it. I understood it how to use but not the connection with the previous point. I mean, do I have to create a new file with the TChain where I define the variable and assigm to a branch (as: chain.SetBranchAddress(…,&)) or do I have to use the previous .h .C files (created by a single root file, but with the same structure of the other root file)? or Do I have to add the Chain inside the .h file created before. I’m a bit confused…  
Sorry for the naive question but it’s not clear to me how to implement this thing.  
Thanks much.

_ROOT Version:_ 5.37/38  
_Platform:_ Unix CentOS 7.9.2009  
_Compiler:_ CINT 5.18

* * *

---

<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:** [December 15, 2022, 3:39pm UTC](https://root-forum.cern.ch/t/analysis-skeleton-for-a-tchain/52777/2 "2022-12-15T15:39:10Z")

</div>

Generate [an “analysis skeleton” for the whole TChain](https://root-forum.cern.ch/t/header-files-for-trees/16308/2), e.g.:

```cpp
{
  TChain *t = new TChain("Data");
  t->Add("file.root");
  t->MakeClass();
  delete t;
}

```

---

<div class="post-metadata">

**Author:** ![Stefano\_John](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/cdc98d/32.png) [@Stefano\_John](https://root-forum.cern.ch/u/Stefano_John)\
**Post date:** [December 15, 2022, 3:50pm UTC](https://root-forum.cern.ch/t/analysis-skeleton-for-a-tchain/52777/3 "2022-12-15T15:50:48Z")

</div>

Yes, I followed this link that you sent me, but couldn’t understand this point.  
Ah ok, so it is independent from the single TTree class! It’s what I wanted to know.  
I was confused by what was written in the tree.h file where it says:

```auto
TTree *fChain; //!pointer to the analyzed TTree or TChain

```

so I didn’t get if to put there the chain or not.  
Thanks for clarified it.
