Re: [ROOT] copy a selected number of entries from one TTree to another..

From: Antoni Munar (munar@fnal.gov)
Date: Wed Nov 27 2002 - 21:45:51 MET


Hi Rene,
thanks for the example. In the mean time, since I am using MakeClass,
I have found the following solution (seems to work, maybe not elegant, but
possibly usefull to somebody else...

  if (fChain == 0) return;

  Int_t nentries = Int_t(fChain->GetEntriesFast());

  TFile fout("hz.root","RECREATE");
  TTree *tfilter;
  TTree *tmp=(TTree*)fChain->GetTree();
  tfilter = (TTree*)tmp->CloneTree(0,"");

  Int_t nbytes = 0, nb = 0;
  for (Int_t jentry=0; jentry<10;jentry++) {
    Int_t ientry = LoadTree(jentry); //in case of a TChain, ientry is the
entry number in the current file
    if (ientry < 0) break;
    nb = fChain->GetEntry(jentry);   nbytes += nb;
    tfilter->Fill();
  }
  tfilter->Write();
  fout->Close();


###################################################
Antoni Munar Ara
Department of Physics and Astronomy
David Rittenhouse Laboratory
University of Pennsylvania
209 South 33-rd Street
Philadelphia, PA (USA)
19104-6396



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:21 MET