Dear,
I have a root file with two TTree (e.g. Tree1 and Tree2) with the following TBranch:
energy
eventID
detectorID
blockID
I want to create a new file with a TTree (TreeTotal) with the same architecture (energy; eventID; detectorID; blockID), but the TBranch energy from Tree1 and Tree2 will be the summed when they have the same eventID, detectorID and blockID. If this situation is not satisfied, then the data will be just copied to TreeTotal. For instance:
Tree1 has:
energy: 2.0; 5.0; 7.0; 4.0
eventID: 1 ; 2 ; 3 ; 4
detectorID: 2 ; 5 ; 9 ; 3
blockID: 1 ; 4 ; 3 ; 2
Tree2 has:
energy: 4.0; 1.0; 3.0; 5.0
eventID: 2 ; 4 ; 5 ; 6
detectorID: 5 ; 3 ; 8 ; 9
blockID: 4 ; 1 ; 2 ; 3
TreeTotal will have:
energy: 2.0; 9.0; 7.0; 4.0; 1.0; 3.0; 5.0
eventID: 1 ; 2 ; 3 ; 4 ; 4 ; 5 ; 6
detectorID: 2 ; 5 ; 9 ; 3 ; 3 ; 8 ; 9
blockID: 1 ; 4 ; 3 ; 2 ; 1 ; 2 ; 3
Please, notice that the summing happens only for event 2, which is the one that all the IDs are the same.
I would like if this can be done in pyRoot and if RDataFrame is suitable for this.
Please read tips for efficient and successful posting and posting code
Please fill also the fields below. Note that root -b -q
will tell you this info, and starting from 6.28/06 upwards, you can call .forum bug
from the ROOT prompt to pre-populate a topic.
ROOT Version: 6.28/04
Platform: Linux Mint
Compiler: g++