copying a TChain

Date: Mon, 11 Jul 2005 16:06:05 -0500

Hello all,
I've got a bunch of files I'm chaining together and my goal is to output a file that has essentially the same structure as the original, minus several subbranches that I don't want. I was trying to follow the instructions that Rene laid out in an old thread called "filter out the chain," but I can't seem to get it to work correctly for my case. I am running 3.05/07. I attached screenshots of the tree to show the structure I'm working with, because I think my problem might have to do with the multiple levels of branches.

Here is a sample of the code I'm using. In this case, I am just trying to activate and fill a couple selected branches:

void jetFill::Loop()
// assume files already loaded into fChain correctly

   if (fChain == 0) return;
   Int_t nentries = Int_t(fChain->GetEntries());

   fChain->SetBranchStatus("*",0);   // disable all branches
   fChain->SetBranchStatus("myQCDEvent",1);   //read only this branch
   fChain->SetBranchStatus("nVertex",1);   //read only this branch
   fChain->SetBranchStatus("vertex_",1);   //read only this branch
   fChain->SetBranchStatus("vertex.Vz",1);   //read only this branch

   cout << " Creating new root-file ..."<< endl;    TFile *newFile = new TFile("small.root","recreate");    cout << " Creating new tree ..."<< endl;

   TTree *tree = (TTree*)fChain->GetTree()->CloneTree(0);

   Int_t nbytes = 0, nb = 0;
   for (Int_t jentry=0; jentry<nentries;jentry++) {

      Int_t ientry = LoadTree(jentry); //in case of a TChain,
      nb = fChain->GetEntry(jentry);

      nbytes += nb;


   }// end loop over events    


   newFile = tree->GetCurrentFile();

When I run this, all of the leaves immediately underneath "myQCDEvent" (technically branches, in this case) are filled, not just nVertex (see snapshot4.png). However, I can see from Print() that vertex_ doesn't contain any events at all, and neither does vertex.Vz or any of the other leaves/branches beneath vertex_ (see snapshot5.png). Can anyone give me an idea about how to fix this so that the branches I choose are actually filled? Thanks a lot! :)

-Chris Doran
 SULI intern, FNAL
 DePauw University Received on Mon Jul 11 2005 - 23:10:16 MEST

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:10 MET