# Creating TTree

**URL:** <https://root-forum.cern.ch/t/creating-ttree/53389>\
**Category:** Newbie\
**Created:** [February 1, 2023, 11:55am UTC](https://root-forum.cern.ch/t/creating-ttree/53389 "2023-02-01T11:55:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lost0431](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/9fc29f/32.png) [@lost0431](https://root-forum.cern.ch/u/lost0431)\
**Post date:** [February 1, 2023, 11:55am UTC](https://root-forum.cern.ch/t/creating-ttree/53389/1 "2023-02-01T11:55:47Z")

</div>

Hi! I’m quite new to root and trying to create a TTree. I want to have “n” amount of branches, say 3, with one arrays of values each, 100 long. When I try to run it and view in TBrowser, the first branch has one “leaf”, the second two leaves and so on, and all with the same values :(.

```
TFile *output = new TFile("testingTree.root", "recreate"); 
TTree *testingTree = new TTree("testingTree", "testingTree");
	
TF1* function = new TF1("function", "100", 0, 2);

for (Int_t m = 0; m < 4; m++)
{	
	
	Double_t var1;
	
	testingTree -> Branch("one", &var1); 
	
	
	for (Int_t i = 0; i < 100; i++)
	{
		var1 = function -> GetRandom(); 
		testingTree -> Fill(); 	
	}
	output -> Write();

} 
output -> Close();

```

Any help would be appreciated!

---

<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:** [February 6, 2023, 8:05am UTC](https://root-forum.cern.ch/t/creating-ttree/53389/2 "2023-02-06T08:05:58Z")

</div>

Welcome to the ROOT forum, @lost0431 !

We vividly recommend to use `RDataFrame::Snapshot` for these things, these days: it’s _way_ easier to use, you will not run in any of these issues. See [`tutorials/dataframe/df008_createDataSetFromScratch.C`](https://root.cern/doc/master/df008__createDataSetFromScratch_8C.html) for an example!

Cheers, Axel
