Hi,
I have a ntuple and I want to copy it with some cuts. The cut process is a little lengthy so I can not do simply CopyTree(selection). Here is my sample code where I want to take cut on x and y variables:
TChain *chain = new TChain("EVENT");
chain->Add("*.root");
int nEvent = chain->GetEntries();
TFile *file = new TFile("EventCut.root", "recreate");
TTree *newtree = chain->CloneTree(0);
Float_t x, y;
TBranch b_x, b_y;
chain->SetBranchAddress("x", &x, &b_x);
chain->SetBranchAddress("y", &y, &b_y);
for(int i=0; i<nEvent; i++){
if(!cut(x, y)) continue; // cut routine which return 1 if satisfied, otherwise 0
newtree->Fill();
}
newtree->Write();
file->Close();
Now, my problem is the variables which I have accessed (here x and y) are not filled with actual values in the newtree. Either they are not filled or filled with some arbitrary values. Any idea will be appreciated.
Thanks.