Creating TTree

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!

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 for an example!

Cheers, Axel