#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=fTree->GetEntriesFast(); Int_t entry,entryNumber; Int_t lastentry = firstentry + nentries -1; if (lastentry > fTree->GetEntriesFast()-1) { lastentry = (Int_t)fTree->GetEntriesFast() -1; nentries = lastentry - firstentry + 1; } // 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); //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; for (entry=firstentry;entryGetEntryNumber(entry); if (entryNumber < 0) break; Int_t localEntry = fTree->LoadTree(entryNumber); if (localEntry < 0) break; if (tnumber != fTree->GetTreeNumber()) { tnumber = fTree->GetTreeNumber(); if (select) select->UpdateFormulaLeaves(); } if (select) { Int_t ndata = select->GetNdata(); Bool_t keep = kFALSE; for(Int_t current = 0; currentEvalInstance(current) != 0); } if (!keep) continue; } fTree->GetEntry(entryNumber); tree->Fill(); } fFormulaList->Clear(); return tree; }