TTree unique entry

Hi all,

I am not sure this is built into a TTree functionality, but I would like to have a TTree with unique entries. That is to say that I want two values (run, cycle) of a tree to represent an index, if any new data is added to this tree with identical (run, cycle) I would like it to override the old data that is associated with this run, cycle.
Is this possible to do in trees? Is there a better-suited object for this task?

Alternatively, if I add two identical entries of run,cycle, will it be possible to ignore the older entries in post-processing?

What do you think is the best way to achieve this?

Cheers,
N.

Hi,

[quote] I would like it to override the old data that is associated with this run, cycle.[/quote]You can not modify the content of TTree (it is a write-once, read-many time structure).

[quote]
Alternatively, if I add two identical entries of run,cycle, will it be possible to ignore the older entries in post-processing? [/quote]It entirely depends on how you do the post-processing :slight_smile:

Cheers,
Philippe.

Hi Philippe,

Is it possible at all to tell draw (for example) to select only one entry per index value?

For example, if I put a timestamp on each of the entries, is it possible to ask TTree->Draw to select only one entry per index value (e.g. run, cycle) using the max(timestamp)?

Is there any other ROOT object better iterative writing?

Cheers,
Nir

Hi,

One solution would be to construct an TEntryList without the ‘old’ entries. A priori you could keep this TEntryList persistent and remove from the list any of the ‘replaced’ entries. Then tree->SetEntryList(entrylist) will limit TTree::Draw to only those entries that are explicitly listed.

Cheers,
Philippe.