Changeset 1207 in Sophya for trunk/SophyaPI/PIext
- Timestamp:
- Sep 29, 2000, 4:26:15 PM (25 years ago)
- Location:
- trunk/SophyaPI/PIext
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PIext/nobjmgr.cc
r1199 r1207 89 89 static string* TmpDir; // Repertoire pour les compilations / link dynamique 90 90 91 92 // Pour completer le nom de l'objet avec le nom du repertoire93 static void RemoveSpacesFromName(string & nom);94 static bool CheckDirName(string & nom);95 static int ParseObjectName(string & nom, string & nomrep, string & nomobj);96 91 // .................................................................. 97 92 … … 1352 1347 1353 1348 /* Nouvelle-Fonction */ 1354 void RemoveSpacesFromName(string & nom)1349 void NamedObjMgr::RemoveSpacesFromName(string & nom) 1355 1350 { 1356 1351 // on supprime les blancs de debut et de fin … … 1364 1359 1365 1360 /* Nouvelle-Fonction */ 1366 bool CheckDirName(string & nom)1361 bool NamedObjMgr::CheckDirName(string & nom) 1367 1362 { 1368 1363 RemoveSpacesFromName(nom); … … 1376 1371 1377 1372 /* Nouvelle-Fonction */ 1378 int ParseObjectName(string & nom, string & nomrep, string & nomobj)1373 int NamedObjMgr::ParseObjectName(string & nom, string & nomrep, string & nomobj) 1379 1374 { 1380 1375 RemoveSpacesFromName(nom); -
trunk/SophyaPI/PIext/nobjmgr.h
r1165 r1207 100 100 // Pour utilisation par ObjMgrWind 101 101 virtual void UpdateObjMgrWindow(int did); 102 103 // Pour completer le nom de l'objet avec le nom du repertoire 104 static void RemoveSpacesFromName(string & nom); 105 static bool CheckDirName(string & nom); 106 static int ParseObjectName(string & nom, string & nomrep, string & nomobj); 102 107 }; 103 108 -
trunk/SophyaPI/PIext/nomgadapter.cc
r1165 r1207 117 117 } 118 118 119 /* --Methode-- */ 120 GeneralFitData* NObjMgrAdapter::GetGeneralFitData(bool& adel 121 ,GeneralFitData::FitErrType errtype 122 ,double errscale,double errmin,int i1,int i2,int j1,int j2) 123 { 124 string s = typeid(*mObj).name(); 125 cout << "NObjMgrAdapter::GetGeneralFitData() - Error : Not supported for "<<s<<endl; 126 adel = false; 127 return(NULL); 128 } 129 130 AnyDataObj* NObjMgrAdapter::FitResidusObj(GeneralFit& mfit) 131 { 132 string s = typeid(*mObj).name(); 133 cout << "NObjMgrAdapter::FitResidusObj() - Error : Not supported for "<<s<<endl; 134 return(NULL); 135 } 119 136 120 137 121 122 123 138 AnyDataObj* NObjMgrAdapter::FitFunctionObj(GeneralFit& mfit) 139 { 140 string s = typeid(*mObj).name(); 141 cout << "NObjMgrAdapter::FitFunctionObj() - Error : Not supported for "<<s<<endl; 142 return(NULL); 143 } -
trunk/SophyaPI/PIext/nomgadapter.h
r1165 r1207 13 13 #include "parradapter.h" 14 14 #include "ntupintf.h" 15 #include "generalfit.h" 15 16 16 17 … … 54 55 // si adel == true, le programme appelant doit faire delete de nti 55 56 virtual NTupleInterface* GetNTupleInterface(bool& adel); 57 58 // Methode pour l'interface GeneralFit. 59 // Si adel==true: 60 // le programme appelant doit faire delete du GeneralFitData retourne 61 virtual GeneralFitData* GetGeneralFitData(bool& adel 62 ,GeneralFitData::FitErrType errtype=GeneralFitData::DefaultError 63 ,double errscale=1.,double errmin=0. 64 ,int i1=0,int i2=-1,int j1=0,int j2=-1); 65 virtual AnyDataObj* FitResidusObj(GeneralFit& mfit); 66 virtual AnyDataObj* FitFunctionObj(GeneralFit& mfit); 67 56 68 protected: 57 69 AnyDataObj* mObj; -
trunk/SophyaPI/PIext/nomgfdadapter.cc
r1165 r1207 7 7 #include "nomgfdadapter.h" 8 8 #include "pipodrw.h" 9 10 #ifndef SANS_EVOLPLANCK 11 #include "objfitter.h" 12 #endif 9 13 10 14 //------------------------------------------------------------------------- … … 70 74 } 71 75 76 /* --Methode-- */ 77 GeneralFitData* NOMAdapter_GeneralFitData::GetGeneralFitData(bool& adel 78 ,GeneralFitData::FitErrType errtype,double errscale,double errmin 79 ,int i1,int i2,int j1,int j2) 80 { 81 adel = false; 82 if(!mG) return(NULL); 83 84 int n = mG->NData(); 85 if(n<=0) return(NULL); 86 int nv = mG->NVar(); 87 if(nv<=0) return(NULL); 88 89 i1 = (i1<0||i1>=n)? 0: i1; 90 i2 = (i2<0||i2>=n||i2<i1)? n-1: i2; 91 n = i2-i1+1; 92 93 // Pas de gestion des erreurs sur les Abscisses Xi 94 GeneralFitData* mGData = new GeneralFitData(nv,n,0); 95 adel = true; 96 97 double *x = new double[nv]; 98 for(int i=i1;i<=i2;i++) { 99 for(int j=0;j<nv;j++) x[j] = mG->Absc(j,i); 100 double f = mG->Val(i); 101 double e = mG->EVal(i); 102 e = GeneralFitData::ComputeError(f,e,errtype,errscale,errmin); 103 mGData->AddData(x,f,e); 104 if(!mG->IsValid(i)) mGData->KillData(i); 105 } 106 delete [] x; 107 108 return mGData; 109 } 110 111 AnyDataObj* NOMAdapter_GeneralFitData::FitResidusObj(GeneralFit& mfit) 112 { 113 GeneralFitData* g = NULL; 114 #ifdef SANS_EVOLPLANCK 115 g = mG->FitResidus(mfit); 116 #else 117 g = new GeneralFitData(ObjectFitter::FitResidus(*mG,mfit)); 118 #endif 119 return g; 120 } 121 122 AnyDataObj* NOMAdapter_GeneralFitData::FitFunctionObj(GeneralFit& mfit) 123 { 124 GeneralFitData* g = NULL; 125 #ifdef SANS_EVOLPLANCK 126 g = mG->FitFunction(mfit); 127 #else 128 g = new GeneralFitData(ObjectFitter::FitFunction(*mG,mfit)); 129 #endif 130 return g; 131 } -
trunk/SophyaPI/PIext/nomgfdadapter.h
r1165 r1207 8 8 9 9 #include "nomgadapter.h" 10 #include "general data.h"10 #include "generalfit.h" 11 11 12 12 //------------------------------------------------------------------------- … … 30 30 virtual NTupleInterface* GetNTupleInterface(bool& adel); 31 31 32 virtual GeneralFitData* GetGeneralFitData(bool& adel 33 ,GeneralFitData::FitErrType errtype=GeneralFitData::DefaultError 34 ,double errscale=1.,double errmin=0. 35 ,int i1=0,int i2=-1,int j1=0,int j2=-1); 36 virtual AnyDataObj* FitResidusObj(GeneralFit& mfit); 37 virtual AnyDataObj* FitFunctionObj(GeneralFit& mfit); 38 32 39 protected: 33 40 GeneralFitData* mG; -
trunk/SophyaPI/PIext/nomhistadapter.cc
r1165 r1207 11 11 #include "servnobjm.h" 12 12 13 #ifndef SANS_EVOLPLANCK 14 #include "objfitter.h" 15 #endif 16 13 17 //------------------------------------------------------------------------- 14 18 // Class Adaptateur d'objet (Pour NamedObjMgr) d'objet Histo / HProf … … 88 92 } 89 93 94 /* --Methode-- */ 95 GeneralFitData* NOMAdapter_Histo::GetGeneralFitData(bool& adel 96 ,GeneralFitData::FitErrType errtype,double errscale,double errmin 97 ,int i1,int i2,int j1,int j2) 98 { 99 adel = false; 100 if(!mHis) return(NULL); 101 102 int nx = mHis->NBins(); 103 if(nx<=0) return(NULL); 104 105 i1 = (i1<0||i1>=nx)? 0: i1; 106 i2 = (i2<0||i2>=nx||i2<i1)? nx-1: i2; 107 108 GeneralFitData* mGData = new GeneralFitData(1,i2-i1+1,0); 109 adel = true; 110 111 for(int i=i1;i<=i2;i++) { 112 double x = mHis->BinCenter(i); 113 double f = (*mHis)(i); 114 double e = (mHis->HasErrors())? mHis->Error(i) : 1.; 115 e = GeneralFitData::ComputeError(f,e,errtype,errscale,errmin); 116 mGData->AddData1(x,f,e); 117 } 118 119 return mGData; 120 } 121 122 AnyDataObj* NOMAdapter_Histo::FitResidusObj(GeneralFit& mfit) 123 { 124 Histo* h = NULL; 125 #ifdef SANS_EVOLPLANCK 126 h = mHis->FitResidus(mfit); 127 #else 128 h = new Histo(ObjectFitter::FitResidus(*mHis,mfit)); 129 #endif 130 return h; 131 } 132 133 AnyDataObj* NOMAdapter_Histo::FitFunctionObj(GeneralFit& mfit) 134 { 135 Histo* h = NULL; 136 #ifdef SANS_EVOLPLANCK 137 h = mHis->FitFunction(mfit); 138 #else 139 h = new Histo(ObjectFitter::FitFunction(*mHis,mfit)); 140 #endif 141 return h; 142 } 90 143 91 144 // ------------------------------------------------------------- … … 215 268 } 216 269 270 271 /* --Methode-- */ 272 GeneralFitData* NOMAdapter_Histo2D::GetGeneralFitData(bool& adel 273 ,GeneralFitData::FitErrType errtype,double errscale,double errmin 274 ,int i1,int i2,int j1,int j2) 275 { 276 adel = false; 277 if(!mHis) return(NULL); 278 279 int nx = mHis->NBinX(); 280 int ny = mHis->NBinY(); 281 if(nx<=0 || ny<=0) return(NULL); 282 283 i1 = (i1<0||i1>=nx)? 0: i1; 284 i2 = (i2<0||i2>=nx||i2<i1)? nx-1: i2; 285 j1 = (j1<0||j1>=ny)? 0: j1; 286 j2 = (j2<0||j2>=ny||j2<j1)? ny-1: j2; 287 288 GeneralFitData* mGData = new GeneralFitData(2,(i2-i1+1)*(j2-j1+1),0); 289 adel = true; 290 291 for(int i=i1;i<=i2;i++) for(int j=j1;j<=j2;j++) { 292 double x,y; mHis->BinCenter(i,j,x,y); 293 double f = (*mHis)(i,j); 294 double e = (mHis->HasErrors())? mHis->Error(i,j) : 1.; 295 e = GeneralFitData::ComputeError(f,e,errtype,errscale,errmin); 296 mGData->AddData2(x,y,f,e); 297 } 298 299 return mGData; 300 } 301 302 AnyDataObj* NOMAdapter_Histo2D::FitResidusObj(GeneralFit& mfit) 303 { 304 Histo2D* h2 = NULL; 305 #ifdef SANS_EVOLPLANCK 306 h2 = mHis->FitFunction(mfit); 307 #else 308 h2 = new Histo2D(ObjectFitter::FitResidus(*mHis,mfit)); 309 #endif 310 return h2; 311 } 312 313 AnyDataObj* NOMAdapter_Histo2D::FitFunctionObj(GeneralFit& mfit) 314 { 315 Histo2D* h2 = NULL; 316 #ifdef SANS_EVOLPLANCK 317 h2 = mHis->FitFunction(mfit); 318 #else 319 h2 = new Histo2D(ObjectFitter::FitFunction(*mHis,mfit)); 320 #endif 321 return h2; 322 } 217 323 218 324 … … 403 509 return(mNt); 404 510 } 405 406 -
trunk/SophyaPI/PIext/nomhistadapter.h
r1165 r1207 12 12 #include "hisprof.h" 13 13 #include "ntuple.h" 14 15 14 #include "xntuple.h" 16 15 … … 37 36 virtual PIDrawer* GetDrawer(string& dopt); 38 37 virtual NTupleInterface* GetNTupleInterface(bool& adel); 38 39 virtual GeneralFitData* GetGeneralFitData(bool& adel 40 ,GeneralFitData::FitErrType errtype=GeneralFitData::DefaultError 41 ,double errscale=1.,double errmin=0. 42 ,int i1=0,int i2=-1,int j1=0,int j2=-1); 43 virtual AnyDataObj* FitResidusObj(GeneralFit& mfit); 44 virtual AnyDataObj* FitFunctionObj(GeneralFit& mfit); 39 45 40 46 protected: … … 79 85 virtual P2DArrayAdapter* Get2DArray(string& dopt); 80 86 virtual NTupleInterface* GetNTupleInterface(bool& adel); 87 88 virtual GeneralFitData* GetGeneralFitData(bool& adel 89 ,GeneralFitData::FitErrType errtype=GeneralFitData::DefaultError 90 ,double errscale=1.,double errmin=0. 91 ,int i1=0,int i2=-1,int j1=0,int j2=-1); 92 virtual AnyDataObj* FitResidusObj(GeneralFit& mfit); 93 virtual AnyDataObj* FitFunctionObj(GeneralFit& mfit); 81 94 82 95 protected: -
trunk/SophyaPI/PIext/nomimagadapter.cc
r1199 r1207 6 6 7 7 #include "nomimagadapter.h" 8 #include "pimgadapter.h" 9 8 10 #ifdef SANS_EVOLPLANCK 9 11 #include "fitsimage.h" 10 #endif 11 #include "pimgadapter.h" 12 #else 13 #include "objfitter.h" 14 #endif 15 12 16 13 17 … … 103 107 } 104 108 109 /* --Methode-- */ 110 template <class T> 111 GeneralFitData* NOMAdapter_Image<T>::GetGeneralFitData(bool& adel 112 ,GeneralFitData::FitErrType errtype,double errscale,double errmin 113 ,int i1,int i2,int j1,int j2) 114 { 115 adel = false; 116 if(!mImg) return(NULL); 117 118 int nx = mImg->XSize(); 119 int ny = mImg->YSize(); 120 if(nx<=0 || ny<=0) return(NULL); 121 122 i1 = (i1<0||i1>=nx)? 0: i1; 123 i2 = (i2<0||i2>=nx||i2<i1)? nx-1: i2; 124 j1 = (j1<0||j1>=ny)? 0: j1; 125 j2 = (j2<0||j2>=ny||j2<j1)? ny-1: j2; 126 127 GeneralFitData* mGData = new GeneralFitData(2,(i2-i1+1)*(j2-j1+1),0); 128 adel = true; 129 130 for(int i=i1;i<=i2;i++) for(int j=j1;j<=j2;j++) { 131 double x = mImg->XPos(i); 132 double y = mImg->YPos(j); 133 double f = (*mImg)(i,j); 134 double e = 1.; 135 e = GeneralFitData::ComputeError(f,e,errtype,errscale,errmin); 136 mGData->AddData2(x,y,f,e); 137 } 138 139 return mGData; 140 } 141 142 template <class T> 143 AnyDataObj* NOMAdapter_Image<T>::FitResidusObj(GeneralFit& mfit) 144 { 145 #ifdef SANS_EVOLPLANCK 146 RzImage* rzim = mImg->FitResidus(mfit); 147 ImageR4* im = new ImageR4(*rzim); 148 return im; 149 #else 150 Image<T>* im = new Image<T>(ObjectFitter::FitResidus(*mImg,mfit)); 151 return im; 152 #endif 153 } 154 155 template <class T> 156 AnyDataObj* NOMAdapter_Image<T>::FitFunctionObj(GeneralFit& mfit) 157 { 158 #ifdef SANS_EVOLPLANCK 159 RzImage* rzim = mImg->FitFunction(mfit); 160 ImageR4* im = new ImageR4(*rzim); 161 return im; 162 #else 163 Image<T>* im = NULL; 164 //im = new Image<T>(ObjectFitter::FitFunction(*mImg,mfit)); 165 return im; 166 #endif 167 } 105 168 106 169 -
trunk/SophyaPI/PIext/nomimagadapter.h
r1199 r1207 9 9 #include "nomgadapter.h" 10 10 #include "cimage.h" 11 #include "generalfit.h" 11 12 12 13 … … 33 34 virtual NTupleInterface* GetNTupleInterface(bool& adel); 34 35 36 virtual GeneralFitData* GetGeneralFitData(bool& adel 37 ,GeneralFitData::FitErrType errtype=GeneralFitData::DefaultError 38 ,double errscale=1.,double errmin=1. 39 ,int i1=0,int i2=-1,int j1=0,int j2=-1); 40 virtual AnyDataObj* FitResidusObj(GeneralFit& mfit); 41 virtual AnyDataObj* FitFunctionObj(GeneralFit& mfit); 42 35 43 protected: 36 44 Image<T> * mImg; -
trunk/SophyaPI/PIext/nommatvecadapter.cc
r1165 r1207 80 80 81 81 82 /* --Methode-- */ 83 GeneralFitData* NOMAdapter_Vector::GetGeneralFitData(bool& adel 84 ,GeneralFitData::FitErrType errtype,double errscale,double errmin 85 ,int i1,int i2,int j1,int j2) 86 { 87 adel = false; 88 if(!mVec) return(NULL); 89 90 int n = mVec->NElts(); 91 if(n<=0) return(NULL); 92 93 i1 = (i1<0||i1>=n)? 0: i1; 94 i2 = (i2<0||i2>=n||i2<i1)? n-1: i2; 95 96 GeneralFitData* mGData = new GeneralFitData(1,i2-i1+1,0); 97 adel = true; 98 99 for(int i=i1;i<=i2;i++) { 100 double x = (double) i; 101 double f = (*mVec)(i); 102 double e = 1.; 103 e = GeneralFitData::ComputeError(f,e,errtype,errscale,errmin); 104 mGData->AddData1(x,f,e); 105 } 106 107 return mGData; 108 } 109 110 AnyDataObj* NOMAdapter_Vector::FitResidusObj(GeneralFit& mfit) 111 { 112 Vector* v = NULL; 113 v = mVec->FitResidus(mfit); 114 return v; 115 } 116 117 AnyDataObj* NOMAdapter_Vector::FitFunctionObj(GeneralFit& mfit) 118 { 119 Vector* v = NULL; 120 v = mVec->FitFunction(mfit); 121 return v; 122 } 123 82 124 // ------------------------------------------------------------- 83 125 … … 199 241 } 200 242 201 243 /* --Methode-- */ 244 GeneralFitData* NOMAdapter_Matrix::GetGeneralFitData(bool& adel 245 ,GeneralFitData::FitErrType errtype,double errscale,double errmin 246 ,int i1,int i2,int j1,int j2) 247 { 248 adel = false; 249 if(!mMtx) return(NULL); 250 251 int nx = mMtx->NRows(); 252 int ny = mMtx->NCol(); 253 if(nx<=0 || ny<=0) return(NULL); 254 255 i1 = (i1<0||i1>=nx)? 0: i1; 256 i2 = (i2<0||i2>=nx||i2<i1)? nx-1: i2; 257 j1 = (j1<0||j1>=ny)? 0: j1; 258 j2 = (j2<0||j2>=ny||j2<j1)? ny-1: j2; 259 260 GeneralFitData* mGData = new GeneralFitData(2,(i2-i1+1)*(j2-j1+1),0); 261 adel = true; 262 263 for(int i=i1;i<=i2;i++) for(int j=j1;j<=j2;j++) { 264 double x = (double) i; 265 double y = (double) j; 266 double f = (*mMtx)(i,j); 267 double e = 1.; 268 e = GeneralFitData::ComputeError(f,e,errtype,errscale,errmin); 269 mGData->AddData2(x,y,f,e); 270 } 271 272 return mGData; 273 } 274 275 AnyDataObj* NOMAdapter_Matrix::FitResidusObj(GeneralFit& mfit) 276 { 277 Matrix* m = NULL; 278 m = mMtx->FitResidus(mfit); 279 return m; 280 } 281 282 AnyDataObj* NOMAdapter_Matrix::FitFunctionObj(GeneralFit& mfit) 283 { 284 Matrix* m = NULL; 285 m = mMtx->FitFunction(mfit); 286 return m; 287 } 202 288 203 289 // ------------------------------------------------------------- -
trunk/SophyaPI/PIext/nommatvecadapter.h
r1165 r1207 8 8 9 9 #include "nomgadapter.h" 10 #include "generalfit.h" 10 11 11 12 #ifdef SANS_EVOLPLANCK … … 39 40 virtual PIDrawer* GetDrawer(string& dopt); 40 41 virtual NTupleInterface* GetNTupleInterface(bool& adel); 42 43 virtual GeneralFitData* GetGeneralFitData(bool& adel 44 ,GeneralFitData::FitErrType errtype=GeneralFitData::DefaultError 45 ,double errscale=1.,double errmin=0. 46 ,int i1=0,int i2=-1,int j1=0,int j2=-1); 47 virtual AnyDataObj* FitResidusObj(GeneralFit& mfit); 48 virtual AnyDataObj* FitFunctionObj(GeneralFit& mfit); 41 49 42 50 protected: … … 83 91 virtual NTupleInterface* GetNTupleInterface(bool& adel); 84 92 93 virtual GeneralFitData* GetGeneralFitData(bool& adel 94 ,GeneralFitData::FitErrType errtype=GeneralFitData::DefaultError 95 ,double errscale=1.,double errmin=0. 96 ,int i1=0,int i2=-1,int j1=0,int j2=-1); 97 virtual AnyDataObj* FitResidusObj(GeneralFit& mfit); 98 virtual AnyDataObj* FitFunctionObj(GeneralFit& mfit); 99 85 100 protected: 86 101 Matrix* mMtx; -
trunk/SophyaPI/PIext/nomtmatvecadapter.cc
r1165 r1207 7 7 8 8 #include "tvector.h" 9 #include "objfitter.h" 9 10 #include "nomtmatvecadapter.h" 10 11 #include "piscdrawwdg.h" … … 119 120 } 120 121 122 123 /* --Methode-- */ 124 template <class T> 125 GeneralFitData* NOMAdapter_TMatrix<T>::GetGeneralFitData(bool& adel 126 ,GeneralFitData::FitErrType errtype,double errscale,double errmin 127 ,int i1,int i2,int j1,int j2) 128 { 129 adel = false; 130 if(!mMtx) return(NULL); 131 132 int nx,ny; 133 TVector<T>* vec = dynamic_cast<TVector<T> *>(mMtx); 134 135 if(vec) { // C'est un TVector 136 nx = vec->NElts(); 137 ny = 1; 138 } else { 139 nx = mMtx->NRows(); 140 ny = mMtx->NCol(); 141 if(nx<=0 || ny<=0) return(NULL); 142 } 143 144 i1 = (i1<0||i1>=nx)? 0: i1; 145 i2 = (i2<0||i2>=nx||i2<i1)? nx-1: i2; 146 j1 = (j1<0||j1>=ny)? 0: j1; 147 j2 = (j2<0||j2>=ny||j2<j1)? ny-1: j2; 148 149 GeneralFitData* mGData = NULL; 150 151 if(vec) { // C'est un TVector 152 mGData = new GeneralFitData(1,(i2-i1+1),0); 153 adel = true; 154 for(int i=i1;i<=i2;i++) { 155 double x = (double) i; 156 double f = (*vec)(i); 157 double e = 1.; 158 e = GeneralFitData::ComputeError(f,e,errtype,errscale,errmin); 159 mGData->AddData1(x,f,e); 160 } 161 } else { 162 mGData = new GeneralFitData(2,(i2-i1+1)*(j2-j1+1),0); 163 adel = true; 164 for(int i=i1;i<=i2;i++) for(int j=j1;j<=j2;j++) { 165 double x = (double) i; 166 double y = (double) j; 167 double f = (*mMtx)(i,j); 168 double e = 1.; 169 e = GeneralFitData::ComputeError(f,e,errtype,errscale,errmin); 170 mGData->AddData2(x,y,f,e); 171 } 172 } 173 174 return mGData; 175 } 176 177 template <class T> 178 AnyDataObj* NOMAdapter_TMatrix<T>::FitResidusObj(GeneralFit& mfit) 179 { 180 TVector<T>* vec = dynamic_cast<TVector<T> *>(mMtx); 181 if(vec) { 182 TVector<T>* v = new TVector<T>(ObjectFitter::FitResidus(*vec,mfit),true); 183 return v; 184 } else { 185 TMatrix<T>* m = new TMatrix<T>(ObjectFitter::FitResidus(*mMtx,mfit),true); 186 return m; 187 } 188 } 189 190 template <class T> 191 AnyDataObj* NOMAdapter_TMatrix<T>::FitFunctionObj(GeneralFit& mfit) 192 { 193 TVector<T>* vec = dynamic_cast<TVector<T> *>(mMtx); 194 if(vec) { 195 TVector<T>* v = new TVector<T>(ObjectFitter::FitFunction(*vec,mfit),true); 196 return v; 197 } else { 198 TMatrix<T>* m = new TMatrix<T>(ObjectFitter::FitFunction(*mMtx,mfit),true); 199 return m; 200 } 201 } 121 202 122 203 … … 226 307 #pragma define_template NOMAdapter_TMatrix<r_4> 227 308 #pragma define_template NOMAdapter_TMatrix<r_8> 228 #pragma define_template NOMAdapter_TMatrix< complex<r_4> >229 #pragma define_template NOMAdapter_TMatrix< complex<r_8> >309 //#pragma define_template NOMAdapter_TMatrix< complex<r_4> > 310 //#pragma define_template NOMAdapter_TMatrix< complex<r_8> > 230 311 //#pragma define_template NTupInt_TMatrix<uint_2> 231 312 //#pragma define_template NTupInt_TMatrix<int_2> … … 243 324 template class NOMAdapter_TMatrix<r_4>; 244 325 template class NOMAdapter_TMatrix<r_8>; 245 template class NOMAdapter_TMatrix< complex<r_4> >;246 template class NOMAdapter_TMatrix< complex<r_8> >;326 //template class NOMAdapter_TMatrix< complex<r_4> >; 327 //template class NOMAdapter_TMatrix< complex<r_8> >; 247 328 // template class NTupInt_TMatrix<uint_2>; 248 329 // template class NTupInt_TMatrix<int_2>; -
trunk/SophyaPI/PIext/nomtmatvecadapter.h
r1165 r1207 10 10 #include "nomgadapter.h" 11 11 #include "tmatrix.h" 12 #include "generaldata.h" 12 13 13 14 //--------------------------------------------------------------- … … 36 37 virtual NTupleInterface* GetNTupleInterface(bool& adel); 37 38 39 virtual GeneralFitData* GetGeneralFitData(bool& adel 40 ,GeneralFitData::FitErrType errtype=GeneralFitData::DefaultError 41 ,double errscale=1.,double errmin=0. 42 ,int i1=0,int i2=-1,int j1=0,int j2=-1); 43 virtual AnyDataObj* FitResidusObj(GeneralFit& mfit); 44 virtual AnyDataObj* FitFunctionObj(GeneralFit& mfit); 45 38 46 protected: 39 47 TMatrix<T>* mMtx; -
trunk/SophyaPI/PIext/piafitting.cc
r1200 r1207 35 35 #include "piafitting.h" 36 36 #include "nobjmgr.h" 37 #include "anydataobj.h" 37 38 #include "pistdimgapp.h" 39 40 #include "nomhistadapter.h" 41 #include "nomgfdadapter.h" 42 #include "nomimagadapter.h" 43 #ifdef SANS_EVOLPLANCK 44 #include "nommatvecadapter.h" 45 #else 46 #include "nomtmatvecadapter.h" 47 #endif 38 48 39 49 //////////////////////////////////////////////////////////////////// … … 56 66 PICheckBox** ckb; int nckb; 57 67 PIOptMenu** pom; int npom; 58 bool ReFillGData; 59 bool ReDecodeFunc; 60 double ErrValue; 68 bool ReFillGData,ReDecodeFunc; 61 69 int saveI1,saveI2, saveJ1, saveJ2; 62 double saveErr Value,saveXC,saveYC;70 double saveErrScale,saveErrMin,saveXC,saveYC; 63 71 }; 64 72 … … 72 80 //| --------------- Fit Lineaire a 1 et 2 dimensions --------------- 73 81 //| Syntaxe: 74 //| fitlin nom pnn [o:.aa,bb,cc, o ;dd,ee,ff o:gg,hh,jj,kk etc...]82 //| fitlin nom pnn [o:.aa,bb,cc, o:dd,ee,ff o:gg,hh,jj,kk etc...] 75 83 //| avec: 76 84 //| nom : cf commentaire ordre ''fit'' … … 84 92 //| fitw nom func 85 93 //| [p:p1,p2,...,pn s:s1,s2,...,sn m:m1,m2,...,mn M:M1,mM2,...,Mn f:f1,...,fn] 86 //| [o:.aa,bb,cc, o ;dd,ee,ff o:gg,hh,jj,kk etc...]94 //| [o:.aa,bb,cc, o:dd,ee,ff o:gg,hh,jj,kk etc...] 87 95 //| cf commentaire ordre ''fit'' 88 96 //| … … 92 100 //| fit nom func 93 101 //| [p:p1,p2,...,pn s:s1,s2,...,sn m:m1,m2,...,mn M:M1,mM2,...,Mn f:f1,...,fn] 94 //| [o:.aa,bb,cc, o ;dd,ee,ff o:gg,hh,jj,kk etc...]102 //| [o:.aa,bb,cc, o:dd,ee,ff o:gg,hh,jj,kk etc...] 95 103 //|----- OBJET ----- 96 104 //| nom : nom de l'objet qui peut etre: … … 139 147 //| Ii1/i2 : numeros des bins X de l'histos utilises pour le fit [i1,i2] 140 148 //|2D Jj1/j2 : numeros des bins Y de l'histos utilises pour le fit [j1,j2] 141 //| - L'erreur est celle associee a l'objet (si elle existe), 142 //| elle est mise a 1 sinon, sauf si E... ou e... est precise: 143 //| Eaa.b : si |val|>=1 erreur = aa.b*sqrt(|val|) 144 //| si |val|<1 erreur = aa.b 145 //| si aa.b <=0 alors aa.b=1.0 146 //| E seul est equivalent a E1.0 147 //| eaa.b : erreur = aa.b 148 //| si aa.b <=0 alors aa.b=1.0 149 //| e seul est equivalent a e1.0 149 //| - Traitement des erreurs : 150 //| Par defaut, l'erreur est celle associee a l'objet (si elle existe), 151 //| elle est mise a 1 sinon. 152 //| haa.b/cc.d : erreur = aa.bb*(erreur associee a l'objet cf ci-dessus) 153 //| Haa.b/cc.d : erreur = aa.b*|val| 154 //| eaa.b/cc.d : erreur = aa.b 155 //| Eaa.b/cc.d : erreur = aa.b*sqrt(|val|) 156 //| aa.b<0 (ou non precise) est equivalent aa.b=1.0 157 //| cc.d non precise est equivalent a cc.d=0 158 //| si cc.d>=0 si erreur>0 erreur = max(erreur,cc.d) 159 //| si erreur<=0 alors erreur 160 //| si cc.d<0 si erreur>0 erreur = max(erreur,|cc.d|) 161 //| si erreur<=0 alors erreur=|cc.d| 150 162 //| xaa.b : demande de centrage: on fit x-aa.b au lieu de x) 151 163 //| x : demande de centrage: on fit x-xc au lieu de x 152 //| avec xc=abscisse du milieu de l'histogramme164 //| avec xc=abscisse du ''milieu logique'' de l'objet. 153 165 //| Actif pour exp+poly 1D, poly 1D 154 166 //| Pour gauss+poly 1D, xc est le centre de la gaussienne. … … 183 195 PIAFitter::PIAFitter(PIACmd *piac, PIStdImgApp* app) 184 196 : mApp(app), FWindFit(NULL) 185 , mNObj(""), m Obj(NULL), mGData(NULL)186 , mNPar(0), mNVar(0), mNBinX(0), mNBinY(0),mNData(0)197 , mNObj(""), mAdObj(NULL), mGData(NULL), delmGData(false) 198 , mNPar(0), mNVar(0), mNData(0) 187 199 , mPar(1), mStep(1), mMin(1), mMax(1), mFix(1) 188 200 , mParSave(1), mStepSave(1), mMinSave(1), mMaxSave(1), mFixSave(1) 189 , mFit(NULL),ApplyXYcentering(false) 190 , mV(NULL), mH(NULL), mM(NULL), mH2(NULL), mIm(NULL), mG(NULL) 201 , mFit(NULL) 191 202 , mFunction(NULL), mFName(""), mFunc(NULL) 192 203 , mDlUFunc(NULL), mNameFitFunc(""), mFitFunc(NULL), mFitFuncDer(NULL) … … 207 218 usage+="\n| --------------- Fit Lineaire a 1 et 2 dimensions --------------- "; 208 219 usage+="\n| Syntaxe: "; 209 usage+="\n| fitlin nom pnn [o:.aa,bb,cc, o ;dd,ee,ff o:gg,hh,jj,kk etc...] ";220 usage+="\n| fitlin nom pnn [o:.aa,bb,cc, o:dd,ee,ff o:gg,hh,jj,kk etc...] "; 210 221 usage+="\n| avec: "; 211 222 usage+="\n| nom : cf commentaire ordre ''fit'' "; … … 219 230 usage+="\n| fitw nom func "; 220 231 usage+="\n| [p:p1,p2,...,pn s:s1,s2,...,sn m:m1,m2,...,mn M:M1,mM2,...,Mn f:f1,...,fn] "; 221 usage+="\n| [o:.aa,bb,cc, o ;dd,ee,ff o:gg,hh,jj,kk etc...] ";232 usage+="\n| [o:.aa,bb,cc, o:dd,ee,ff o:gg,hh,jj,kk etc...] "; 222 233 usage+="\n| cf commentaire ordre ''fit'' "; 223 234 usage+="\n| "; … … 227 238 usage+="\n| fit nom func "; 228 239 usage+="\n| [p:p1,p2,...,pn s:s1,s2,...,sn m:m1,m2,...,mn M:M1,mM2,...,Mn f:f1,...,fn] "; 229 usage+="\n| [o:.aa,bb,cc, o ;dd,ee,ff o:gg,hh,jj,kk etc...] ";240 usage+="\n| [o:.aa,bb,cc, o:dd,ee,ff o:gg,hh,jj,kk etc...] "; 230 241 usage+="\n|----- OBJET ----- "; 231 242 usage+="\n| nom : nom de l'objet qui peut etre: "; … … 274 285 usage+="\n| Ii1/i2 : numeros des bins X de l'histos utilises pour le fit [i1,i2] "; 275 286 usage+="\n|2D Jj1/j2 : numeros des bins Y de l'histos utilises pour le fit [j1,j2] "; 276 usage+="\n| - L'erreur est celle associee a l'objet (si elle existe), "; 277 usage+="\n| elle est mise a 1 sinon, sauf si E... ou e... est precise: "; 278 usage+="\n| Eaa.b : si |val|>=1 erreur = aa.b*sqrt(|val|) "; 279 usage+="\n| si |val|<1 erreur = aa.b "; 280 usage+="\n| si aa.b <=0 alors aa.b=1.0 "; 281 usage+="\n| E seul est equivalent a E1.0 "; 282 usage+="\n| eaa.b : erreur = aa.b "; 283 usage+="\n| si aa.b <=0 alors aa.b=1.0 "; 284 usage+="\n| e seul est equivalent a e1.0 "; 287 usage+="\n| - Traitement des erreurs : "; 288 usage+="\n| Par defaut, l'erreur est celle associee a l'objet (si elle existe), "; 289 usage+="\n| elle est mise a 1 sinon. "; 290 usage+="\n| haa.b/cc.d : erreur = aa.bb*(erreur associee a l'objet cf ci-dessus) "; 291 usage+="\n| Haa.b/cc.d : erreur = aa.b*|val| "; 292 usage+="\n| eaa.b/cc.d : erreur = aa.b "; 293 usage+="\n| Eaa.b/cc.d : erreur = aa.b*sqrt(|val|) "; 294 usage+="\n| aa.b<0 (ou non precise) est equivalent aa.b=1.0 "; 295 usage+="\n| cc.d non precise est equivalent a cc.d=0 "; 296 usage+="\n| si cc.d>=0 si erreur>0 erreur = max(erreur,cc.d) "; 297 usage+="\n| si erreur<=0 alors erreur "; 298 usage+="\n| si cc.d<0 si erreur>0 erreur = max(erreur,|cc.d|) "; 299 usage+="\n| si erreur<=0 alors erreur=|cc.d| "; 285 300 usage+="\n| xaa.b : demande de centrage: on fit x-aa.b au lieu de x) "; 286 301 usage+="\n| x : demande de centrage: on fit x-xc au lieu de x "; 287 usage+="\n| avec xc=abscisse du milieu de l'histogramme";302 usage+="\n| avec xc=abscisse du ''milieu logique'' de l'objet. "; 288 303 usage+="\n| Actif pour exp+poly 1D, poly 1D "; 289 304 usage+="\n| Pour gauss+poly 1D, xc est le centre de la gaussienne. "; … … 352 367 PIAFitter::~PIAFitter() 353 368 { 354 if(mFit != NULL) {delete mFit; mFit=NULL;} 355 if(mFunction != NULL) {delete mFunction; mFunction=NULL;} 356 if(mFunc != NULL) {delete mFunc; mFunc=NULL;} 357 if(mGData != NULL) {delete mGData; mGData=NULL;} 358 if(FWindFit != NULL) {delete FWindFit; FWindFit=NULL;} 359 if (mDlUFunc != NULL) {delete mDlUFunc; mDlUFunc=NULL;} 360 } 361 362 /* --Methode-- */ 363 void PIAFitter::ResetDPointer(void) 364 // Reset des pointeurs sur les donnees 365 { 366 mNObj = ""; mObj=NULL; 367 mV=NULL; mH=NULL; mM=NULL; mH2=NULL; mIm=NULL; mG=NULL; 369 if(delmGData && mGData != NULL) {delete mGData; mGData=NULL; delmGData=false;} 370 if(mFit != NULL) {delete mFit; mFit=NULL;} 371 if(mFunction != NULL) {delete mFunction; mFunction=NULL;} 372 if(mFunc != NULL) {delete mFunc; mFunc=NULL;} 373 if(FWindFit != NULL) {delete FWindFit; FWindFit=NULL;} 374 if(mDlUFunc != NULL) {delete mDlUFunc; mDlUFunc=NULL;} 368 375 } 369 376 … … 373 380 { 374 381 mOpt.okres = mOpt.okfun = false; 382 375 383 mOpt.polcx = mOpt.polcy = 0; 376 384 mOpt.xc = mOpt.yc = 0.; 385 377 386 mOpt.stc2 = 1.e-3; 378 387 mOpt.nstep = 100; 379 mOpt.err_e = mOpt.err_E = -1.; 388 389 mOpt.err_type = GeneralFitData::DefaultError; 390 mOpt.err_scale = 1.; mOpt.err_min = 0.; 391 380 392 mOpt.lp = 1; mOpt.lpg = 0; 381 mOpt.i1 = mOpt.j1 = mOpt.i2 = mOpt.j2 = -1; 393 394 mOpt.i1 = mOpt.j1 = 0; 395 mOpt.i2 = mOpt.j2 = -1; 396 382 397 mOpt.fromlastfit = false; 383 398 mOpt.autoinifit = false; … … 417 432 } 418 433 } 419 if(strstr(opt.c_str(),",E")) { // Erreurs imposees a "sqrt(val)" ou "aa.b*sqrt(val)" 434 if(strstr(opt.c_str(),",h")) { 435 mOpt.err_type = GeneralFitData::DefaultError; 436 p = opt.find(",h"); q = opt.find_first_of(',',p+1); 437 dum = opt.substr(p,q-p); 438 if(dum.length()>2) sscanf(dum.c_str(),",h%lf/%lf",&mOpt.err_scale,&mOpt.err_min); 439 } 440 if(strstr(opt.c_str(),",H")) { 441 mOpt.err_type = GeneralFitData::ProporError; 442 p = opt.find(",H"); q = opt.find_first_of(',',p+1); 443 dum = opt.substr(p,q-p); 444 if(dum.length()>2) sscanf(dum.c_str(),",H%lf/%lf",&mOpt.err_scale,&mOpt.err_min); 445 } 446 if(strstr(opt.c_str(),",e")) { 447 mOpt.err_type = GeneralFitData::ConstantError; 448 p = opt.find(",e"); q = opt.find_first_of(',',p+1); 449 dum = opt.substr(p,q-p); 450 if(dum.length()>2) sscanf(dum.c_str(),",e%lf/%lf",&mOpt.err_scale,&mOpt.err_min); 451 } 452 if(strstr(opt.c_str(),",E")) { 453 mOpt.err_type = GeneralFitData::SqrtError; 420 454 p = opt.find(",E"); q = opt.find_first_of(',',p+1); 421 455 dum = opt.substr(p,q-p); 422 if(dum.length()>2) sscanf(dum.c_str(),",E%lf",&mOpt.err_E); 423 if(mOpt.err_E<=0.) mOpt.err_E = 1.; //mOpt.err_e=-1.; 424 } 425 if(strstr(opt.c_str(),",e")) { // Erreurs imposees a "1" ou "aa.b" 426 p = opt.find(",e"); q = opt.find_first_of(',',p+1); 427 dum = opt.substr(p,q-p); 428 if(dum.length()>2) sscanf(dum.c_str(),",e%lf",&mOpt.err_e); 429 if(mOpt.err_e<=0.) mOpt.err_e = 1.; //mOpt.err_E=-1.; 456 if(dum.length()>2) sscanf(dum.c_str(),",E%lf/%lf",&mOpt.err_scale,&mOpt.err_min); 430 457 } 431 458 if(strstr(opt.c_str(),",X")) { // Valeur du StopChi2 … … 467 494 // Decodage de l'objet a fitter 468 495 { 496 mNObj = ""; 469 497 NamedObjMgr omg; 470 498 AnyDataObj* mobj = omg.GetObj(obj); … … 473 501 return;} 474 502 475 // Reset 476 ResetDPointer(); 477 mNVar = mNBinX = mNBinY = mNData = 0; 478 479 mObj = mobj; mNObj = obj; 480 string ctyp = typeid(*mObj).name(); 481 482 // 1D 483 if (typeid(*mObj) == typeid(Vector)) { 484 mNVar = 1; 485 mV = (Vector*) mObj; mNBinX = mV->NElts(); mNBinY = 1; 486 } 487 else if ( (typeid(*mObj) == typeid(HProf)) || (typeid(*mObj) == typeid(Histo)) ) { 488 mNVar = 1; 489 mH = (Histo*) mObj; mNBinX = mH->NBins(); mNBinY = 1; 490 } 491 // 2D 492 else if (typeid(*mObj) == typeid(Matrix)) { 493 mNVar = 2; 494 mM = (Matrix*) mObj; mNBinX = mM->NCol(); mNBinY =mM->NRows(); 495 } 496 else if (typeid(*mObj) == typeid(Histo2D)) { 497 mNVar = 2; 498 mH2 = (Histo2D*) mObj; mNBinX = mH2->NBinX(); mNBinY = mH2->NBinY(); 499 } 500 else if (typeid(*mObj) == typeid(GeneralFitData)) { 501 mG = (GeneralFitData*) mObj; mNBinX = mG->NData(); mNBinY = 1; 502 if( mG->NVar()==1) mNVar = 1; 503 else if(mG->NVar()==2) mNVar = 2; 504 else 505 {cout<<"PIAFitter::DecodeObject Error: \n" 506 <<" GeneralFitData ne peut avoir que 1 ou 2 variables d'abscisse: " 507 <<((GeneralFitData*) mObj)->NVar()<<endl; 508 return;} 509 } 510 #ifdef SANS_EVOLPLANCK 511 else if (dynamic_cast<RzImage*>(mObj)) { 512 mNVar = 2; 513 mIm = (RzImage*) mObj; mNBinX = mIm->XSize(); mNBinY = mIm->YSize(); 514 } 515 #else 516 //CMV_A_FAIRE else if (dynamic_cast<RzImage*>(mObj)) { 517 //CMV_A_FAIRE mNVar = 2; 518 //CMV_A_FAIRE mIm = (RzImage*) mObj; mNBinX = mIm->XSize(); mNBinY = mIm->YSize(); 519 //CMV_A_FAIRE } 520 #endif 521 else { 522 cout<<"PIAFitter::DecodeObject Error , Objet n'est pas un " 523 <<"Histo1D/HProf/Vector/Histo2D/Image/Matrix/GeneralFitData "<<ctyp<<endl; 524 return; 525 } 526 527 mNData = mNBinX*mNBinY; 528 if(mNData<=0) { 529 cout<<"L'objet a "<<mNBinX<<","<<mNBinY<<" bins ("<<mNData<<")"<<endl; 530 return; 531 } 503 mNObj = obj; 532 504 533 505 return; … … 541 513 if(mOpt.lp<0) mOpt.lp = 0; 542 514 if(mOpt.lpg<0) mOpt.lpg = 0; 543 mOpt.i1 = (mOpt.i1<0||mOpt.i1>=mNBinX)? 0: mOpt.i1;544 mOpt.i2 = (mOpt.i2<0||mOpt.i2>=mNBinX||mOpt.i2<=mOpt.i1)? mNBinX-1: mOpt.i2;545 if(mNVar>=2) {546 mOpt.j1 = (mOpt.j1<0||mOpt.j1>=mNBinY)? 0: mOpt.j1;547 mOpt.j2 = (mOpt.j2<0||mOpt.j2>=mNBinY||mOpt.j2<=mOpt.j1)? mNBinY-1: mOpt.j2;548 } else mOpt.j2 = mOpt.j1 = 0;549 if(mOpt.polcx==2) {550 if(mV||mM) mOpt.xc = (mOpt.i2-mOpt.i1+1)/2.;551 else if(mH) mOpt.xc = (mH->XMin()+mH->XMax())/2.;552 else if(mH2) mOpt.xc = (mH2->XMin()+mH2->XMax())/2.;553 else if(mG) {double mini,maxi; mG->GetMnMx(2,mini,maxi); mOpt.xc=(mini+maxi)/2.;}554 else if(mIm) {mOpt.xc = mIm->XOrg() + mIm->XPixSize()*(mOpt.i2-mOpt.i1+1)/2.;}555 }556 if(mOpt.polcy==2 && mNVar>=2) {557 if(mM) mOpt.yc = (mOpt.j2-mOpt.j1+1)/2.;558 if(mH2) mOpt.yc = (mH2->YMin()+mH2->YMax())/2.;559 if(mG) {double mini,maxi; mG->GetMnMx(12,mini,maxi); mOpt.yc=(mini+maxi)/2.;}560 if(mIm) {mOpt.yc = mIm->YOrg() + mIm->YPixSize()*(mOpt.j2-mOpt.j1+1)/2.;}561 }562 if(mOpt.err_e>0.) mOpt.err_E=-1.;563 if(mOpt.err_E>0.) mOpt.err_e =-1.;564 515 if(mOpt.stc2<=0.) mOpt.stc2 = 1.e-3; 565 516 if(mOpt.nstep<2) mOpt.nstep = 100; 566 567 517 return; 568 518 } … … 572 522 // Print des options 573 523 { 574 cout<<"Fit ["<<mNBinX<<","<<mNBinY<<"]("<<mNData<<") dim="<<mNVar<<":"524 cout<<"Fit("<<mNData<<") dim="<<mNVar<<":" 575 525 <<" Int=["<<mOpt.i1<<","<<mOpt.i2<<"],["<<mOpt.j1<<","<<mOpt.j2<<"]"<<endl 576 526 <<" Cent="<<mOpt.polcx<<","<<mOpt.polcy<<","<<mOpt.xc<<"+x"<<","<<mOpt.yc<<"+y" 577 <<" TypE="<<mOpt.err_ e<<","<<mOpt.err_E527 <<" TypE="<<mOpt.err_type<<","<<mOpt.err_scale<<","<<mOpt.err_min 578 528 <<" StpX2="<<mOpt.stc2<<" Nstep="<<mOpt.nstep<<endl 579 529 <<" Init.LFit="<<mOpt.fromlastfit<<" AutoIni.Fit="<<mOpt.autoinifit … … 587 537 // ATTENTION: cette methode a besoin que les options soient decodees et checkees 588 538 { 589 if(mNData<=0) return; 590 if(mGData!=NULL) {delete mGData; mGData=NULL;} 591 mGData = new GeneralFitData(mNVar,mNData,0); 592 593 for(int i=mOpt.i1;i<=mOpt.i2;i++) for(int j=mOpt.j1;j<=mOpt.j2;j++) { 594 double x,y=0.,f,e; 595 596 if(mV) 597 {x= (double) i; f=(*mV)(i); e=1.;} 598 else if(mH) 599 {x=mH->BinCenter(i); f=(*mH)(i); e=(mH->HasErrors())?mH->Error(i):1.;} 600 else if(mM) 601 {x=(double) i; y=(double) j; f=(*mM)(j,i); e=1.;} 602 else if(mH2) 603 {r_8 xf,yf; mH2->BinCenter(i,j,xf,yf); x=xf; y=yf; 604 f=(*mH2)(i,j); e=(mH2->HasErrors())?mH2->Error(i,j):1.;} 605 else if(mIm) 606 {x=mIm->XOrg()+(i+0.5)*mIm->XPixSize(); y=mIm->YOrg()+(j+0.5)*mIm->YPixSize(); 607 f=mIm->DValue(i,j); e=1.;} 608 else if(mG&&mNVar==1) {x= mG->X(i); f=mG->Val(i); e=mG->EVal(i);} 609 else if(mG&&mNVar==2) {x= mG->X(i); y=mG->Y(i); f=mG->Val(i); e=mG->EVal(i);} 610 else x=y=f=e=0.; 611 612 // Gestion des erreurs a utiliser 613 if(mOpt.err_e>0.) e=mOpt.err_e; 614 else if(mOpt.err_E>0.) {e=(f<-1.||f>1.)?mOpt.err_E*sqrt(fabs(f)):mOpt.err_E;} 615 616 // Remplissage de generalfitdata 617 if(ApplyXYcentering) { // pour fitlin 618 if(mOpt.polcx>0) x-=mOpt.xc; 619 if(mNVar>=2 && mOpt.polcy>0) y-=mOpt.yc; 620 } 621 if(mNVar==1) mGData->AddData1(x,f,e); 622 else if(mNVar==2) mGData->AddData2(x,y,f,e); 623 } 624 625 if(mGData->NData()<=0) { 626 cout<<"Pas de donnees dans GeneralFitData: "<<mGData->NData()<<endl; 539 if(delmGData && mGData!=NULL) {delete mGData; mGData=NULL; delmGData=false;} 540 mNVar = mNData = 0; 541 542 NamedObjMgr omg; 543 mAdObj = omg.GetObjAdapter(mNObj); // Ne pas deleter 544 if(mAdObj == NULL) { 545 cout<<"PIAFitter::DecodeObject Error , ObjAdapter==NULL for "<<mNObj<<endl; 627 546 return; 628 547 } 629 548 mGData = mAdObj->GetGeneralFitData(delmGData 549 ,mOpt.err_type,mOpt.err_scale,mOpt.err_min 550 ,mOpt.i1,mOpt.i2,mOpt.j1,mOpt.j2); 551 if(mGData == NULL) { 552 cout<<"PIAFitter::DecodeObject Error , No adaptor for "<<mNObj<<endl; 553 return; 554 } 555 mNData = mGData->NData(); 556 if(mNData<=0) { 557 cout<<"No data in GeneralFitData: "<<mNData<<endl; 558 return; 559 } 560 mNVar = mGData->NVar(); 561 if(mNVar<=0 || mNVar>2) { 562 cout<<"Fit only support 1 and 2D : NVar = "<<mNVar<<endl; 563 return; 564 } 565 566 // Gestion du centrage automatique si demande 567 GetCentering(); 568 569 // Prints 630 570 if(mOpt.lp>2) { 631 571 mGData->PrintStatus(); 632 572 mGData->PrintData(0); 633 mGData->PrintData(m GData->NData()-1);573 mGData->PrintData(mNData-1); 634 574 double mini,maxi; 635 575 mGData->GetMnMx(2,mini,maxi); … … 648 588 649 589 /* --Methode-- */ 590 void PIAFitter::GetCentering(void) 591 // Calcul le centrage automatique 592 { 593 if(!mGData) return; 594 if(mOpt.polcx==2) { 595 double mini,maxi; 596 mGData->GetMnMx(2,mini,maxi); 597 mOpt.xc=(mini+maxi)/2.; 598 } 599 if(mOpt.polcy==2 && mNVar>=2) { 600 double mini,maxi; 601 mGData->GetMnMx(12,mini,maxi); 602 mOpt.yc=(mini+maxi)/2.; 603 } 604 } 605 606 /* --Methode-- */ 650 607 void PIAFitter::DecodeFunction(string func) 651 608 // Fonction a fitter 652 609 // ATTENTION: cette methode a besoin que les donnees soient lues 653 // (pour m opt.xc,yc et mNVar)610 // (pour mOpt.xc,yc et mNVar) 654 611 { 655 612 if(func.length()<=0) … … 911 868 // Mise a disposition des resultats (fonction fitee et residus) 912 869 { 913 if(mFit && (mOpt.okres||mOpt.okfun)) { 914 NamedObjMgr omg; 915 string nomres = mNObj + "_res"; 916 string nomfun = mNObj + "_fun"; 917 //#################### 918 #ifdef SANS_EVOLPLANCK 919 //#################### 920 if(mV) { 921 if(mOpt.okres) {Vector* ob = mV->FitResidus(*mFit); if(ob) omg.AddObj(ob,nomres);} 922 if(mOpt.okfun) {Vector* ob = mV->FitFunction(*mFit); if(ob) omg.AddObj(ob,nomfun);} 923 } else if(mH) { 924 if(mOpt.okres) {Histo* ob = mH->FitResidus(*mFit); if(ob) omg.AddObj(ob,nomres);} 925 if(mOpt.okfun) {Histo* ob = mH->FitFunction(*mFit); if(ob) omg.AddObj(ob,nomfun);} 926 } else if(mM) { 927 if(mOpt.okres) {Matrix* ob = mM->FitResidus(*mFit); if(ob) omg.AddObj(ob,nomres);} 928 if(mOpt.okfun) {Matrix* ob = mM->FitFunction(*mFit); if(ob) omg.AddObj(ob,nomfun);} 929 } else if(mH2) { 930 if(mOpt.okres) 931 {Histo2D* ob = mH2->FitResidus(*mFit); if(ob) omg.AddObj(ob,nomres);} 932 if(mOpt.okfun) 933 {Histo2D* ob = mH2->FitFunction(*mFit); if(ob) omg.AddObj(ob,nomfun);} 934 } else if(mIm) { 935 if(mOpt.okres) { 936 RzImage* ob = mIm->FitResidus(*mFit); 937 if(ob) {ImageR4* rob = new ImageR4(*ob); omg.AddObj(rob,nomres); delete ob;} 938 } 939 if(mOpt.okfun) { 940 RzImage* ob = mIm->FitFunction(*mFit); 941 if(ob) {ImageR4* rob = new ImageR4(*ob); omg.AddObj(rob,nomfun); delete ob;} 942 } 943 } else if(mG) { 944 if(mOpt.okres) 945 {GeneralFitData* ob = mG->FitResidus(*mFit); if(ob) omg.AddObj(ob,nomres);} 946 if(mOpt.okfun) 947 {GeneralFitData* ob = mG->FitFunction(*mFit); if(ob) omg.AddObj(ob,nomfun);} 948 } 949 //#################### 950 #else 951 //#################### 952 if(mV) { 953 if(mOpt.okres) { 954 Vector* ob = new Vector(ObjectFitter::FitResidus(*mV, *mFit),true); 955 if(ob) omg.AddObj(ob,nomres); 956 } 957 if(mOpt.okfun) { 958 Vector* ob = new Vector(ObjectFitter::FitFunction(*mV, *mFit),true); 959 if(ob) omg.AddObj(ob,nomfun); 960 } 961 } else if(mH) { 962 if(mOpt.okres) { 963 Histo* ob = new Histo(ObjectFitter::FitResidus(*mH, *mFit)); 964 if(ob) omg.AddObj(ob,nomres); 965 } 966 if(mOpt.okfun) { 967 Histo* ob = new Histo(ObjectFitter::FitFunction(*mH, *mFit)); 968 if(ob) omg.AddObj(ob,nomfun); 969 } 970 } else if(mM) { 971 if(mOpt.okres) { 972 Matrix* ob = new Matrix(ObjectFitter::FitResidus(*mM, *mFit), true); 973 if(ob) omg.AddObj(ob,nomres); 974 } 975 if(mOpt.okfun) { 976 Matrix* ob = new Matrix(ObjectFitter::FitFunction(*mM, *mFit), true); 977 if(ob) omg.AddObj(ob,nomfun); 978 } 979 } else if(mH2) { 980 if(mOpt.okres) { 981 Histo2D* ob = new Histo2D(ObjectFitter::FitResidus(*mH2, *mFit)); 982 if(ob) omg.AddObj(ob,nomres); 983 } 984 if(mOpt.okfun) { 985 Histo2D* ob = new Histo2D(ObjectFitter::FitFunction(*mH2, *mFit)); 986 if(ob) omg.AddObj(ob,nomfun); 987 } 988 //CMV_A_FAIRE } else if(mIm) { 989 //CMV_A_FAIRE if(mOpt.okres) { 990 //CMV_A_FAIRE RzImage* ob = mIm->FitResidus(*mFit); 991 //CMV_A_FAIRE if(ob) {ImageR4* rob = new ImageR4(*ob); omg.AddObj(rob,nomres); delete ob;} 992 //CMV _A_FAIRE } 993 //CMV_A_FAIRE if(mOpt.okfun) { 994 //CMV_A_FAIRE RzImage* ob = mIm->FitFunction(*mFit); 995 //CMV_A_FAIRE if(ob) {ImageR4* rob = new ImageR4(*ob); omg.AddObj(rob,nomfun); delete ob;} 996 //CMV_A_FAIRE } 997 } else if(mG) { 998 if(mOpt.okres) { 999 //GeneralFitData* ob = new GeneralFitData(mG->FitResidus(*mFit)); 1000 GeneralFitData* ob = new GeneralFitData(ObjectFitter::FitResidus(*mG, *mFit)); 1001 if(ob) omg.AddObj(ob,nomres); 1002 } 1003 if(mOpt.okfun) { 1004 //GeneralFitData* ob = new GeneralFitData(mG->FitFunction(*mFit)); 1005 GeneralFitData* ob = new GeneralFitData(ObjectFitter::FitFunction(*mG, *mFit)); 1006 if(ob) omg.AddObj(ob,nomfun); 1007 } 1008 } 1009 //#################### 1010 #endif 1011 //#################### 1012 } 870 if(!mFit) return; 871 872 NamedObjMgr omg; 873 string nomresfun = "__dummy__"; 874 875 if(mOpt.okres) { 876 nomresfun = mNObj + "_res"; 877 AnyDataObj* ob = mAdObj->FitResidusObj(*mFit); 878 if(ob) omg.AddObj(ob,nomresfun); 879 } 880 881 if(mOpt.okfun) { 882 nomresfun = mNObj + "_fun"; 883 AnyDataObj* ob = mAdObj->FitFunctionObj(*mFit); 884 if(ob) omg.AddObj(ob,nomresfun); 885 } 886 1013 887 return; 1014 888 } … … 1029 903 if(mFName.length()>1) sscanf(mFName.c_str()+1,"%d",°re); 1030 904 905 double xc = (mOpt.polcx>0) ? mOpt.xc : 0.; 906 double yc = (mOpt.polcy>0) ? mOpt.yc : 0.; 907 1031 908 if(mNVar==1) { // Fit lineaire de polynome 1D 1032 cout<<"Fit (lineaire) 1D polynome de degre "<<degre<<endl; 909 cout<<"Fit (lineaire) 1D polynome de degre "<<degre 910 <<" (xc="<<xc<<")"<<endl; 1033 911 Poly p1(0); 1034 double c2rl = mGData->PolFit(0,p1,degre );912 double c2rl = mGData->PolFit(0,p1,degre,xc); 1035 913 cout<<"C2r_lineaire = "<<c2rl<<endl; 1036 914 if(mOpt.lp>0) cout<<p1<<endl; 1037 915 } else if(mNVar==2) { // Fit lineaire de polynome 2D 1038 cout<<"Fit (lineaire) polynome 2D de degre "<<degre<<endl; 916 cout<<"Fit (lineaire) polynome 2D de degre "<<degre 917 <<" (xc,yc="<<xc<<","<<yc<<")"<<endl; 1039 918 Poly2 p2(0); 1040 double c2rl = mGData->PolFit(0,1,p2,degre );919 double c2rl = mGData->PolFit(0,1,p2,degre,xc,yc); 1041 920 cout<<"C2r_lineaire = "<<c2rl<<endl; 1042 921 if(mOpt.lp>0) cout<<p2<<endl; … … 1148 1027 <<" avec Options: [p:p1,...,pn s:s1,...,sn m:m1,...,mn \n" 1149 1028 <<" M:M1,...,Mn f:f1,...,fn o:.,.,. o:.,.,.]\n" 1150 <<" ou fitlin nomobj func[o:.,.,. o:.,.,.]\n";1029 <<" ou fitlin nomobj pnn [o:.,.,. o:.,.,.]\n"; 1151 1030 return(-1); 1152 1031 } … … 1172 1051 DecodeObject(tokens[0]); 1173 1052 CheckOptions(); 1053 FillGData(); 1174 1054 if(mOpt.lp>0) PrintOptions(); 1175 if(kw == "fitlin") ApplyXYcentering=true; else ApplyXYcentering=false;1176 FillGData();1177 1055 DecodeFunction(tokens[1]); 1178 1056 DecodeParam(mSp,mSs,mSm,mSM,mSf); … … 1306 1184 , mDap(par), mFitter(fiter), mFunc(func) 1307 1185 , ReFillGData(false), ReDecodeFunc(false) 1308 , ErrValue(1.)1309 1186 , saveI1(0), saveI2(0), saveJ1(0), saveJ2(0) 1310 , saveErr Value(1.), saveXC(0.), saveYC(0.)1187 , saveErrScale(1.),saveErrMin(0.), saveXC(0.), saveYC(0.) 1311 1188 { 1312 1189 #ifdef SANS_EVOLPLANCK … … 1319 1196 1320 1197 // Alloc de la taille 1321 nlab = 1 3+npar; lab = new PILabel*[nlab]; {for(int i=0;i<nlab;i++) lab[i]=NULL;}1322 ntxt = 1 0+4*npar; txt = new PIText*[ntxt]; {for(int i=0;i<ntxt;i++) txt[i]=NULL;}1198 nlab = 15+npar; lab = new PILabel*[nlab]; {for(int i=0;i<nlab;i++) lab[i]=NULL;} 1199 ntxt = 15+4*npar; txt = new PIText*[ntxt]; {for(int i=0;i<ntxt;i++) txt[i]=NULL;} 1323 1200 nbut = 6; but = new PIButton*[nbut]; {for(int i=0;i<nbut;i++) but[i]=NULL;} 1324 1201 nckb = 2+npar; ckb = new PICheckBox*[nckb]; {for(int i=0;i<nckb;i++) ckb[i]=NULL;} … … 1360 1237 // new ligne 1361 1238 cpx = spx; cpy += bsy+spy; 1362 pom[0] = new PIOptMenu(this,"Err def",1. 5*bsx,bsy,cpx,cpy);1239 pom[0] = new PIOptMenu(this,"Err def",1.25*bsx,bsy,cpx,cpy); 1363 1240 pom[0]->AppendItem("Err def",2101); 1364 1241 pom[0]->AppendItem("Err cste",2102); 1365 1242 pom[0]->AppendItem("Err sqrt",2103); 1243 pom[0]->AppendItem("Err prop",2104); 1366 1244 pom[0]->SetValue(2101); 1367 1245 pom[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1368 cpx += int(1.5*bsx+spx); 1246 cpx += int(1.25*bsx+spx); 1247 lab[1] = new PILabel(this,"E_Scale",bsx, bsy, cpx, cpy); 1248 lab[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1249 cpx += bsx+spx; 1369 1250 txt[0] = new PIText(this,"",bsx,bsy,cpx,cpy); 1370 1251 txt[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1371 1252 cpx += bsx+spx; 1372 lab[ 1] = new PILabel(this,"Prt,dbg",bsx,bsy,cpx,cpy);1373 lab[ 1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);1374 cpx += bsx+spx;1375 txt[1] = new PIText(this,"", bsx,bsy,cpx,cpy);1253 lab[2] = new PILabel(this,"E_Min",0.75*bsx,bsy,cpx,cpy); 1254 lab[2]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1255 cpx += int(0.75*bsx+spx); 1256 txt[1] = new PIText(this,"",0.75*bsx,bsy,cpx,cpy); 1376 1257 txt[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1377 1258 1378 1259 // new ligne 1379 1260 cpx = spx; cpy += bsy+spy; 1380 lab[ 2] = new PILabel(this,"Stop Xi2",1.25*bsx,bsy,cpx,cpy);1381 lab[ 2]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);1382 cpx += int(1.25*bsx+spx);1383 txt[2] = new PIText(this,"", bsx,bsy,cpx,cpy);1261 lab[3] = new PILabel(this,"Prt,dbg",bsx,bsy,cpx,cpy); 1262 lab[3]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1263 cpx += bsx+spx; 1264 txt[2] = new PIText(this,"",0.5*bsx,bsy,cpx,cpy); 1384 1265 txt[2]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1385 cpx += bsx+spx;1386 lab[ 3] = new PILabel(this,"Iter",bsx, bsy, cpx,cpy);1387 lab[ 3]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);1266 cpx += int(0.5*bsx+spx); 1267 lab[4] = new PILabel(this,"Stop X2",bsx,bsy,cpx,cpy); 1268 lab[4]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1388 1269 cpx += bsx+spx; 1389 1270 txt[3] = new PIText(this,"",bsx,bsy,cpx,cpy); 1390 1271 txt[3]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1272 cpx += bsx+spx; 1273 lab[5] = new PILabel(this,"Iter",0.5*bsx, bsy, cpx, cpy); 1274 lab[5]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1275 cpx += int(0.5*bsx+spx); 1276 txt[4] = new PIText(this,"",0.75*bsx,bsy,cpx,cpy); 1277 txt[4]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1391 1278 1392 1279 // new ligne 1393 1280 cpx = spx; cpy += bsy+spy; 1394 lab[ 4] = new PILabel(this,"Range X",bsx,bsy,cpx,cpy);1395 lab[ 4]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);1281 lab[6] = new PILabel(this,"Range X",bsx,bsy,cpx,cpy); 1282 lab[6]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1396 1283 cpx += bsx+spx; 1397 txt[4] = new PIText(this,"",0.75*bsx,bsy,cpx,cpy);1398 txt[4]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);1399 cpx += int(0.75*bsx+spx);1400 1284 txt[5] = new PIText(this,"",0.75*bsx,bsy,cpx,cpy); 1401 1285 txt[5]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1402 1286 cpx += int(0.75*bsx+spx); 1403 lab[5] = new PILabel(this,"Y",bsx/2,bsy,cpx,cpy);1404 lab[5]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);1405 cpx += int(bsx/2.+spx);1406 1287 txt[6] = new PIText(this,"",0.75*bsx,bsy,cpx,cpy); 1407 1288 txt[6]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1408 1289 cpx += int(0.75*bsx+spx); 1290 lab[7] = new PILabel(this,"Y",bsx/2,bsy,cpx,cpy); 1291 lab[7]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1292 cpx += int(bsx/2.+spx); 1409 1293 txt[7] = new PIText(this,"",0.75*bsx,bsy,cpx,cpy); 1410 1294 txt[7]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1295 cpx += int(0.75*bsx+spx); 1296 txt[8] = new PIText(this,"",0.75*bsx,bsy,cpx,cpy); 1297 txt[8]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1411 1298 1412 1299 // new ligne 1413 1300 cpx = spx; cpy += bsy+spy; 1414 lab[ 6] = new PILabel(this,"Cent",bsx/2,bsy,cpx,cpy);1415 lab[ 6]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);1301 lab[8] = new PILabel(this,"Cent",bsx/2,bsy,cpx,cpy); 1302 lab[8]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1416 1303 cpx += int(bsx/2.+spx); 1417 1304 pom[1] = new PIOptMenu(this,"X.No",1.25*bsx,bsy,cpx,cpy); … … 1422 1309 pom[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1423 1310 cpx += int(1.25*bsx+spx); 1424 txt[ 8] = new PIText(this,"",bsx,bsy,cpx,cpy);1425 txt[ 8]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);1311 txt[9] = new PIText(this,"",bsx,bsy,cpx,cpy); 1312 txt[9]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1426 1313 cpx += bsx+spx; 1427 1314 pom[2] = new PIOptMenu(this,"Y.No",1.25*bsx,bsy,cpx,cpy); … … 1432 1319 pom[2]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1433 1320 cpx += int(1.25*bsx+spx); 1434 txt[ 9] = new PIText(this,"",bsx,bsy,cpx,cpy);1435 txt[ 9]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);1321 txt[10] = new PIText(this,"",bsx,bsy,cpx,cpy); 1322 txt[10]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1436 1323 1437 1324 // new ligne … … 1451 1338 // new ligne 1452 1339 cpx = spx; cpy += bsy+spy; 1453 lab[ 7] = new PILabel(this,"Par",bsx/2,bsy,cpx,cpy);1454 lab[ 7]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);1340 lab[9] = new PILabel(this,"Par",bsx/2,bsy,cpx,cpy); 1341 lab[9]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1455 1342 cpx += int(bsx/2.+spx); 1456 lab[ 8] = new PILabel(this,"Fx",bsx/3,bsy,cpx,cpy);1457 lab[ 8]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);1343 lab[10] = new PILabel(this,"Fx",bsx/3,bsy,cpx,cpy); 1344 lab[10]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1458 1345 cpx += int(bsx/3.+spx); 1459 lab[9] = new PILabel(this,"Init",bsx,bsy,cpx,cpy); 1460 lab[9]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1461 cpx += bsx+spx; 1462 lab[10] = new PILabel(this,"Step",bsx,bsy,cpx,cpy); 1463 lab[10]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1464 cpx += bsx+spx; 1465 lab[11] = new PILabel(this,"Min",bsx,bsy,cpx,cpy); 1346 lab[11] = new PILabel(this,"Init",bsx,bsy,cpx,cpy); 1466 1347 lab[11]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1467 1348 cpx += bsx+spx; 1468 lab[12] = new PILabel(this," Max",bsx,bsy,cpx,cpy);1349 lab[12] = new PILabel(this,"Step",bsx,bsy,cpx,cpy); 1469 1350 lab[12]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1351 cpx += bsx+spx; 1352 lab[13] = new PILabel(this,"Min",bsx,bsy,cpx,cpy); 1353 lab[13]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1354 cpx += bsx+spx; 1355 lab[14] = new PILabel(this,"Max",bsx,bsy,cpx,cpy); 1356 lab[14]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1470 1357 1471 1358 // new lines: Parametres (npar lignes) … … 1474 1361 cpx = spx; cpy += bsy+spy; 1475 1362 char str[8]; sprintf(str,"P%d",i); 1476 lab[1 3+i] = new PILabel(this,str,bsx/2,bsy,cpx,cpy);1477 lab[1 3+i]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);1363 lab[15+i] = new PILabel(this,str,bsx/2,bsy,cpx,cpy); 1364 lab[15+i]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1478 1365 cpx += int(bsx/2.+spx); 1479 1366 // Attention pas de message entre 1500 et 2000 (permet 500 parametres!) … … 1482 1369 cpx+=int(bsx/3.+spx); 1483 1370 for(int j=0;j<4;j++) { 1484 txt[1 0+4*i+j] = new PIText(this,"",bsx,bsy,cpx,cpy);1485 txt[1 0+4*i+j]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);1371 txt[15+4*i+j] = new PIText(this,"",bsx,bsy,cpx,cpy); 1372 txt[15+4*i+j]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1486 1373 cpx += bsx+spx; 1487 1374 } … … 1523 1410 int npar = mFitter->mNPar; 1524 1411 1412 // Les menus d'options 1413 if(mFitter->mOpt.err_type==GeneralFitData::DefaultError) pom[0]->SetValue(2101); 1414 if(mFitter->mOpt.err_type==GeneralFitData::ConstantError) pom[0]->SetValue(2102); 1415 if(mFitter->mOpt.err_type==GeneralFitData::SqrtError) pom[0]->SetValue(2103); 1416 if(mFitter->mOpt.err_type==GeneralFitData::ProporError) pom[0]->SetValue(2104); 1417 1525 1418 // Les check-boxes 1526 1419 ckb[0]->SetState(mFitter->mOpt.okfun); … … 1531 1424 // Les champs textes 1532 1425 char str[128]; string dum; 1533 sprintf(str,"%f",ErrValue); dum=str; txt[0]->SetText(dum); 1534 sprintf(str,"%d,%d",mFitter->mOpt.lp,mFitter->mOpt.lpg); dum=str; txt[1]->SetText(dum); 1535 sprintf(str,"%f",mFitter->mOpt.stc2); dum=str; txt[2]->SetText(dum); 1536 sprintf(str,"%d",mFitter->mOpt.nstep); dum=str; txt[3]->SetText(dum); 1537 sprintf(str,"%d",mFitter->mOpt.i1); dum=str; txt[4]->SetText(dum); 1538 sprintf(str,"%d",mFitter->mOpt.i2); dum=str; txt[5]->SetText(dum); 1539 sprintf(str,"%d",mFitter->mOpt.j1); dum=str; txt[6]->SetText(dum); 1540 sprintf(str,"%d",mFitter->mOpt.j2); dum=str; txt[7]->SetText(dum); 1541 sprintf(str,"%f",mFitter->mOpt.xc); dum=str; txt[8]->SetText(dum); 1542 sprintf(str,"%f",mFitter->mOpt.yc); dum=str; txt[9]->SetText(dum); 1426 sprintf(str,"%f",mFitter->mOpt.err_scale); dum=str; txt[0]->SetText(dum); 1427 sprintf(str,"%f",mFitter->mOpt.err_min); dum=str; txt[1]->SetText(dum); 1428 sprintf(str,"%d,%d",mFitter->mOpt.lp,mFitter->mOpt.lpg); dum=str; txt[2]->SetText(dum); 1429 sprintf(str,"%f",mFitter->mOpt.stc2); dum=str; txt[3]->SetText(dum); 1430 sprintf(str,"%d",mFitter->mOpt.nstep); dum=str; txt[4]->SetText(dum); 1431 sprintf(str,"%d",mFitter->mOpt.i1); dum=str; txt[5]->SetText(dum); 1432 sprintf(str,"%d",mFitter->mOpt.i2); dum=str; txt[6]->SetText(dum); 1433 sprintf(str,"%d",mFitter->mOpt.j1); dum=str; txt[7]->SetText(dum); 1434 sprintf(str,"%d",mFitter->mOpt.j2); dum=str; txt[8]->SetText(dum); 1435 sprintf(str,"%f",mFitter->mOpt.xc); dum=str; txt[9]->SetText(dum); 1436 sprintf(str,"%f",mFitter->mOpt.yc); dum=str; txt[10]->SetText(dum); 1543 1437 if(npar>0) { 1544 1438 for(int i=0;i<npar;i++) { 1545 sprintf(str,"%f",mFitter->mPar(i)); dum=str; txt[1 0+4*i+0]->SetText(dum);1546 sprintf(str,"%f",mFitter->mStep(i)); dum=str; txt[1 0+4*i+1]->SetText(dum);1547 sprintf(str,"%f",mFitter->mMin(i)); dum=str; txt[1 0+4*i+2]->SetText(dum);1548 sprintf(str,"%f",mFitter->mMax(i)); dum=str; txt[1 0+4*i+3]->SetText(dum);1439 sprintf(str,"%f",mFitter->mPar(i)); dum=str; txt[15+4*i+0]->SetText(dum); 1440 sprintf(str,"%f",mFitter->mStep(i)); dum=str; txt[15+4*i+1]->SetText(dum); 1441 sprintf(str,"%f",mFitter->mMin(i)); dum=str; txt[15+4*i+2]->SetText(dum); 1442 sprintf(str,"%f",mFitter->mMax(i)); dum=str; txt[15+4*i+3]->SetText(dum); 1549 1443 } 1550 1444 } … … 1573 1467 cout<<"PIAFitterWind::Process Error , Pas d'objet de nom " 1574 1468 <<mFitter->mNObj<<endl; 1575 mFitter->ResetDPointer();return;1469 return; 1576 1470 } 1577 1471 1578 1472 // On recupere les champs textes 1579 1473 string dum; char str[128]; 1580 // Attention gestion du type d'erreur 1474 // Attention gestion du type d'erreur (scale et min) 1581 1475 dum=txt[0]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' '); 1582 sscanf(str,"%lf",&ErrValue); if(ErrValue<=0.) ErrValue=1.; 1583 if(mFitter->mOpt.err_e>0. ) mFitter->mOpt.err_e = ErrValue; 1584 if(mFitter->mOpt.err_E>0. ) mFitter->mOpt.err_E = ErrValue; 1585 if(saveErrValue!=ErrValue) { 1586 if(lp) cout<<"ErrValue changed: "<<ErrValue<<endl; 1476 sscanf(str,"%lf",&(mFitter->mOpt.err_scale)); 1477 if(saveErrScale!=mFitter->mOpt.err_scale) { 1478 if(lp) cout<<"ErrScale changed: "<<mFitter->mOpt.err_scale<<endl; 1587 1479 ReFillGData = true; 1588 saveErr Value = ErrValue;1480 saveErrScale = mFitter->mOpt.err_scale; 1589 1481 } 1590 1482 dum=txt[1]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' '); 1483 sscanf(str,"%lf",&(mFitter->mOpt.err_min)); 1484 if(saveErrMin!=mFitter->mOpt.err_min) { 1485 if(lp) cout<<"ErrMin changed: "<<mFitter->mOpt.err_min<<endl; 1486 ReFillGData = true; 1487 saveErrMin = mFitter->mOpt.err_min; 1488 } 1489 dum=txt[2]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' '); 1591 1490 sscanf(str,"%d,%d",&(mFitter->mOpt.lp),&(mFitter->mOpt.lpg)); 1592 dum=txt[ 2]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' ');1491 dum=txt[3]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' '); 1593 1492 sscanf(str,"%lf",&(mFitter->mOpt.stc2)); 1594 dum=txt[ 3]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' ');1493 dum=txt[4]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' '); 1595 1494 sscanf(str,"%d",&(mFitter->mOpt.nstep)); 1596 1495 // Attention si les valeurs de mOpt.i1/.i2/.j1/.j2 ont ete changees 1597 dum=txt[ 4]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' ');1496 dum=txt[5]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' '); 1598 1497 sscanf(str,"%d",&(mFitter->mOpt.i1)); 1599 dum=txt[ 5]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' ');1498 dum=txt[6]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' '); 1600 1499 sscanf(str,"%d",&(mFitter->mOpt.i2)); 1601 dum=txt[ 6]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' ');1500 dum=txt[7]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' '); 1602 1501 sscanf(str,"%d",&(mFitter->mOpt.j1)); 1603 dum=txt[ 7]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' ');1502 dum=txt[8]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' '); 1604 1503 sscanf(str,"%d",&(mFitter->mOpt.j2)); 1605 1504 if(saveI1!=mFitter->mOpt.i1 || saveI2!=mFitter->mOpt.i2 || … … 1615 1514 saveJ1=mFitter->mOpt.j1; saveJ2=mFitter->mOpt.j2; 1616 1515 } 1617 dum=txt[ 8]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' ');1516 dum=txt[9]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' '); 1618 1517 sscanf(str,"%lf",&(mFitter->mOpt.xc)); 1619 dum=txt[ 9]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' ');1518 dum=txt[10]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' '); 1620 1519 sscanf(str,"%lf",&(mFitter->mOpt.yc)); 1621 1520 if(saveXC!=mFitter->mOpt.xc || saveYC!=mFitter->mOpt.yc) { 1622 1521 if(lp) cout<<"mOpt.xc,yc changed: "<<mFitter->mOpt.xc 1623 1522 <<" , "<<mFitter->mOpt.xc<<endl; 1624 Re FillGData = true; ReDecodeFunc = true;1523 ReDecodeFunc = true; 1625 1524 saveXC = mFitter->mOpt.xc; saveYC = mFitter->mOpt.yc; 1626 1525 } … … 1628 1527 if(npar>0) { 1629 1528 for(int i=0;i<npar;i++) { 1630 dum=txt[1 0+4*i+0]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' ');1529 dum=txt[15+4*i+0]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' '); 1631 1530 sscanf(str,"%lf",&(mFitter->mPar(i))); 1632 dum=txt[1 0+4*i+1]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' ');1531 dum=txt[15+4*i+1]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' '); 1633 1532 sscanf(str,"%lf",&(mFitter->mStep(i))); 1634 dum=txt[1 0+4*i+2]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' ');1533 dum=txt[15+4*i+2]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' '); 1635 1534 sscanf(str,"%lf",&(mFitter->mMin(i))); 1636 dum=txt[1 0+4*i+3]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' ');1535 dum=txt[15+4*i+3]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' '); 1637 1536 sscanf(str,"%lf",&(mFitter->mMax(i))); 1638 1537 } … … 1645 1544 if(ReFillGData) mFitter->FillGData(); 1646 1545 ReFillGData = false; 1546 if(ReDecodeFunc) mFitter->DecodeFunction(mFunc); 1547 ReDecodeFunc = false; 1647 1548 } 1648 1549 else if(msg ==111) { 1649 1550 if(lp) cout<<"Update from last"<<endl; 1650 mFitter->ResetOptions();1651 1551 mFitter->mOpt = mFitter->mOptSave; 1652 1552 mFitter->ReSetParam(); 1653 1553 mFitter->InitParFromLastFit(); 1654 ReFillGData = true;1554 ReFillGData = ReDecodeFunc = true; 1655 1555 } 1656 1556 else if(msg ==222) { … … 1658 1558 mFitter->ResetOptions(); 1659 1559 mFitter->ReSetParam(); 1660 ReFillGData = true;1560 ReFillGData = ReDecodeFunc = true; 1661 1561 } 1662 1562 else if(msg ==333) { 1663 1563 if(lp) cout<<"Do the fit"<<endl; 1664 1564 mFitter->CheckOptions(); 1665 if(ReFillGData) { 1666 if(lp) cout<<"ReFill Data"<<endl; 1667 mFitter->FillGData(); 1668 } 1565 if(ReFillGData) mFitter->FillGData(); 1669 1566 ReFillGData = false; 1670 1567 if(ReDecodeFunc) mFitter->DecodeFunction(mFunc); … … 1695 1592 } 1696 1593 } 1697 else if(2101<=msg && msg<=2103) { 1698 mFitter->mOpt.err_e = mFitter->mOpt.err_E = -1.; 1699 if(msg==2102) mFitter->mOpt.err_e = ErrValue; 1700 else if(msg==2103) mFitter->mOpt.err_E = ErrValue; 1701 if(lp) cout<<"Err_cste="<<mFitter->mOpt.err_e 1702 <<" Err_sqrt="<<mFitter->mOpt.err_E 1703 <<" ErrValue="<<ErrValue<<endl; 1594 else if(2101<=msg && msg<=2104) { 1595 if(msg==2101) 1596 {mFitter->mOpt.err_type = GeneralFitData::DefaultError; dum="DefaultError";} 1597 if(msg==2102) 1598 {mFitter->mOpt.err_type = GeneralFitData::ConstantError; dum="ConstantError";} 1599 if(msg==2103) 1600 {mFitter->mOpt.err_type = GeneralFitData::SqrtError; dum="SqrtError";} 1601 if(msg==2104) 1602 {mFitter->mOpt.err_type = GeneralFitData::ProporError; dum="ProporError";} 1603 if(lp) cout<<"Err_type="<<dum 1604 <<" Err_scale="<<mFitter->mOpt.err_scale 1605 <<" Err_min="<<mFitter->mOpt.err_min<<endl; 1704 1606 ReFillGData = true; 1705 1607 } … … 1708 1610 if(lp) cout<<"Centrage X polcx="<<mFitter->mOpt.polcx 1709 1611 <<" xc="<<mFitter->mOpt.xc<<endl; 1710 ReFillGData = true; ReDecodeFunc = true; 1612 mFitter->GetCentering(); 1613 ReDecodeFunc = true; 1711 1614 } 1712 1615 else if(2011<=msg && msg<=2013) { … … 1714 1617 if(lp) cout<<"Centrage Y polcy="<<mFitter->mOpt.polcy 1715 1618 <<" yc="<<mFitter->mOpt.yc<<endl; 1716 ReFillGData = true; ReDecodeFunc = true; 1619 mFitter->GetCentering(); 1620 ReDecodeFunc = true; 1717 1621 } 1718 1622 else if(msg>=1500 && msg<2000) { -
trunk/SophyaPI/PIext/piafitting.h
r1200 r1207 11 11 #include <vector> 12 12 13 #include " anydataobj.h"13 #include "nomgadapter.h" 14 14 15 15 #include "pdlmgr.h" … … 24 24 class GeneralFunction; class GeneralFunc; class GeneralFit; 25 25 class GeneralFitData; 26 class Histo; class Histo2D;27 class RzImage;28 26 #else 29 27 #include "tvector.h" … … 31 29 class GeneralFunction; class GeneralFunc; class GeneralFit; 32 30 class GeneralFitData; 33 class Histo; class Histo2D;34 class RzImage; //CMV_A_VIRER class RzImage35 31 } 36 32 #endif … … 53 49 bool okres, okfun; 54 50 int polcx,polcy; double xc,yc; 55 double err_e, err_E; 51 GeneralFitData::FitErrType err_type; 52 double err_scale,err_min; 56 53 double stc2; 57 54 int nstep; … … 61 58 } DFOPTIONS ; 62 59 63 void ResetDPointer(void);64 60 void ResetOptions(void); 65 61 void DecodeOptions(string opt); … … 68 64 void PrintOptions(void); 69 65 void FillGData(void); 66 void GetCentering(void); 70 67 void DecodeFunction(string func); 71 68 void ReSetParam(void); … … 89 86 PIAFitterWind* FWindFit; // Fenetre de config interactive 90 87 // Objet a fitter 91 string mNObj; AnyDataObj* mObj; // Do not delete 88 string mNObj; 89 NObjMgrAdapter* mAdObj; // Ne pas deleter 92 90 // Structure de data pour le fit, parametres et options 93 91 GeneralFitData* mGData; 94 int_4 mNPar,mNVar,mNBinX,mNBinY,mNData; 92 bool delmGData; 93 int_4 mNPar,mNVar,mNData; 95 94 Vector mPar; Vector mStep; Vector mMin; Vector mMax; Vector mFix; 96 95 Vector mParSave; Vector mStepSave; Vector mMinSave; Vector mMaxSave; Vector mFixSave; … … 98 97 DFOPTIONS mOpt; 99 98 DFOPTIONS mOptSave; 100 bool ApplyXYcentering;101 // Possibles objets a fitter102 Vector* mV; Histo* mH; // Do not delete103 Matrix* mM; Histo2D* mH2; // Do not delete104 RzImage* mIm; // Do not delete105 GeneralFitData* mG; // Do not delete106 99 // Gestion des fonctions de fit predefinies 107 100 GeneralFunction* mFunction; string mFName; -
trunk/SophyaPI/PIext/piinit.cc
r1105 r1207 61 61 serv->RegisterClass(new TVector<r_8>, new NOMAdapter_TMatrix<r_8> ); 62 62 serv->RegisterClass(new TMatrix<r_8>, new NOMAdapter_TMatrix<r_8> ); 63 serv->RegisterClass(new TVector<complex<r_4> >, new NOMAdapter_TMatrix<complex<r_4> > );64 serv->RegisterClass(new TMatrix<complex<r_4> >, new NOMAdapter_TMatrix<complex<r_4> > );65 serv->RegisterClass(new TVector<complex<r_8> >, new NOMAdapter_TMatrix<complex<r_8> > );66 serv->RegisterClass(new TMatrix<complex<r_8> >, new NOMAdapter_TMatrix<complex<r_8> > );63 //CMV// serv->RegisterClass(new TVector<complex<r_4> >, new NOMAdapter_TMatrix<complex<r_4> > ); 64 //CMV// serv->RegisterClass(new TMatrix<complex<r_4> >, new NOMAdapter_TMatrix<complex<r_4> > ); 65 //CMV// serv->RegisterClass(new TVector<complex<r_8> >, new NOMAdapter_TMatrix<complex<r_8> > ); 66 //CMV// serv->RegisterClass(new TMatrix<complex<r_8> >, new NOMAdapter_TMatrix<complex<r_8> > ); 67 67 #endif 68 68
Note:
See TracChangeset
for help on using the changeset viewer.