+ // if a weight function is specified -> enter 2nd run with weights
+ if (weightFlag == true && fUseRobust == true) {
+ // sort points for weighting
+ Double_t *sortList = new Double_t[npoints];
+ Int_t *indexList = new Int_t[npoints];
+ for (Int_t ipoint=0; ipoint<npoints; ipoint++){
+ Double_t funx = fFormula->Eval((*fPoints)(ipoint, 0));
+ Double_t delta = TMath::Abs((*fPoints)[ipoint][nvar] - funx);
+ sortList[ipoint] = delta;
+ }
+ TMath::Sort(npoints, sortList, indexList, false);
+ for (Int_t ip=0; ip<npoints; ip++){
+ Double_t t = ip/(Double_t)npoints;
+ (*fWeights)(indexList[ip]) = fWeightFunction->Eval(t);
+ }
+
+ // set up the fitter
+ fUseRobust = false;
+ for (Int_t iparam=0; iparam<nparam; iparam++){
+ minuit->SetParameter(iparam, Form("p[%d]",iparam), (*fParam)(iparam), (*fParam)(iparam)/10, (*fParamLimits)(iparam, 0), (*fParamLimits)(iparam, 1));
+ }
+ // start fitting
+ if (fMaxCalls == 500 && fPrecision == 1) minuit->ExecuteCommand(fFitAlgorithm, 0, 0);
+ if (fMaxCalls != 500 || fPrecision != 1) minuit->ExecuteCommand(fFitAlgorithm, argList, 2);
+ fUseRobust = true;
+
+ delete [] sortList;
+ delete [] indexList;
+ }
+