Dear ROOT friends,
I have tested the TProfile output with the example below. The closest values that I get between the TProfile and the mean are:
The TH2D mean value is: 3.267409
The TProfile value is: 3.267731
Is it possible / how can I get the TProfile to always return the exact mean?
Thanks,
Jonatan
{
TH2D* htot = new TH2D("htot", "", 10, 0, 10, 1000, 0, 10);
TF2 f2("f2", "xygaus", 0, 100, 0, 100);
f2.SetParameters(1, 0, 5, 0, 4);
double x;
double y;
double bin_sum = 0;
int bin_entries = 0;
for(int i=0; i<2000; i++)
{
f2.GetRandom2(x,y);
if (y < 0.1) continue; // Just in case, avoiding edges
if (y > 9.9) continue; // Just in case, avoiding edges
if (x > 1.1 && x < 1.9) // Just in case, avoiding edges
{
htot->Fill(x,y);
bin_entries++;
bin_sum += y;
}
}
TProfile* hprof = (TProfile*)htot->ProfileX();
printf("\n");
printf(" The TH2D mean value is: %f\n", bin_sum / bin_entries);
printf(" The TProfile value is: %f\n", hprof->GetBinContent(2));
printf("\n");
}
ROOT Version: 6.10/09