I am using the root 3.10/02 pro.
I have 100 trees and want to select some events from each of them and add them to one big tree. I wrote two functions
TTree smalltree;
TEventList evlist;
GetEvent(file, selection) {
TFile *f;
if (smalltree) delete smalltree;
if (f) delete f;
f=new TFile(file);
smalltree=(TTree*)f->Get("T");
smalltree->Draw(">>evlist", selection);
evlist=gDirectory->Get("evlist");
}
CreateBigTree() {
TTree *bigtree=new TTree("bigtree", "Big Tree");
TEvent *evsmall, *evbig;
bigtree->SetBranchAddress("Events", "TEvent", &evbig, 32000, 0);
while (inputfile>>file) {
GetEvent(file, selection);
smalltree->SetBranchAddress("Events", &evsmall);
for (i=0; i<evlist->GetN(); i++) {
smalltree->GetEntry(evlist->GetEntry(i));
evbig=evsmall;
bigtree->Fill();
}
}
Everything is ok for the first file, but segmetation error happens as soon as it start to read the second file. I tried to delete evsmall and set it to 0 in CreateBigTree(). It doesn’t help. Could you tell me how to fullfill my goal?
Thanks