Store the "rank" of a variable as a new branch in the root file

Dear experts,

I want to store the rank of a variable as a new branch in my root file. I have a root file ( attached). It has a tree “dsubszerostp”, which consist of a number of branches. As I do,

dsubszerostp->Scan(“BDT:evt_no”)

I can see that an event number ,for e.g. event number 4, has more than one values of the variable BDT. Now in an event I want to arrange these BDT values in the descending order, and provide the rank to each of the BDT values. I want to provide the rank 1 to the highest value of BDT in that event, 2 to the second highest and so on. Repeat the same for all the events and eventually store this “rank” for all the events as a separate new branch in the tree dsubszerostp.
As a newbie in root and c++ I am struggling to execute this idea in the codes. Could any one help me on this? How do I get started? Any kind of help will be highly appreciated.

Bs2Ds0STplnul-Cands_BDT.root (2.3 MB)

Regards,
Bibek

Hi Bibek,

I think the best way to achieve this is to use RDataFrame.
With this tool, you can easily add columns to your input datasets and write out the resulting, enriched columnar dataset to a root file.
Here you can find a tutorial showing how to perform the aforementioned operations (adding a column and save the new dataset).
Let me know if you encounter issues taking advantage of this system.

Cheers,
Danilo

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