Hi Art,
You also mentioned, you solve the problem. What did you change?
Philippe.
On 1/18/12 4:13 PM, Snyder, Arthur E. wrote:
> hmmm,, mmm
>
> |SetBranchAddress| is done in the selector |Init| function. The cloned tree and the file it's to go in are created on the 1st call to |process| call. Off hand I don't see how the order can be wrong ..
>
> -Art
> ________________________________________
> From: Philippe Canal [pcanal_at_fnal.gov]
> Sent: Wednesday, January 18, 2012 2:07 PM
> To: Snyder, Arthur E.
> Cc: roottalk_at_root.cern.ch
> Subject: Re: [ROOT] Adding variabesl and writing out a tree
>
> Hi Art,
>
> > 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|.
>
> This is unexpected and indicative that there is another problem somewhere.
>
> > -However when I read the file back in |McSourceId| has not been set to |w|, nor have the other variables I change.
>
> Most likely the call to SetBranchAddress is not done at the right time and/or on the right TTree.
>
> Cheers,
> Philippe.
>
> On 1/18/12 12:37 PM, Arthur E. Snyder wrote:
>> 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 - 23:17:58 CET
This archive was generated by hypermail 2.2.0 : Thu Jan 19 2012 - 17:50:01 CET