[ROOT] how to modify data in a tree ?

From: Krzysztof Syryczynski (ksyrycz@fuw.edu.pl)
Date: Mon May 24 2004 - 14:36:40 MEST


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