Merge multiple events into a new single event

Hi all,
I want to do following:

  1. select from a single Tree,which has various branches, several events (e.g.: eventnr 1 and 23 and 51).
    Then I would like to merge those e.g. 3 events into a single one and store it in a new tree (which I have already created with auto newtree = oldtree->Clone(0)).
  2. repeat step 1) multiple times (with of course different events)
Old Tree:                                                            New Tree:
Selected Eventnumbers:                                    Created Eventnumbers:                
1,23,51                                                               1
2,4                                                                   2
99,134,188                                                            3

.....

Is there a method in ROOT how I could do this?

Thanks in advance!

Hi @jenegger,

welcome back on the forum.

You can select certain events from the TTree and copy them into a new TTree object, but if you copy N events you will receive N events in the new tree. For very easy filtering and saving new objects with only selected events you could try using RDataFrame, see: ROOT: ROOT::RDataFrame Class Reference

I’m a bit confused why would you like to merge a few events into a single event? Usually the events represent collisions, so each event is an individual instance.

Cheers,
Marta

HI Marta,
thanks a lot for the clear answer!
I am aware that my problem of merging events is exotic. Maybe I have to think about other ways to tackle it.
Best Regards
Tobias

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.