Re: pb with minimisation from TF2::GetMinimumXY

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Mon, 11 Dec 2006 14:09:44 +0100


In your "Fit" function, you should (at least) change

  float x, y;
to
  double x, y;

Rene Brun

eric.houla_at_free.fr wrote:
> Hi all!
>
> I'm experiencing a problem using the above method from TF2.
> Here is what i'm doing:
>
>
> void RetMDF(double *x, double *par){
>
> return MDF(x);
>
> }
>
> void Fit(){
>
> TF2 *func = new TF2("function", RetMDF, 51, 53, 1, 1022, 0);
> func->Draw("surf1");
>
> float x, y;
> func->GetMinimumXY(x, y)<<endl;
>
> }
> I attached the macro MDF.C where is defined the function.
>
> The problem is that calling GetMinimumXY, i have the message:
> Warning in <TF2::GetMinimumXY>: Abnormal termination of minimization
>
> and x =0 and y = 0...Is there something wrong somewhere ?
>
> Thank you.
>
>
>
>
>
>
> ------------------------------------------------------------------------
>
> // -*- mode: c++ -*-
> //
> // File MDF.C generated by TMultiDimFit::MakeRealCode
> // on Mon Dec 11 13:20:12 2006
> // ROOT version 5.13/04
> //
> // This file contains the function
> //
> // double MDF(double *x);
> //
> // For evaluating the parameterization obtained
> // from TMultiDimFit and the point x
> //
> // See TMultiDimFit class documentation for more information
> //
> //
> // Static data variables
> //
> static int gNVariables = 2;
> static int gNCoefficients = 4;
> static double gDMean = 31.0686;
> // Assignment to mean vector.
> static double gXMean[] = {
> 7.10543e-15, -1.3327e-15 };
>
> // Assignment to minimum vector.
> static double gXMin[] = {
> 50, 0 };
>
> // Assignment to maximum vector.
> static double gXMax[] = {
> 54, 1023 };
>
> // Assignment to coefficients vector.
> static double gCoefficient[] = {
> 0.133231,
> -0.266462,
> -0.117676,
> 0.0917969
> };
>
> // Assignment to error coefficients vector.
> static double gCoefficientRMS[] = {
> 4.67491e-12,
> 7.149e-12,
> 1.27628e-11,
> 1.41424e-11
> };
>
> // Assignment to powers vector.
> // The powers are stored row-wise, that is
> // p_ij = gPower[i * NVariables + j];
> static int gPower[] = {
> 1, 1,
> 3, 1,
> 2, 1,
> 4, 1
> };
>
> //
> // The function double MDF(double *x)
> //
> double MDF(double *x) {
> double returnValue = gDMean;
> int i = 0, j = 0, k = 0;
> for (i = 0; i < gNCoefficients ; i++) {
> // Evaluate the ith term in the expansion
> double term = gCoefficient[i];
> for (j = 0; j < gNVariables; j++) {
> // Evaluate the polynomial in the jth variable.
> int power = gPower[gNVariables * i + j];
> double p1 = 1, p2 = 0, p3 = 0, r = 0;
> double v = 1 + 2. / (gXMax[j] - gXMin[j]) * (x[j] - gXMax[j]);
> // what is the power to use!
> switch(power) {
> case 1: r = 1; break;
> case 2: r = v; break;
> default:
> p2 = v;
> for (k = 3; k <= power; k++) {
> p3 = p2 * v;
> p1 = p2; p2 = p3;
> }
> r = p3;
> }
> // multiply this term by the poly in the jth var
> term *= r;
> }
> // Add this term to the final result
> returnValue += term;
> }
> return returnValue;
> }
>
> // EOF for MDF.C
>
Received on Mon Dec 11 2006 - 14:09:53 MET

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:32:02 MET