updating values in a tree

From: Maximilien Fechner <maximilien.fechner_at_cea.fr>
Date: Tue, 8 Jun 2010 11:52:09 +0200


Dear ROOT-ers,

If this question has already been answered, please point to the answer, I couldn't find it in the archive...

I have a ROOT tree containing data in one split branch. The branch holds a TCLonesArray of identical objects (very lightweight, just a struct with a few double values). I would like to update some of those values "on the fly" : the branch already exists, the variables too, I just want to change their values.
but calling "branch->Fill" doesn't update the values... (see example below).

Is there a way to do what I describe ?

Many thanks in advance,
-Maximilien Fechner

Here's a simple example:

TFile* f = new TFile("aaa.root","update"); TTree* a = (TTree*)f->Get("tree");
TClonesArray* p =new TClonesArray("smallobject"); TBranch* theb;
a->SetBranchAddress("B",&p,&theb);

for ( int i = 0 ; i < a->GetEntries(); i++) {

    a->GetEntry(i);
    smallobject* o = dynamic_cast<smallobject*>( (*p)[0]);     p->to_be_updated = my_new_result();
    theb->Fill();
}

a->Write("",TObject::kWriteDelete);

-> the values of "to_be_updated" are still the same after this is run...

-- 
Maximilien Fechner, PhD
CEA IRFU SPP Centre de Saclay
91191 Gif-sur-Yvette
France
Received on Tue Jun 08 2010 - 11:52:14 CEST

This archive was generated by hypermail 2.2.0 : Tue Jun 08 2010 - 17:50:01 CEST