Changeset 1200 in Sophya for trunk/SophyaPI/PIext
- Timestamp:
- Sep 23, 2000, 2:02:00 AM (25 years ago)
- Location:
- trunk/SophyaPI/PIext
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PIext/piafitting.cc
r1111 r1200 42 42 class PIAFitterWind : public PIWindow { 43 43 public : 44 PIAFitterWind(PIStdImgApp* par, PIAFitter* fiter );44 PIAFitterWind(PIStdImgApp* par, PIAFitter* fiter,string func); 45 45 virtual ~PIAFitterWind(); 46 46 virtual void Show(); … … 50 50 PIStdImgApp* mDap; 51 51 PIAFitter* mFitter; 52 string mFunc; 52 53 PILabel** lab; int nlab; 53 54 PIText** txt; int ntxt; … … 56 57 PIOptMenu** pom; int npom; 57 58 bool ReFillGData; 59 bool ReDecodeFunc; 60 double ErrValue; 58 61 int saveI1,saveI2, saveJ1, saveJ2; 59 double ErrValue;62 double saveErrValue,saveXC,saveYC; 60 63 }; 61 64 … … 184 187 , mPar(1), mStep(1), mMin(1), mMax(1), mFix(1) 185 188 , mParSave(1), mStepSave(1), mMinSave(1), mMaxSave(1), mFixSave(1) 186 , mFit(NULL) 189 , mFit(NULL),ApplyXYcentering(false) 187 190 , mV(NULL), mH(NULL), mM(NULL), mH2(NULL), mIm(NULL), mG(NULL) 188 191 , mFunction(NULL), mFName(""), mFunc(NULL) … … 549 552 else if(mH2) mOpt.xc = (mH2->XMin()+mH2->XMax())/2.; 550 553 else if(mG) {double mini,maxi; mG->GetMnMx(2,mini,maxi); mOpt.xc=(mini+maxi)/2.;} 551 else if(mIm) {mOpt.xc = mIm->XOrg() *mIm->XPixSize()*(mOpt.i2-mOpt.i1+1)/2.;}554 else if(mIm) {mOpt.xc = mIm->XOrg() + mIm->XPixSize()*(mOpt.i2-mOpt.i1+1)/2.;} 552 555 } 553 556 if(mOpt.polcy==2 && mNVar>=2) { … … 555 558 if(mH2) mOpt.yc = (mH2->YMin()+mH2->YMax())/2.; 556 559 if(mG) {double mini,maxi; mG->GetMnMx(12,mini,maxi); mOpt.yc=(mini+maxi)/2.;} 557 if(mIm) {mOpt.yc = mIm->YOrg() *mIm->YPixSize()*(mOpt.j2-mOpt.j1+1)/2.;}560 if(mIm) {mOpt.yc = mIm->YOrg() + mIm->YPixSize()*(mOpt.j2-mOpt.j1+1)/2.;} 558 561 } 559 562 if(mOpt.err_e>0.) mOpt.err_E=-1.; … … 612 615 613 616 // Remplissage de generalfitdata 614 if(mFName[0]=='p') {x -= mOpt.xc; if(mNVar>=2) y -= mOpt.yc;} 617 if(ApplyXYcentering) { // pour fitlin 618 if(mOpt.polcx>0) x-=mOpt.xc; 619 if(mNVar>=2 && mOpt.polcy>0) y-=mOpt.yc; 620 } 615 621 if(mNVar==1) mGData->AddData1(x,f,e); 616 622 else if(mNVar==2) mGData->AddData2(x,y,f,e); … … 645 651 // Fonction a fitter 646 652 // ATTENTION: cette methode a besoin que les donnees soient lues 653 // (pour mopt.xc,yc et mNVar) 647 654 { 648 655 if(func.length()<=0) … … 660 667 int degre=0; if(func.length()>1) sscanf(func.c_str()+1,"%d",°re); 661 668 cout<<"Fit polynome 1D de degre "<<degre<<endl; 662 Polyn1D* myf = new Polyn1D(degre, mOpt.xc);669 Polyn1D* myf = new Polyn1D(degre,((mOpt.polcx>0)?mOpt.xc:0.)); 663 670 mFunction = myf; mNPar = mFunction->NPar(); mFName = func; 664 671 … … 667 674 cout<<"Fit d'exponentielle+polynome 1D de degre "<<degre<<endl; 668 675 Exp1DPol* myf; 669 if(degre>=0) myf = new Exp1DPol((unsigned int)degre, mOpt.xc);670 else myf = new Exp1DPol( mOpt.xc);676 if(degre>=0) myf = new Exp1DPol((unsigned int)degre,((mOpt.polcx>0)?mOpt.xc:0.)); 677 else myf = new Exp1DPol(((mOpt.polcx>0)?mOpt.xc:0.)); 671 678 mFunction = myf; mNPar = mFunction->NPar(); mFName = func; 672 679 … … 690 697 int degre=0; if(func.length()>1) sscanf(func.c_str()+1,"%d",°re); 691 698 cout<<"Fit polynome 2D de degre "<<degre<<endl; 692 Polyn2D* myf = new Polyn2D(degre,mOpt.xc,mOpt.yc); 699 Polyn2D* myf = 700 new Polyn2D(degre,((mOpt.polcx>0)?mOpt.xc:0.),((mOpt.polcy>0)?mOpt.yc:0.)); 693 701 mFunction = myf; mNPar = mFunction->NPar(); mFName = func; 694 702 … … 1165 1173 CheckOptions(); 1166 1174 if(mOpt.lp>0) PrintOptions(); 1175 if(kw == "fitlin") ApplyXYcentering=true; else ApplyXYcentering=false; 1167 1176 FillGData(); 1168 1177 DecodeFunction(tokens[1]); 1169 1178 DecodeParam(mSp,mSs,mSm,mSM,mSf); 1170 if 1179 if(kw == "fit") { 1171 1180 int rc = DoFit(); 1172 1181 if(rc>=0) FitFunRes(); 1173 } else if 1182 } else if(kw == "fitlin") { 1174 1183 LinFit(); 1175 } else if 1184 } else if(kw == "fitw") { 1176 1185 if(FWindFit!=NULL) {delete FWindFit; FWindFit=NULL;} 1177 FWindFit = new PIAFitterWind(mApp,this );1186 FWindFit = new PIAFitterWind(mApp,this,tokens[1]); 1178 1187 FWindFit->Show(); 1179 1188 } … … 1293 1302 1294 1303 /* --Methode-- */ 1295 PIAFitterWind::PIAFitterWind(PIStdImgApp* par, PIAFitter* fiter )1304 PIAFitterWind::PIAFitterWind(PIStdImgApp* par, PIAFitter* fiter,string func) 1296 1305 : PIWindow((PIMsgHandler*)par, "PIAFitter", PIWK_normal, 240, 240, 150, 150) 1297 , mDap(par), mFitter(fiter), ReFillGData(false) 1298 , saveI1(0), saveI2(0), saveJ1(0), saveJ2(0), ErrValue(1.) 1306 , mDap(par), mFitter(fiter), mFunc(func) 1307 , ReFillGData(false), ReDecodeFunc(false) 1308 , ErrValue(1.) 1309 , saveI1(0), saveI2(0), saveJ1(0), saveJ2(0) 1310 , saveErrValue(1.), saveXC(0.), saveYC(0.) 1299 1311 { 1300 1312 #ifdef SANS_EVOLPLANCK … … 1571 1583 if(mFitter->mOpt.err_e>0. ) mFitter->mOpt.err_e = ErrValue; 1572 1584 if(mFitter->mOpt.err_E>0. ) mFitter->mOpt.err_E = ErrValue; 1585 if(saveErrValue!=ErrValue) { 1586 if(lp) cout<<"ErrValue changed: "<<ErrValue<<endl; 1587 ReFillGData = true; 1588 saveErrValue = ErrValue; 1589 } 1573 1590 dum=txt[1]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' '); 1574 1591 sscanf(str,"%d,%d",&(mFitter->mOpt.lp),&(mFitter->mOpt.lpg)); … … 1602 1619 dum=txt[9]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' '); 1603 1620 sscanf(str,"%lf",&(mFitter->mOpt.yc)); 1621 if(saveXC!=mFitter->mOpt.xc || saveYC!=mFitter->mOpt.yc) { 1622 if(lp) cout<<"mOpt.xc,yc changed: "<<mFitter->mOpt.xc 1623 <<" , "<<mFitter->mOpt.xc<<endl; 1624 ReFillGData = true; ReDecodeFunc = true; 1625 saveXC = mFitter->mOpt.xc; saveYC = mFitter->mOpt.yc; 1626 } 1604 1627 1605 1628 if(npar>0) { … … 1640 1663 if(lp) cout<<"Do the fit"<<endl; 1641 1664 mFitter->CheckOptions(); 1642 if(ReFillGData) mFitter->FillGData(); 1665 if(ReFillGData) { 1666 if(lp) cout<<"ReFill Data"<<endl; 1667 mFitter->FillGData(); 1668 } 1643 1669 ReFillGData = false; 1670 if(ReDecodeFunc) mFitter->DecodeFunction(mFunc); 1671 ReDecodeFunc = false; 1644 1672 int rc = mFitter->DoFit(); 1645 1673 if(rc>=0) mFitter->FitFunRes(); … … 1680 1708 if(lp) cout<<"Centrage X polcx="<<mFitter->mOpt.polcx 1681 1709 <<" xc="<<mFitter->mOpt.xc<<endl; 1682 ReFillGData = true; 1710 ReFillGData = true; ReDecodeFunc = true; 1683 1711 } 1684 1712 else if(2011<=msg && msg<=2013) { … … 1686 1714 if(lp) cout<<"Centrage Y polcy="<<mFitter->mOpt.polcy 1687 1715 <<" yc="<<mFitter->mOpt.yc<<endl; 1688 ReFillGData = true; 1716 ReFillGData = true; ReDecodeFunc = true; 1689 1717 } 1690 1718 else if(msg>=1500 && msg<2000) { -
trunk/SophyaPI/PIext/piafitting.h
r1105 r1200 98 98 DFOPTIONS mOpt; 99 99 DFOPTIONS mOptSave; 100 bool ApplyXYcentering; 100 101 // Possibles objets a fitter 101 102 Vector* mV; Histo* mH; // Do not delete
Note:
See TracChangeset
for help on using the changeset viewer.