Hello all,
i have several root files which contain the directory structure Event0/TreeR (here is the actual data stored).
Now i want to merge them into one root file with this kind of structure:
Event0/TreeR … (first root file from the list)
Event1/TreeR … (second…)
and so on.
But until now my root file is very small, so i guess nothing is stored.
Here is my macro:
{
ifstream fin(“cosmic_recpoints_200610XX.list”);
char filename[200];
char *chainname[700];
char treename[200];
char dirname[200];
int n=0;
TFile *newfile = new TFile(“cosmic_recpoints_200610XX.root”,“RECREATE”);
TDirectory *hdir[700];
TTree *newtree[700];
TChain chain(“TreeR”);
while (fin>>filename){
chainname[n]=filename;
sprintf(treename,"%s/Event0/TreeR",chainname[n]);
sprintf(dirname,"Event%d",n);
cout <<n<<" "<<dirname<<" "<< chainname[n]<<" "<<treename<<endl;
chain.Add(treename);
chain.SetBranchStatus("*",1);
hdir[n] = new TDirectory(dirname,dirname);
hdir[n]->cd();
newtree[n] = chain.CloneTree(0);
//newtree[n]->GetBranch("TRDcluster")->SetFile("test.root");
newtree[n]->CopyEntries(TreeR);
newtree[n]->Print();
chain.Reset();
newfile->cd();
gDirectory->pwd();
n++;
}
newfile->Write();
}
Thanks in advance for your replies,
best regards