2 using namespace profileFit;
38 ostringstream errorMsg;
42 errorMsg <<
" ProfileFitter::Fit() "
43 <<
" ERROR: variance is not initialized, exit!";
44 cerr << errorMsg.str() << endl;
46 throw std::runtime_error(errorMsg.str());
77 TMinuit theMinuit(nPar);
83 const double xMax = theMax.first;
84 const double nMax = theMax.second;
87 theMinuit.mnparm(
eGHnMax,
"nMax", nMax, nMax*5e-2,0,0,ierflag);
88 theMinuit.mnparm(
eGHXmax,
"xMax", xMax, 10.,0,0,ierflag);
89 theMinuit.mnparm(
eGHX0,
"x0",-100., 10.,-1000,500.,ierflag);
90 theMinuit.mnparm(
eGHLambda,
"lamb", 60., 5.,10.,150.,ierflag);
104 TMinuit theMinuit(nPar);
110 const double xMax = theMax.first;
111 const double nMax = theMax.second;
114 theMinuit.mnparm(
eGiAnMax,
"nMax", nMax,nMax*5e-2,0,0,ierflag);
115 theMinuit.mnparm(
eGiAXmax,
"xMax", xMax, 10.,0,0,ierflag);
116 theMinuit.mnparm(
eGiASigma1,
"sig1", 0.2, .05,0.,.5,ierflag);
117 theMinuit.mnparm(
eGiASigma2,
"sig2", 0.2, .05,0.,.5,ierflag);
135 TMinuit theMinuit(nPar);
143 const double nMax = theMax.second;
144 const double xMax = theMax.first;
148 for (
unsigned int i=0;i<
fDepth.size(); i++ ) {
156 if ( leftSum > rightSum )
160 theMinuit.mnparm(
eDGHnMax1,
"nMax1", nMax*0.5, nMax*1e-1, 0., 0., ierflag);
161 theMinuit.mnparm(
eDGHXmax1,
"xMax1", xMax-deltaX, 10., 0., 0., ierflag);
162 theMinuit.mnparm(
eDGHX01,
"x01", -100., 10., -1000., 500., ierflag);
163 theMinuit.mnparm(
eDGHLambda1,
"lamb1", 61., 5., 10., 150., ierflag);
165 theMinuit.mnparm(
eDGHnMax2,
"nMax2", nMax*0.5, nMax*1e-1, 0., 0., ierflag);
166 theMinuit.mnparm(
eDGHXmax2,
"xMax2", xMax+deltaX, 10., 0., 0., ierflag);
167 theMinuit.mnparm(
eDGHX02,
"x02", -100.+deltaX, 10., -1000., 500., ierflag);
168 theMinuit.mnparm(
eDGHLambda2,
"lamb2", 61., 5., 10., 150., ierflag);
178 std::pair<double, double>
183 vector<double>::const_iterator maximum = max_element(
fSize.begin(),
186 const double nMax = *maximum;
187 const int iMax = (maximum-
fSize.begin());
188 const double xMax =
fDepth[iMax];
190 return pair<double,double>(xMax,nMax);
197 double& value,
double*
const par,
202 const double nMax = par[
eGHnMax];
203 const double xMax = par[
eGHXmax];
204 const double x0 = par[
eGHX0];
209 for (
unsigned int i=0;i<
fDepth.size();i++ ) {
211 const double y =
fSize[i];
215 const double x =
fDepth[i];
216 const double fx = (x>x0)?
GHFunction(x,x0,lambda,xMax,nMax):0.;
219 chi2 +=
pow(y-fx,2)/vy;
227 const double fdefX0 = -121.;
228 const double rmsX0 = 172.;
229 chi2+=(x0-fdefX0)*(x0-fdefX0)/rmsX0/rmsX0;
230 const double fdefLambda = 61.;
231 const double rmsLambda = 13.;
232 chi2+=(lambda-fdefLambda)*(lambda-fdefLambda)/rmsLambda/rmsLambda;
242 double& value,
double*
const par,
257 for (
unsigned int i=0;i<
fDepth.size();i++ ) {
259 const double y =
fSize[i];
263 const double x =
fDepth[i];
266 chi2 +=
pow(y-fx,2)/vy;
274 const double meanSigma1 = 0.2;
275 const double vSigma1 =
pow(0.03,2);
276 const double meanSigma2 = 0.2;
277 const double vSigma2 =
pow(0.03,2);
278 chi2+=
pow(sigma1-meanSigma1,2)/vSigma1;
279 chi2+=
pow(sigma2-meanSigma2,2)/vSigma2;
290 double& value,
double*
const par,
296 const double x01 = par[
eDGHX01];
300 const double x02 = par[
eDGHX02];
305 for (
unsigned int i = 0; i <
fDepth.size(); i++) {
307 const double y =
fSize[i];
311 const double x =
fDepth[i];
312 const double fx1 = (x>x01)?
GHFunction(x,x01,lambda1,xMax1,nMax1):0.;
313 const double fx2 = (x>x02)?
GHFunction(x,x02,lambda2,xMax2,nMax2):0.;
316 chi2 +=
pow(y-fx1-fx2,2)/vy;
324 const double fdefX0_minus_Xmax = -816.;
325 const double rmsX0_minus_Xmax = 183.;
326 chi2+=(x01-xMax1-fdefX0_minus_Xmax)*(x01-xMax1-fdefX0_minus_Xmax)/rmsX0_minus_Xmax/rmsX0_minus_Xmax;
327 chi2+=(x02-xMax2-fdefX0_minus_Xmax)*(x02-xMax2-fdefX0_minus_Xmax)/rmsX0_minus_Xmax/rmsX0_minus_Xmax;
329 const double fdefLambda = 61.;
330 const double rmsLambda = 13.;
331 chi2+=(lambda1-fdefLambda)*(lambda1-fdefLambda)/rmsLambda/rmsLambda;
332 chi2+=(lambda2-fdefLambda)*(lambda2-fdefLambda)/rmsLambda/rmsLambda;
337 if ( nMax1<0. || nMax2<0.)
350 double arglist[2]={100000, 1.};
351 theMinuit.mnexcm(
"MIGRAD", arglist, 2, ierflag);
355 cerr <<
" MIGRAD failed. Error: " << ierflag << endl;
359 theMinuit.mnexcm(
"HESSE", arglist, 2, ierflag);
361 double amin, edm, errdef;
362 int nvpar, nparx, icstat;
363 theMinuit.mnstat(amin, edm, errdef, nvpar, nparx, icstat);
369 for (
int i=0;i<nparx;i++ )
383 theMinuit.SetPrintLevel(0);
387 theMinuit.SetPrintLevel(-1);
388 theMinuit.mnexcm(
"SET NOW", 0 ,0,ierflag);
392 theMinuit.mnexcm(
"SET ERR",&arglist,1,ierflag);
405 theMinuit.mnparm(i,name.str().c_str(),
411 theMinuit.mnparm(i,name.str().c_str(),
static std::vector< double > fSizeError
std::vector< double > fFitErrors
void InitMinuit(TMinuit &) const
static void GaussInAgeFitFunction(int &, double *const, double &, double *const, const int)
double pow(const double x, const unsigned int i)
static EFitFunctionType fFunctionType
static void DoubleGHFitFunction(int &, double *const, double &, double *const, const int)
double GaussInAgeFunction(const double X, const double nMax, const double xMax, const double sigma1, const double sigma2)
std::pair< double, double > FindMaximum() const
std::vector< double > fStepParameters
double GHFunction(const double X, const double x0, const double lambda, const double xMax, const double nMax)
static unsigned int fNdof
static bool fIsConstrained
static void GHFitFunction(int &, double *const, double &, double *const, const int)
void UserStartInit(TMinuit &theMinuit)
std::vector< double > fLimitsDown
std::vector< double > fStartParameters
std::vector< double > fFitParameters
static std::vector< double > fSize
std::vector< double > fLimitsUp
static std::vector< double > fDepth