Change specific value in a branch

Hi,

I have a fairly basic (I hope) question about changing specific values in a branch of a tree.

I am trying to use trees to store my parameter data generated in an interactive analysis session on disk. Some of the values generated needed to be updated after filling (such as live time after cuts). How does one go about doing this? With regards to the tree, each event consists of a set or floats as parameters, and each parameter is then represented by a separate branch in the tree. The number of parameters is the same for each event, but parameters can be added or deleted for all the events together by the user in session. What I wish to do is access a parameter value at a specific index in a specific branch, change it, then write that change to disk - if I have simply missed that section of the guide then please point me in the right direction!

Hi,

you create a new tree with just those branches that you need to update. Then in subsequent analyses you open that new tree and make the old tree a friend of it (TTree::AddFriend()).

Cheers, Axel.

Hi Axel,

Perhaps I have misunderstood your answer, but it isn’t a case of accessing the branch, but a specific value in the branch. If I have 5 million floats representing live time of events in sequence in a branch on disk, I want to know how to get at value number 4 million, change it, and save. Do I have to remake the entire branch to do this?

Andy

Hi Andy,

TTrees are write-once, read-many: they are not meant for changing values once they are written. The only alternative I can come up with is for the case where you only change a small fraction, and where the order of entries doesn’t matter. In that case you could keep a TEntryList of replaced tree entries. You would add only the new, replacing values to a new tree which you grow from an empty clone of the old tree. When analyzing you chain the old and the new tree, and you skip those entries that you stored in the TEntryList.

Cheers, Axel.

Hi Axel,

Cheers, though unfortunately the entries must be sequential. I have a non-tree alternative and will probably use that - thanks anyway, though.

Andy