Sorting and Comparing Multiple NTUPLEs

Hi Rooters
I have three NTUPLES, each contains 100000 events. I want to analyze these NTUPLES on event by event basis.

So, I take the first event of first NTUPLE and match its EventNumber with EventNumber of 2nd NTUPLE using a for-loop. Unfortunately, the NTUPLES are not sorted with respect to EventNumber and for-loop takes very long to match the EventNumber in 2nd NTUPLE with EventNumber in 1st NTUPLE. Once, these two are matched, I run another nested for-loop to match for EventNumber from 3rd NTUPLE. And again, it takes too long.

What I am saying is that the first entry in 1st NUTPLE has EventNumber=12345678. But EventNumber=12345678 in 2nd NTUPLE is 98000th entry. And EventNumber=12345678 in 3rd NTUPLE is 76000th entry.

Is there a smart way to scan the NTUPLES quickly and get entry numbers of 2nd and 3rd NTUPLES with EventNumber=XXXX without using for-loops?

Cheers
Aatif

Hi,

I am not sure if it performs better, but the to do what you want ROOT
trees/tuples can have friends.

TNtuple n1("n1","", "x:evt");
TNtuple n2("n2","", "x:evt");
TNtuple n3("n3","", "x:evt");

// make variables in the other ntuples know in n1
n1.AddFriend(n2);
n1.AddFriend(n3);

n1.Draw("n1.x+n2.x+n3.x", "n1.evt==n2.evt && n1.evt==n3.evt");

This can still be slow if your data is spread out differently in the trees.

Draw() makes a histogram?

See “Retrieving the result of Draw” and “Saving the result of Draw to an histogram” in the TTree::Draw method description.