How to use GetEntryNumberWithBestIndex()?

Given three TNtuples, I’d like to iterate over one and, for each element, find the closest element in the other two. I understand GetEntryNumberWithBestIndex() may be useful for this, but I don’t quite understand the syntax. What do “major” and “minor” correspond to?

Here’s a simple example of what I’m trying to do. Consider three TNtuples, A, B & C, each with a single branch:

A = [1, 7, 12, 43, 98]
B = [3, 6, 39, 49, 78]
C = [2, 4, 90, 101, 123]

I’ll use an RDataFrame and ForEach() to iterate over A. When I get to, say, the value 7, I want the index of the closest values from B & C, which are 6 and 4.


Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


It looks like a RDF question. @eguiraud can help you I think.

Hi,
same answer as Find closest value in a column of a TNtuple? I’m afraid, this usecase is not something RDF is meant for.

GetEntryNumberWithBestIndex is a method to deal with friend trees, it does not solve this usecase.

In fact this is not something Trees/TNtuples are meant for: if I understand correctly, to get the result you need there is no way you can do less than 2 or 3 nested for loops. Nested loops over all events in a TNtuple are not something ROOT interfaces are designed for (you can do nested loops, but it’s very expensive in terms of runtime). The typical way to deal with this is to load the data into memory, as you do in Find closest value in a column of a TNtuple? .

Hope this helps!
Enrico

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