//In this tutorial, we create multiple root files, and then use a TChain object to link them into a "single tree" #include using namespace std; void treechain(){ TFile* f = TFile::Open("file.root","RECREATE"); TTree* t = new TTree("t","a simple tree"); t->SetMaxTreeSize(5); //size of 500 bytes Int_t data_A, data_B, data_C; t->Branch("dA",&data_A,"data_A/I"); t->Branch("dB",&data_B,"data_B/I"); t->Branch("dC",&data_C,"data_C/I"); for (Int_t i = 0; i<5;i++){ data_A = 10; data_B = 30; data_C = 60; t->Fill(); } t->Write(); gROOT->ProcessLine(".!ls -lthr"); //Declare a chain /* TChain chain("t"); //Remember that the tree in our root files is called t. Since TChain is derived from TTree, we need t in the argument here. chain.Add("file.root"); chain.Add("file_1.root"); chain.Add("file_2.root"); chain.Print(); */ }