Reading an N-tuple and Placing Results for New Variables in a Tree Branch

I have an n-tuple as the result of running some analysis codes to produce some multi-jet final states. I ran for 100 multi-jet events, so most of the histograms have 600+ entries corresponding to all the jets produced: for example, there are histograms for eta, phi, transverse momentum, jet mass etc. I basically have one tree in the n-tuple with 1 branch, the branch has leaves for all the variables for the jets. I need to pull out the two leading jets from every event (ie. the two jets with highest transverse momentum) and then calculate delta eta, delta phi and the invariant mass for the dijet and then put those into histograms in a new branch of the tree and fill a branch with the new variables (I will probably call the variables ‘invariantmass12’ etc).

Can anyone advise? I have a template pre-processing ROOT macro for reading n-tuples which I have been tinkering with (attached below). The macro can select a n-tuple, specify a tree and then select variables from it and read them in a for-loop but I have not been able to see how to make it perform the task I need, as it seems like I need to loop over all the possible jet combinations in each separate event one-by-one.

The template I am using is one from GitHub:

Are you completely stuck with an old ROOT, or could you use 6.14 if I could show you that you will fall in love with ROOT and you get your PhD a year earlier?

If so: could you send one single entry from your tree, such that I can prototype the analysis the way we suggest to do it today? I’ll fill the same histos, do the same cuts etc.

Axel.

Hi,

if you are looking for a single command to extract 1 event from your tree to share with us, this would be a possible solution:

~> rooteventselector -l 1 yourRootFile.root:yourTreeName newRootFileWith1EventOnly.root

Cheers,
Danilo

I would I be willing to use a newer version of ROOT, if you can explain how it works clearly I am all ears as I am finding this a steep learning curve at the moment. Danilo, I have tried to use the rooteventselector command as you outlined above but seem to get a string of error messages, I don’t know if these are due to using an older version of ROOT? I have attached the error code if that makes sense. I have also attached the ROOT browser which I am seeing, to check that I am identifying the name of the tree correctly, as it does not seem to work. Is there another command I can use to try and extract 1 event from the tree?


Hi,

this is one of the many ways to extract an event: you can directly share the full file to let us re-express your analysis :slight_smile:
The reason why the command is not working is because you are invoking it from the root prompt while you should do that from your shell.

Cheers,
Danilo

Hi Danilo,

I’ve attached the ROOT file produced after extracting 1 eventnewfile.root (8.0 KB)
I’ve also attached the original ROOT file with all the events if that helps kine_test5_CC_pe-_hww_4j_sm_FCChe_cteq_P-80_60_50000_exotics.root (34.2 KB)

Hi Axel,

I think I might be stuck with an older ROOT, I’m not sure. Basically I log-in to a terminal at another University and get to a shell that way, and then type in the root command in the shell to get up ROOT. I could perhaps install a newer version on my computer though.

I have attached an entry from the tree as a new ROOT file as well as the ROOT file produced from the original analysis, or did you mean that you wanted to see the analysis code which produced the ROOT file in the first place?

I also show on screen the ROOT file which is produced if I extract 1 event, this produces another tree, so I can show the histogram for transverse momentum of the jets in 1 event. I basically just need to select the two highest P_t jets from all the events and then fill histograms with variables for those two jets, like the eta difference between them, invariant mass etc

Hi,
To work on the leading jets of an event, keep these jets inside one TTree entry. You can e.g. have vector<double> inside each TTree entry.

Try not to histogram values - histogramming should be the last step; it hides all correlation info.

So start with the initial tree, containing the 100 multi-jet events. I warmly recommend to use ROOT:RDataFrame from ROOT 6.14, which you can simply download from https://root.cern/download/ then untar (tar xzf root-v6.14.00...tar.gz) and do . where/you/untarred/root/bin/thisroot.sh to set it up.

RDataFrame will make your analysis much more structured and easier for yourself; the current code (“template” as you call it) has several infinite loops; variables that are unused etc.

I don’t really know how else to help given the info I have.

Cheers, Axel.

Thanks for your help. I’m not sure if I am missing something but I still don’t really get how to separate the leading jets over the 100 events in the analysis and calculate the quantities I need for each of the 100 dijets in turn. Is there an example script somewhere which would read an ntuple in this way? Sorry for now following, but I am fairly new to ROOT. I think the main thing is to print the invariant mass on screen but I would like to histogram as well for the visual element although I don’t think this is essential as you say. Could you advise how I could loop over all the jet combinations and print the invariant mass just as a first step?

Something like this file Signal4.C (1.1 KB) might work - a translation of your github “template”! It shows how to find the leading cluster; you can so something similar for finding the two leading jets.

Axel.

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