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 - rhorho ;
double result = (1 / (2 * TMath::Pi() * sigma_x * sigma_y * sigma_z * sqrt©))
* exp (-(u * u - 2 * rho * u * v + v * v + ww) / (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