Changeset 490 in Sophya
- Timestamp:
- Oct 21, 1999, 5:25:53 PM (26 years ago)
- Location:
- trunk/SophyaLib/NTools
- Files:
-
- 2 added
- 30 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/NTools/NTools.o.list
r404 r490 11 11 fct1dfit.o 12 12 fct2dfit.o 13 fftpackc.o 14 fftserver.o 13 15 generaldata.o 14 16 generalfit.o … … 25 27 nbrandom.o 26 28 nbtri.o 29 ntupintf.o 27 30 ntuple.o 28 31 outilsinit.o -
trunk/SophyaLib/NTools/cimage.cc
r270 r490 5 5 // LAL (Orsay) / IN2P3-CNRS DAPNIA/SPP (Saclay) / CEA 6 6 7 // $Id: cimage.cc,v 1. 4 1999-04-27 15:03:01ansari Exp $7 // $Id: cimage.cc,v 1.5 1999-10-21 15:25:42 ansari Exp $ 8 8 9 9 … … 1069 1069 if(deb>0) cout<<"MoySigmaIter mean="<<mean<<" sigma="<<sigma 1070 1070 <<" npix="<<rc<<" entre "<<xmin<<","<<xmax<<endl; 1071 if( rc <= 0 ) return rc;1071 if( rc <= 0 || sigma<=0. ) return rc; 1072 1072 if( it>=1 && fabs((double)(sigma-sigmaold))/sigma < perdiff ) break; 1073 1073 xmin = mean - scut*sigma; if(testl && xmin<lowbad ) xmin = lowbad; … … 1213 1213 { 1214 1214 int i,j; 1215 int x,y; 1215 // int x,y; $CHECK$ Reza 21/06/99 changement de methode de calcul des bornes 1216 1216 const T1* pt_pim; 1217 1217 T2* pt_copie; … … 1221 1221 int step_pim_x; 1222 1222 int pim_siz_x, pim_siz_y; 1223 int copie_siz_x, copie_siz_y; 1223 // int copie_siz_x, copie_siz_y; $CHECK$ Reza 21/06/99 changement de methode de calcul des bornes 1224 1224 int switch_copie; 1225 1225 … … 1227 1227 pim_siz_y=pim.YSize(); 1228 1228 if((org_pim_x < 0) || (org_pim_x > pim_siz_x)) 1229 { cout<< "CopieImage_erreure : org_pim_x: " <<org_pim_x<<" < 0 ou > a "<<pim_siz_x<< "\n\n";1229 { cout<< "CopieImage_erreure : org_pim_x: " <<org_pim_x<<" < 0 ou > a "<<pim_siz_x<<endl; 1230 1230 THROW(rangeCheckErr);} 1231 1231 if((org_pim_y < 0) || (org_pim_y > pim_siz_y)) 1232 { cout<< "CopieImage_erreure : org_pim_y: " <<org_pim_y<<" < 0 ou > a "<<pim_siz_y<< "\n\n";1232 { cout<< "CopieImage_erreure : org_pim_y: " <<org_pim_y<<" < 0 ou > a "<<pim_siz_y<<endl; 1233 1233 THROW(rangeCheckErr);} 1234 1234 1235 copie_siz_x=copie.XSize(); 1236 copie_siz_y=copie.YSize(); 1237 if((org_copie_x < 0) || (org_copie_x > copie_siz_x)) 1238 { cout<< "CopieImage_erreure : org_copie_x: " <<org_copie_x<<" < 0 ou > a "<<copie_siz_x<<"\n\n"; 1235 if( (org_copie_x < 0) || (org_copie_x > copie.XSize()) ) 1236 { cout<< "CopieImage_erreure : org_copie_x: " <<org_copie_x<<" < 0 ou > a "<< copie.XSize() << endl; 1239 1237 THROW(rangeCheckErr);} 1240 if( (org_copie_y < 0) || (org_copie_y > copie_siz_y))1241 { cout<< "CopieImage_erreure : org_copie_y: " <<org_copie_y<<" < 0 ou > a "<< copie_siz_y<<"\n\n";1238 if( (org_copie_y < 0) || (org_copie_y > copie.YSize()) ) 1239 { cout<< "CopieImage_erreure : org_copie_y: " <<org_copie_y<<" < 0 ou > a "<< copie.YSize() << endl; 1242 1240 THROW(rangeCheckErr);} 1241 1242 /* $CHECK$ Reza 21/06/99 Changement de methode de calcul ------ 1243 $CHECK$ Reza 21/06/99 , je change la taille a copier en fonction de l'origine de copie 1244 copie_siz_x=copie.XSize()-org_copie_x; 1245 copie_siz_y=copie.YSize()-org_copie_y; 1243 1246 1244 1247 x=pim_lpav_x; … … 1268 1271 } 1269 1272 else 1270 { 1273 { 1271 1274 step_copie_x=copie_siz_x-l_copie_x; 1272 1275 } … … 1285 1288 } 1286 1289 1287 pt_pim = pim.ImagePtr()+org_pim_y*pim_siz_x+org_pim_x; 1288 pt_copie=copie.ImagePtr()+org_copie_y*copie_siz_x+org_copie_x; 1290 */ 1291 1292 l_copie_x = copie.XSize()-org_copie_x; 1293 l_copie_y = copie.YSize()-org_copie_y; 1294 if ( pim_lpav_x > (pim.XSize()-org_pim_x) ) pim_lpav_x = pim.XSize()-org_pim_x; 1295 if ( pim_lpav_y > (pim.YSize()-org_pim_y) ) pim_lpav_y = pim.YSize()-org_pim_y; 1296 if ( (pim_lpav_x > 0) && (l_copie_x > pim_lpav_x) ) l_copie_x = pim_lpav_x; 1297 if ( (pim_lpav_y > 0) && (l_copie_y > pim_lpav_y) ) l_copie_y = pim_lpav_y; 1298 step_pim_x = pim.XSize()-l_copie_x; 1299 step_copie_x = copie.XSize()-l_copie_x; 1300 1301 pt_pim = pim.ImagePtr() + org_pim_y*pim.XSize() + org_pim_x; 1302 pt_copie=copie.ImagePtr() + org_copie_y*copie.XSize() + org_copie_x; 1289 1303 1290 1304 switch((int)ConvType(*pt_pim,*pt_copie)) { … … 1361 1375 if (!pim.ImagePtr()) THROW(nullPtrErr); 1362 1376 if (!copie.ImagePtr()) THROW(nullPtrErr); 1363 copie.SetOrg(org_pim_x,org_pim_y); 1364 1365 /* $CHECK$ Reza 28/04/95 : Je protege pour le moment contre les pave en 1377 copie.SetOrg( pim.XOrg()+org_pim_x-org_copie_x, pim.YOrg()+org_pim_y-org_copie_y); 1378 // copie.SetOrg(org_pim_x,org_pim_y); 1379 1380 /* Reza 28/04/95 : Je protege pour le moment contre les pave en 1366 1381 dehors de l'image, mais je veux pouvoir copier des paves decale par 1367 rapport aux bornes de l'image source Re- $CHECK$ CMV+Reza 30/09/96 */ 1382 rapport aux bornes de l'image source Re- CMV+Reza 30/09/96 */ 1383 /* $CHECK$ Reza 21/06/99 - Ca devrait etre OK */ 1368 1384 if ( (org_pim_x < 0) || (org_pim_y < 0) || 1369 1385 (org_pim_x >= pim.XSize() ) || (org_pim_y >= pim.YSize() ) || 1370 1386 ((org_pim_x+copie.XSize()) > pim.XSize()) || 1371 ((org_pim_y+copie.YSize()) > pim.YSize()) ) copie.Zero(); 1372 if ( (org_pim_x < 0) || (org_pim_y < 0) || 1373 (org_pim_x >= pim.XSize() ) || (org_pim_y >= pim.YSize() )) return; 1387 ((org_pim_y+copie.YSize()) > pim.YSize()) ) copie.Zero(); 1388 1389 if ( (org_pim_x >= pim.XSize()) || (org_pim_y >= pim.YSize()) ) { 1390 copie.SetOrg( pim.XOrg()+org_pim_x-org_copie_x, pim.YOrg()+org_pim_y-org_copie_y); 1391 return; 1392 } 1393 // if ( (org_pim_x < 0) || (org_pim_y < 0) || 1394 // (org_pim_x >= pim.XSize() ) || (org_pim_y >= pim.YSize() )) return; 1395 1396 int oox = org_pim_x; 1397 int ooy = org_pim_y; 1398 int ocx = org_copie_x; 1399 int ocy = org_copie_y; 1400 if (oox < 0) { ocx -= oox; oox = 0; } 1401 if (ooy < 0) { ocy -= ooy; ooy = 0; } 1374 1402 /* Fin de $CHECK$ */ 1403 1404 // void CopieImageF(Image<T2>& copie, Image<T1> const& pim, 1405 // int org_pim_x, int org_pim_y, /* origine pave a copier */ 1406 // int pim_lpav_x, int pim_lpav_y, /* largeur pave a copier */ 1407 // int org_copie_x, int org_copie_y, /* origine copie */ 1408 // double cutmin, double cutmax) /* coupure pour max range*/ 1375 1409 1376 1410 if((pim_lpav_x <= 0) || (pim_lpav_x > pim.XSize())) pim_lpav_x=pim.XSize(); 1377 1411 if((pim_lpav_y <= 0) || (pim_lpav_y > pim.YSize())) pim_lpav_y=pim.YSize(); 1378 TRY{1379 CopieImageF(copie, pim, org_pim_x,org_pim_y,1412 try { 1413 CopieImageF(copie, pim, oox, ooy, 1380 1414 pim_lpav_x, pim_lpav_y, 1381 o rg_copie_x,org_copie_y,cutmin,cutmax);1415 ocx, ocy, cutmin,cutmax); 1382 1416 } catch(RangeCheckError) { 1383 // if (merr != rangeCheckErr) THROW(merr);Re- $CHECK$ CMV+Reza 30/09/961417 // $PLANCKCHECK$ if (merr != rangeCheckErr) THROW(merr); // Re- $CHECK$ CMV+Reza 30/09/96 1384 1418 } ENDTRY 1419 1420 copie.SetOrg( pim.XOrg()+org_pim_x-org_copie_x, pim.YOrg()+org_pim_y-org_copie_y); 1385 1421 } 1386 1422 -
trunk/SophyaLib/NTools/datacards.h
r220 r490 1 1 // This may look like C code, but it is really -*- C++ -*- 2 2 // 3 // $Id: datacards.h,v 1. 1.1.1 1999-04-09 17:57:55ansari Exp $3 // $Id: datacards.h,v 1.2 1999-10-21 15:25:42 ansari Exp $ 4 4 // 5 5 // Datacards, acquisition EROS II … … 20 20 #include <vector> 21 21 #include <string> 22 23 #if defined(__KCC__)24 using std::string ;25 #include <functional.h>26 #include <list.h>27 #include <vector.h>28 #endif29 22 30 23 #include "peida.h" -
trunk/SophyaLib/NTools/dates.h
r241 r490 6 6 #include <iostream.h> 7 7 #include "pexceptions.h" 8 #if defined(__KCC__)9 using std::string ;10 #endif11 8 12 9 class TimeZone; -
trunk/SophyaLib/NTools/dvlist.h
r404 r490 16 16 #include <string.h> 17 17 #include <string> 18 #if defined(__KCC__)19 using std::string ;20 #include <list.h>21 #include <map.h>22 #endif23 18 24 19 namespace PlanckDPC { -
trunk/SophyaLib/NTools/fct2dfit.cc
r307 r490 56 56 : GeneralFunction(2,nPar), VolEps(1.e-4) 57 57 { 58 DBASSERT( nPar>0 );58 ASSERT( nPar>0 ); 59 59 } 60 60 … … 212 212 , mPsf2D(psf2d), mNStar(nstar) 213 213 { 214 DBASSERT( nstar>0 && psf2d!=NULL );214 ASSERT( nstar>0 && psf2d!=NULL ); 215 215 mNForme = mPsf2D->NPar() - 7; 216 DBASSERT( mNForme>=0 );216 ASSERT( mNForme>=0 ); 217 217 mNParm = mPsf2D->NPar(); 218 218 mParm = new double[mNParm]; … … 1539 1539 double X2_GauRho2D::Value(GeneralFitData& data, double* parm, int& ndataused) 1540 1540 { 1541 DBASSERT( data.NVar()==2 );1541 ASSERT( data.NVar()==2 ); 1542 1542 double x[2],z; 1543 1543 … … 1556 1556 double X2_GauRho2D::Derivee2(GeneralFitData& data, int i,int j, double* parm) 1557 1557 { 1558 DBASSERT( data.NVar()==2 && i<7 && j<7);1558 ASSERT( data.NVar()==2 && i<7 && j<7); 1559 1559 double x[2],dparm[7]; 1560 1560 -
trunk/SophyaLib/NTools/generaldata.cc
r307 r490 8 8 #include <string> 9 9 10 #if defined(__KCC__) 11 using std::string ; 12 #endif 13 10 #include "strutil.h" 14 11 #include "nbtri.h" 15 12 #include "generalfit.h" … … 134 131 //-- 135 132 { 136 DBASSERT( nVar>0 && ndatalloc>0 );133 ASSERT( nVar>0 && ndatalloc>0 ); 137 134 138 135 Delete(); … … 176 173 //-- 177 174 { 178 DBASSERT(ptr >= 0 && ptr < mNDataAlloc);175 ASSERT(ptr >= 0 && ptr < mNDataAlloc); 179 176 mNData = ptr; 180 177 mNDataGood = 0; … … 190 187 //-- 191 188 { 192 DBASSERT(i >= 0 && i < mNData);189 ASSERT(i >= 0 && i < mNData); 193 190 194 191 if( ! mOK[i] ) return; … … 203 200 //-- 204 201 { 205 DBASSERT(i1 >= 0 && i1 < mNData);206 DBASSERT(i2 >= 0 && i2 < mNData);207 DBASSERT(i1 <= i2 );202 ASSERT(i1 >= 0 && i1 < mNData); 203 ASSERT(i2 >= 0 && i2 < mNData); 204 ASSERT(i1 <= i2 ); 208 205 209 206 for(int i=i1;i<=i2;i++) KillData(i); … … 217 214 //-- 218 215 { 219 DBASSERT(i >= 0 && i < mNData);216 ASSERT(i >= 0 && i < mNData); 220 217 221 218 if( mOK[i] ) return; … … 234 231 //-- 235 232 { 236 DBASSERT(i1 >= 0 && i1 < mNData);237 DBASSERT(i2 >= 0 && i2 < mNData);238 DBASSERT(i1 <= i2 );233 ASSERT(i1 >= 0 && i1 < mNData); 234 ASSERT(i2 >= 0 && i2 < mNData); 235 ASSERT(i1 <= i2 ); 239 236 240 237 for(int i=i1;i<=i2;i++) ValidData(i); … … 281 278 //-- 282 279 { 283 DBASSERT(i>=0 && i<mNData);280 ASSERT(i>=0 && i<mNData); 284 281 bool ok = true; 285 282 … … 335 332 //-- 336 333 { 337 DBASSERT(mNData < mNDataAlloc);334 ASSERT(mNData < mNDataAlloc); 338 335 bool ok = true; 339 336 … … 377 374 //-- 378 375 { 379 DBASSERT(nData>0 && mNData+nData<=mNDataAlloc);376 ASSERT(nData>0 && mNData+nData<=mNDataAlloc); 380 377 381 378 for(int i=0;i<nData;i++) { … … 394 391 //-- 395 392 { 396 DBASSERT(nData>0 && mNData+nData<=mNDataAlloc);393 ASSERT(nData>0 && mNData+nData<=mNDataAlloc); 397 394 398 395 for(int i=0;i<nData;i++) { … … 411 408 //-- 412 409 { 413 DBASSERT(nData>0 && mNData+nData<=mNDataAlloc);410 ASSERT(nData>0 && mNData+nData<=mNDataAlloc); 414 411 415 412 for(int i=0;i<nData;i++) { … … 429 426 //-- 430 427 { 431 DBASSERT(nData>0 && mNData+nData<=mNDataAlloc);428 ASSERT(nData>0 && mNData+nData<=mNDataAlloc); 432 429 433 430 for(int i=0;i<nData;i++) { … … 454 451 //-- 455 452 { 456 DBASSERT(nData>0 && mNData+nData<=mNDataAlloc);453 ASSERT(nData>0 && mNData+nData<=mNDataAlloc); 457 454 if(mOk_EXP && !errxp) {for(int j=0;j<mNVar;j++) BuffVar[mNVar+j] = Def_ErrX;} 458 455 … … 473 470 //-- 474 471 { 475 DBASSERT(nData>0 && mNData+nData<=mNDataAlloc);472 ASSERT(nData>0 && mNData+nData<=mNDataAlloc); 476 473 477 474 if(mOk_EXP && !errxp) {for(int j=0;j<mNVar;j++) BuffVar[mNVar+j] = Def_ErrX;} … … 506 503 //-- 507 504 { 508 DBASSERT(i>=0 && i<mNData);505 ASSERT(i>=0 && i<mNData); 509 506 510 507 cout<<" "<<i<<" F( "; … … 540 537 //-- 541 538 { 542 DBASSERT(mNData>0);539 ASSERT(mNData>0); 543 540 544 541 PrintData(0,mNData-1); 545 542 } 546 543 547 ////////////////////////////////////////////////////////////////////// 548 //++ 549 int GeneralFitData::GetMinMax(int var,int& imin,int& imax) 544 //++ 545 void GeneralFitData::Show(ostream& os) const 546 // 547 // Impression de l'etat de la structure de donnees avec bornes sur "s" 548 //-- 549 { 550 double min,max; 551 os<<"GeneralFitData:: NVar,ErrX="<<mNVar<<","<<mOk_EXP 552 <<" Data: "<<mNData<<" Good,Alloc="<<mNDataGood<<","<<mNDataAlloc<<endl; 553 for(int k=0;k<2*NVar()+3;k++) { 554 GetMinMax(k,min,max); 555 os<<" - "<<k<<" "<<ColumnName(k)<<" , "<<min<<","<<max<<endl; 556 } 557 return; 558 } 559 560 ////////////////////////////////////////////////////////////////////// 561 //++ 562 int GeneralFitData::GetMnMx(int var,int& imin,int& imax) const 550 563 // 551 564 // Retourne les numeros des points de valeurs minimum et maximum … … 582 595 583 596 //++ 584 int GeneralFitData::GetM inMax(int var,double& min,double& max)597 int GeneralFitData::GetMnMx(int var,double& min,double& max) const 585 598 // 586 599 // Retourne le minimum et le maximum de la variable ``var'' 587 // (cf commentaires GetM inMax).600 // (cf commentaires GetMnMx). 588 601 //-- 589 602 { 590 603 min = 1.; max = -1.; 591 604 int imin,imax; 592 int ntest = GetM inMax(var,imin,imax);605 int ntest = GetMnMx(var,imin,imax); 593 606 if(ntest<=0) return ntest; 594 607 int ix = var/10; … … 615 628 // 616 629 // Retourne la moyenne et le sigma de la variable ``var'' 617 // (cf commentaires GetM inMax).630 // (cf commentaires GetMnMx). 618 631 //| - Return : nombre de donnees utilisees, -1 si pb, -2 si sigma<0. 619 632 //| - Seuls les points valides de valeur entre min,max sont utilises. … … 655 668 // 656 669 // Retourne le mode de la variable ``var'' 657 // (cf commentaires GetM inMax).670 // (cf commentaires GetMnMx). 658 671 //| - Return : nombre de donnees utilisees, -1 si pb. 659 672 //| - Seuls les points valides de valeur entre min,max sont utilises. … … 876 889 ////////////////////////////////////////////////////////////////////// 877 890 //++ 891 // int inline int GetSpaceFree() const 892 // Retourne la place restante dans la structure (nombre de 893 // donnees que l'on peut encore stoquer). 894 //-- 895 //++ 896 // inline int NVar() const 897 // Retourne le nombre de variables Xi 898 //-- 899 //++ 900 // inline int NData() 901 // Retourne le nombre de donnees 902 //-- 903 //++ 904 // inline int NDataGood() const 905 // Retourne le nombre de bonnes donnees (utilisees pour le fit) 906 //-- 907 //++ 908 // inline int NDataAlloc() const 909 // Retourne la place maximale allouee pour les donnees 910 //-- 911 //++ 912 // inline unsigned short int IsValid(int i) const 913 // Retourne 1 si point valide, sinon 0 914 //-- 915 //++ 916 // inline bool HasXErrors() 917 // Retourne ``true'' si il y a des erreurs sur les variables 918 // d'abscisse, ``false'' sinon. 919 //-- 920 //++ 921 // inline double X1(int i) const 922 // Retourne l'abscisse pour 1 dimension (y=f(x)) donnee I 923 //-- 924 //++ 925 // inline double X(int i) const 926 // Retourne la 1er abscisse (X) pour (v=f(x,y,z,...)) donnee I 927 //-- 928 //++ 929 // inline double Y(int i) const 930 // Retourne la 2sd abscisse (Y) pour (v=f(x,y,z,...)) donnee I 931 //-- 932 //++ 933 // inline double Z(int i) const 934 // Retourne la 3ieme abscisse (Z) pour (v=f(x,y,z,...)) donnee I 935 //-- 936 //++ 937 // inline double Absc(int j,int i) const 938 // Retourne la Jieme abscisse (Xj) pour (v=f(x0,x1,x2,...)) donnee I 939 //-- 940 //++ 941 // inline double Val(int i) const 942 // Retourne la valeur de la Ieme donnee 943 //-- 944 //++ 945 // inline double EX1(int i) const 946 // Retourne l'erreur (dx) sur l'abscisse pour 1 dimension (y=f(x)) donnee I 947 //-- 948 //++ 949 // inline double EX(int i) const 950 // Retourne l'erreur (dx) sur la 1er abscisse (X) pour (v=f(x,y,z,...)) donnee I 951 //-- 952 //++ 953 // inline double EY(int i) const 954 // Retourne l'erreur (dy) sur la 2sd abscisse (Y) pour (v=f(x,y,z,...)) donnee I 955 //-- 956 //++ 957 // inline double EZ(int i) const 958 // Retourne l'erreur (dz) sur la 3ieme abscisse (Z) pour (v=f(x,y,z,...)) donnee I 959 //-- 960 //++ 961 // inline double EAbsc(int j,int i) const 962 // Retourne l'erreur (dxj) sur la Jieme abscisse (Xj) pour (v=f(x0,x1,x2,...)) donnee I 963 //-- 964 //++ 965 // inline double EVal(int i) const {return mErr[i];} 966 // Retourne l'erreur de la Ieme donnee 967 //-- 968 969 970 ////////////////////////////////////////////////////////////////////// 971 // ------- Implementation de l interface NTuple --------- 972 973 uint_4 GeneralFitData::NbLines() const 974 { 975 return(NData()); 976 } 977 978 //++ 979 uint_4 GeneralFitData::NbColumns() const 980 // 981 // Retourne le nombre de colonnes du ntuple equivalent: 982 //| Exemple: on a une fonction sur un espace a 4 dimensions: 983 //| "x0,x1,x2,x3 , ex0,ex1,ex2,ex3 , y, ey , ok" 984 //| 0 1 2 3 4 5 6 7 8 9 10 985 //| | | | | | | | 986 //| 0 nv-1 nv 2*nv-1 2*nv 2*nv+1 2*nv+2 987 //| soit 2*nvar+3 variables/colonnes. 988 //-- 989 { 990 return(2*NVar()+3); 991 } 992 993 r_8 * GeneralFitData::GetLineD(int n) const 994 { 995 return(GetVec(n,NULL)); 996 } 997 998 r_8 GeneralFitData::GetCell(int n, int k) const 999 { 1000 if(k<0 || k>=2*NVar()+3) return 0.; 1001 r_8 * val = GetVec(n,NULL); 1002 return val[k]; 1003 } 1004 1005 r_8 GeneralFitData::GetCell(int n, string const & nom) const 1006 { 1007 int k = ColumnIndex(nom); 1008 return(GetCell(n,k)); 1009 } 1010 1011 //++ 1012 void GeneralFitData::GetMinMax(int k, double& min, double& max) const 1013 // 1014 // Retourne le minimum et le maximum de la variable `k'. 1015 //-- 1016 { 1017 int var; 1018 if(k<0 || k>=2*NVar()+3) return; 1019 else if(k<NVar()) var = 10*k+2; // Variable Xi 1020 else if(k<2*NVar()) var = 10*(k-NVar())+3; // Variable EXi 1021 else if(k==2*NVar()) var = 0; // Variable Y 1022 else if(k==2*NVar()+1) var = 1; // Variable EY 1023 else {min=0.; max=1.; return;} // Variable Ok 1024 GetMnMx(var,min,max); 1025 return; 1026 } 1027 1028 void GeneralFitData::GetMinMax(string const & nom, double& min, double& max) const 1029 { 1030 int k = ColumnIndex(nom); 1031 GetMinMax(k,min,max); 1032 } 1033 1034 int GeneralFitData::ColumnIndex(string const & nom) const 1035 { 1036 char str[64]; int k = -1; 1037 strcpy(str,nom.c_str()); strip(str,'L',' '); 1038 if(str[0]=='y') return 2*NVar(); 1039 if(str[0]=='o') return 2*NVar()+2; 1040 if(str[0]=='x') {sscanf(str,"x%d",&k); return k;} 1041 if(str[0]=='e') 1042 if(str[1]=='y') return 2*NVar()+1; 1043 else if(str[1]=='x') {sscanf(str,"ex%d",&k); return NVar()+k;} 1044 return -1; 1045 } 1046 1047 string GeneralFitData::ColumnName(int k) const 1048 { 1049 if(k==2*NVar()) return string("y"); 1050 else if(k==2*NVar()+1) return string("ey"); 1051 else if(k==2*NVar()+2) return string("ok"); 1052 else if(k<0 || k>=2*NVar()+3) return string(""); 1053 1054 char str[64] = ""; 1055 if(k<NVar()) sprintf(str,"x%d",k); 1056 else if(k<2*NVar()) sprintf(str,"ex%d",k-NVar()); 1057 return string(str); 1058 } 1059 1060 //++ 878 1061 string GeneralFitData::VarList_C(const char* nomx) const 879 1062 // … … 911 1094 } 912 1095 913 //////////////////////////////////////////////////////////////////////914 //++915 // int inline int GetSpaceFree() const916 // Retourne la place restante dans la structure (nombre de917 // donnees que l'on peut encore stoquer).918 //--919 //++920 // inline int NVar() const921 // Retourne le nombre de variables Xi922 //--923 //++924 // inline int NData()925 // Retourne le nombre de donnees926 //--927 //++928 // inline int NDataGood() const929 // Retourne le nombre de bonnes donnees (utilisees pour le fit)930 //--931 //++932 // inline int NDataAlloc() const933 // Retourne la place maximale allouee pour les donnees934 //--935 //++936 // inline unsigned short int IsValid(int i) const937 // Retourne 1 si point valide, sinon 0938 //--939 //++940 // inline bool HasXErrors()941 // Retourne ``true'' si il y a des erreurs sur les variables942 // d'abscisse, ``false'' sinon.943 //--944 //++945 // inline double X1(int i) const946 // Retourne l'abscisse pour 1 dimension (y=f(x)) donnee I947 //--948 //++949 // inline double X(int i) const950 // Retourne la 1er abscisse (X) pour (v=f(x,y,z,...)) donnee I951 //--952 //++953 // inline double Y(int i) const954 // Retourne la 2sd abscisse (Y) pour (v=f(x,y,z,...)) donnee I955 //--956 //++957 // inline double Z(int i) const958 // Retourne la 3ieme abscisse (Z) pour (v=f(x,y,z,...)) donnee I959 //--960 //++961 // inline double Absc(int j,int i) const962 // Retourne la Jieme abscisse (Xj) pour (v=f(x0,x1,x2,...)) donnee I963 //--964 //++965 // inline double Val(int i) const966 // Retourne la valeur de la Ieme donnee967 //--968 //++969 // inline double EX1(int i) const970 // Retourne l'erreur (dx) sur l'abscisse pour 1 dimension (y=f(x)) donnee I971 //--972 //++973 // inline double EX(int i) const974 // Retourne l'erreur (dx) sur la 1er abscisse (X) pour (v=f(x,y,z,...)) donnee I975 //--976 //++977 // inline double EY(int i) const978 // Retourne l'erreur (dy) sur la 2sd abscisse (Y) pour (v=f(x,y,z,...)) donnee I979 //--980 //++981 // inline double EZ(int i) const982 // Retourne l'erreur (dz) sur la 3ieme abscisse (Z) pour (v=f(x,y,z,...)) donnee I983 //--984 //++985 // inline double EAbsc(int j,int i) const986 // Retourne l'erreur (dxj) sur la Jieme abscisse (Xj) pour (v=f(x0,x1,x2,...)) donnee I987 //--988 //++989 // inline double EVal(int i) const {return mErr[i];}990 // Retourne l'erreur de la Ieme donnee991 //--992 993 1096 /////////////////////////////////////////////////////////// 994 1097 // -------------------------------------------------------- … … 997 1100 /////////////////////////////////////////////////////////// 998 1101 999 FIO_GeneralFitData::FIO_GeneralFitData() 1000 { 1001 dobj=new GeneralFitData; 1002 ownobj=true; 1003 } 1004 1005 FIO_GeneralFitData::FIO_GeneralFitData(string const & filename) 1006 { 1007 dobj=new GeneralFitData; 1008 ownobj=true; 1009 Read(filename); 1010 } 1011 1012 FIO_GeneralFitData::FIO_GeneralFitData(const GeneralFitData & obj) 1013 { 1014 dobj = new GeneralFitData(obj); 1015 ownobj=true; 1016 } 1017 1018 FIO_GeneralFitData::FIO_GeneralFitData(GeneralFitData * obj) 1019 { 1020 dobj = obj; 1021 ownobj=false; 1022 } 1023 1024 FIO_GeneralFitData::~FIO_GeneralFitData() 1025 { 1026 if (ownobj && dobj) delete dobj; 1027 } 1028 1029 AnyDataObj* FIO_GeneralFitData::DataObj() 1030 { 1031 return(dobj); 1032 } 1033 1034 void FIO_GeneralFitData::ReadSelf(PInPersist& is) 1102 1103 void ObjFileIO<GeneralFitData>::ReadSelf(PInPersist& is) 1035 1104 { 1036 1105 char strg[256]; … … 1076 1145 } 1077 1146 1078 void FIO_GeneralFitData::WriteSelf(POutPersist& os) const1147 void ObjFileIO<GeneralFitData>::WriteSelf(POutPersist& os) const 1079 1148 { 1080 1149 if (dobj == NULL) return; … … 1114 1183 return; 1115 1184 } 1185 1186 1187 #ifdef __CXX_PRAGMA_TEMPLATES__ 1188 #pragma define_template ObjFileIO<GeneralFitData> 1189 #endif 1190 1191 #if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES) 1192 template class ObjFileIO<GeneralFitData>; 1193 #endif -
trunk/SophyaLib/NTools/generaldata.h
r307 r490 4 4 #define GENERALDATA_SEEN 5 5 6 #include "objfio.h" 7 #include <iostream.h> 6 8 #include "pexceptions.h" 7 9 #include "ppersist.h" 10 #include "ntupintf.h" 8 11 #include "poly.h" 9 #include "anydataobj.h"10 12 11 13 namespace PlanckDPC { 12 14 13 15 class GeneralFit; 14 class FIO_GeneralFitData;15 16 16 17 //================================================================ … … 18 19 //================================================================ 19 20 20 class GeneralFitData : public AnyDataObj {21 class GeneralFitData : public AnyDataObj , public NTupleInterface { 21 22 friend class GeneralFit; 22 friend class FIO_GeneralFitData;23 friend class ObjFileIO<GeneralFitData>; 23 24 public: 24 25 enum {Def_ErrF = 1, Def_ErrX = 0}; … … 63 64 void PrintData(int i1,int i2); 64 65 void PrintData(); 66 void Show(ostream& os) const; 67 inline void Show() const {Show(cout);} 65 68 66 69 inline int GetSpaceFree() const { return mNDataAlloc - mNData; } … … 103 106 {if(i>=0 && i<mNData) return mErr[i]; else return 0.;} 104 107 105 r_8* GetVec(int n, r_8* ret=NULL) const 106 r_4* GetVecR4(int n, r_4* ret=NULL) const 107 int GetM inMax(int var,int& imin,int& imax);108 int GetM inMax(int var,double& min,double& max);108 r_8* GetVec(int n, r_8* ret=NULL) const; 109 r_4* GetVecR4(int n, r_4* ret=NULL) const; 110 int GetMnMx(int var,int& imin,int& imax) const; 111 int GetMnMx(int var,double& min,double& max) const; 109 112 int GetMeanSigma(int var,double& mean,double& sigma,double min=1.,double max=-1.); 110 113 int GetMoMeMed(int var,double& mode,double& mean,double& median, … … 115 118 GeneralFitData FitResidus(GeneralFit& gfit); 116 119 GeneralFitData FitFunction(GeneralFit& gfit); 117 string VarList_C(const char* nomx) const; 120 121 // Declaration de l interface NTuple 122 virtual uint_4 NbLines() const; 123 virtual uint_4 NbColumns() const; 124 virtual r_8 * GetLineD(int n) const; 125 virtual r_8 GetCell(int n, int k) const; 126 virtual r_8 GetCell(int n, string const & nom) const; 127 virtual void GetMinMax(int k, double& min, double& max) const; 128 virtual void GetMinMax(string const & nom, double& min, double& max) const; 129 virtual int ColumnIndex(string const & nom) const; 130 virtual string ColumnName(int k) const; 131 virtual string VarList_C(const char* nomx=NULL) const; 118 132 119 133 protected: … … 134 148 }; 135 149 150 inline ostream& operator << (ostream& s, GeneralFitData const & g) 151 {g.Show(s); return(s);} 152 136 153 ///////////////////////////////////////////////////////////////////////// 137 154 // Classe pour la gestion de persistance 138 class FIO_GeneralFitData : public PPersist { 139 public: 140 FIO_GeneralFitData(); 141 FIO_GeneralFitData(string const & filename); 142 FIO_GeneralFitData(const GeneralFitData & obj); 143 FIO_GeneralFitData(GeneralFitData * obj); 144 virtual ~FIO_GeneralFitData(); 145 virtual AnyDataObj* DataObj(); 146 inline operator GeneralFitData() { return(*dobj); } 147 protected : 148 virtual void ReadSelf(PInPersist&); 149 virtual void WriteSelf(POutPersist&) const; 150 GeneralFitData * dobj; 151 bool ownobj; 152 }; 155 156 inline POutPersist& operator << (POutPersist& os, GeneralFitData & obj) 157 { ObjFileIO<GeneralFitData> fio(&obj); fio.Write(os); return(os); } 158 inline PInPersist& operator >> (PInPersist& is, GeneralFitData & obj) 159 { ObjFileIO<GeneralFitData> fio(&obj); fio.Read(is); return(is); } 160 161 // Classe pour la gestion de persistance 162 // ObjFileIO<GeneralFitData> 153 163 154 164 } // Fin du namespace -
trunk/SophyaLib/NTools/generalfit.cc
r307 r490 7 7 #include <string> 8 8 9 #if defined(__KCC__)10 using std::string ;11 #endif12 13 9 #include "pexceptions.h" 14 10 #include "generalfit.h" … … 41 37 : mNVar(nVar), mNPar(nPar) 42 38 { 43 DBASSERT( nVar > 0 && nPar > 0 );39 ASSERT( nVar > 0 && nPar > 0 ); 44 40 deltaParm = new double[nPar]; 45 41 tmpParm = new double[nPar]; … … 86 82 //-- 87 83 { 88 DBASSERT(numPar >= 0 && numPar < mNPar);84 ASSERT(numPar >= 0 && numPar < mNPar); 89 85 deltaParm[numPar] = d; 90 86 } … … 226 222 : mNPar(nPar) 227 223 { 228 DBASSERT( nPar>0 );224 ASSERT( nPar>0 ); 229 225 deltaParm = new double[nPar]; 230 226 END_CONSTRUCTOR … … 307 303 //-- 308 304 { 309 DBASSERT(numPar >= 0 && numPar < mNPar);305 ASSERT(numPar >= 0 && numPar < mNPar); 310 306 311 307 deltaParm[numPar] = d; … … 375 371 D (f->NPar()) 376 372 { 377 DBASSERT(mNVar>0 && mNPar>0);378 DBASSERT(mNPar<1000000);373 ASSERT(mNVar>0 && mNPar>0); 374 ASSERT(mNPar<1000000); 379 375 380 376 TRY { … … 418 414 D (f->NPar()) 419 415 { 420 DBASSERT( mNPar>0 );421 DBASSERT( mNPar < 1000000 );416 ASSERT( mNPar>0 ); 417 ASSERT( mNPar < 1000000 ); 422 418 423 419 TRY { … … 573 569 //-- 574 570 { 575 DBASSERT(n>=0 && n<mNPar);571 ASSERT(n>=0 && n<mNPar); 576 572 Eps(n) = (ep<=0.) ? EPS_FIT_MIN: ep; 577 573 if(debugLevel>0) cout<<"SetEps("<<n<<") = "<<Eps(n)<<endl; … … 616 612 //-- 617 613 { 618 DBASSERT( mFuncXi2 == NULL );619 DBASSERT( f != NULL );620 DBASSERT( f->NVar() == mNVar );621 DBASSERT( f->NPar() == mNPar );614 ASSERT( mFuncXi2 == NULL ); 615 ASSERT( f != NULL ); 616 ASSERT( f->NVar() == mNVar ); 617 ASSERT( f->NPar() == mNPar ); 622 618 mFunction = f; 623 619 if(debugLevel>0) cout<<"SetFunction "<<mFunction<<endl; … … 632 628 //-- 633 629 { 634 DBASSERT( mFunction == NULL );635 DBASSERT( f != NULL );636 DBASSERT( f->NPar() == mNPar );630 ASSERT( mFunction == NULL ); 631 ASSERT( f != NULL ); 632 ASSERT( f->NPar() == mNPar ); 637 633 mFuncXi2 = f; 638 634 if(debugLevel>0) cout<<"SetFuncXi2 "<<mFuncXi2<<endl; … … 646 642 //-- 647 643 { 648 DBASSERT( data->NVar()==mNVar || mFunction==NULL);644 ASSERT( data->NVar()==mNVar ); 649 645 mData = data; 650 646 mNddl = mData->NDataGood() - mNParFree; … … 661 657 //-- 662 658 { 663 DBASSERT(n>=0 && n<mNPar);659 ASSERT(n>=0 && n<mNPar); 664 660 665 661 Param(n) = value; … … 688 684 //-- 689 685 { 690 DBASSERT(n>=0 && n<mNPar);686 ASSERT(n>=0 && n<mNPar); 691 687 SetParam(n,value,step,min,max); 692 688 nameParam[n] = name; … … 700 696 //-- 701 697 { 702 DBASSERT(n>=0 && n<mNPar);698 ASSERT(n>=0 && n<mNPar); 703 699 Param(n) = value; 704 700 if(debugLevel) {cout<<"Set_Param "; PrintParm(n);} … … 713 709 //-- 714 710 { 715 DBASSERT(n>=0 && n<mNPar);711 ASSERT(n>=0 && n<mNPar); 716 712 if(step>0.) { 717 713 if( fixParam[n] ) { fixParam[n]=0; mNParFree++;} … … 734 730 //-- 735 731 { 736 DBASSERT(i>=0 && i<mNPar);732 ASSERT(i>=0 && i<mNPar); 737 733 if(val<0.) minStepDeriv(i) = Eps(i); 738 734 else minStepDeriv(i) = val; … … 759 755 //-- 760 756 { 761 DBASSERT(n>=0 && n<mNPar && max>min);757 ASSERT(n>=0 && n<mNPar && max>min); 762 758 763 759 minParam(n) = min; … … 778 774 //-- 779 775 { 780 DBASSERT(n>=0 && n<mNPar && maxParam(n)>minParam(n));776 ASSERT(n>=0 && n<mNPar && maxParam(n)>minParam(n)); 781 777 SetBound(n,minParam(n),maxParam(n)); 782 778 } … … 788 784 //-- 789 785 { 790 DBASSERT(n>=0 && n<mNPar);786 ASSERT(n>=0 && n<mNPar); 791 787 792 788 if( boundParam[n] ) { … … 814 810 //-- 815 811 { 816 DBASSERT(n>=0 && n<mNPar);812 ASSERT(n>=0 && n<mNPar); 817 813 818 814 Param(n) = v; … … 833 829 //-- 834 830 { 835 DBASSERT(n>=0 && n<mNPar);831 ASSERT(n>=0 && n<mNPar); 836 832 SetFix(n,Param(n)); 837 833 } … … 843 839 //-- 844 840 { 845 DBASSERT(n>=0 && n<mNPar);841 ASSERT(n>=0 && n<mNPar); 846 842 847 843 if( fixParam[n] ) { … … 873 869 //-- 874 870 { 875 DBASSERT(n>=0 && n<mNPar);871 ASSERT(n>=0 && n<mNPar); 876 872 return Param(n); 877 873 } … … 892 888 //-- 893 889 { 894 DBASSERT(n>=0 && n<mNPar);890 ASSERT(n>=0 && n<mNPar); 895 891 return errParam(n); 896 892 } … … 902 898 //-- 903 899 { 904 DBASSERT(i>=0 && i<mNPar && j>=0 && j<mNPar);900 ASSERT(i>=0 && i<mNPar && j>=0 && j<mNPar); 905 901 return ATGA(i,j); 906 902 } … … 913 909 //-- 914 910 { 915 DBASSERT(n>=0 && n<mNPar);911 ASSERT(n>=0 && n<mNPar); 916 912 return stepParam(n); 917 913 } … … 923 919 //-- 924 920 { 925 DBASSERT(n>=0 && n<mNPar);921 ASSERT(n>=0 && n<mNPar); 926 922 return maxParam(n); 927 923 } … … 933 929 //-- 934 930 { 935 DBASSERT(n>=0 && n<mNPar);931 ASSERT(n>=0 && n<mNPar); 936 932 return minParam(n); 937 933 } … … 986 982 //-- 987 983 { 988 DBASSERT(n>=0 && n<mNPar);984 ASSERT(n>=0 && n<mNPar); 989 985 990 986 cout<<"Par["<<n<<"] "<<nameParam[n] … … 1396 1392 //-- 1397 1393 { 1398 double c2 = - .1;1394 double c2 = -1.; 1399 1395 if(par==NULL) par = Param.Data(); 1400 1396 if( mData->NData() <= 0 ) {nddl = -100; return 0.;} … … 1622 1618 void GeneralFit::CheckSanity() 1623 1619 { 1624 DBASSERT( mData != NULL );1625 DBASSERT( mFunction != NULL || mFuncXi2 != NULL );1620 ASSERT( mData != NULL ); 1621 ASSERT( mFunction != NULL || mFuncXi2 != NULL ); 1626 1622 if( mFunction != NULL ) { 1627 DBASSERT( mFunction->NVar() == mNVar );1628 DBASSERT( mData->NVar() == mNVar );1623 ASSERT( mFunction->NVar() == mNVar ); 1624 ASSERT( mData->NVar() == mNVar ); 1629 1625 } 1630 DBASSERT( mNParFree > 0 && mNParFree <= mNPar );1631 DBASSERT( mNParBound >= 0 && mNParBound <= mNPar );1632 DBASSERT( mNParFree <= mData->NDataGood() );1626 ASSERT( mNParFree > 0 && mNParFree <= mNPar ); 1627 ASSERT( mNParBound >= 0 && mNParBound <= mNPar ); 1628 ASSERT( mNParFree <= mData->NDataGood() ); 1633 1629 } 1634 1630 … … 1638 1634 // D = (max-min)/Pi 1639 1635 { 1640 // DBASSERT(i>=0 && i<mNPar);1636 // ASSERT(i>=0 && i<mNPar); 1641 1637 C(i) = D(i) = 0.; 1642 1638 if( !boundParam[i] || fixParam[i] ) return; … … 1661 1657 // tr = tan( (p-C)/D ) 1662 1658 { 1663 // DBASSERT(i>=0 && i<mNPar);1659 // ASSERT(i>=0 && i<mNPar); 1664 1660 double tr = p; 1665 1661 if(boundParam[i]) tr = tan((p-C(i))/D(i)); … … 1692 1688 // p = C+D*atan(tr) 1693 1689 { 1694 // DBASSERT(i>=0 && i<mNPar);1690 // ASSERT(i>=0 && i<mNPar); 1695 1691 double p = tr; 1696 1692 if(boundParam[i]) p = C(i)+D(i)*atan(tr); … … 1724 1720 // attention: df/dp = (1+tr**2)/D * dF/dtr = coeff * dF/dtr 1725 1721 { 1726 // DBASSERT(i>=0 && i<mNPar);1722 // ASSERT(i>=0 && i<mNPar); 1727 1723 double coeff = 1.; 1728 1724 if(boundParam[i]) coeff = (1.+tr*tr)/D(i); … … 1756 1752 // attention: df/dtr = D/(1+tr**2) * dF/dp = coeff * dF/dp 1757 1753 { 1758 // DBASSERT(i>=0 && i<mNPar);1754 // ASSERT(i>=0 && i<mNPar); 1759 1755 double coeff = 1.; 1760 1756 if(boundParam[i]) coeff = D(i)/(1.+tr*tr); -
trunk/SophyaLib/NTools/hisprof.cc
r308 r490 303 303 /////////////////////////////////////////////////////////// 304 304 305 FIO_HProf::FIO_HProf() 306 { 307 dobj=new HProf; 308 ownobj=true; 309 } 310 311 FIO_HProf::FIO_HProf(string const & filename) 312 { 313 dobj=new HProf; 314 ownobj=true; 315 Read(filename); 316 } 317 318 FIO_HProf::FIO_HProf(const HProf & obj) 319 { 320 dobj = new HProf(obj); 321 ownobj=true; 322 } 323 324 FIO_HProf::FIO_HProf(HProf * obj) 325 { 326 dobj = obj; 327 ownobj=false; 328 } 329 330 FIO_HProf::~FIO_HProf() 331 { 332 if (ownobj && dobj) delete dobj; 333 } 334 335 AnyDataObj* FIO_HProf::DataObj() 336 { 337 return(dobj); 338 } 339 340 void FIO_HProf::ReadSelf(PInPersist& is) 305 306 void ObjFileIO<HProf>::ReadSelf(PInPersist& is) 341 307 { 342 308 char strg[256]; … … 365 331 366 332 // Ecriture de l'histogramme 367 FIO_Histo fio_h((Histo&)*dobj); 368 fio_h.Read(is); 369 333 is >> (Histo&)(*dobj); 370 334 return; 371 335 } 372 336 373 void FIO_HProf::WriteSelf(POutPersist& os) const337 void ObjFileIO<HProf>::WriteSelf(POutPersist& os) const 374 338 { 375 339 if (dobj == NULL) return; … … 396 360 397 361 // Ecriture de l'histogramme 398 FIO_Histo fio_h((Histo&)*dobj); 399 fio_h.Write(os); 362 // FIO_Histo fio_h((Histo&)*dobj); 363 // fio_h.Write(os); 364 os << (Histo&)(*dobj); 400 365 401 366 return; 402 367 } 368 369 #ifdef __CXX_PRAGMA_TEMPLATES__ 370 #pragma define_template ObjFileIO<HProf> 371 #endif 372 373 #if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES) 374 template class ObjFileIO<HProf>; 375 #endif -
trunk/SophyaLib/NTools/hisprof.h
r307 r490 11 11 12 12 class HProf : public Histo { 13 friend class FIO_HProf;13 friend class ObjFileIO<HProf>; 14 14 public: 15 15 … … 65 65 }; 66 66 67 ///////////////////////////////////////////////////////////////////////// 67 68 inline POutPersist& operator << (POutPersist& os, HProf & obj) 69 { ObjFileIO<HProf> fio(&obj); fio.Write(os); return(os); } 70 inline PInPersist& operator >> (PInPersist& is, HProf & obj) 71 { ObjFileIO<HProf> fio(&obj); fio.Read(is); return(is); } 68 72 // Classe pour la gestion de persistance 69 class FIO_HProf : public PPersist { 70 public: 71 FIO_HProf(); 72 FIO_HProf(string const & filename); 73 FIO_HProf(const HProf & obj); 74 FIO_HProf(HProf * obj); 75 virtual ~FIO_HProf(); 76 virtual AnyDataObj* DataObj(); 77 inline operator HProf() { return(*dobj); } 78 protected : 79 virtual void ReadSelf(PInPersist&); 80 virtual void WriteSelf(POutPersist&) const; 81 HProf * dobj; 82 bool ownobj; 83 }; 73 // ObjFileIO<HProf> 74 84 75 85 76 } // Fin du namespace -
trunk/SophyaLib/NTools/history_eros
r253 r490 2 2 -----------> cspline.cc 3 3 Repository revision: 1.5 /projects/Eros/CVSEros/CodeCxx/Outils/cspline.cc,v 4 OK 1.5 4 5 -----------> cspline.h 5 6 Repository revision: 1.4 /projects/Eros/CVSEros/CodeCxx/Outils/cspline.h,v 7 OK 1.4 6 8 -----------> cvector.cc 7 9 Repository revision: 1.8 /projects/Eros/CVSEros/CodeCxx/Outils/cvector.cc,v 10 OK 1.8 8 11 -----------> cvector.h 9 12 Repository revision: 1.7 /projects/Eros/CVSEros/CodeCxx/Outils/cvector.h,v 13 OK 1.7 10 14 -----------> datacards.cc 11 15 Repository revision: 1.18 /projects/Eros/CVSEros/CodeCxx/Outils/datacards.cc,v 16 OK 1.18 12 17 -----------> datacards.h 13 18 Repository revision: 1.10 /projects/Eros/CVSEros/CodeCxx/Outils/datacards.h,v 19 MAJ 1.11 (pour namespace std de KCC) 14 20 -----------> datatypes.cc 15 21 Repository revision: 1.5 /projects/Eros/CVSEros/CodeCxx/Outils/datatypes.cc,v 22 OK 1.5 16 23 -----------> datatypes.h 17 24 Repository revision: 1.4 /projects/Eros/CVSEros/CodeCxx/Outils/datatypes.h,v 25 OK 1.4 18 26 -----------> dates.cc 19 27 Repository revision: 1.11 /projects/Eros/CVSEros/CodeCxx/Outils/dates.cc,v 28 OK 1.11 20 29 -----------> dates.h 21 30 Repository revision: 1.9 /projects/Eros/CVSEros/CodeCxx/Outils/dates.h,v 31 MAJ 1.10 22 32 -----------> difeq.cc 23 33 Repository revision: 1.9 /projects/Eros/CVSEros/CodeCxx/Outils/difeq.cc,v 34 OK 1.9 24 35 -----------> difeq.h 25 36 Repository revision: 1.6 /projects/Eros/CVSEros/CodeCxx/Outils/difeq.h,v 37 OK 1.6 26 38 -----------> dvlist.cc 27 39 Repository revision: 1.9 /projects/Eros/CVSEros/CodeCxx/Outils/dvlist.cc,v 40 OK 1.9 28 41 -----------> dvlist.h 29 42 Repository revision: 1.14 /projects/Eros/CVSEros/CodeCxx/Outils/dvlist.h,v 43 MAJ 1.16 30 44 -----------> fct1dfit.cc 31 45 Repository revision: 1.7 /projects/Eros/CVSEros/CodeCxx/Outils/fct1dfit.cc,v 46 OK 1.7 32 47 -----------> fct1dfit.h 33 48 Repository revision: 1.4 /projects/Eros/CVSEros/CodeCxx/Outils/fct1dfit.h,v 49 OK 1.4 34 50 -----------> fct2dfit.cc 35 51 Repository revision: 1.8 /projects/Eros/CVSEros/CodeCxx/Outils/fct2dfit.cc,v 52 MAJ 1.9 36 53 -----------> fct2dfit.h 37 54 Repository revision: 1.4 /projects/Eros/CVSEros/CodeCxx/Outils/fct2dfit.h,v 55 OK 1.4 38 56 -----------> generaldata.cc 39 57 Repository revision: 1.6 /projects/Eros/CVSEros/CodeCxx/Outils/generaldata.cc,v 58 MAJ 1.9 40 59 -----------> generaldata.h 41 60 Repository revision: 1.4 /projects/Eros/CVSEros/CodeCxx/Outils/generaldata.h,v 61 MAJ 1.5 42 62 -----------> generalfit.cc 43 63 Repository revision: 1.47 /projects/Eros/CVSEros/CodeCxx/Outils/generalfit.cc,v 64 MAJ 1.51 44 65 -----------> generalfit.h 45 66 Repository revision: 1.20 /projects/Eros/CVSEros/CodeCxx/Outils/generalfit.h,v 67 OK 1.20 46 68 -----------> hisprof.cc 47 69 Repository revision: 1.3 /projects/Eros/CVSEros/CodeCxx/Outils/hisprof.cc,v 70 OK 1.3 48 71 -----------> hisprof.h 49 72 Repository revision: 1.3 /projects/Eros/CVSEros/CodeCxx/Outils/hisprof.h,v 73 OK 1.3 50 74 -----------> histos.cc 51 75 Repository revision: 1.27 /projects/Eros/CVSEros/CodeCxx/Outils/histos.cc,v 76 OK 1.27 52 77 -----------> histos.h 53 78 Repository revision: 1.19 /projects/Eros/CVSEros/CodeCxx/Outils/histos.h,v 79 OK 1.19 54 80 -----------> histos2.cc 55 81 Repository revision: 1.17 /projects/Eros/CVSEros/CodeCxx/Outils/histos2.cc,v 82 MAJ 1.19 56 83 -----------> histos2.h 57 84 Repository revision: 1.15 /projects/Eros/CVSEros/CodeCxx/Outils/histos2.h,v 85 MAJ 1.16 58 86 -----------> integ.cc 59 87 Repository revision: 1.8 /projects/Eros/CVSEros/CodeCxx/Outils/integ.cc,v 88 OK 1.8 60 89 -----------> integ.h 61 90 Repository revision: 1.6 /projects/Eros/CVSEros/CodeCxx/Outils/integ.h,v 91 MAJ 1.7 62 92 -----------> linfit.cc 63 93 Repository revision: 1.4 /projects/Eros/CVSEros/CodeCxx/Outils/linfit.cc,v 94 OK 1.4 64 95 -----------> linfit.h 65 96 Repository revision: 1.7 /projects/Eros/CVSEros/CodeCxx/Outils/linfit.h,v 97 OK 1.7 66 98 -----------> matrix.cc 67 99 Repository revision: 1.17 /projects/Eros/CVSEros/CodeCxx/Outils/matrix.cc,v 100 MAJ 1.18 68 101 -----------> matrix.h 69 102 Repository revision: 1.8 /projects/Eros/CVSEros/CodeCxx/Outils/matrix.h,v 103 OK 1.8 70 104 -----------> median.cc 71 105 Repository revision: 1.1 /projects/Eros/CVSEros/CodeCxx/Outils/median.cc,v 106 OK 1.1 72 107 -----------> median.h 73 108 Repository revision: 1.1 /projects/Eros/CVSEros/CodeCxx/Outils/median.h,v 109 OK 1.1 74 110 -----------> nbconst.h 75 111 Repository revision: 1.6 /projects/Eros/CVSEros/CodeCxx/Outils/nbconst.h,v 112 MAJ 1.7 juste un commentaire /**/ en // 113 114 -----------> ntupintf.cc 115 Repository revision: 1.3 /projects/Eros/CVSEros/CodeCxx/Outils/ntupintf.h,v 116 OK - ajoute 117 -----------> ntupintf.h 118 Repository revision: 1.4 /projects/Eros/CVSEros/CodeCxx/Outils/ntupintf.h,v 119 OK - ajoute 76 120 -----------> ntuple.cc 77 121 Repository revision: 1.12 /projects/Eros/CVSEros/CodeCxx/Outils/ntuple.cc,v 122 OK 1.19 78 123 -----------> ntuple.h 124 MAJ 1.15 79 125 Repository revision: 1.9 /projects/Eros/CVSEros/CodeCxx/Outils/ntuple.h,v 80 126 -----------> outilsinit.cc 81 127 Repository revision: 1.2 /projects/Eros/CVSEros/CodeCxx/Outils/outilsinit.cc,v 128 1.3 Ajout de XNTuple, pas fait 82 129 -----------> outilsinit.h 83 130 Repository revision: 1.3 /projects/Eros/CVSEros/CodeCxx/Outils/outilsinit.h,v 131 OK 1.3 84 132 -----------> pclassids.h 85 133 Repository revision: 1.8 /projects/Eros/CVSEros/CodeCxx/Outils/pclassids.h,v 134 MAJ 1.9 ClassId_XNTuple 86 135 -----------> peida.h 87 136 Repository revision: 1.4 /projects/Eros/CVSEros/CodeCxx/Outils/peida.h,v 137 OK 1.4 88 138 -----------> pemath.h 89 139 Repository revision: 1.2 /projects/Eros/CVSEros/CodeCxx/Outils/pemath.h,v 140 OK 1.2 90 141 -----------> perandom.cc 91 142 Repository revision: 1.11 /projects/Eros/CVSEros/CodeCxx/Outils/perandom.cc,v 143 OK 1.11 92 144 -----------> perandom.h 93 145 Repository revision: 1.8 /projects/Eros/CVSEros/CodeCxx/Outils/perandom.h,v 146 OK 1.8 94 147 -----------> poly.cc 95 148 Repository revision: 1.10 /projects/Eros/CVSEros/CodeCxx/Outils/poly.cc,v 149 MAJ 1.12 96 150 -----------> poly.h 97 151 Repository revision: 1.8 /projects/Eros/CVSEros/CodeCxx/Outils/poly.h,v 152 OK 1.8 98 153 -----------> pversion.cc 99 154 Repository revision: 1.4 /projects/Eros/CVSEros/CodeCxx/Outils/pversion.cc,v 155 OK 1.4 100 156 -----------> pversion.h 101 157 Repository revision: 1.37 /projects/Eros/CVSEros/CodeCxx/Outils/pversion.h,v 158 OK 1.42 rien a faire - numero de version 159 102 160 -----------> rk4cdifeq.cc 103 161 Repository revision: 1.4 /projects/Eros/CVSEros/CodeCxx/Outils/rk4cdifeq.cc,v 162 OK 1.4 104 163 -----------> rk4cdifeq.h 105 164 Repository revision: 1.2 /projects/Eros/CVSEros/CodeCxx/Outils/rk4cdifeq.h,v 165 OK 1.2 106 166 -----------> simplesort.cc 107 167 Repository revision: 1.9 /projects/Eros/CVSEros/CodeCxx/Outils/simplesort.cc,v 168 OK 1.9 108 169 -----------> simplesort.h 109 170 Repository revision: 1.11 /projects/Eros/CVSEros/CodeCxx/Outils/simplesort.h,v 171 MAJ 1.12 KCC std 172 110 173 -----------> simps2d.h 111 174 Repository revision: 1.1 /projects/Eros/CVSEros/CodeCxx/Outils/simps2d.h,v 175 OK 1.1 112 176 -----------> tabmath.cc 113 177 Repository revision: 1.3 /projects/Eros/CVSEros/CodeCxx/Outils/tabmath.cc,v 178 OK 1.3 114 179 -----------> tabmath.h 115 180 Repository revision: 1.2 /projects/Eros/CVSEros/CodeCxx/Outils/tabmath.h,v 181 OK 1.2 116 182 -----------> utils.cc 117 183 Repository revision: 1.9 /projects/Eros/CVSEros/CodeCxx/Outils/utils.cc,v 184 OK 1.9 118 185 -----------> utils.h 119 186 Repository revision: 1.14 /projects/Eros/CVSEros/CodeCxx/Outils/utils.h,v 187 OK 1.15 KCC std 120 188 121 189 NTools from Images++ 122 190 -----------> cimage.cc 123 191 Repository revision: 1.36 /projects/Eros/CVSEros/CodeCxx/Images/cimage.cc,v 192 MAJ 1.38 124 193 -----------> cimage.h 125 194 Repository revision: 1.22 /projects/Eros/CVSEros/CodeCxx/Images/cimage.h,v 195 OK 1.22 126 196 -----------> dynccd.cc 127 197 Repository revision: 1.20 /projects/Eros/CVSEros/CodeCxx/Images/dynccd.cc,v 198 OK 1.20 128 199 -----------> dynccd.h 129 200 Repository revision: 1.11 /projects/Eros/CVSEros/CodeCxx/Images/dynccd.h,v 201 OK 1.11 130 202 -----------> imageop.cc 131 203 Repository revision: 1.27 /projects/Eros/CVSEros/CodeCxx/Images/imageop.cc,v 204 MAJ 1.28 NoiseFiltImage 132 205 -----------> imageop.h 133 206 Repository revision: 1.17 /projects/Eros/CVSEros/CodeCxx/Images/imageop.h,v 207 MAJ 1.18 134 208 -----------> rzimage.cc 135 209 Repository revision: 1.29 /projects/Eros/CVSEros/CodeCxx/Images/rzimage.cc,v 210 OK 1.29 136 211 -----------> rzimage.h 137 212 Repository revision: 1.13 /projects/Eros/CVSEros/CodeCxx/Images/rzimage.h,v 213 OK 1.13 138 214 -----------> rzvect.h 139 215 Repository revision: 1.6 /projects/Eros/CVSEros/CodeCxx/Images/rzvect.h,v 216 OK 1.6 217 218 -
trunk/SophyaLib/NTools/histos.cc
r307 r490 1 1 // 2 // $Id: histos.cc,v 1. 3 1999-05-19 15:57:59ansari Exp $2 // $Id: histos.cc,v 1.4 1999-10-21 15:25:45 ansari Exp $ 3 3 // 4 4 … … 1737 1737 /////////////////////////////////////////////////////////// 1738 1738 1739 FIO_Histo::FIO_Histo() 1740 { 1741 dobj=new Histo; 1742 ownobj=true; 1743 } 1744 1745 FIO_Histo::FIO_Histo(string const & filename) 1746 { 1747 dobj=new Histo; 1748 ownobj=true; 1749 Read(filename); 1750 } 1751 1752 FIO_Histo::FIO_Histo(const Histo & obj) 1753 { 1754 dobj = new Histo(obj); 1755 ownobj=true; 1756 } 1757 1758 FIO_Histo::FIO_Histo(Histo * obj) 1759 { 1760 dobj = obj; 1761 ownobj=false; 1762 } 1763 1764 FIO_Histo::~FIO_Histo() 1765 { 1766 if (ownobj && dobj) delete dobj; 1767 } 1768 1769 AnyDataObj* FIO_Histo::DataObj() 1770 { 1771 return(dobj); 1772 } 1773 1774 void FIO_Histo::ReadSelf(PInPersist& is) 1739 void ObjFileIO<Histo>::ReadSelf(PInPersist& is) 1775 1740 { 1776 1741 char strg[256]; … … 1813 1778 } 1814 1779 1815 void FIO_Histo::WriteSelf(POutPersist& os) const1780 void ObjFileIO<Histo>::WriteSelf(POutPersist& os) const 1816 1781 { 1817 1782 if (dobj == NULL) return; … … 1856 1821 return; 1857 1822 } 1823 1824 #ifdef __CXX_PRAGMA_TEMPLATES__ 1825 #pragma define_template ObjFileIO<Histo> 1826 #endif 1827 1828 #if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES) 1829 template class ObjFileIO<Histo>; 1830 #endif -
trunk/SophyaLib/NTools/histos.h
r307 r490 1 1 // This may look like C code, but it is really -*- C++ -*- 2 2 // 3 // $Id: histos.h,v 1. 2 1999-05-19 15:58:00ansari Exp $3 // $Id: histos.h,v 1.3 1999-10-21 15:25:47 ansari Exp $ 4 4 // 5 5 … … 7 7 #define HISTOS_SEEN 8 8 9 #include "objfio.h" 10 #include <iostream.h> 9 11 #include <stdio.h> 10 12 #include "peida.h" … … 18 20 19 21 class Histo : public AnyDataObj { 20 friend class FIO_Histo;22 friend class ObjFileIO<Histo>; 21 23 public: 22 24 … … 156 158 }; 157 159 158 ///////////////////////////////////////////////////////////////////////// 160 161 inline POutPersist& operator << (POutPersist& os, Histo & obj) 162 { ObjFileIO<Histo> fio(&obj); fio.Write(os); return(os); } 163 inline PInPersist& operator >> (PInPersist& is, Histo & obj) 164 { ObjFileIO<Histo> fio(&obj); fio.Read(is); return(is); } 165 159 166 // Classe pour la gestion de persistance 160 class FIO_Histo : public PPersist { 161 public: 162 FIO_Histo(); 163 FIO_Histo(string const & filename); 164 FIO_Histo(const Histo & obj); 165 FIO_Histo(Histo * obj); 166 virtual ~FIO_Histo(); 167 virtual AnyDataObj* DataObj(); 168 inline operator Histo() { return(*dobj); } 169 protected : 170 virtual void ReadSelf(PInPersist&); 171 virtual void WriteSelf(POutPersist&) const; 172 Histo * dobj; 173 bool ownobj; 174 }; 167 // ObjFileIO<Histo> 168 175 169 176 170 } // Fin du namespace -
trunk/SophyaLib/NTools/histos2.cc
r308 r490 45 45 , hprojx(NULL), hprojy(NULL) 46 46 { 47 DBASSERT(nxBin>0 && nyBin>0 && xMin<xMax && yMin<yMax);47 ASSERT(nxBin>0 && nyBin>0 && xMin<xMax && yMin<yMax); 48 48 for(int i=0;i<3;i++) for(int j=0;j<3;j++) over[i][j]=0.; 49 49 Zero(); … … 663 663 int i,j; 664 664 v.Realloc(nx,ny); 665 if(!err2) for(i=0;i<nx;i++) 666 for(j=0;j<ny;j++) { v(i,j) = 0.; return;} 667 for(i=0;i<nx;i++) 668 for(j=0;j<ny;j++) v(i,j) = Error2(i,j); 665 if(!err2) 666 {for(i=0;i<nx;i++) for(j=0;j<ny;j++) v(i,j) = 0.; return;} 667 for(i=0;i<nx;i++) for(j=0;j<ny;j++) v(i,j) = Error2(i,j); 669 668 return; 670 669 } … … 678 677 int i,j; 679 678 v.Realloc(nx,ny); 680 if(!err2) for(i=0;i<nx;i++) 681 for(j=0;j<ny;j++) { v(i,j) = 0.; return;} 682 for(i=0;i<nx;i++) 683 for(j=0;j<ny;j++) v(i,j) = Error(i,j); 679 if(!err2) 680 {for(i=0;i<nx;i++) for(j=0;j<ny;j++) v(i,j) = 0.; return;} 681 for(i=0;i<nx;i++) for(j=0;j<ny;j++) v(i,j) = Error(i,j); 684 682 return; 685 683 } … … 1786 1784 /////////////////////////////////////////////////////////// 1787 1785 1788 FIO_Histo2D::FIO_Histo2D() 1789 { 1790 dobj=new Histo2D; 1791 ownobj=true; 1792 } 1793 1794 FIO_Histo2D::FIO_Histo2D(string const & filename) 1795 { 1796 dobj=new Histo2D; 1797 ownobj=true; 1798 Read(filename); 1799 } 1800 1801 FIO_Histo2D::FIO_Histo2D(const Histo2D & obj) 1802 { 1803 dobj = new Histo2D(obj); 1804 ownobj=true; 1805 } 1806 1807 FIO_Histo2D::FIO_Histo2D(Histo2D * obj) 1808 { 1809 dobj = obj; 1810 ownobj=false; 1811 } 1812 1813 FIO_Histo2D::~FIO_Histo2D() 1814 { 1815 if (ownobj && dobj) delete dobj; 1816 } 1817 1818 AnyDataObj* FIO_Histo2D::DataObj() 1819 { 1820 return(dobj); 1821 } 1822 1823 void FIO_Histo2D::ReadSelf(PInPersist& is) 1786 1787 void ObjFileIO<Histo2D>::ReadSelf(PInPersist& is) 1824 1788 { 1825 1789 char strg[256]; … … 1879 1843 is.GetLine(strg, 255); 1880 1844 dobj->SetProjX(); 1881 FIO_Histofio_h(dobj->hprojx);1845 ObjFileIO<Histo> fio_h(dobj->hprojx); 1882 1846 fio_h.Read(is); 1883 1847 } … … 1885 1849 is.GetLine(strg, 255); 1886 1850 dobj->SetProjY(); 1887 FIO_Histofio_h(dobj->hprojy);1851 ObjFileIO<Histo> fio_h(dobj->hprojy); 1888 1852 fio_h.Read(is); 1889 1853 } … … 1893 1857 is.GetLine(strg, 255); 1894 1858 dobj->SetSliX(nslix); 1895 DBASSERT (nslix==dobj->NSliX());1859 ASSERT (nslix==dobj->NSliX()); 1896 1860 for(int j=0;j<dobj->NSliX();j++) 1897 { FIO_Histofio_h(dobj->HSliX(j)); fio_h.Read(is);}1861 {ObjFileIO<Histo> fio_h(dobj->HSliX(j)); fio_h.Read(is);} 1898 1862 } 1899 1863 if(nsliy>0) { 1900 1864 is.GetLine(strg, 255); 1901 1865 dobj->SetSliY(nsliy); 1902 DBASSERT (nsliy==dobj->NSliY());1866 ASSERT (nsliy==dobj->NSliY()); 1903 1867 for(int j=0;j<dobj->NSliY();j++) 1904 { FIO_Histofio_h(dobj->HSliY(j)); fio_h.Read(is);}1868 {ObjFileIO<Histo> fio_h(dobj->HSliY(j)); fio_h.Read(is);} 1905 1869 } 1906 1870 … … 1912 1876 dobj->SetBandX(min,max); 1913 1877 }} 1914 DBASSERT (nbanx==dobj->NBandX());1878 ASSERT (nbanx==dobj->NBandX()); 1915 1879 {for(int j=0; j<dobj->NBandX(); j++) { 1916 FIO_Histofio_h(dobj->HBandX(j));1880 ObjFileIO<Histo> fio_h(dobj->HBandX(j)); 1917 1881 fio_h.Read(is); 1918 1882 }} … … 1924 1888 dobj->SetBandY(min,max); 1925 1889 }} 1926 DBASSERT (nbany==dobj->NBandY());1890 ASSERT (nbany==dobj->NBandY()); 1927 1891 {for(int j=0; j<dobj->NBandY(); j++) { 1928 FIO_Histofio_h(dobj->HBandY(j));1892 ObjFileIO<Histo> fio_h(dobj->HBandY(j)); 1929 1893 fio_h.Read(is); 1930 1894 }} … … 1934 1898 } 1935 1899 1936 void FIO_Histo2D::WriteSelf(POutPersist& os) const1900 void ObjFileIO<Histo2D>::WriteSelf(POutPersist& os) const 1937 1901 { 1938 1902 if (dobj == NULL) return; … … 2010 1974 sprintf(strg,"Histo2D: Projection X"); 2011 1975 os.PutLine(strg); 2012 FIO_Histofio_h(dobj->hprojx); fio_h.Write(os);1976 ObjFileIO<Histo> fio_h(dobj->hprojx); fio_h.Write(os); 2013 1977 } 2014 1978 if(projy) { 2015 1979 sprintf(strg,"Histo2D: Projection Y"); 2016 1980 os.PutLine(strg); 2017 FIO_Histofio_h(dobj->hprojy); fio_h.Write(os);1981 ObjFileIO<Histo> fio_h(dobj->hprojy); fio_h.Write(os); 2018 1982 } 2019 1983 … … 2024 1988 for(int j=0;j<nslix;j++) { 2025 1989 Histo* h = dobj->HSliX(j); 2026 FIO_Histofio_h(h); fio_h.Write(os);1990 ObjFileIO<Histo> fio_h(h); fio_h.Write(os); 2027 1991 } 2028 1992 } … … 2032 1996 for(int j=0;j<nsliy;j++) { 2033 1997 Histo* h = dobj->HSliY(j); 2034 FIO_Histofio_h(h); fio_h.Write(os);1998 ObjFileIO<Histo> fio_h(h); fio_h.Write(os); 2035 1999 } 2036 2000 } … … 2047 2011 for(it = dobj->lbandx.begin(); it != dobj->lbandx.end(); it++) { 2048 2012 Histo* h = (*it).H; 2049 FIO_Histofio_h(h); fio_h.Write(os);2013 ObjFileIO<Histo> fio_h(h); fio_h.Write(os); 2050 2014 } 2051 2015 } … … 2060 2024 for(it = dobj->lbandy.begin(); it != dobj->lbandy.end(); it++) { 2061 2025 Histo* h = (*it).H; 2062 FIO_Histofio_h(h); fio_h.Write(os);2026 ObjFileIO<Histo> fio_h(h); fio_h.Write(os); 2063 2027 } 2064 2028 } … … 2066 2030 return; 2067 2031 } 2032 2033 2034 #ifdef __CXX_PRAGMA_TEMPLATES__ 2035 #pragma define_template ObjFileIO<Histo2D> 2036 #endif 2037 2038 #if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES) 2039 template class ObjFileIO<Histo2D>; 2040 #endif -
trunk/SophyaLib/NTools/histos2.h
r307 r490 23 23 24 24 class Histo2D : public AnyDataObj { 25 friend class FIO_Histo2D;25 friend class ObjFileIO<Histo2D>; 26 26 public: 27 27 … … 216 216 ///////////////////////////////////////////////////////////////////////// 217 217 // Classe pour la gestion de persistance 218 class FIO_Histo2D : public PPersist { 219 public: 220 FIO_Histo2D(); 221 FIO_Histo2D(string const & filename); 222 FIO_Histo2D(const Histo2D & obj); 223 FIO_Histo2D(Histo2D * obj); 224 virtual ~FIO_Histo2D(); 225 virtual AnyDataObj* DataObj(); 226 inline operator Histo2D() { return(*dobj); } 227 protected : 228 virtual void ReadSelf(PInPersist&); 229 virtual void WriteSelf(POutPersist&) const; 230 Histo2D * dobj; 231 bool ownobj; 232 }; 218 219 inline POutPersist& operator << (POutPersist& os, Histo2D & obj) 220 { ObjFileIO<Histo2D> fio(&obj); fio.Write(os); return(os); } 221 inline PInPersist& operator >> (PInPersist& is, Histo2D & obj) 222 { ObjFileIO<Histo2D> fio(&obj); fio.Read(is); return(is); } 223 224 // Classe pour la gestion de persistance 225 // ObjFileIO<Histo2D> 233 226 234 227 } // Fin du namespace -
trunk/SophyaLib/NTools/imageop.cc
r270 r490 528 528 529 529 } 530 531 /* Nouvelle-Fonction */ 532 //++ 533 ImageR4* NoiseFiltImage(ImageR4& img, ImageR4& filtre, DynCCD& dynccd) 534 // Calcule une image de bruit, a partir de "img" et de "dynccd" 535 // prenant en compte le filtre de convolution "filtre". 536 // L'image de bruit renvoyee contient les correlations de bruit entre 537 // pixels, du au filtrage (convolution) de l'image "img" par le 538 // filtre "filtre". 539 //-- 540 { 541 ImageR4* ImgBrt = NoiseImage(&img,&dynccd); 542 543 int i,j; 544 for (i=0; i<ImgBrt->XSize(); i++) 545 for (j=0; j<ImgBrt->YSize(); j++) (*ImgBrt)(i,j) =(*ImgBrt)(i,j) *(*ImgBrt)(i,j); 546 547 ImageR4 Filter2(filtre.XSize(), filtre.YSize()) ; 548 for (i=0; i<filtre.XSize(); i++) 549 for (j=0; j<filtre.YSize(); j++) (Filter2)(i,j) = filtre(i,j) * filtre(i,j); 550 551 ImageR4* out2; 552 out2 = new ImageR4(ImgBrt->XSize(), ImgBrt->YSize()); 553 FilterImage(ImgBrt, out2, &Filter2); 554 for (i=0; i<out2->XSize(); i++) 555 for (j=0; j<out2->YSize(); j++) (*out2)(i,j) =sqrt((*out2)(i,j)); 556 delete ImgBrt; 557 return(out2); 558 } 559 530 560 531 561 ////////////////////////////////////////////////////////////////////////////// -
trunk/SophyaLib/NTools/imageop.h
r220 r490 13 13 #include "cimage.h" 14 14 #include "cspline.h" 15 #include "dynccd.h" 15 16 16 17 template <class T> … … 49 50 Image<T> * FilterImage(Image<T> const * pim, Image<T> * pom, ImageR4 *matx); 50 51 52 // Calcul une image de bruit prenant en compte le filtre de convolution 53 ImageR4* NoiseFiltImage(ImageR4& img, ImageR4& filtre, DynCCD& dynccd); 54 51 55 /////////////////////////////////////////////////////////////////// 52 56 //// Filtre statistique d'images -
trunk/SophyaLib/NTools/integ.h
r307 r490 3 3 // integ.h 4 4 // 5 // $Id: integ.h,v 1. 3 1999-05-19 15:58:01ansari Exp $5 // $Id: integ.h,v 1.4 1999-10-21 15:25:49 ansari Exp $ 6 6 // 7 7 … … 12 12 #include "pexceptions.h" 13 13 #include <set> 14 #if defined(__KCC__)15 #include <set.h>16 #endif17 14 18 15 namespace PlanckDPC {class GeneralFunction;} -
trunk/SophyaLib/NTools/matrix.cc
r307 r490 1 // $Id: matrix.cc,v 1. 4 1999-05-19 15:58:02ansari Exp $1 // $Id: matrix.cc,v 1.5 1999-10-21 15:25:49 ansari Exp $ 2 2 3 3 #include "machdefs.h" … … 240 240 //-- 241 241 { 242 DBASSERT( b != 0. );242 ASSERT( b != 0. ); 243 243 double* p = data; 244 244 double* pEnd = data + ndata; … … 572 572 void Matrix::WriteSelf(POutPersist& s) const 573 573 { 574 DBASSERT(ndata == nr*nc);574 ASSERT(ndata == nr*nc); 575 575 s << nr << nc; 576 576 s.PutR8s(data, ndata); … … 582 582 s >> r >> c; 583 583 Realloc(r,c); 584 DBASSERT(ndata == nr*nc);584 ASSERT(ndata == nr*nc); 585 585 s.GetR8s(data, ndata); 586 586 } -
trunk/SophyaLib/NTools/ntuple.cc
r475 r490 2 2 #include <string.h> 3 3 4 #include "strutil.h" 4 5 #include "perrors.h" 5 6 #include "ntuple.h" … … 16 17 // 17 18 // Classe de ntuples 19 //-- 20 //++ 21 // Links Parents 22 // PPersist 23 // NTupleInterface 18 24 //-- 19 25 … … 35 41 //++ 36 42 NTuple::NTuple(int nvar, char** noms, int blk) 37 // 38 // Createur d'un ntuple de `nvar' variables dont les 39 // noms sont dans le tableau de cahines de caracteres `noms' 40 // avec `blk' d'evenements par blocks. 41 //-- 42 { 43 mNVar = mNEnt = mBlk = mNBlk = 0; 44 mVar = NULL; 45 mVarD = NULL; 46 mNames = NULL; 47 mInfo = NULL; 48 if (nvar <= 0) THROW(sizeMismatchErr); 49 mNVar = nvar; 50 mVar = new r_4[nvar]; 51 mVarD = new r_8[nvar]; 52 if (blk < 10) blk = 10; 53 mBlk = blk; 54 // On prend des noms de LENNAME char pour le moment 55 mNames = new char[nvar*LENNAME1]; 56 r_4* pt = new r_4[nvar*blk]; 57 mNBlk = 1; 58 mPtr.push_back(pt); 59 int i; 60 for(i=0; i<nvar; i++) 61 { 62 strncpy(mNames+i*LENNAME1, noms[i], LENNAME); 63 mNames[i*LENNAME1+LENNAME] = '\0'; 64 } 65 return; 43 // 44 // Createur d'un ntuple de `nvar' variables dont les 45 // noms sont dans le tableau de cahines de caracteres `noms' 46 // avec `blk' d'evenements par blocks. 47 //-- 48 { 49 mNVar = mNEnt = mBlk = mNBlk = 0; 50 mVar = NULL; 51 mVarD = NULL; 52 mNames = NULL; 53 mInfo = NULL; 54 if (nvar <= 0) THROW(sizeMismatchErr); 55 mNVar = nvar; 56 mVar = new r_4[nvar]; 57 mVarD = new r_8[nvar]; 58 if (blk < 10) blk = 10; 59 mBlk = blk; 60 // On prend des noms de LENNAME char pour le moment 61 mNames = new char[nvar*LENNAME1]; 62 r_4* pt = new r_4[nvar*blk]; 63 mNBlk = 1; 64 mPtr.push_back(pt); 65 int i; 66 for(i=0; i<nvar; i++) 67 { strncpy(mNames+i*LENNAME1, noms[i], LENNAME); 68 mNames[i*LENNAME1+LENNAME] = '\0'; } 69 return; 70 } 71 72 // cmv 8/10/99 73 //++ 74 NTuple::NTuple(const NTuple& NT) 75 // 76 // Createur par copie (clone). 77 //-- 78 : mNVar(0), mNEnt(0), mBlk(0), mNBlk(0) 79 , mVar(NULL), mVarD(NULL), mNames(NULL), mInfo(NULL) 80 { 81 if(NT.mNVar<=0) return; // cas ou NT est cree par defaut 82 mNVar = NT.mNVar; 83 mBlk = NT.mBlk; 84 mVar = new r_4[NT.mNVar]; 85 mVarD = new r_8[NT.mNVar]; 86 mNames = new char[NT.mNVar*LENNAME1]; 87 88 int i; 89 r_4* pt = new r_4[mNVar*mBlk]; 90 mNBlk = 1; mPtr.push_back(pt); 91 92 for(i=0;i<mNVar;i++) strcpy(mNames+i*LENNAME1,NT.NomIndex(i)); 93 94 if(NT.mInfo!=NULL) {mInfo = new DVList; *mInfo = *(NT.mInfo);} 95 96 if(NT.mNEnt<=0) return; 97 for(i=0;i<NT.mNEnt;i++) {r_4* x=NT.GetVec(i,NULL); Fill(x);} 98 99 return; 66 100 } 67 101 … … 79 113 mInfo = NULL; 80 114 PInPersist s(flnm); 81 Read(s); 115 ObjFileIO<NTuple> fiont(this); 116 fiont.Read(s); 82 117 } 83 118 … … 96 131 if (mInfo) delete mInfo; 97 132 int i; 98 for(i=0; i<mNBlk; i++) delete[] mPtr[i];133 if(mNBlk>0) for(i=0; i<mNBlk; i++) delete[] mPtr[i]; 99 134 mPtr.erase(mPtr.begin(), mPtr.end()); 100 135 mNVar = mNEnt = mBlk = mNBlk = 0; … … 102 137 mVarD = NULL; 103 138 mNames = NULL; 139 mInfo = NULL; 104 140 return; 141 } 142 143 /* --Methode-- cmv 08/10/99 */ 144 //++ 145 NTuple& NTuple::operator = (const NTuple& NT) 146 // 147 // Operateur egal (clone). 148 //-- 149 { 150 if(this == &NT) return *this; 151 Clean(); 152 if(NT.mNVar<=0) return *this; // cas ou NT est cree par defaut 153 mNVar = NT.mNVar; 154 mBlk = NT.mBlk; 155 mVar = new r_4[NT.mNVar]; 156 mVarD = new r_8[NT.mNVar]; 157 mNames = new char[NT.mNVar*LENNAME1]; 158 159 int i; 160 r_4* pt = new r_4[mNVar*mBlk]; 161 mNBlk = 1; mPtr.push_back(pt); 162 163 for(i=0;i<mNVar;i++) strcpy(mNames+i*LENNAME1,NT.NomIndex(i)); 164 165 if(NT.mInfo!=NULL) {mInfo = new DVList; *mInfo = *(NT.mInfo);} 166 167 if(NT.mNEnt<=0) return *this; 168 for(i=0;i<NT.mNEnt;i++) {r_4* x=NT.GetVec(i,NULL); Fill(x);} 169 170 // En fait il faudrait un createur par copie qui partage les donnees 171 // quand l'objet est temporaire... trop complique A FAIRE ! cmv. 172 return *this; 105 173 } 106 174 … … 167 235 } 168 236 169 /* --Methode-- */170 //++171 string NTuple::VarList_C(const char* nomx) const172 //173 // Retourne une chaine de caracteres avec la declaration des noms de174 // variables. si "nomx!=NULL" , des instructions d'affectation175 // a partir d'un tableau "nomx[i]" sont ajoutees.176 //--177 {178 string rets;179 int i;180 for(i=0; i<mNVar; i++) {181 if ( (i%5 == 0) && (i > 0) ) rets += ";";182 if (i%5 == 0) rets += "\ndouble ";183 else rets += ",";184 rets += mNames+i*LENNAME1;185 }186 rets += "; \n";187 if (nomx) {188 char buff[256];189 for(i=0; i<mNVar; i++) {190 sprintf(buff,"%s=%s[%d]; ", mNames+i*LENNAME1, nomx, i);191 rets += buff;192 if ( (i%3 == 0) && (i > 0) ) rets += "\n";193 }194 }195 196 return(rets);197 }198 237 199 238 /* --Methode-- */ … … 231 270 } 232 271 233 /* --Methode-- */ 234 //++ 235 void NTuple::GetMinMax(int k, float& min, float& max) const 272 273 274 /* --Methode-- */ 275 //++ 276 DVList& NTuple::Info() 277 // 278 // Renvoie une référence sur l'objet DVList Associé 279 //-- 280 { 281 if (mInfo == NULL) mInfo = new DVList; 282 return(*mInfo); 283 } 284 285 /* --Methode-- */ 286 //++ 287 void NTuple::Print(int num, int nmax) const 288 // 289 // Imprime `nmax' evenements a partir du numero `num'. 290 //-- 291 { 292 int i,j; 293 294 printf("Num "); 295 for(i=0; i<mNVar; i++) printf("%8s ", mNames+i*LENNAME1); 296 putchar('\n'); 297 298 if (nmax <= 0) nmax = 1; 299 if (num < 0) num = 0; 300 nmax += num; 301 if (nmax > mNEnt) nmax = mNEnt; 302 for(i=num; i<nmax; i++) { 303 GetVec(i, NULL); 304 printf("%6d ", i); 305 for(j=0; j<mNVar; j++) printf("%8g ", (float)mVar[j]); 306 putchar('\n'); 307 } 308 return; 309 } 310 311 /* --Methode-- */ 312 //++ 313 void NTuple::Show(ostream& os) const 314 // 315 // Imprime l'information generale sur le ntuple. 316 //-- 317 { 318 os << "NTuple: NVar= " << mNVar << " NEnt=" << mNEnt 319 << " (Blk Sz,Nb= " << mBlk << " ," << mNBlk << ")\n"; 320 os << " Variables Min Max \n"; 321 int i; 322 double min, max; 323 char buff[128]; 324 for(i=0; i<mNVar; i++) { 325 GetMinMax(i, min, max); 326 sprintf(buff, "%3d %16s %10lg %10lg \n", i, mNames+i*LENNAME1, min, max); 327 os << (string)buff ; 328 } 329 os << endl; 330 } 331 332 333 /* --Methode-- */ 334 //++ 335 int NTuple::FillFromASCIIFile(string const& fn, float defval) 336 // 337 // Remplit le ntuple a partir d'un fichier ASCII. 338 // Renvoie le nombre de lignes ajoutees. 339 //-- 340 { 341 if (NbColumns() < 1) { 342 cout << "NTuple::FillFromASCIIFile() Ntuple has " << NbColumns() << " columns" << endl; 343 return(-1); 344 } 345 FILE * fip = fopen(fn.c_str(), "r"); 346 if (fip == NULL) { 347 cout << "NTuple::FillFromASCIIFile() Error opening file " << fn << endl; 348 return(-2); 349 } 350 351 char lineb[4096]; 352 char *line; 353 char buff[64]; 354 char* ccp; 355 int i,j,l,kk; 356 int postab, posb; 357 float* xv = new float[NbColumns()]; 358 359 int nlread = 0; 360 int nvar = NbColumns(); 361 // On boucle sur toutes les lignes 362 while (fgets(lineb,4096,fip) != NULL) { 363 lineb[4095] = '\0'; 364 j = 0; line = lineb; 365 // On enleve les espaces et tab de debut 366 while ( (line[j] != '\0') && ((line[j] == ' ') || (line[j] == '\t')) ) j++; 367 line = lineb+j; 368 // Il faut que le premier caractere non-espace soit un digit, ou + ou - ou . 369 if (!( isdigit(line[0]) || (line[0] == '+') || (line[0] == '-') || (line[0] == '.') )) continue; 370 ccp = line; 371 for(kk=0; kk<nvar; kk++) xv[kk] = defval; 372 for(kk=0; kk<nvar; kk++) { 373 // Les mots sont separes par des espaces ou des tab 374 postab = posc(ccp, '\t' ); 375 posb = posc(ccp, ' ' ); 376 if (postab >= 0) { 377 if (posb < 0) posb = postab; 378 else if (postab < posb) posb = postab; 379 } 380 if (posb >= 0) ccp[posb] = '\0'; 381 if ( isdigit(line[0]) || (line[0] == '+') || (line[0] == '-') || (line[0] == '.') ) 382 xv[kk] = atof(ccp); 383 if (posb < 0) break; 384 ccp += posb+1; j = 0; 385 while ( (ccp[j] != '\0') && ((ccp[j] == ' ') || (ccp[j] == '\t')) ) j++; 386 ccp += j; 387 } 388 Fill(xv); 389 nlread++; 390 } 391 392 delete[] xv; 393 cout << "NTuple::FillFromASCIIFile( " << fn << ") " << nlread << " fill from file " << endl; 394 return(nlread); 395 } 396 397 398 // ------- Implementation de l interface NTuple --------- 399 400 /* --Methode-- */ 401 uint_4 NTuple::NbLines() const 402 { 403 return(NEntry()); 404 } 405 /* --Methode-- */ 406 uint_4 NTuple::NbColumns() const 407 { 408 return(NVar()); 409 } 410 411 /* --Methode-- */ 412 r_8 * NTuple::GetLineD(int n) const 413 { 414 return(GetVecD(n)); 415 } 416 417 /* --Methode-- */ 418 r_8 NTuple::GetCell(int n, int k) const 419 { 420 return(GetVal(n, k)); 421 } 422 423 /* --Methode-- */ 424 r_8 NTuple::GetCell(int n, string const & nom) const 425 { 426 return(GetVal(n, nom.c_str())); 427 } 428 429 /* --Methode-- */ 430 //++ 431 void NTuple::GetMinMax(int k, double& min, double& max) const 236 432 // 237 433 // Retourne le minimum et le maximum de la variable `k'. … … 241 437 if ( (k < 0) || (k >= mNVar) ) return; 242 438 int jb,ib,i; 243 floatx;439 double x; 244 440 i=0; 245 441 for(jb=0; jb< mNBlk; jb++) … … 256 452 257 453 /* --Methode-- */ 258 //++ 259 DVList& NTuple::Info() 260 // 261 // Renvoie une référence sur l'objet DVList Associé 262 //-- 263 { 264 if (mInfo == NULL) mInfo = new DVList; 265 return(*mInfo); 266 } 267 268 /* --Methode-- */ 269 //++ 270 void NTuple::Print(int num, int nmax) const 271 // 272 // Imprime `nmax' evenements a partir du numero `num'. 273 //-- 274 { 275 int i,j; 276 277 printf("Num "); 278 for(i=0; i<mNVar; i++) printf("%8s ", mNames+i*LENNAME1); 279 putchar('\n'); 280 281 if (nmax <= 0) nmax = 1; 282 if (num < 0) num = 0; 283 nmax += num; 284 if (nmax > mNEnt) nmax = mNEnt; 285 for(i=num; i<nmax; i++) { 286 GetVec(i, NULL); 287 printf("%6d ", i); 288 for(j=0; j<mNVar; j++) printf("%8g ", (float)mVar[j]); 289 putchar('\n'); 290 } 454 void NTuple::GetMinMax(string const & nom, double& min, double& max) const 455 { 456 GetMinMax(IndexNom(nom.c_str()), min, max); 457 } 458 459 /* --Methode-- */ 460 int NTuple::ColumnIndex(string const & nom) const 461 { 462 return(IndexNom(nom.c_str())); 463 } 464 465 /* --Methode-- */ 466 string NTuple::ColumnName(int k) const 467 { 468 return(NomIndex(k)); 469 } 470 471 /* --Methode-- */ 472 //++ 473 string NTuple::VarList_C(const char* nomx) const 474 // 475 // Retourne une chaine de caracteres avec la declaration des noms de 476 // variables. si "nomx!=NULL" , des instructions d'affectation 477 // a partir d'un tableau "nomx[i]" sont ajoutees. 478 //-- 479 { 480 string rets=""; 481 int i; 482 for(i=0; i<mNVar; i++) { 483 if ( (i%5 == 0) && (i > 0) ) rets += ";"; 484 if (i%5 == 0) rets += "\ndouble "; 485 else rets += ","; 486 rets += mNames+i*LENNAME1; 487 } 488 rets += "; \n"; 489 if (nomx) { 490 char buff[256]; 491 for(i=0; i<mNVar; i++) { 492 sprintf(buff,"%s=%s[%d]; ", mNames+i*LENNAME1, nomx, i); 493 rets += buff; 494 if ( (i%3 == 0) && (i > 0) ) rets += "\n"; 495 } 496 } 497 498 return(rets); 499 } 500 501 502 /* --Methode-- */ 503 //++ 504 string NTuple::LineHeaderToString() const 505 // Retourne une chaine de caracteres avec la liste des noms de 506 // variables, utilisables pour une impression 507 //-- 508 { 509 char buff[32]; 510 string rets=" Num "; 511 for(int i=0; i<mNVar; i++) { 512 sprintf(buff, "%8s ", mNames+i*LENNAME1); 513 rets += buff; 514 } 515 rets += '\n'; 516 return(rets); 517 } 518 519 /* --Methode-- */ 520 //++ 521 string NTuple::LineToString(int n) const 522 // Retourne une chaine de caracteres avec le contenu de la ligne "n" 523 // utilisable pour une impression 524 //-- 525 { 526 char buff[32]; 527 double* val; 528 val = GetLineD(n); 529 sprintf(buff,"%6d: ",n); 530 string rets=buff; 531 int i; 532 for(i=0; i<mNVar; i++) { 533 sprintf(buff, "%8.3g ", val[i]); 534 rets += buff; 535 } 536 rets += '\n'; 537 return(rets); 538 } 539 540 541 /* --Methode-- */ 542 //++ 543 void ObjFileIO<NTuple>::WriteSelf(POutPersist& s) const 544 // 545 // Ecriture ppersist du ntuple. 546 //-- 547 { 548 char strg[256]; 549 if (dobj->mInfo) sprintf(strg, "NVar=%6d NEnt=%9d BlkSz=%6d NBlk=%6d HasInfo", 550 (int)dobj->mNVar, (int)dobj->mNEnt, (int)dobj->mBlk, (int)dobj->mNBlk); 551 else sprintf(strg, "NVar=%6d NEnt=%9d BlkSz=%6d NBlk=%6d ", 552 (int)dobj->mNVar, (int)dobj->mNEnt, (int)dobj->mBlk, (int)dobj->mNBlk); 553 s.PutLine(strg); 554 s.PutI4(dobj->mNVar); 555 s.PutBytes(dobj->mNames, dobj->mNVar*LENNAME1); 556 s.PutI4(dobj->mNEnt); 557 s.PutI4(dobj->mBlk); 558 s.PutI4(dobj->mNBlk); 559 if (dobj->mInfo) s << (*(dobj->mInfo)); 560 int jb; 561 for(jb=0; jb<dobj->mNBlk; jb++) 562 s.PutR4s(dobj->mPtr[jb], dobj->mNVar*dobj->mBlk); 291 563 return; 292 564 } … … 294 566 /* --Methode-- */ 295 567 //++ 296 void NTuple::Show(ostream& os) const 297 // 298 // Imprime l'information generale sur le ntuple. 299 //-- 300 { 301 os << "NTuple: NVar= " << mNVar << " NEnt=" << mNEnt 302 << " (Blk Sz,Nb= " << mBlk << " ," << mNBlk << ")\n"; 303 os << " Variables Min Max \n"; 304 int i; 305 float min, max; 306 char buff[128]; 307 for(i=0; i<mNVar; i++) { 308 GetMinMax(i, min, max); 309 sprintf(buff, "%3d %16s %10g %10g \n", i, mNames+i*LENNAME1, min, max); 310 os << (string)buff ; 311 } 312 os << endl; 313 } 314 315 316 /* --Methode-- */ 317 //++ 318 void NTuple::WriteSelf(POutPersist& s) const 319 // 320 // Ecriture ppersist du ntuple. 321 //-- 322 { 568 void ObjFileIO<NTuple>::ReadSelf(PInPersist& s) 569 // 570 // Lecture ppersist du ntuple. 571 //-- 572 { 573 574 dobj->Clean(); 575 323 576 char strg[256]; 324 if (mInfo) sprintf(strg, "NVar=%6d NEnt=%9d BlkSz=%6d NBlk=%6d HasInfo", 325 (int)mNVar, (int)mNEnt, (int)mBlk, (int)mNBlk); 326 else sprintf(strg, "NVar=%6d NEnt=%9d BlkSz=%6d NBlk=%6d ", 327 (int)mNVar, (int)mNEnt, (int)mBlk, (int)mNBlk); 328 s.PutLine(strg); 329 s.PutI4(mNVar); 330 s.PutBytes(mNames, mNVar*LENNAME1); 331 s.PutI4(mNEnt); 332 s.PutI4(mBlk); 333 s.PutI4(mNBlk); 334 if (mInfo) s << (*mInfo); 335 int jb; 336 for(jb=0; jb<mNBlk; jb++) 337 s.PutR4s(mPtr[jb], mNVar*mBlk); 338 return; 339 } 340 341 /* --Methode-- */ 342 //++ 343 void NTuple::ReadSelf(PInPersist& s) 344 // 345 // Lecture ppersist du ntuple. 346 //-- 347 { 348 349 Clean(); 350 351 char strg[256]; 352 s.GetLine(strg, 255); 353 // Pour savoir s'il y avait un DVList Info associe 354 bool hadinfo = false; 355 if (strncmp(strg+strlen(strg)-7, "HasInfo", 7) == 0) hadinfo = true; 356 357 s.GetI4(mNVar); 358 mNames = new char[mNVar*LENNAME1]; 359 mVar = new r_4[mNVar]; 360 mVarD = new r_8[mNVar]; 361 s.GetBytes(mNames, mNVar*LENNAME1); 362 s.GetI4(mNEnt); 363 s.GetI4(mBlk); 364 s.GetI4(mNBlk); 365 366 if (hadinfo) { // Lecture eventuelle du DVList Info 367 if (mInfo == NULL) mInfo = new DVList; 368 s >> (*mInfo); 369 } 370 371 int jb; 372 for(jb=0; jb<mNBlk; jb++) { 373 r_4* pt = new r_4[mNVar*mBlk]; 374 mPtr.push_back(pt); 375 s.GetR4s(mPtr[jb], mNVar*mBlk); 376 } 377 } 378 379 NTuple& NTuple::operator=(const NTuple &ntpl) 380 { 381 mNVar= ntpl.mNVar; 382 mNEnt= ntpl.mNEnt; 383 mBlk = ntpl.mBlk; 384 mNBlk= ntpl.mNBlk; 385 386 mVar= new r_4[mNVar]; 387 for(int k = 0; k < mNVar; k++) 388 mVar[k]= ntpl.mVar[k]; 389 390 mVarD= new r_8[mNVar]; 391 for(int k = 0; k < mNVar; k++) 392 mVarD[k]= ntpl.mVarD[k]; 393 394 mNames = new char[mNVar*LENNAME1]; 395 for(int i = 0; i < mNVar; i++) 396 { 397 strncpy(mNames+i*LENNAME1,(ntpl.mNames)+i*LENNAME1, LENNAME); 398 mNames[i*LENNAME1+LENNAME] = '\0'; 399 } 400 401 for(int k = 0; k < mNBlk; k++) 402 { 403 r_4 *ptr= new r_4[mNVar*mBlk]; 404 for(int i = 0; i < mNVar*mBlk; i++) 405 { 406 *(ptr+i)= *(ntpl.mPtr[k]+i); 407 } 408 mPtr.push_back(ptr); 409 } 410 411 mInfo = new DVList; 412 if(ntpl.mInfo) 413 { 414 *mInfo= *(ntpl.mInfo); 415 } 416 else 417 { 418 mInfo = NULL; 419 } 420 421 return *this; 422 } 577 s.GetLine(strg, 255); 578 // Pour savoir s'il y avait un DVList Info associe 579 bool hadinfo = false; 580 if (strncmp(strg+strlen(strg)-7, "HasInfo", 7) == 0) hadinfo = true; 581 582 s.GetI4(dobj->mNVar); 583 dobj->mNames = new char[dobj->mNVar*LENNAME1]; 584 dobj->mVar = new r_4[dobj->mNVar]; 585 dobj->mVarD = new r_8[dobj->mNVar]; 586 s.GetBytes(dobj->mNames, dobj->mNVar*LENNAME1); 587 s.GetI4(dobj->mNEnt); 588 s.GetI4(dobj->mBlk); 589 s.GetI4(dobj->mNBlk); 590 591 if (hadinfo) { // Lecture eventuelle du DVList Info 592 if (dobj->mInfo == NULL) dobj->mInfo = new DVList; 593 s >> (*(dobj->mInfo)); 594 } 595 596 int jb; 597 for(jb=0; jb<dobj->mNBlk; jb++) { 598 r_4* pt = new r_4[dobj->mNVar*dobj->mBlk]; 599 dobj->mPtr.push_back(pt); 600 s.GetR4s(dobj->mPtr[jb], dobj->mNVar*dobj->mBlk); 601 } 602 603 } 604 605 #ifdef __CXX_PRAGMA_TEMPLATES__ 606 #pragma define_template ObjFileIO<NTuple> 607 #endif 608 609 #if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES) 610 template class ObjFileIO<NTuple>; 611 #endif -
trunk/SophyaLib/NTools/ntuple.h
r475 r490 1 // This may look like C code, but it is really -*- C++ -*- 1 2 // Class NTuple 2 3 // CMV+Reza Juillet 97 3 4 // CEA-DAPNIA LAL-IN2P3/CNRS 4 // added overloading of operator = F. Touze, Guy Le Meur 19-OCT-995 5 6 6 #ifndef NTUPLE_H_SEEN 7 7 #define NTUPLE_H_SEEN 8 9 #include "objfio.h" 8 10 9 11 #include <iostream.h> … … 11 13 #include <vector> 12 14 13 #if defined(__KCC__) 14 using std::string ; 15 #include <vector.h> 16 #endif 17 15 #include "ntupintf.h" 18 16 #include "ppersist.h" 19 17 #include "dvlist.h" 20 18 19 namespace PlanckDPC { 21 20 22 class NTuple : public PPersist{21 class NTuple : public AnyDataObj , public NTupleInterface { 23 22 public: 24 enum {classId = ClassId_NTuple };23 // enum {classId = ClassId_NTuple }; 25 24 26 25 NTuple(int nvar, char** noms, int blk=512); 27 26 NTuple(); 27 NTuple(const NTuple& NT); 28 28 NTuple(char* flnm); 29 29 virtual ~NTuple(); 30 30 31 NTuple &operator=(const NTuple &ntpl);32 31 NTuple& operator = (const NTuple& NT); 32 33 33 void Fill(r_4* x); 34 34 35 inline int_4 NEntry() { return(mNEnt); } 36 inline int_4 NVar() { return(mNVar); } 37 inline int_4 BLock() { return(mBlk); } 35 inline int_4 NEntry() const { return(mNEnt); } 36 inline int_4 NVar() const { return(mNVar); } 37 inline int_4 BLock() const { return(mBlk); } 38 // $CHECK$ Reza 21/10/99 Pourquoi faire BLock() ? 38 39 39 40 float GetVal(int n, int k) const; 40 inline float GetVal(int n, c har* nom) const41 { return(GetVal(n, IndexNom(nom)) ); }41 inline float GetVal(int n, const char* nom) const 42 { return(GetVal(n, IndexNom(nom)) ); } 42 43 int IndexNom(const char* nom) const ; 43 44 char* NomIndex(int k) const; 44 string VarList_C(const char* nomx=NULL) const;45 45 46 46 r_4* GetVec(int n, r_4* ret=NULL) const ; 47 47 r_8* GetVecD(int n, r_8* ret=NULL) const ; 48 48 49 void GetMinMax(int k, float& min, float& max) const ; 50 inline void GetMinMax(const char* nom, float& min, float& max) const 51 { GetMinMax(IndexNom(nom), min, max); } 52 49 // Impression, I/O 53 50 void Print(int num, int nmax=1) const ; 54 51 void Show(ostream& os) const; … … 57 54 DVList& Info(); 58 55 59 int_4 ClassId() const { return classId; } 60 static PPersist* Create() { return new NTuple;}56 // Remplissage depuis fichier ASCII 57 int FillFromASCIIFile(string const& fn, float defval=0.); 61 58 62 virtual void WriteSelf(POutPersist&) const;63 virtual void ReadSelf(PInPersist&);64 59 60 // Declaration de l interface NTuple 61 virtual uint_4 NbLines() const ; 62 virtual uint_4 NbColumns() const ; 63 virtual r_8 * GetLineD(int n) const ; 64 virtual r_8 GetCell(int n, int k) const ; 65 virtual r_8 GetCell(int n, string const & nom) const ; 66 virtual void GetMinMax(int k, double& min, double& max) const ; 67 virtual void GetMinMax(string const & nom, double& min, double& max) const ; 68 virtual int ColumnIndex(string const & nom) const ; 69 virtual string ColumnName(int k) const; 70 virtual string VarList_C(const char* nomx=NULL) const ; 71 virtual string LineHeaderToString() const; 72 virtual string LineToString(int n) const; 73 74 // Pour la gestion de persistance 75 friend class ObjFileIO<NTuple> ; 65 76 66 77 private: … … 81 92 { nt.Show(s); return(s); } 82 93 94 inline POutPersist& operator << (POutPersist& os, NTuple & obj) 95 { ObjFileIO<NTuple> fio(&obj); fio.Write(os); return(os); } 96 inline PInPersist& operator >> (PInPersist& is, NTuple & obj) 97 { ObjFileIO<NTuple> fio(&obj); fio.Read(is); return(is); } 98 99 // Classe pour la gestion de persistance 100 // ObjFileIO<NTuple> 101 83 102 #ifdef __MWERKS__ 84 103 __MSL_FIX_ITERATORS__(r_4*); 85 104 #endif 86 105 106 } // namespace PlanckDPC 107 87 108 #endif 88 109 -
trunk/SophyaLib/NTools/outilsinit.cc
r307 r490 13 13 #include "ntuple.h" 14 14 #include "generaldata.h" 15 #include "tmatrix.h" 16 #include "tvector.h" 15 17 16 18 #include "cimage.h" … … 35 37 PPRegister(Poly2); 36 38 PPRegister(ObjFileIO<DVList>); 37 //PPRegister(Histo); 38 //PPRegister(Histo2D); 39 //PPRegister(HProf); 40 PPRegister(NTuple); 41 //PPRegister(GeneralFitData); 39 PPRegister(ObjFileIO<Histo>); 40 PPRegister(ObjFileIO<Histo2D>); 41 PPRegister(ObjFileIO<HProf>); 42 43 PPRegister(ObjFileIO<NTuple>); 44 PPRegister(ObjFileIO<GeneralFitData>); 45 46 PPRegister(FIO_TMatrix<uint_1>); 47 PPRegister(FIO_TMatrix<uint_2>); 48 PPRegister(FIO_TMatrix<int_2>); 49 PPRegister(FIO_TMatrix<int_4>); 50 PPRegister(FIO_TMatrix<int_8>); 51 PPRegister(FIO_TMatrix<uint_8>); 52 PPRegister(FIO_TMatrix<r_4>); 53 PPRegister(FIO_TMatrix<r_8>); 54 PPRegister(FIO_TMatrix< complex<float> >); 55 PPRegister(FIO_TMatrix< complex<double> >); 56 57 PPRegister(FIO_TVector<uint_1>); 58 PPRegister(FIO_TVector<uint_2>); 59 PPRegister(FIO_TVector<int_2>); 60 PPRegister(FIO_TVector<int_4>); 61 PPRegister(FIO_TVector<int_8>); 62 PPRegister(FIO_TVector<uint_8>); 63 PPRegister(FIO_TVector<r_4>); 64 PPRegister(FIO_TVector<r_8>); 65 PPRegister(FIO_TVector< complex<float> >); 66 PPRegister(FIO_TVector< complex<double> >); 67 42 68 43 69 PPRegister(RzImage); -
trunk/SophyaLib/NTools/pclassids.h
r253 r490 29 29 ClassId_HProf = 0x0203, 30 30 ClassId_NTuple = 0x0210, 31 31 ClassId_XNTuple = 0x0211, 32 32 33 ClassId_GeneralFitData = 0x0290, 33 34 -
trunk/SophyaLib/NTools/poly.cc
r244 r490 566 566 maxDegY = degreY; 567 567 568 for (int i=0; i<= tmp.degX; i++) 569 for (int j=0; j<= tmp.degY; j++) 568 // Attention - Reza 30/09/99 569 // il faut prendre le min en degre du polynome de depart et le nouveau 570 int cdegx = (tmp.degX < degreX) ? tmp.degX : degreX; 571 int cdegy = (tmp.degY < degreY) ? tmp.degY : degreY; 572 for (int i=0; i<= cdegx; i++) 573 for (int j=0; j<= cdegy; j++) 570 574 Coef(i,j) = tmp.Coef(i,j); 571 575 } -
trunk/SophyaLib/NTools/pversion.h
r220 r490 2 2 #define PVERSION_H 3 3 4 #define PEIDA_VERSION 4.05 #define PEIDA_REVISION 16 #define PEIDA_TAG "V_ Avr99"4 #define PEIDA_VERSION 1.0 5 #define PEIDA_REVISION 6 6 #define PEIDA_TAG "V_Nov99" 7 7 8 8 #endif -
trunk/SophyaLib/NTools/simplesort.h
r220 r490 1 1 // This may look like C code, but it is really -*- C++ -*- 2 2 // 3 // $Id: simplesort.h,v 1. 1.1.1 1999-04-09 17:57:58ansari Exp $3 // $Id: simplesort.h,v 1.2 1999-10-21 15:25:52 ansari Exp $ 4 4 // 5 5 … … 61 61 #include <functional> 62 62 #include <algorithm> 63 #if defined(__KCC__)64 #include <functional.h>65 #include <algorithm.h>66 #endif67 63 68 64 -
trunk/SophyaLib/NTools/tmatrix.h
r307 r490 194 194 bool ownobj; 195 195 }; 196 197 template <class T> 198 inline POutPersist& operator << (POutPersist& os, TMatrix<T> & obj) 199 { FIO_TMatrix<T> fio(&obj); fio.Write(os); return(os); } 200 template <class T> 201 inline PInPersist& operator >> (PInPersist& is, TMatrix<T> & obj) 202 { FIO_TMatrix<T> fio(&obj); fio.Read(is); return(is); } 196 203 197 204 ///////////////////////////////////////////////////////////////////////// -
trunk/SophyaLib/NTools/tvector.h
r307 r490 92 92 }; 93 93 94 template <class T> 95 inline POutPersist& operator << (POutPersist& os, TVector<T> & obj) 96 { FIO_TVector<T> fio(&obj); fio.Write(os); return(os); } 97 template <class T> 98 inline PInPersist& operator >> (PInPersist& is, TVector<T> & obj) 99 { FIO_TVector<T> fio(&obj); fio.Read(is); return(is); } 100 94 101 } // Fin du namespace 95 102 -
trunk/SophyaLib/NTools/utils.h
r244 r490 1 1 // This may look like C code, but it is really -*- C++ -*- 2 2 // 3 // $Id: utils.h,v 1. 2 1999-04-22 16:18:52ansari Exp $3 // $Id: utils.h,v 1.3 1999-10-21 15:25:53 ansari Exp $ 4 4 // 5 5 … … 13 13 #include <stdio.h> 14 14 15 #if defined(__KCC__)16 using std::string ;17 #endif18 15 19 16 // MemCpy marche meme en cas de recouvrement.
Note:
See TracChangeset
for help on using the changeset viewer.