How to get the averages of a tree->Draw("y:x","","profs")


When doing a Draw(“y:x”,"",“profs”), ROOT is doing already the averaging as expected, calculating the average and RMS of the several “y” values at the same “x” ordinate. When I try to get the information back in a vector, I get the raw data, not the average.

Long_t nel = tree->Draw(“y:x”,"",“profs”)

Root has plotted 4 markers.

Now I get the values back into vectors:

Double_t *y = tree->GetV1();
Double_t *x = tree->GetV2();
root [10] for (Int_t i=0 ; i<nel ; i++) std::cout<<x[i]<<" " << y[i]<<std::endl ;
0.1 1.8259e+14
1e+15 1.5558e+14
1e+15 1.5558e+14
7e+15 4.97032e+13
7e+15 4.20688e+13
2e+16 9.09792e+13
2e+16 8.11512e+13
2e+16 9.09792e+13

I got the 8 values without averages!!

thank you

When you do :

Long_t nel = tree->Draw("y:x","","profs") 

Root creates and fills a profile histogram with the y:x values then it plots it … that what you see.
When you do GetV1() … you get the raw data as shown when you issue the command

Long_t nel = tree->Draw("y:x") 

To retrieve the TProfile search for “htemp” in:


thank you for your answer.

Looping over htemp works, as long as the values I am interested on are different from zero. I mean, htemp is booked with a number of bins (100?) and some of those bins will be empty. So then I have to filter out bins with 0 bin entries.

Use the appropriate getter to find the number of bins

That’s not very difficult :slight_smile: