Getting mean from htemp

Hello
Here’s my question.
I have multiple branches in a Ttree for different inputs such as energy, angle etc. Around 20 of them are Rear detection and the other 20 are front detection. I would like to iterate over the branches, get the mean for all branches that have ‘Front Detection’ and ‘Rear detection’. Get the ratio of the mean i.e. mean of front/mean of back and create a histogram of this ratio versus the angle, grouped by the energy distribution. Can I please get some help and direction?

Check out this example on how to read and loop over a tree: ROOT: tutorials/tree/tree1.C Source File
(in particular, the function tree1r). Once you can read any variable, you can do what you need and fill histograms as also shown in the same example.

Hi. I have looked at this and the documentation as well. I am doing this on Jupyter notebooks and I already have the trees and branches filled. I want to iterate over the branches to get their mean, store them in a result and use those values to draw a histogram. I hope this made more sense than my badly worded question?

Have you tried to use RDataFrame?

RDataFrame df("treeName", "file.root")
dfRear=df.Filter("rearDetectionCondition")
dfFront =df.Filter("feontDetectionCondition")

meanVals={}
for c in df.GetColumnNames():
    meanVals.update( { c : {"front" : dfFront.Mean(c), "rear" :dfRear.Mean(c))


for k in meanVals.keys():
   MeanRear = meanVals[k]["rear"].GetValue()
   MeanFront = meanVals[k]["front"]. GetValue() 

Just to give an idea how you can collect on 2 subset of the same tree the mean value of all columns