TTree* filter_tree(TTree* t, const char* selection, const char* vars, TFile* fout); void filter_tree(const char* ntuple, const char* files, const char* selection, const char* vars, const char* fout); TTree* filter_tree(TTree* t, const char* selection, const char* vars, TFile* fout) { // ttf implements the event selection TTreeFormula ttf("filter_tree",selection,t); // turn off all branches in input t->SetBranchStatus("*",0); // tokenize array of variable names TString s(vars); TObjArray* vlist = s.Tokenize(", "); // loop over variable names, turning on associated branch in input std::cout<<"filter_tree: writing out the following variables:"<GetEntries(); i++){ TObjString* obj = dynamic_cast(vlist->At(i)); TString v=obj->GetString(); std::cout<SetBranchStatus(v.Data(),1); } std::cout<<"end of variables"<cd(); TTree* tc = t->CloneTree(0); // go through and turn on branches needed by selection std::cout<<"Turning on branches"<GetBranch()->GetName()<SetBranchStatus(ttf.GetLeaf(j)->GetBranch()->GetName(),1); } ttf.UpdateFormulaLeaves(); Long64_t nbr=0; std::cout.precision(3); Long64_t i=0; Long64_t npass=0; bool keep_going=true; Int_t current_tree=-1; while(true) { if(t->GetTreeNumber()!=current_tree) { current_tree=t->GetTreeNumber(); ttf.UpdateFormulaLeaves(); } // load branches needed by selection for(Int_t j=0; j< ttf.GetNcodes(); j++){ Long64_t nb = ttf.GetLeaf(j)->GetBranch()->GetEntry(i); if(nb<=0){ // done reading std::cout<<"Should be done (1)? : [i,j] = "< 0.0){ npass++; Long64_t nb=t->GetEntry(i,0); if(nb<=0){ // done reading std::cout<<"Should be done (2)?"<Fill(); } // how's it going if(i%100000==0){ std::cout<