Hi,
I want to select a subset of events based on a selection given as a text string and store the results into a separate tree with the same structure as the original.
I have a little function:
TTree* makeSelectedTree(TTree* origtree,string selection){
cerr<<“applying selection: “<<selection<<” to tree: “
<GetName()<<”\n”;
TEventList* evlist=new TEventList(“cursel”);
origtree->Draw(">>cursel",
selection.c_str());
cerr<<“number of entries in the event list: “<GetN()<<”\n”;
TTree* t_clone=origtree->CloneTree(0);
//t_clone->SetName(Form("%s_%s",origtree->GetName(),selection.c_str()));
//TEventlist* evlist=(*TEventList)gDirectory->Get(selectionname.c_str());
for(int iev=0;ievGetN();iev++){
cerr<<“iev: “<<iev<<”\t-> “;
origtree->GetEntry(evlist->GetEntry(iev));
cerr<<” got entry; filling\t”;
t_clone->Fill();
cerr<<" filled\n";
}
delete evlist;
cerr<<“number of entries in the return tree: “<<t_clone->GetEntries()<<”\n”;
return t_clone;
}
origtree is read from a file. I am doing in for several files and trees in my program. On one of the trees this happens:
applying selection: TMath::Abs(tracketa)>=0.000&&TMath::Abs(tracketa)<5.000&&trackp>=0.000&&trackp<1000000000.000 to tree: t_fitdata_per_ele_IsEM_CustomMediumPID_fake
number of entries in the event list: 6167
…
iev: 3982 -> got entry; filling filled
iev: 3983 -> got entry; filling filled
iev: 3984 -> got entry; filling Error in TTree::Fill: Failed filling branch:t_fitdata_per_ele_IsEM_CustomMediumPID_fake.trtfrac, nbytes=-1
This error is symptomatic of a Tree created as a memory-resident Tree
Instead of doing:
TTree *T = new TTree(…)
TFile *f = new TFile(…)
you should do:
TFile *f = new TFile(…)
TTree *T = new TTree(…)
Error in TTree::Fill: Failed filling branch:t_fitdata_per_ele_IsEM_CustomMediumPID_fake.nblhits, nbytes=-1
This error is symptomatic of a Tree created as a memory-resident Tree
Instead of doing:
TTree *T = new TTree(…)
TFile *f = new TFile(…)
you should do:
TFile *f = new TFile(…)
TTree *T = new TTree(…)
Error in TTree::Fill: Failed filling branch:t_fitdata_per_ele_IsEM_CustomMediumPID_fake.EoverP, nbytes=-1
Error in TTree::Fill: Failed filling branch:t_fitdata_per_ele_IsEM_CustomMediumPID_fake.tracketa, nbytes=-1
Error in TTree::Fill: Failed filling branch:t_fitdata_per_ele_IsEM_CustomMediumPID_fake.trackp, nbytes=-1
filled
iev: 3985 -> got entry; filling Error in TTree::Fill: Failed filling branch:t_fitdata_per_ele_IsEM_CustomMediumPID_fake.f1, nbytes=-1
This error is symptomatic of a Tree created as a memory-resident Tree
Instead of doing:
TTree *T = new TTree(…)
TFile *f = new TFile(…)
you should do:
TFile *f = new TFile(…)
TTree *T = new TTree(…)
Error in TTree::Fill: Failed filling branch:t_fitdata_per_ele_IsEM_CustomMediumPID_fake.Et, nbytes=-1
This error is symptomatic of a Tree created as a memory-resident Tree
Instead of doing:
TTree *T = new TTree(…)
TFile *f = new TFile(…)
you should do:
TFile *f = new TFile(…)
TTree *T = new TTree(…)
filled
iev: 3986 -> got entry; filling filled
iev: 3987 -> got entry; filling filled
iev: 3988 -> got entry; filling filled
…
iev: 6165 -> got entry; filling filled
iev: 6166 -> got entry; filling filled
number of entries in the return tree: 6167
What is going on???
I tried adding line:
t_clone->SetDirectory(origtree->GetDirectory());
after the CloneTree line but this didn’t help.
Thank you for any help…
Wojtek