RE: copying a TChain

From: Philippe Canal <pcanal_at_fnal.gov>
Date: Tue, 12 Jul 2005 09:52:27 -0500

 

> When I run this, all of the leaves immediately underneath "myQCDEvent"
> (technically branches, in this case) are filled, not just nVertex (see
> snapshot4.png).

Isn't that what you ask with

   fChain->SetBranchStatus("myQCDEvent",1); //read only this branch

> Can anyone give me an idea about how to fix this so that the branches I
choose are
> actually filled?

First try with a more recent version of ROOT. The current production release
is 4.04/02. If this still fails, send me a concrete example (aka root file and work script).

Cheers,
Philippe.

Ps. None of your attachment made it to the list

-----Original Message-----
From: owner-roottalk_at_pcroot.cern.ch [mailto:owner-roottalk_at_pcroot.cern.ch] On Behalf Of CHRISTOPHER DORAN
Sent: Monday, July 11, 2005 4:06 PM
To: roottalk_at_pcroot.cern.ch
Subject: [ROOT] copying a TChain

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
   fChain->GetEntry(0);

   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;

      tree->Fill();

   }// end loop over events    

   tree->Print();

   newFile = tree->GetCurrentFile();
   newFile->Write();
   newFile->Close();
}

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 Tue Jul 12 2005 - 16:53:37 MEST

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