#include #include void treeloopMacro_small(){ // gROOT->Reset(); Int_t ds; Int_t dir; dir=bjorn; Char_t directory[100]; if(dir==bjorn) sprintf(directory,"/usit/cargo/fysepf2/maikenp/data/SusyView/MiniTuples"); vector datasets; datasets.push_back(kSU1); datasets.push_back(kSU2); //datasets.push_back(kSU3); //datasets.push_back(kSU4); //datasets.push_back(kSU6); for(unsigned int i=0; iAdd(datasetpath(dir,ds).c_str()); oldChain->SetBranchStatus("*",0); oldChain->SetBranchStatus("El_N",1); oldChain->SetBranchStatus("El_m",1); oldChain->SetBranchStatus("El_E",1); oldChain->SetBranchStatus("El_p_T",1); char loopOutputFile[100]; /*Gives the output a name like MiniTree4_SU1.root*/ sprintf(loopOutputFile, "%s/MiniTree4_%s.root", directory,dsname(ds).c_str()); TFile *ff = new TFile (loopOutputFile,"RECREATE"); ff->cd(); //Create a clone of old tree header. Do not copy events TTree *newTree= oldChain->CloneTree(0); //Divert wanted branch to a separate file and copy all events newTree->GetBranch("El_p_T")->SetFile(loopOutputFile); cout<<"Copying entries in trees....This may take a while....."<CopyEntries(oldChain); newTree->Print(); ff->Write(); ff->Close(); } }