Hi,
TTree are designed for write-once, read many times. Modifying values
inside a TTree is not supported.
Instead we recommend to either create a new TTree containing the modify
values and to be used as a 'Friend' of the old tree. Alternatively,
you can use CloneTree to duplicate the TTree into a new file and modify
the values during the duplication.
Cheers,
Philippe.
-----Original Message-----
From: owner-roottalk@pcroot.cern.ch
[mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Krzysztof Syryczynski
Sent: Monday, May 24, 2004 7:37 AM
To: roottalk@pcroot.cern.ch
Subject: [ROOT] how to modify data in a tree ?
root 4.00/03 CINT 5.15.128 Red Hat 7.2
Hello
I'd like to modify values written in one of the branches.
Unfortunately I cannot find a tree method like "SetEntry(i)".
Fill() adds new data instead of changing existing.
How to correct the following lines:
TFile *fH = new TFile("mlpHiggs.root","update");
TTree *tH = (TTree *)fH->Get("sig_filtered");
Float_t nch;
tH->SetBranchAddress("nch", &nch);
tH->SetBranchStatus("*",0);
tH->SetBranchStatus("nch",1);
const int ent=tH->GetEntriesFast();
for (Int_t i=0;i<ent;i++) { tH->GetEntry(i); nch=7; tH->Fill(); }
tH->StartViewer();
tv__tree->Draw("nch","","", 12345678, 0);
fH->Write();
Cheers
Krzysztof Syryczynski
This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:08 MET