Minuit2 Scan with other variables recalculated

[color=#FF4000]See Updates below: Contour question solved, Scan() still trouble.[/color]

Hello,

I seek to minimize a chi squared function over two physical parameters and several systematics. When I plot the 2D contour of both physical parameters, and the 1D scans of each alone, I see that the N-2 remaining minimization parameters are not re-minimized. That is, they are held static, and just the two parameters in question are ‘live’. How do I instruct the code to re-minimize the N-2 parameters? I use the members Contour(unsigned int i, unsigned int j, unsigned int& npoints, double* xi, double* xj) and Scan(unsigned int i, unsigned int& nstep, double* x, double* y, double xmin = 0, double xmax = 0). It seems I should be using the MNContour method, but that is not a member of Minuit2. The code is below.

Thanks!

[code] ROOT::Minuit2::Minuit2Minimizer min ( ROOT::Minuit2::kMigrad );
min.SetMaxFunctionCalls(1000000);
min.SetMaxIterations(100000);
min.SetTolerance(1e-5);
ROOT::Math::Functor f(&Chi2, Npulls+2);
min.SetFunction(f);
const double npstep = 1e-6; // stepsize of nuissance parameters
Int_t mindex = 0; // because renumbering sucks
min.SetVariable(mindex, “systematic #1”, 0.001, npstep); mindex++; //guesses based on test th13=0 < real th13
. . .
min.SetVariable(mindex, “systematic #43”, -0.001, npstep); mindex++;
min.SetLimitedVariable(mindex, “phys param 1”, 0.100, 1e-4, 0.00, 1.00); mindex++; //
min.SetLimitedVariable(mindex, “phys param 2”, 0.000, 1e-6, -1.0, 2.00); mindex++;

min.Minimize();
const double *xs = min.X();

unsigned int Npts = 40;
long int param0 = Npulls+0; //phys param 1
long int param1 = Npulls+1; //phys param 2

//plot 1D scans:
double xarr[Npts], chiarr[Npts];
min.Scan(param0, Npts, xarr, chiarr, 0, 0.20);
TGraph *g = new TGraph(Npts, xarr, chiarr);
TCanvas *C = new TCanvas(“C”, “C”, 600, 450);
C->cd(); g->Draw(“ca”);

//plot 2D contour(s)
min.SetErrorDef(1); 
double param0arr[Npts], param1arr[Npts];
min.Contour(param0, param1, Npts, &param0arr[0], &param1arr[0]); 
double sig1Xarr[Npts], sig1Yarr[Npts];
TGraph *cont1sig = new TGraph(Npts, sig1Xarr, sig1Yarr);
cont1sig->SetLineStyle(2);

[/code]

Okay, It seems in Minuit2 that Contour() is actually performing the function of the old Minuit MnContour(), the old Minuit Contour() no longer exists, and hence there is no Minuit2 MnContour(). This is not clear from the ROOT documentation, unless I am looking at the wrong place! root.cern.ch/root/html/ROOT__Mat … mizer.html simply says that Contour() will, [quote]" find the contour points (xi,xj) of the function for parameter i and j around the minimum The contour will be find for value of the function = Min + ErrorUp();"[/quote]
So now I am only asking about the Scan() function. I am looking for my chi squared as a function of one parameter, minimized over the remaining N-1 parameters. Scan() merely holds the other N-1 parameters fixed. Note that performing the scan manually-- Fixing my parameter for N values and minimizing the chi squared function N times-- is not an option because my fit to the discrete N points is not accurate enough for my subsequent calculations. What should I do?

Thanks!

[url]Minuit2

[quote=“Pepe Le Pew”][url]Minuit2

Thank you Pepe, for the link http://root.cern.ch/root/html/ROOT__Minuit2__MnScan.html#ROOT__Minuit2__MnScan:MnScan. It discusses ROOT::Minuit2::MnScan. Can you help instruct me on how to integrate that into my code? I don’t know enough ROOT. My code looks like this: ROOT::Minuit2::Minuit2Minimizer min ( ROOT::Minuit2::kMigrad ); ... ROOT::Math::Functor f(&Chi2, Npulls+2); min.SetFunction(f);

ROOT::Minuit2::MnScan objectname; or min.MnScan(…); don’t work.

Update:
To get around this in the short term, I scan manually using a for loop. Before the for loop, I minimize with the active variable free ( SetLimitedVariable(, “title”, …) ). In the for loop, I fixed that variable for each iteration ( SetFixedVariable(, “title”, …) then minimize again). After the for loop, I free the variable with ( SetLimitedVariable(, “title”, …) ), then run Contour(). and “title” are always the same. Unfortunately, when I run Contour(), it still thinks the variable is fixed and fails! Is there a better way?

Thanks!