#include #include #include #include #include #include void make_subsample2(void) { TChain *fChain = new TChain("tsm"); fChain->Add("/work/eowyn-clued0/noeding/ROOT/zee60_130/data/diem/0/D0ChunkAnalyze.root"); //fChain->Add("/work/eowyn-clued0/noeding/ROOT/zee60_130/data/diem/1/D0ChunkAnalyze.root"); //fChain->Add("/work/eowyn-clued0/noeding/ROOT/zee60_130/data/diem/2/D0ChunkAnalyze.root"); //fChain->Add("/work/eowyn-clued0/noeding/ROOT/zee60_130/data/diem/3/D0ChunkAnalyze.root"); //fChain->Add("/work/eowyn-clued0/noeding/ROOT/zee60_130/data/diem/4/D0ChunkAnalyze.root"); TFile *newfile = new TFile("zee60_130_subsample.root","recreate"); TTree* newtree = get_new_tree(fChain); //(TTree*)fChain->CopyTree("LETM_Nelectron>1"); newfile->Write(); newfile->Close(); } TTree* get_new_tree(TChain *ch) { TTree *tree = ch->CloneTree(0); TTree *fTree = ch->CloneTree(0); if (tree == 0) return 0; Int_t firstentry=0; Int_t nentries= (Int_t) ch->GetTree()->GetEntriesFast();//fTree->GetEntries(); cout << nentries << endl; Int_t entry,entryNumber; // Compile selection expression if there is one TTreeFormula *select = 0; // no need to interfer with fSelect since we // handle the loop explicitly below and can call // UpdateFormulaLeaves ourselves. select = new TTreeFormula("Selection","LETM_Nelectron>1",fTree); //fFormulaList->Add(select); //if (strlen(selection)) { // select = new TTreeFormula("Selection",selection,fTree); // if (!select || !select->GetNdim()) { delete select; } // fFormulaList->Add(select); //} //loop on the specified entries Int_t tnumber = -1; cout << "hallo" << endl; cout << firstentry << endl; cout << nentries << endl; for (entry=firstentry;entryGetEntryNumber(entry); if (entryNumber < 0) break; //cout << "a"<LoadTree(entryNumber); if (localEntry < 0) break; //cout <<"b"<GetTreeNumber()) { tnumber = fTree->GetTreeNumber(); if (select) select->UpdateFormulaLeaves(); } //cout << "before select"<GetNdata(); Bool_t keep = kFALSE; for(Int_t current = 0; currentEvalInstance(current) != 0); } if (!keep) continue; } //cout << "c"<GetEntry(entryNumber); tree->Fill(); } cout << "for loop done" << endl; //fFormulaList->Clear(); return tree; }