Adding variabesl and writing out a tree

From: Arthur E. Snyder <snyder_at_slac.stanford.edu>
Date: Wed, 18 Jan 2012 10:37:48 -0800

I'm trying to modify some variables and write out some events in my tree, making a reduced sized tree with some useful weights added.

To do this i clone tree, so

  pOutputTree=fChain->CloneTree(0);

I change the value of one of the variables

McSourceId=w (re-using a Mc variable not used for data, but there ...)

I fill the tree:

if(pOutputTree!=0) pOutputTree->Fill();

and when |input->Process| is done I write it out:

  if(pOutputTree!=0) {

     pOutputFile=new TFile(outputFileName,"create");
     pOutputTree->Write();
     pOutputFile ->Close();

   }

-However when I read the file back in |McSourceId| has not been set to
|w|, nor have the other variables I change.

So is there some way to make this work?

-Art S.

PS. There is another odd problem. If I create the output |TFile| just before the |CloneTree(0)| I end up with the complete original input tree rather than the selected events for which I called new tree |Fill|. So I keep it in memory and open and write to TFile only at the end.

I don't think this is related to above problem ...

A.E. Snyder, The Former Group C (TFC)        \!c*p?/
SLAC Mail Stop #95                          ((.   .))
Box 4349                                        |
Stanford, Ca, USA, 94309                      '\|/`
e-mail:snyder_at_slac.stanford.edu                 o
phone:650-926-2701                              _
http://www.slac.stanford.edu/~snyder          BaBar
FAX:707-313-0250                          Collaboration
                                                 &
                                            Fermi/GLAST
Received on Wed Jan 18 2012 - 19:37:57 CET

This archive was generated by hypermail 2.2.0 : Wed Jan 18 2012 - 23:50:01 CET