So I created 2 list of masses and i want to apply a cut to one variable to draw the histogram of the other but I am having trouble in adding branches to my existing root file. Is there a way to apply a cut to the histogram without using the tree Draw method. Thanks for the help
Once the histogram is created, the data is reduced, and no cut can be applied on the entries any more.
If you want to easily create new columns of a dataset and represent their entries as histograms, perhaps applying selection cuts, I would recommend to look into RDataFrame.
Thanks for the reply, I guess I can use the Filter method of RDataFrame but that would still have me add a new branch to my dataset. When I use the TTree Branch method to add a list of masses to my root file it only adds one entry, so I was trying to look for a different solution. Would it be possible for you to show me the way I can I add a list as a branch to my dataset?
So the second parameter to the Define method is a producer as written in the docs. Would that be referring to a function that outputs the list of masses?
I think I start to understand what you are trying to accomplish: if I am not too wrong, we can identify an easy solution.
Are the names J_psi_15_PXJ_psi_15_PYJ_psi_15_PZJ_psi_15_PE and phi_1020_PX… your branches?
So this code worked but I wanted to ask, does this code add a column to my dataframe or a branch to the tree in my root file? In order to use the tree Draw method I would need a need a new branch in my tree.
And also when I do mydf.Display(“JpsiPhiMass”) it gives me the error that regex “JpsiPhiMass” did not match any column.
Alright so the final solution is as follows:
I used the above code given by Danilo and then I execute the following command:
myDF.Snapshot(“nameofTree”, “path_to_root_file”)
This will create the new column and add it to the tree in the ROOT file. Thank you for all the help on this.