Reset a leaf to correct value in a TTree

Good evening all,

I have a tree containing a TBranch called Event inside which some leaves of which one is called weight.
I would like to reset this variabel weight to a correct value and leave all the other leaves and branches intact.

Does anyone know how to do that ???

Thanks a lot.

See maybe this: http://root.cern.ch/root/html/TTree.html#TTree:CloneTree and the “copytree3.C” tutorial: http://root.cern.ch/root/html/tutorials/tree/index.html
Note: in general, you can read an entry from the original tree (from an old, existing, root file), you can then modify its leafs in RAM, and then you can write that modified entry to a new “cloned” tree (to a newly created root file), and so on in a loop for all entries in the original tree.

Hi,

thanks a lot for the help.
What i would like to do actually is reset the value of the leaf in the original tree, i.e. by not using a new file.

Thanks a lot.

You can modify the values of leafs in RAM for the entry “i” right after you “MyTree->GetEntry(i);” (and before you actually use them in your analysis). No need to save the modified values in a new root file, of course, but you will need to repeat this procedure each time you read this entry again from your root file.
Just to make it clear -> there is no way to modify these values in your old, existing, root files.

Well ,that is my point actually.
I would like to change the values before I use them in my analysis.

Is there a possibility to add a leaf to an existing branch ???

Thanks a lot.

See http://root.cern.ch/download/doc/ROOTUsersGuideHTML/ch12s16.html#d5e15409 and
search for “Adding a Branch to an Existing Tree” in http://root.cern.ch/root/html/TTree.html

Sorry but I dont want to add a branch to an existing tree but want to add a leaf to an existing branch.

Thanks a lot.

Hi,

You can not (at least not in any easy way) add a leaf to a branch inside an existing file. If you really need this feature (humm … why?), you would need to create a brand new TTree object which the right branch and leaf structure and copy the data over from the old one to the new one.

Philippe.