Re: how to change only one variable of a TNtuple

From: Philippe Canal <pcanal_at_fnal.gov>
Date: Thu, 3 Mar 2011 16:23:23 -0600


Hi Wei,

TNtuple are write once, read many time, you will need to copy and change your existring TNtuple, for example:

      TFile *input = TFile::Open("input.root");
      TTree *inputtree; input->GetObject("ntuple",inputtree);
      Float_t myvalue;
      inputtree->SetBranchAddress("what",&myvalue);

      TFile *output = TFile::Open("output.root","RECREATE");
      TTree *outputtree = inputtre->CloneTree(-1);

      for(Long64_t entry = 0; entry < inputtree->GetEntries(); ++entry) {
          inputtree->GetEntry(entry);
          myvalue = some_operation( myvalue, ....);
          outputtree->Fill();
     }
     outputfile->Write();
     delete outputfile;

Cheers,
Philippe.

On 3/3/11 2:15 PM, wxie wrote:
> Assuming I made a ROOT file contains a TNtuple. I later found one variable in
> the ntuple is not correctly filled. What is the best way to correct only
> this variable but leave other part of the ROOT file unchanged? An example would
> be appreciated.
>
> Thanks
> --Wei
>
Received on Thu Mar 03 2011 - 23:23:29 CET

This archive was generated by hypermail 2.2.0 : Fri Mar 04 2011 - 05:50:02 CET