I have a TNtuple with 40 columns. With those 40 columns, I’d like to produce a list of triplets, each element of a triplet being contributed by a different column, and each triplet made so as to minimize the difference between the elements in the triplet. So, I’d like a list of triplets {a,b,c} where max{a,b,c} - min{a,b,c} is minimized.
Currently, I’m storing the data in a 40 (yes, 40!) C++ vectors. I’ve written a binary search algorithm which, instead of returning the index of a found element, makes a comparison of elements neighboring the “closest” element, and returns the overall closest. I store these triplets in a vector of vectors, then sort by max(a,b,c) - min(a,b,c). Finally, to ensure every triplet is unique (no two share an element), I iterate over the sorted vector of vectors, storing “used” elements in a cache and, with every iteration, checking that an element of that triplet isn’t in the cache before keeping it.
This won’t, of course, work with a TNtuple. Is there a nice “ROOT” way to do this?
Please read tips for efficient and successful posting and posting code
ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided