Problem with TF3::GetRandom3

Hello everyone,

I’m facing a strange problem with TF3::GetRandom3 with ROOT 5.34.30.
When applying this method (e.g. with f->GetRandom3(x[0],x[1],x[2])), I get the following error message :

Error in TF3::Integral: Must be called with a TF2 only
Error in TF3::CentralMoment2: Integral zero over range

And the returned values are all 0. The funny thing is that this worked perfectly with my previous ROOT version, 5.34.18.

Here’s a more precise example:

double gaus3d(double x, double p) { // example function from which draw random numbers
double sigma_x = p[0];
double sigma_y = p[1];
double sigma_z = p[2];
double rho = p[3];
double u = x[0] / sigma_x ;
double v = x[1] / sigma_y ;
double w = x[2] / sigma_z ;
double c = 1 - rho
rho ;
double result = (1 / (2 * TMath::Pi() * sigma_x * sigma_y * sigma_z * sqrt©))
* exp (-(u * u - 2 * rho * u * v + v * v + w
w) / (2 * c));
return result;
}

int n = 100;
TF3 * f = new TF3(“g3d”,gaus3d,-10,10,-10,10,-10,10,4);
f->SetNpx(200);
f->SetNpy(200);
f->SetNpz(200);

double par[4] = {2,2,2,0.5};
double x[3] = {0,0,0};
f->SetParameters(par);
for (int i = 0; i < n; ++i) {
f->GetRandom3(x[0],x[1],x[2]);
}

Does anyone have an idea of how to fix this?

Thanks!
Vincent

Hi,

I don’t have any problem running this code with 5.34.31 and also with ROOT 6 versions

Best Regards

Lorenzo

Hi,

Thanks for your answer. On what OS have you done the test? It seems that the problem is Mac OS - related.
I’m facing the issue with Mac OS X 10.8.5, but I don’t have any problem when using a Linux distribution (e.g. Mageia).

Vincent

Hi,

I have tested on MacOS 10.10.3. But I doubt that this problem is due to the OS version. It could be due to a wrongly built version of ROOT.
I would try to re-build and re-install ROOT, possibly using the latest version of 5.34 or 6.

Cheers

Lorenzo