Changeset 490 in Sophya


Ignore:
Timestamp:
Oct 21, 1999, 5:25:53 PM (26 years ago)
Author:
ansari
Message:

Merge avec PEIDA++ (~V 3.8) et nettoyage pour nouveau PPersist Reza+cmv 21/10/99

Location:
trunk/SophyaLib/NTools
Files:
2 added
30 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/NTools/NTools.o.list

    r404 r490  
    1111fct1dfit.o
    1212fct2dfit.o
     13fftpackc.o
     14fftserver.o
    1315generaldata.o
    1416generalfit.o
     
    2527nbrandom.o
    2628nbtri.o
     29ntupintf.o
    2730ntuple.o
    2831outilsinit.o
  • trunk/SophyaLib/NTools/cimage.cc

    r270 r490  
    55// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
    66
    7 // $Id: cimage.cc,v 1.4 1999-04-27 15:03:01 ansari Exp $       
     7// $Id: cimage.cc,v 1.5 1999-10-21 15:25:42 ansari Exp $       
    88
    99
     
    10691069  if(deb>0) cout<<"MoySigmaIter mean="<<mean<<" sigma="<<sigma
    10701070                <<" npix="<<rc<<" entre "<<xmin<<","<<xmax<<endl;
    1071   if( rc <= 0 ) return rc;
     1071  if( rc <= 0 || sigma<=0. ) return rc;
    10721072  if( it>=1 && fabs((double)(sigma-sigmaold))/sigma < perdiff ) break;
    10731073  xmin = mean - scut*sigma; if(testl && xmin<lowbad ) xmin = lowbad;
     
    12131213{
    12141214int i,j;
    1215 int x,y;
     1215// int x,y;  $CHECK$ Reza 21/06/99 changement de methode de calcul des bornes
    12161216const T1* pt_pim;
    12171217T2* pt_copie;
     
    12211221int step_pim_x;
    12221222int 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
    12241224int switch_copie;
    12251225
     
    12271227pim_siz_y=pim.YSize();
    12281228if((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;
    12301230    THROW(rangeCheckErr);}
    12311231if((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;
    12331233    THROW(rangeCheckErr);}
    12341234
    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";
     1235if( (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;
    12391237    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";
     1238if( (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;
    12421240    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
     1244copie_siz_x=copie.XSize()-org_copie_x;
     1245copie_siz_y=copie.YSize()-org_copie_y;
    12431246
    12441247x=pim_lpav_x;
     
    12681271    }
    12691272  else
    1270     {
     1273    { 
    12711274     step_copie_x=copie_siz_x-l_copie_x;
    12721275    }
     
    12851288   }
    12861289
    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
     1292l_copie_x = copie.XSize()-org_copie_x;
     1293l_copie_y = copie.YSize()-org_copie_y;
     1294if ( pim_lpav_x > (pim.XSize()-org_pim_x) )  pim_lpav_x = pim.XSize()-org_pim_x;
     1295if ( pim_lpav_y > (pim.YSize()-org_pim_y) )  pim_lpav_y = pim.YSize()-org_pim_y;
     1296if ( (pim_lpav_x > 0) && (l_copie_x > pim_lpav_x) )  l_copie_x = pim_lpav_x;
     1297if ( (pim_lpav_y > 0) && (l_copie_y > pim_lpav_y) )  l_copie_y = pim_lpav_y;
     1298step_pim_x = pim.XSize()-l_copie_x;
     1299step_copie_x = copie.XSize()-l_copie_x;
     1300
     1301pt_pim  = pim.ImagePtr() + org_pim_y*pim.XSize() + org_pim_x;
     1302pt_copie=copie.ImagePtr() + org_copie_y*copie.XSize() + org_copie_x;
    12891303
    12901304switch((int)ConvType(*pt_pim,*pt_copie)) {
     
    13611375if (!pim.ImagePtr())   THROW(nullPtrErr);
    13621376if (!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
     1377copie.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
    13661381dehors 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 */
     1382rapport aux bornes de l'image source  Re- CMV+Reza 30/09/96 */
     1383/* $CHECK$ Reza 21/06/99 - Ca devrait etre OK  */
    13681384if ( (org_pim_x < 0) || (org_pim_y < 0) ||
    13691385     (org_pim_x >= pim.XSize() ) || (org_pim_y >= pim.YSize() ) ||
    13701386     ((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
     1389if ( (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
     1396int oox = org_pim_x;
     1397int ooy = org_pim_y;
     1398int ocx = org_copie_x;
     1399int ocy = org_copie_y;
     1400if (oox < 0)  { ocx -= oox;  oox = 0; }
     1401if (ooy < 0)  { ocy -= ooy;  ooy = 0; }
    13741402/*  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*/
    13751409
    13761410if((pim_lpav_x <= 0) || (pim_lpav_x > pim.XSize())) pim_lpav_x=pim.XSize();
    13771411if((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,
     1412try {
     1413  CopieImageF(copie, pim, oox, ooy,
    13801414              pim_lpav_x, pim_lpav_y,
    1381               org_copie_x,org_copie_y,cutmin,cutmax);
     1415              ocx, ocy, cutmin,cutmax);
    13821416  }  catch(RangeCheckError) {
    1383       // if (merr != rangeCheckErr) THROW(merr);  Re- $CHECK$ CMV+Reza 30/09/96
     1417// $PLANCKCHECK$   if (merr != rangeCheckErr) THROW(merr);  // Re- $CHECK$ CMV+Reza 30/09/96
    13841418  } ENDTRY
     1419
     1420copie.SetOrg( pim.XOrg()+org_pim_x-org_copie_x, pim.YOrg()+org_pim_y-org_copie_y);
    13851421}
    13861422
  • trunk/SophyaLib/NTools/datacards.h

    r220 r490  
    11// This may look like C code, but it is really -*- C++ -*-
    22//
    3 // $Id: datacards.h,v 1.1.1.1 1999-04-09 17:57:55 ansari Exp $
     3// $Id: datacards.h,v 1.2 1999-10-21 15:25:42 ansari Exp $
    44//
    55// Datacards, acquisition EROS II
     
    2020#include <vector>
    2121#include <string>
    22 
    23 #if defined(__KCC__)
    24 using std::string ;
    25 #include <functional.h>
    26 #include <list.h>
    27 #include <vector.h>
    28 #endif
    2922
    3023#include "peida.h"
  • trunk/SophyaLib/NTools/dates.h

    r241 r490  
    66#include <iostream.h>
    77#include "pexceptions.h"
    8 #if defined(__KCC__)
    9 using std::string ;
    10 #endif
    118
    129class TimeZone;
  • trunk/SophyaLib/NTools/dvlist.h

    r404 r490  
    1616#include <string.h>
    1717#include <string>
    18 #if defined(__KCC__)
    19 using std::string ;
    20 #include <list.h>
    21 #include <map.h>
    22 #endif
    2318
    2419namespace PlanckDPC {
  • trunk/SophyaLib/NTools/fct2dfit.cc

    r307 r490  
    5656: GeneralFunction(2,nPar), VolEps(1.e-4)
    5757{
    58 DBASSERT( nPar>0 );
     58ASSERT( nPar>0 );
    5959}
    6060
     
    212212  , mPsf2D(psf2d), mNStar(nstar)
    213213{
    214 DBASSERT( nstar>0 && psf2d!=NULL );
     214ASSERT( nstar>0 && psf2d!=NULL );
    215215mNForme = mPsf2D->NPar() - 7;
    216 DBASSERT( mNForme>=0 );
     216ASSERT( mNForme>=0 );
    217217mNParm = mPsf2D->NPar();
    218218mParm = new double[mNParm];
     
    15391539double X2_GauRho2D::Value(GeneralFitData& data, double* parm, int& ndataused)
    15401540{
    1541  DBASSERT( data.NVar()==2 );
     1541 ASSERT( data.NVar()==2 );
    15421542 double x[2],z;
    15431543
     
    15561556double X2_GauRho2D::Derivee2(GeneralFitData& data, int i,int j, double* parm)
    15571557{
    1558  DBASSERT( data.NVar()==2 && i<7 && j<7);
     1558 ASSERT( data.NVar()==2 && i<7 && j<7);
    15591559 double x[2],dparm[7];
    15601560
  • trunk/SophyaLib/NTools/generaldata.cc

    r307 r490  
    88#include <string>
    99
    10 #if defined(__KCC__)
    11 using std::string ;
    12 #endif
    13 
     10#include "strutil.h"
    1411#include "nbtri.h"
    1512#include "generalfit.h"
     
    134131//--
    135132{
    136 DBASSERT( nVar>0 && ndatalloc>0 );
     133ASSERT( nVar>0 && ndatalloc>0 );
    137134
    138135Delete();
     
    176173//--
    177174{
    178  DBASSERT(ptr >= 0 && ptr < mNDataAlloc);
     175 ASSERT(ptr >= 0 && ptr < mNDataAlloc);
    179176 mNData = ptr;
    180177 mNDataGood = 0;
     
    190187//--
    191188{
    192  DBASSERT(i >= 0 && i < mNData);
     189 ASSERT(i >= 0 && i < mNData);
    193190
    194191 if( ! mOK[i] ) return;
     
    203200//--
    204201{
    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 );
    208205
    209206 for(int i=i1;i<=i2;i++) KillData(i);
     
    217214//--
    218215{
    219  DBASSERT(i >= 0 && i < mNData);
     216 ASSERT(i >= 0 && i < mNData);
    220217
    221218 if( mOK[i] ) return;
     
    234231//--
    235232{
    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 );
    239236
    240237 for(int i=i1;i<=i2;i++) ValidData(i);
     
    281278//--
    282279{
    283  DBASSERT(i>=0 && i<mNData);
     280 ASSERT(i>=0 && i<mNData);
    284281 bool ok = true;
    285282
     
    335332//--
    336333{
    337  DBASSERT(mNData < mNDataAlloc);
     334 ASSERT(mNData < mNDataAlloc);
    338335 bool ok = true;
    339336
     
    377374//--
    378375{
    379  DBASSERT(nData>0 && mNData+nData<=mNDataAlloc);
     376 ASSERT(nData>0 && mNData+nData<=mNDataAlloc);
    380377
    381378 for(int i=0;i<nData;i++) {
     
    394391//--
    395392{
    396  DBASSERT(nData>0 && mNData+nData<=mNDataAlloc);
     393 ASSERT(nData>0 && mNData+nData<=mNDataAlloc);
    397394
    398395 for(int i=0;i<nData;i++) {
     
    411408//--
    412409{
    413  DBASSERT(nData>0 && mNData+nData<=mNDataAlloc);
     410 ASSERT(nData>0 && mNData+nData<=mNDataAlloc);
    414411
    415412 for(int i=0;i<nData;i++) {
     
    429426//--
    430427{
    431  DBASSERT(nData>0 && mNData+nData<=mNDataAlloc);
     428 ASSERT(nData>0 && mNData+nData<=mNDataAlloc);
    432429
    433430 for(int i=0;i<nData;i++) {
     
    454451//--
    455452{
    456  DBASSERT(nData>0 && mNData+nData<=mNDataAlloc);
     453 ASSERT(nData>0 && mNData+nData<=mNDataAlloc);
    457454 if(mOk_EXP && !errxp) {for(int j=0;j<mNVar;j++) BuffVar[mNVar+j] = Def_ErrX;}
    458455
     
    473470//--
    474471{
    475  DBASSERT(nData>0 && mNData+nData<=mNDataAlloc);
     472 ASSERT(nData>0 && mNData+nData<=mNDataAlloc);
    476473
    477474 if(mOk_EXP && !errxp) {for(int j=0;j<mNVar;j++) BuffVar[mNVar+j] = Def_ErrX;}
     
    506503//--
    507504{
    508  DBASSERT(i>=0 && i<mNData);
     505 ASSERT(i>=0 && i<mNData);
    509506
    510507 cout<<" "<<i<<" F( ";
     
    540537//--
    541538{
    542  DBASSERT(mNData>0);
     539 ASSERT(mNData>0);
    543540
    544541 PrintData(0,mNData-1);
    545542}
    546543
    547 //////////////////////////////////////////////////////////////////////
    548 //++
    549 int GeneralFitData::GetMinMax(int var,int& imin,int& imax)
     544//++
     545void GeneralFitData::Show(ostream& os) const
     546//
     547//      Impression de l'etat de la structure de donnees avec bornes sur "s"
     548//--
     549{
     550double min,max;
     551os<<"GeneralFitData:: NVar,ErrX="<<mNVar<<","<<mOk_EXP
     552  <<" Data: "<<mNData<<" Good,Alloc="<<mNDataGood<<","<<mNDataAlloc<<endl;
     553for(int k=0;k<2*NVar()+3;k++) {
     554  GetMinMax(k,min,max);
     555  os<<" - "<<k<<" "<<ColumnName(k)<<"  ,  "<<min<<","<<max<<endl;
     556}
     557return;
     558}
     559
     560//////////////////////////////////////////////////////////////////////
     561//++
     562int GeneralFitData::GetMnMx(int var,int& imin,int& imax) const
    550563//
    551564//      Retourne les numeros des points de valeurs minimum et maximum
     
    582595
    583596//++
    584 int GeneralFitData::GetMinMax(int var,double& min,double& max)
     597int GeneralFitData::GetMnMx(int var,double& min,double& max) const
    585598//
    586599//      Retourne le minimum et le maximum de la variable ``var''
    587 //      (cf commentaires GetMinMax).
     600//      (cf commentaires GetMnMx).
    588601//--
    589602{
    590603min = 1.; max = -1.;
    591604int imin,imax;
    592 int ntest = GetMinMax(var,imin,imax);
     605int ntest = GetMnMx(var,imin,imax);
    593606if(ntest<=0) return ntest;
    594607int ix = var/10;
     
    615628//
    616629//      Retourne la moyenne et le sigma de la variable ``var''
    617 //      (cf commentaires GetMinMax).
     630//      (cf commentaires GetMnMx).
    618631//| - Return : nombre de donnees utilisees, -1 si pb, -2 si sigma<0.
    619632//| - Seuls les points valides de valeur entre min,max sont utilises.
     
    655668//
    656669//      Retourne le mode de la variable ``var''
    657 //      (cf commentaires GetMinMax).
     670//      (cf commentaires GetMnMx).
    658671//| - Return : nombre de donnees utilisees, -1 si pb.
    659672//| - Seuls les points valides de valeur entre min,max sont utilises.
     
    876889//////////////////////////////////////////////////////////////////////
    877890//++
     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
     973uint_4 GeneralFitData::NbLines() const
     974{
     975return(NData());
     976}
     977
     978//++
     979uint_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{
     990return(2*NVar()+3);
     991}
     992
     993r_8 * GeneralFitData::GetLineD(int n) const
     994{
     995return(GetVec(n,NULL));
     996}
     997
     998r_8 GeneralFitData::GetCell(int n, int k) const
     999{
     1000if(k<0 || k>=2*NVar()+3) return 0.;
     1001r_8 * val = GetVec(n,NULL);
     1002return val[k];
     1003}
     1004
     1005r_8 GeneralFitData::GetCell(int n, string const & nom) const
     1006{
     1007int k = ColumnIndex(nom);
     1008return(GetCell(n,k));
     1009}
     1010
     1011//++
     1012void GeneralFitData::GetMinMax(int k, double& min, double& max)  const
     1013//
     1014//      Retourne le minimum et le maximum de la variable `k'.
     1015//--
     1016{
     1017int var;
     1018if(k<0 || k>=2*NVar()+3) return;
     1019else if(k<NVar())      var = 10*k+2;          // Variable Xi
     1020else if(k<2*NVar())    var = 10*(k-NVar())+3; // Variable EXi
     1021else if(k==2*NVar())   var = 0;               // Variable Y
     1022else if(k==2*NVar()+1) var = 1;               // Variable EY
     1023else {min=0.; max=1.; return;}                // Variable Ok
     1024GetMnMx(var,min,max);
     1025return;
     1026}
     1027
     1028void GeneralFitData::GetMinMax(string const & nom, double& min, double& max)   const
     1029{
     1030int k = ColumnIndex(nom);
     1031GetMinMax(k,min,max);
     1032}
     1033
     1034int GeneralFitData::ColumnIndex(string const & nom)  const
     1035{
     1036char str[64]; int k = -1;
     1037strcpy(str,nom.c_str()); strip(str,'L',' ');
     1038if(str[0]=='y') return 2*NVar();
     1039if(str[0]=='o') return 2*NVar()+2;
     1040if(str[0]=='x') {sscanf(str,"x%d",&k); return k;}
     1041if(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;}
     1044return -1;
     1045}
     1046
     1047string GeneralFitData::ColumnName(int k) const
     1048{
     1049if(k==2*NVar())                return string("y");
     1050else if(k==2*NVar()+1)         return string("ey");
     1051else if(k==2*NVar()+2)         return string("ok");
     1052else if(k<0 || k>=2*NVar()+3)  return string("");
     1053
     1054char str[64] = "";
     1055if(k<NVar()) sprintf(str,"x%d",k);
     1056else if(k<2*NVar()) sprintf(str,"ex%d",k-NVar());
     1057return string(str);
     1058}
     1059
     1060//++
    8781061string GeneralFitData::VarList_C(const char* nomx)  const
    8791062//
     
    9111094}
    9121095
    913 //////////////////////////////////////////////////////////////////////
    914 //++
    915 // int inline int GetSpaceFree() const
    916 //      Retourne la place restante dans la structure (nombre de
    917 //      donnees que l'on peut encore stoquer).
    918 //--
    919 //++
    920 // inline int  NVar()       const
    921 //      Retourne le nombre de variables Xi
    922 //--
    923 //++
    924 // inline int  NData()
    925 //      Retourne le nombre de donnees
    926 //--
    927 //++
    928 // inline int  NDataGood()  const
    929 //      Retourne le nombre de bonnes donnees (utilisees pour le fit)
    930 //--
    931 //++
    932 // inline int  NDataAlloc() const
    933 //      Retourne la place maximale allouee pour les donnees
    934 //--
    935 //++
    936 // inline unsigned short int IsValid(int i) const
    937 //      Retourne 1 si point valide, sinon 0
    938 //--
    939 //++
    940 // inline bool HasXErrors()
    941 //      Retourne ``true'' si il y a des erreurs sur les variables
    942 //      d'abscisse, ``false'' sinon.
    943 //--
    944 //++
    945 // inline double X1(int i) const
    946 //      Retourne l'abscisse pour 1 dimension (y=f(x)) donnee I
    947 //--
    948 //++
    949 // inline double X(int i) const
    950 //      Retourne la 1er abscisse (X) pour (v=f(x,y,z,...)) donnee I
    951 //--
    952 //++
    953 // inline double Y(int i) const
    954 //      Retourne la 2sd abscisse (Y) pour (v=f(x,y,z,...)) donnee I
    955 //--
    956 //++
    957 // inline double Z(int i) const
    958 //      Retourne la 3ieme abscisse (Z) pour (v=f(x,y,z,...)) donnee I
    959 //--
    960 //++
    961 // inline double Absc(int j,int i) const
    962 //      Retourne la Jieme abscisse (Xj) pour (v=f(x0,x1,x2,...)) donnee I
    963 //--
    964 //++
    965 // inline double Val(int i) const
    966 //      Retourne la valeur de la Ieme donnee
    967 //--
    968 //++
    969 // inline double EX1(int i) const
    970 //      Retourne l'erreur (dx) sur l'abscisse pour 1 dimension (y=f(x)) donnee I
    971 //--
    972 //++
    973 // inline double EX(int i) const
    974 //      Retourne l'erreur (dx) sur la 1er abscisse (X) pour (v=f(x,y,z,...)) donnee I
    975 //--
    976 //++
    977 // inline double EY(int i) const
    978 //      Retourne l'erreur (dy) sur la 2sd abscisse (Y) pour (v=f(x,y,z,...)) donnee I
    979 //--
    980 //++
    981 // inline double EZ(int i) const
    982 //      Retourne l'erreur (dz) sur la 3ieme abscisse (Z) pour (v=f(x,y,z,...)) donnee I
    983 //--
    984 //++
    985 // inline double EAbsc(int j,int i) const
    986 //      Retourne l'erreur (dxj) sur la Jieme abscisse (Xj) pour (v=f(x0,x1,x2,...)) donnee I
    987 //--
    988 //++
    989 // inline double EVal(int i) const {return mErr[i];}
    990 //      Retourne l'erreur de la Ieme donnee
    991 //--
    992 
    9931096///////////////////////////////////////////////////////////
    9941097// --------------------------------------------------------
     
    9971100///////////////////////////////////////////////////////////
    9981101
    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
     1103void ObjFileIO<GeneralFitData>::ReadSelf(PInPersist& is)
    10351104{
    10361105char strg[256];
     
    10761145}
    10771146
    1078 void FIO_GeneralFitData::WriteSelf(POutPersist& os) const
     1147void ObjFileIO<GeneralFitData>::WriteSelf(POutPersist& os) const
    10791148{
    10801149if (dobj == NULL)   return;
     
    11141183return;
    11151184}
     1185
     1186
     1187#ifdef __CXX_PRAGMA_TEMPLATES__
     1188#pragma define_template ObjFileIO<GeneralFitData>
     1189#endif
     1190
     1191#if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES)
     1192template class ObjFileIO<GeneralFitData>;
     1193#endif
  • trunk/SophyaLib/NTools/generaldata.h

    r307 r490  
    44#define GENERALDATA_SEEN
    55
     6#include "objfio.h"
     7#include <iostream.h>
    68#include "pexceptions.h"
    79#include "ppersist.h"
     10#include "ntupintf.h"
    811#include "poly.h"
    9 #include "anydataobj.h"
    1012
    1113namespace PlanckDPC {
    1214
    1315class GeneralFit;
    14 class FIO_GeneralFitData;
    1516
    1617//================================================================
     
    1819//================================================================
    1920
    20 class GeneralFitData : public AnyDataObj {
     21class GeneralFitData : public AnyDataObj , public NTupleInterface {
    2122  friend class GeneralFit;
    22   friend class FIO_GeneralFitData;
     23  friend class ObjFileIO<GeneralFitData>;
    2324public:
    2425  enum {Def_ErrF = 1, Def_ErrX = 0};
     
    6364  void PrintData(int i1,int i2);
    6465  void PrintData();
     66  void Show(ostream& os) const;
     67  inline void Show() const {Show(cout);}
    6568
    6669  inline int GetSpaceFree() const { return mNDataAlloc - mNData; }
     
    103106                {if(i>=0 && i<mNData) return mErr[i]; else return 0.;}
    104107
    105   r_8* GetVec(int n, r_8* ret=NULL)  const ;
    106   r_4* GetVecR4(int n, r_4* ret=NULL)  const ;
    107   int GetMinMax(int var,int& imin,int& imax);
    108   int GetMinMax(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;
    109112  int GetMeanSigma(int var,double& mean,double& sigma,double min=1.,double max=-1.);
    110113  int GetMoMeMed(int var,double& mode,double& mean,double& median,
     
    115118  GeneralFitData FitResidus(GeneralFit& gfit);
    116119  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;
    118132
    119133protected:
     
    134148};
    135149
     150inline ostream& operator << (ostream& s, GeneralFitData const & g)
     151                         {g.Show(s); return(s);}
     152
    136153/////////////////////////////////////////////////////////////////////////
    137154// 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
     156inline POutPersist& operator << (POutPersist& os, GeneralFitData & obj)
     157{ ObjFileIO<GeneralFitData> fio(&obj);  fio.Write(os);  return(os); }
     158inline 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>
    153163
    154164} // Fin du namespace
  • trunk/SophyaLib/NTools/generalfit.cc

    r307 r490  
    77#include <string>
    88
    9 #if defined(__KCC__)
    10 using std::string ;
    11 #endif
    12 
    139#include "pexceptions.h"
    1410#include "generalfit.h"
     
    4137  : mNVar(nVar), mNPar(nPar)
    4238{
    43  DBASSERT( nVar > 0 && nPar > 0 );
     39 ASSERT( nVar > 0 && nPar > 0 );
    4440 deltaParm = new double[nPar];
    4541 tmpParm   = new double[nPar];
     
    8682//--
    8783{
    88  DBASSERT(numPar >= 0 && numPar < mNPar);
     84 ASSERT(numPar >= 0 && numPar < mNPar);
    8985 deltaParm[numPar] = d;
    9086}
     
    226222  : mNPar(nPar)
    227223{
    228  DBASSERT( nPar>0 );
     224 ASSERT( nPar>0 );
    229225 deltaParm = new double[nPar];
    230226 END_CONSTRUCTOR
     
    307303//--
    308304{
    309  DBASSERT(numPar >= 0 && numPar < mNPar);
     305 ASSERT(numPar >= 0 && numPar < mNPar);
    310306 
    311307 deltaParm[numPar] = d;
     
    375371    D             (f->NPar())
    376372{
    377  DBASSERT(mNVar>0 && mNPar>0);
    378  DBASSERT(mNPar<1000000);
     373 ASSERT(mNVar>0 && mNPar>0);
     374 ASSERT(mNPar<1000000);
    379375
    380376 TRY {
     
    418414    D             (f->NPar())
    419415{
    420  DBASSERT( mNPar>0 );
    421  DBASSERT( mNPar < 1000000 );
     416 ASSERT( mNPar>0 );
     417 ASSERT( mNPar < 1000000 );
    422418
    423419 TRY {
     
    573569//--
    574570{
    575  DBASSERT(n>=0 && n<mNPar);
     571 ASSERT(n>=0 && n<mNPar);
    576572 Eps(n) = (ep<=0.) ? EPS_FIT_MIN: ep;
    577573 if(debugLevel>0) cout<<"SetEps("<<n<<") = "<<Eps(n)<<endl;
     
    616612//--
    617613{
    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 );
    622618 mFunction = f;
    623619 if(debugLevel>0) cout<<"SetFunction "<<mFunction<<endl;
     
    632628//--
    633629{
    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 );
    637633 mFuncXi2  = f;
    638634 if(debugLevel>0) cout<<"SetFuncXi2 "<<mFuncXi2<<endl;
     
    646642//--
    647643{
    648  DBASSERT( data->NVar()==mNVar || mFunction==NULL );
     644 ASSERT( data->NVar()==mNVar );
    649645 mData = data;
    650646 mNddl = mData->NDataGood() - mNParFree;
     
    661657//--
    662658{
    663  DBASSERT(n>=0 && n<mNPar);
     659 ASSERT(n>=0 && n<mNPar);
    664660
    665661 Param(n)     = value;
     
    688684//--
    689685{
    690  DBASSERT(n>=0 && n<mNPar);
     686 ASSERT(n>=0 && n<mNPar);
    691687 SetParam(n,value,step,min,max);
    692688 nameParam[n] = name;
     
    700696//--
    701697{
    702  DBASSERT(n>=0 && n<mNPar);
     698 ASSERT(n>=0 && n<mNPar);
    703699 Param(n) = value;
    704700 if(debugLevel) {cout<<"Set_Param "; PrintParm(n);}
     
    713709//--
    714710{
    715  DBASSERT(n>=0 && n<mNPar);
     711 ASSERT(n>=0 && n<mNPar);
    716712 if(step>0.) {
    717713   if( fixParam[n] ) { fixParam[n]=0; mNParFree++;}
     
    734730//--
    735731{
    736  DBASSERT(i>=0 && i<mNPar);
     732 ASSERT(i>=0 && i<mNPar);
    737733 if(val<0.) minStepDeriv(i) = Eps(i);
    738734   else     minStepDeriv(i) = val;
     
    759755//--
    760756{
    761  DBASSERT(n>=0 && n<mNPar && max>min);
     757 ASSERT(n>=0 && n<mNPar && max>min);
    762758
    763759 minParam(n)  = min;
     
    778774//--
    779775{
    780  DBASSERT(n>=0 && n<mNPar && maxParam(n)>minParam(n));
     776 ASSERT(n>=0 && n<mNPar && maxParam(n)>minParam(n));
    781777 SetBound(n,minParam(n),maxParam(n));
    782778}
     
    788784//--
    789785{
    790  DBASSERT(n>=0 && n<mNPar);
     786 ASSERT(n>=0 && n<mNPar);
    791787
    792788 if( boundParam[n] ) {
     
    814810//--
    815811{
    816  DBASSERT(n>=0 && n<mNPar);
     812 ASSERT(n>=0 && n<mNPar);
    817813
    818814 Param(n) = v;
     
    833829//--
    834830{
    835  DBASSERT(n>=0 && n<mNPar);
     831 ASSERT(n>=0 && n<mNPar);
    836832 SetFix(n,Param(n));
    837833}
     
    843839//--
    844840{
    845  DBASSERT(n>=0 && n<mNPar);
     841 ASSERT(n>=0 && n<mNPar);
    846842
    847843 if( fixParam[n] ) {
     
    873869//--
    874870{
    875  DBASSERT(n>=0 && n<mNPar);
     871 ASSERT(n>=0 && n<mNPar);
    876872 return Param(n);
    877873}
     
    892888//--
    893889{
    894  DBASSERT(n>=0 && n<mNPar);
     890 ASSERT(n>=0 && n<mNPar);
    895891 return errParam(n);
    896892}
     
    902898//--
    903899{
    904  DBASSERT(i>=0 && i<mNPar && j>=0 && j<mNPar);
     900 ASSERT(i>=0 && i<mNPar && j>=0 && j<mNPar);
    905901 return ATGA(i,j);
    906902}
     
    913909//--
    914910{
    915  DBASSERT(n>=0 && n<mNPar);
     911 ASSERT(n>=0 && n<mNPar);
    916912 return stepParam(n);
    917913}
     
    923919//--
    924920{
    925  DBASSERT(n>=0 && n<mNPar);
     921 ASSERT(n>=0 && n<mNPar);
    926922 return maxParam(n);
    927923}
     
    933929//--
    934930{
    935  DBASSERT(n>=0 && n<mNPar);
     931 ASSERT(n>=0 && n<mNPar);
    936932 return minParam(n);
    937933}
     
    986982//--
    987983{
    988  DBASSERT(n>=0 && n<mNPar);
     984 ASSERT(n>=0 && n<mNPar);
    989985
    990986 cout<<"Par["<<n<<"] "<<nameParam[n]
     
    13961392//--
    13971393{
    1398 double c2 = -.1;
     1394double c2 = -1.;
    13991395if(par==NULL) par = Param.Data();
    14001396if( mData->NData() <= 0 ) {nddl = -100; return 0.;}
     
    16221618void GeneralFit::CheckSanity()
    16231619{
    1624   DBASSERT( mData != NULL );
    1625   DBASSERT( mFunction != NULL || mFuncXi2 != NULL );
     1620  ASSERT( mData != NULL );
     1621  ASSERT( mFunction != NULL || mFuncXi2 != NULL );
    16261622  if( mFunction != NULL ) {
    1627     DBASSERT( mFunction->NVar() == mNVar );
    1628     DBASSERT( mData->NVar() == mNVar );
     1623    ASSERT( mFunction->NVar() == mNVar );
     1624    ASSERT( mData->NVar() == mNVar );
    16291625  }
    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() );
    16331629}
    16341630
     
    16381634// D = (max-min)/Pi
    16391635{
    1640   // DBASSERT(i>=0 && i<mNPar);
     1636  // ASSERT(i>=0 && i<mNPar);
    16411637 C(i) = D(i) = 0.;
    16421638 if( !boundParam[i] || fixParam[i] ) return;
     
    16611657// tr = tan( (p-C)/D )
    16621658{
    1663  // DBASSERT(i>=0 && i<mNPar);
     1659 // ASSERT(i>=0 && i<mNPar);
    16641660 double tr = p;
    16651661 if(boundParam[i]) tr = tan((p-C(i))/D(i));
     
    16921688// p = C+D*atan(tr)
    16931689{
    1694  // DBASSERT(i>=0 && i<mNPar);
     1690 // ASSERT(i>=0 && i<mNPar);
    16951691 double p = tr;
    16961692 if(boundParam[i]) p = C(i)+D(i)*atan(tr);
     
    17241720// attention: df/dp = (1+tr**2)/D * dF/dtr = coeff * dF/dtr
    17251721{
    1726  // DBASSERT(i>=0 && i<mNPar);
     1722 // ASSERT(i>=0 && i<mNPar);
    17271723 double coeff = 1.;
    17281724 if(boundParam[i]) coeff = (1.+tr*tr)/D(i);
     
    17561752// attention: df/dtr = D/(1+tr**2) * dF/dp = coeff * dF/dp
    17571753{
    1758   // DBASSERT(i>=0 && i<mNPar);
     1754  // ASSERT(i>=0 && i<mNPar);
    17591755 double coeff = 1.;
    17601756 if(boundParam[i]) coeff = D(i)/(1.+tr*tr);
  • trunk/SophyaLib/NTools/hisprof.cc

    r308 r490  
    303303///////////////////////////////////////////////////////////
    304304
    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
     306void ObjFileIO<HProf>::ReadSelf(PInPersist& is)
    341307{
    342308char strg[256];
     
    365331
    366332// Ecriture de l'histogramme
    367 FIO_Histo fio_h((Histo&)*dobj);
    368 fio_h.Read(is);
    369 
     333is >> (Histo&)(*dobj);
    370334return;
    371335}
    372336
    373 void FIO_HProf::WriteSelf(POutPersist& os) const
     337void ObjFileIO<HProf>::WriteSelf(POutPersist& os) const
    374338{
    375339if (dobj == NULL)   return;
     
    396360
    397361// 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);
     364os << (Histo&)(*dobj);
    400365
    401366return;
    402367}
     368
     369#ifdef __CXX_PRAGMA_TEMPLATES__
     370#pragma define_template ObjFileIO<HProf>
     371#endif
     372
     373#if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES)
     374template class ObjFileIO<HProf>;
     375#endif
  • trunk/SophyaLib/NTools/hisprof.h

    r307 r490  
    1111
    1212class HProf : public Histo {
    13   friend class FIO_HProf;
     13  friend class ObjFileIO<HProf>;
    1414public:
    1515
     
    6565};
    6666
    67 /////////////////////////////////////////////////////////////////////////
     67
     68inline POutPersist& operator << (POutPersist& os, HProf & obj)
     69{ ObjFileIO<HProf> fio(&obj);  fio.Write(os);  return(os); }
     70inline PInPersist& operator >> (PInPersist& is, HProf & obj)
     71{ ObjFileIO<HProf> fio(&obj);  fio.Read(is);  return(is); }
    6872// 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
    8475
    8576} // Fin du namespace
  • trunk/SophyaLib/NTools/history_eros

    r253 r490  
    22-----------> cspline.cc
    33   Repository revision: 1.5     /projects/Eros/CVSEros/CodeCxx/Outils/cspline.cc,v
     4   OK                   1.5
    45-----------> cspline.h
    56   Repository revision: 1.4     /projects/Eros/CVSEros/CodeCxx/Outils/cspline.h,v
     7   OK                   1.4
    68-----------> cvector.cc
    79   Repository revision: 1.8     /projects/Eros/CVSEros/CodeCxx/Outils/cvector.cc,v
     10   OK                   1.8
    811-----------> cvector.h
    912   Repository revision: 1.7     /projects/Eros/CVSEros/CodeCxx/Outils/cvector.h,v
     13   OK                   1.7
    1014-----------> datacards.cc
    1115   Repository revision: 1.18    /projects/Eros/CVSEros/CodeCxx/Outils/datacards.cc,v
     16   OK                   1.18
    1217-----------> datacards.h
    1318   Repository revision: 1.10    /projects/Eros/CVSEros/CodeCxx/Outils/datacards.h,v
     19   MAJ                  1.11   (pour namespace std de KCC)
    1420-----------> datatypes.cc
    1521   Repository revision: 1.5     /projects/Eros/CVSEros/CodeCxx/Outils/datatypes.cc,v
     22   OK                   1.5
    1623-----------> datatypes.h
    1724   Repository revision: 1.4     /projects/Eros/CVSEros/CodeCxx/Outils/datatypes.h,v
     25   OK                   1.4
    1826-----------> dates.cc
    1927   Repository revision: 1.11    /projects/Eros/CVSEros/CodeCxx/Outils/dates.cc,v
     28   OK                   1.11
    2029-----------> dates.h
    2130   Repository revision: 1.9     /projects/Eros/CVSEros/CodeCxx/Outils/dates.h,v
     31   MAJ                  1.10
    2232-----------> difeq.cc
    2333   Repository revision: 1.9     /projects/Eros/CVSEros/CodeCxx/Outils/difeq.cc,v
     34   OK                   1.9
    2435-----------> difeq.h
    2536   Repository revision: 1.6     /projects/Eros/CVSEros/CodeCxx/Outils/difeq.h,v
     37   OK                   1.6
    2638-----------> dvlist.cc
    2739   Repository revision: 1.9     /projects/Eros/CVSEros/CodeCxx/Outils/dvlist.cc,v
     40   OK                   1.9
    2841-----------> dvlist.h
    2942   Repository revision: 1.14    /projects/Eros/CVSEros/CodeCxx/Outils/dvlist.h,v
     43   MAJ                  1.16
    3044-----------> fct1dfit.cc
    3145   Repository revision: 1.7     /projects/Eros/CVSEros/CodeCxx/Outils/fct1dfit.cc,v
     46   OK                   1.7
    3247-----------> fct1dfit.h
    3348   Repository revision: 1.4     /projects/Eros/CVSEros/CodeCxx/Outils/fct1dfit.h,v
     49   OK                   1.4
    3450-----------> fct2dfit.cc
    3551   Repository revision: 1.8     /projects/Eros/CVSEros/CodeCxx/Outils/fct2dfit.cc,v
     52   MAJ                  1.9
    3653-----------> fct2dfit.h
    3754   Repository revision: 1.4     /projects/Eros/CVSEros/CodeCxx/Outils/fct2dfit.h,v
     55   OK                   1.4
    3856-----------> generaldata.cc
    3957   Repository revision: 1.6     /projects/Eros/CVSEros/CodeCxx/Outils/generaldata.cc,v
     58   MAJ                  1.9
    4059-----------> generaldata.h
    4160   Repository revision: 1.4     /projects/Eros/CVSEros/CodeCxx/Outils/generaldata.h,v
     61   MAJ                  1.5
    4262-----------> generalfit.cc
    4363   Repository revision: 1.47    /projects/Eros/CVSEros/CodeCxx/Outils/generalfit.cc,v
     64   MAJ                  1.51
    4465-----------> generalfit.h
    4566   Repository revision: 1.20    /projects/Eros/CVSEros/CodeCxx/Outils/generalfit.h,v
     67   OK                   1.20
    4668-----------> hisprof.cc
    4769   Repository revision: 1.3     /projects/Eros/CVSEros/CodeCxx/Outils/hisprof.cc,v
     70   OK                   1.3
    4871-----------> hisprof.h
    4972   Repository revision: 1.3     /projects/Eros/CVSEros/CodeCxx/Outils/hisprof.h,v
     73   OK                   1.3
    5074-----------> histos.cc
    5175   Repository revision: 1.27    /projects/Eros/CVSEros/CodeCxx/Outils/histos.cc,v
     76   OK                   1.27
    5277-----------> histos.h
    5378   Repository revision: 1.19    /projects/Eros/CVSEros/CodeCxx/Outils/histos.h,v
     79   OK                   1.19
    5480-----------> histos2.cc
    5581   Repository revision: 1.17    /projects/Eros/CVSEros/CodeCxx/Outils/histos2.cc,v
     82   MAJ                  1.19
    5683-----------> histos2.h
    5784   Repository revision: 1.15    /projects/Eros/CVSEros/CodeCxx/Outils/histos2.h,v
     85   MAJ                  1.16
    5886-----------> integ.cc
    5987   Repository revision: 1.8     /projects/Eros/CVSEros/CodeCxx/Outils/integ.cc,v
     88   OK                   1.8
    6089-----------> integ.h
    6190   Repository revision: 1.6     /projects/Eros/CVSEros/CodeCxx/Outils/integ.h,v
     91   MAJ                  1.7
    6292-----------> linfit.cc
    6393   Repository revision: 1.4     /projects/Eros/CVSEros/CodeCxx/Outils/linfit.cc,v
     94   OK                   1.4
    6495-----------> linfit.h
    6596   Repository revision: 1.7     /projects/Eros/CVSEros/CodeCxx/Outils/linfit.h,v
     97   OK                   1.7
    6698-----------> matrix.cc
    6799   Repository revision: 1.17    /projects/Eros/CVSEros/CodeCxx/Outils/matrix.cc,v
     100   MAJ                  1.18
    68101-----------> matrix.h
    69102   Repository revision: 1.8     /projects/Eros/CVSEros/CodeCxx/Outils/matrix.h,v
     103   OK                   1.8
    70104-----------> median.cc
    71105   Repository revision: 1.1     /projects/Eros/CVSEros/CodeCxx/Outils/median.cc,v
     106   OK                   1.1
    72107-----------> median.h
    73108   Repository revision: 1.1     /projects/Eros/CVSEros/CodeCxx/Outils/median.h,v
     109   OK                   1.1
    74110-----------> nbconst.h
    75111   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
    76120-----------> ntuple.cc
    77121   Repository revision: 1.12    /projects/Eros/CVSEros/CodeCxx/Outils/ntuple.cc,v
     122   OK                   1.19
    78123-----------> ntuple.h
     124   MAJ                  1.15
    79125   Repository revision: 1.9     /projects/Eros/CVSEros/CodeCxx/Outils/ntuple.h,v
    80126-----------> outilsinit.cc
    81127   Repository revision: 1.2     /projects/Eros/CVSEros/CodeCxx/Outils/outilsinit.cc,v
     128                        1.3   Ajout de XNTuple, pas fait
    82129-----------> outilsinit.h
    83130   Repository revision: 1.3     /projects/Eros/CVSEros/CodeCxx/Outils/outilsinit.h,v
     131   OK                   1.3
    84132-----------> pclassids.h
    85133   Repository revision: 1.8     /projects/Eros/CVSEros/CodeCxx/Outils/pclassids.h,v
     134   MAJ                  1.9     ClassId_XNTuple
    86135-----------> peida.h
    87136   Repository revision: 1.4     /projects/Eros/CVSEros/CodeCxx/Outils/peida.h,v
     137   OK                   1.4
    88138-----------> pemath.h
    89139   Repository revision: 1.2     /projects/Eros/CVSEros/CodeCxx/Outils/pemath.h,v
     140   OK                   1.2
    90141-----------> perandom.cc
    91142   Repository revision: 1.11    /projects/Eros/CVSEros/CodeCxx/Outils/perandom.cc,v
     143   OK                   1.11
    92144-----------> perandom.h
    93145   Repository revision: 1.8     /projects/Eros/CVSEros/CodeCxx/Outils/perandom.h,v
     146   OK                   1.8
    94147-----------> poly.cc
    95148   Repository revision: 1.10    /projects/Eros/CVSEros/CodeCxx/Outils/poly.cc,v
     149   MAJ                  1.12
    96150-----------> poly.h
    97151   Repository revision: 1.8     /projects/Eros/CVSEros/CodeCxx/Outils/poly.h,v
     152   OK                   1.8
    98153-----------> pversion.cc
    99154   Repository revision: 1.4     /projects/Eros/CVSEros/CodeCxx/Outils/pversion.cc,v
     155   OK                   1.4
    100156-----------> pversion.h
    101157   Repository revision: 1.37    /projects/Eros/CVSEros/CodeCxx/Outils/pversion.h,v
     158   OK                   1.42    rien a faire - numero de version
     159   
    102160-----------> rk4cdifeq.cc
    103161   Repository revision: 1.4     /projects/Eros/CVSEros/CodeCxx/Outils/rk4cdifeq.cc,v
     162   OK                   1.4
    104163-----------> rk4cdifeq.h
    105164   Repository revision: 1.2     /projects/Eros/CVSEros/CodeCxx/Outils/rk4cdifeq.h,v
     165   OK                   1.2
    106166-----------> simplesort.cc
    107167   Repository revision: 1.9     /projects/Eros/CVSEros/CodeCxx/Outils/simplesort.cc,v
     168   OK                   1.9
    108169-----------> simplesort.h
    109170   Repository revision: 1.11    /projects/Eros/CVSEros/CodeCxx/Outils/simplesort.h,v
     171   MAJ                  1.12    KCC std
     172   
    110173-----------> simps2d.h
    111174   Repository revision: 1.1     /projects/Eros/CVSEros/CodeCxx/Outils/simps2d.h,v
     175   OK                   1.1
    112176-----------> tabmath.cc
    113177   Repository revision: 1.3     /projects/Eros/CVSEros/CodeCxx/Outils/tabmath.cc,v
     178   OK                   1.3
    114179-----------> tabmath.h
    115180   Repository revision: 1.2     /projects/Eros/CVSEros/CodeCxx/Outils/tabmath.h,v
     181   OK                   1.2
    116182-----------> utils.cc
    117183   Repository revision: 1.9     /projects/Eros/CVSEros/CodeCxx/Outils/utils.cc,v
     184   OK                   1.9
    118185-----------> utils.h
    119186   Repository revision: 1.14    /projects/Eros/CVSEros/CodeCxx/Outils/utils.h,v
     187   OK                   1.15    KCC std
    120188
    121189NTools from Images++
    122190-----------> cimage.cc
    123191   Repository revision: 1.36    /projects/Eros/CVSEros/CodeCxx/Images/cimage.cc,v
     192   MAJ                  1.38
    124193-----------> cimage.h
    125194   Repository revision: 1.22    /projects/Eros/CVSEros/CodeCxx/Images/cimage.h,v
     195   OK                   1.22
    126196-----------> dynccd.cc
    127197   Repository revision: 1.20    /projects/Eros/CVSEros/CodeCxx/Images/dynccd.cc,v
     198   OK                   1.20
    128199-----------> dynccd.h
    129200   Repository revision: 1.11    /projects/Eros/CVSEros/CodeCxx/Images/dynccd.h,v
     201   OK                   1.11
    130202-----------> imageop.cc
    131203   Repository revision: 1.27    /projects/Eros/CVSEros/CodeCxx/Images/imageop.cc,v
     204   MAJ                  1.28    NoiseFiltImage
    132205-----------> imageop.h
    133206   Repository revision: 1.17    /projects/Eros/CVSEros/CodeCxx/Images/imageop.h,v
     207   MAJ                  1.18   
    134208-----------> rzimage.cc
    135209   Repository revision: 1.29    /projects/Eros/CVSEros/CodeCxx/Images/rzimage.cc,v
     210   OK                   1.29
    136211-----------> rzimage.h
    137212   Repository revision: 1.13    /projects/Eros/CVSEros/CodeCxx/Images/rzimage.h,v
     213   OK                   1.13
    138214-----------> rzvect.h
    139215   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  
    11//
    2 // $Id: histos.cc,v 1.3 1999-05-19 15:57:59 ansari Exp $
     2// $Id: histos.cc,v 1.4 1999-10-21 15:25:45 ansari Exp $
    33//
    44
     
    17371737///////////////////////////////////////////////////////////
    17381738
    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)
     1739void ObjFileIO<Histo>::ReadSelf(PInPersist& is)
    17751740{
    17761741char strg[256];
     
    18131778}
    18141779
    1815 void FIO_Histo::WriteSelf(POutPersist& os) const
     1780void ObjFileIO<Histo>::WriteSelf(POutPersist& os) const
    18161781{
    18171782if (dobj == NULL)   return;
     
    18561821return;
    18571822}
     1823
     1824#ifdef __CXX_PRAGMA_TEMPLATES__
     1825#pragma define_template ObjFileIO<Histo>
     1826#endif
     1827
     1828#if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES)
     1829template class ObjFileIO<Histo>;
     1830#endif
  • trunk/SophyaLib/NTools/histos.h

    r307 r490  
    11// This may look like C code, but it is really -*- C++ -*-
    22//
    3 // $Id: histos.h,v 1.2 1999-05-19 15:58:00 ansari Exp $
     3// $Id: histos.h,v 1.3 1999-10-21 15:25:47 ansari Exp $
    44//
    55
     
    77#define HISTOS_SEEN
    88
     9#include "objfio.h"
     10#include <iostream.h>
    911#include <stdio.h>
    1012#include "peida.h"
     
    1820
    1921class Histo : public AnyDataObj {
    20   friend class FIO_Histo;
     22  friend class ObjFileIO<Histo>;
    2123public:
    2224
     
    156158};
    157159
    158 /////////////////////////////////////////////////////////////////////////
     160
     161inline POutPersist& operator << (POutPersist& os, Histo & obj)
     162{ ObjFileIO<Histo> fio(&obj);  fio.Write(os);  return(os); }
     163inline PInPersist& operator >> (PInPersist& is, Histo & obj)
     164{ ObjFileIO<Histo> fio(&obj);  fio.Read(is);  return(is); }
     165
    159166// 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
    175169
    176170} // Fin du namespace
  • trunk/SophyaLib/NTools/histos2.cc

    r308 r490  
    4545      , hprojx(NULL), hprojy(NULL)
    4646{
    47 DBASSERT(nxBin>0 && nyBin>0 && xMin<xMax && yMin<yMax);
     47ASSERT(nxBin>0 && nyBin>0 && xMin<xMax && yMin<yMax);
    4848for(int i=0;i<3;i++) for(int j=0;j<3;j++) over[i][j]=0.;
    4949Zero();
     
    663663int i,j;
    664664v.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);
     665if(!err2)
     666  {for(i=0;i<nx;i++) for(j=0;j<ny;j++) v(i,j) = 0.; return;}
     667for(i=0;i<nx;i++) for(j=0;j<ny;j++) v(i,j) = Error2(i,j);
    669668return;
    670669}
     
    678677int i,j;
    679678v.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);
     679if(!err2)
     680  {for(i=0;i<nx;i++) for(j=0;j<ny;j++) v(i,j) = 0.; return;}
     681for(i=0;i<nx;i++) for(j=0;j<ny;j++) v(i,j) = Error(i,j);
    684682return;
    685683}
     
    17861784///////////////////////////////////////////////////////////
    17871785
    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
     1787void  ObjFileIO<Histo2D>::ReadSelf(PInPersist& is)
    18241788{
    18251789char strg[256];
     
    18791843  is.GetLine(strg, 255);
    18801844  dobj->SetProjX();
    1881   FIO_Histo fio_h(dobj->hprojx);
     1845  ObjFileIO<Histo> fio_h(dobj->hprojx);
    18821846  fio_h.Read(is);
    18831847}
     
    18851849  is.GetLine(strg, 255);
    18861850  dobj->SetProjY();
    1887   FIO_Histo fio_h(dobj->hprojy);
     1851  ObjFileIO<Histo> fio_h(dobj->hprojy);
    18881852  fio_h.Read(is);
    18891853}
     
    18931857  is.GetLine(strg, 255);
    18941858  dobj->SetSliX(nslix);
    1895   DBASSERT (nslix==dobj->NSliX());
     1859  ASSERT (nslix==dobj->NSliX());
    18961860  for(int j=0;j<dobj->NSliX();j++)
    1897     {FIO_Histo fio_h(dobj->HSliX(j)); fio_h.Read(is);}
     1861    {ObjFileIO<Histo> fio_h(dobj->HSliX(j)); fio_h.Read(is);}
    18981862}
    18991863if(nsliy>0) {
    19001864  is.GetLine(strg, 255);
    19011865  dobj->SetSliY(nsliy);
    1902   DBASSERT (nsliy==dobj->NSliY());
     1866  ASSERT (nsliy==dobj->NSliY());
    19031867  for(int j=0;j<dobj->NSliY();j++)
    1904     {FIO_Histo fio_h(dobj->HSliY(j)); fio_h.Read(is);}
     1868    {ObjFileIO<Histo> fio_h(dobj->HSliY(j)); fio_h.Read(is);}
    19051869}
    19061870
     
    19121876    dobj->SetBandX(min,max);
    19131877  }}
    1914   DBASSERT (nbanx==dobj->NBandX());
     1878  ASSERT (nbanx==dobj->NBandX());
    19151879  {for(int j=0; j<dobj->NBandX(); j++) {
    1916     FIO_Histo fio_h(dobj->HBandX(j));
     1880    ObjFileIO<Histo> fio_h(dobj->HBandX(j));
    19171881    fio_h.Read(is);
    19181882  }}
     
    19241888    dobj->SetBandY(min,max);
    19251889  }}
    1926   DBASSERT (nbany==dobj->NBandY());
     1890  ASSERT (nbany==dobj->NBandY());
    19271891  {for(int j=0; j<dobj->NBandY(); j++) {
    1928     FIO_Histo fio_h(dobj->HBandY(j));
     1892    ObjFileIO<Histo> fio_h(dobj->HBandY(j));
    19291893    fio_h.Read(is);
    19301894  }}
     
    19341898}
    19351899
    1936 void FIO_Histo2D::WriteSelf(POutPersist& os) const
     1900void ObjFileIO<Histo2D>::WriteSelf(POutPersist& os) const
    19371901{
    19381902if (dobj == NULL)   return;
     
    20101974  sprintf(strg,"Histo2D: Projection X");
    20111975  os.PutLine(strg);
    2012   FIO_Histo fio_h(dobj->hprojx); fio_h.Write(os);
     1976  ObjFileIO<Histo> fio_h(dobj->hprojx); fio_h.Write(os);
    20131977}
    20141978if(projy) {
    20151979  sprintf(strg,"Histo2D: Projection Y");
    20161980  os.PutLine(strg);
    2017   FIO_Histo fio_h(dobj->hprojy); fio_h.Write(os);
     1981  ObjFileIO<Histo> fio_h(dobj->hprojy); fio_h.Write(os);
    20181982}
    20191983
     
    20241988  for(int j=0;j<nslix;j++) {
    20251989    Histo* h = dobj->HSliX(j);
    2026     FIO_Histo fio_h(h); fio_h.Write(os);
     1990    ObjFileIO<Histo> fio_h(h); fio_h.Write(os);
    20271991  }
    20281992}
     
    20321996  for(int j=0;j<nsliy;j++) {
    20331997    Histo* h = dobj->HSliY(j);
    2034     FIO_Histo fio_h(h); fio_h.Write(os);
     1998    ObjFileIO<Histo> fio_h(h); fio_h.Write(os);
    20351999  }
    20362000}
     
    20472011  for(it = dobj->lbandx.begin(); it != dobj->lbandx.end(); it++) {
    20482012    Histo* h = (*it).H;
    2049     FIO_Histo fio_h(h); fio_h.Write(os);
     2013    ObjFileIO<Histo> fio_h(h); fio_h.Write(os);
    20502014  }
    20512015}
     
    20602024  for(it = dobj->lbandy.begin(); it != dobj->lbandy.end(); it++) {
    20612025    Histo* h = (*it).H;
    2062     FIO_Histo fio_h(h); fio_h.Write(os);
     2026    ObjFileIO<Histo> fio_h(h); fio_h.Write(os);
    20632027  }
    20642028}
     
    20662030return;
    20672031}
     2032
     2033
     2034#ifdef __CXX_PRAGMA_TEMPLATES__
     2035#pragma define_template ObjFileIO<Histo2D>
     2036#endif
     2037
     2038#if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES)
     2039template class ObjFileIO<Histo2D>;
     2040#endif
  • trunk/SophyaLib/NTools/histos2.h

    r307 r490  
    2323
    2424class Histo2D : public AnyDataObj {
    25   friend class FIO_Histo2D;
     25  friend class ObjFileIO<Histo2D>;
    2626public:
    2727
     
    216216/////////////////////////////////////////////////////////////////////////
    217217// 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
     219inline POutPersist& operator << (POutPersist& os, Histo2D & obj)
     220{ ObjFileIO<Histo2D> fio(&obj);  fio.Write(os);  return(os); }
     221inline 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>
    233226
    234227} // Fin du namespace
  • trunk/SophyaLib/NTools/imageop.cc

    r270 r490  
    528528
    529529}
     530
     531/* Nouvelle-Fonction */
     532//++
     533ImageR4* 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
    530560
    531561//////////////////////////////////////////////////////////////////////////////
  • trunk/SophyaLib/NTools/imageop.h

    r220 r490  
    1313#include "cimage.h"
    1414#include "cspline.h"
     15#include "dynccd.h"
    1516
    1617template <class T>
     
    4950Image<T> * FilterImage(Image<T> const * pim, Image<T> * pom, ImageR4 *matx);
    5051
     52// Calcul une image de bruit prenant en compte le filtre de convolution
     53ImageR4* NoiseFiltImage(ImageR4& img, ImageR4& filtre, DynCCD& dynccd);
     54
    5155///////////////////////////////////////////////////////////////////
    5256//// Filtre statistique d'images
  • trunk/SophyaLib/NTools/integ.h

    r307 r490  
    33// integ.h
    44//
    5 // $Id: integ.h,v 1.3 1999-05-19 15:58:01 ansari Exp $
     5// $Id: integ.h,v 1.4 1999-10-21 15:25:49 ansari Exp $
    66//
    77
     
    1212#include "pexceptions.h"
    1313#include <set>
    14 #if defined(__KCC__)
    15 #include <set.h>
    16 #endif
    1714
    1815namespace PlanckDPC {class GeneralFunction;}
  • trunk/SophyaLib/NTools/matrix.cc

    r307 r490  
    1 // $Id: matrix.cc,v 1.4 1999-05-19 15:58:02 ansari Exp $
     1// $Id: matrix.cc,v 1.5 1999-10-21 15:25:49 ansari Exp $
    22
    33#include "machdefs.h"
     
    240240//--
    241241{
    242   DBASSERT( b != 0. );
     242  ASSERT( b != 0. );
    243243  double* p    = data;
    244244  double* pEnd = data + ndata;
     
    572572void Matrix::WriteSelf(POutPersist& s) const
    573573{
    574   DBASSERT(ndata == nr*nc);
     574  ASSERT(ndata == nr*nc);
    575575  s << nr << nc;
    576576  s.PutR8s(data, ndata);
     
    582582  s >> r >> c;
    583583  Realloc(r,c);
    584   DBASSERT(ndata == nr*nc);
     584  ASSERT(ndata == nr*nc);
    585585  s.GetR8s(data, ndata);
    586586}
  • trunk/SophyaLib/NTools/ntuple.cc

    r475 r490  
    22#include <string.h>
    33
     4#include "strutil.h"
    45#include "perrors.h"
    56#include "ntuple.h"
     
    1617//
    1718//      Classe de ntuples
     19//--
     20//++
     21// Links        Parents
     22// PPersist
     23// NTupleInterface
    1824//--
    1925
     
    3541//++
    3642NTuple::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{
     49mNVar = mNEnt = mBlk = mNBlk = 0;
     50mVar = NULL;
     51mVarD = NULL;
     52mNames = NULL;
     53mInfo = NULL;
     54if (nvar <= 0)  THROW(sizeMismatchErr);
     55mNVar = nvar;
     56mVar = new r_4[nvar];
     57mVarD = new r_8[nvar];
     58if (blk < 10) blk = 10;
     59mBlk = blk;
     60// On prend des noms de LENNAME char pour le moment
     61mNames = new char[nvar*LENNAME1];
     62r_4* pt = new r_4[nvar*blk];
     63mNBlk = 1;
     64mPtr.push_back(pt);
     65int i;
     66for(i=0; i<nvar; i++)
     67  { strncpy(mNames+i*LENNAME1, noms[i], LENNAME); 
     68  mNames[i*LENNAME1+LENNAME] = '\0'; }
     69return;
     70}
     71
     72//                                       cmv 8/10/99
     73//++
     74NTuple::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{
     81if(NT.mNVar<=0) return; // cas ou NT est cree par defaut
     82mNVar = NT.mNVar;
     83mBlk = NT.mBlk;
     84mVar = new r_4[NT.mNVar];
     85mVarD = new r_8[NT.mNVar];
     86mNames = new char[NT.mNVar*LENNAME1];
     87
     88int i;
     89r_4* pt = new r_4[mNVar*mBlk];
     90mNBlk = 1; mPtr.push_back(pt);
     91
     92for(i=0;i<mNVar;i++) strcpy(mNames+i*LENNAME1,NT.NomIndex(i));
     93
     94if(NT.mInfo!=NULL) {mInfo = new DVList; *mInfo = *(NT.mInfo);}
     95
     96if(NT.mNEnt<=0) return;
     97for(i=0;i<NT.mNEnt;i++) {r_4* x=NT.GetVec(i,NULL); Fill(x);}
     98
     99return;
    66100}
    67101
     
    79113mInfo = NULL;
    80114PInPersist s(flnm);
    81 Read(s);
     115ObjFileIO<NTuple> fiont(this);
     116fiont.Read(s);
    82117}
    83118
     
    96131if (mInfo) delete mInfo;
    97132int i;
    98 for(i=0; i<mNBlk; i++)  delete[] mPtr[i];
     133if(mNBlk>0) for(i=0; i<mNBlk; i++)  delete[] mPtr[i];
    99134mPtr.erase(mPtr.begin(), mPtr.end());
    100135mNVar = mNEnt = mBlk = mNBlk = 0;
     
    102137mVarD = NULL;
    103138mNames = NULL;
     139mInfo = NULL;
    104140return;
     141}
     142
     143/* --Methode--        cmv 08/10/99 */
     144//++
     145NTuple& NTuple::operator = (const NTuple& NT)
     146//
     147//      Operateur egal (clone).
     148//--
     149{
     150if(this == &NT) return *this;
     151Clean();
     152if(NT.mNVar<=0) return *this; // cas ou NT est cree par defaut
     153mNVar = NT.mNVar;
     154mBlk = NT.mBlk;
     155mVar = new r_4[NT.mNVar];
     156mVarD = new r_8[NT.mNVar];
     157mNames = new char[NT.mNVar*LENNAME1];
     158
     159int i;
     160r_4* pt = new r_4[mNVar*mBlk];
     161mNBlk = 1; mPtr.push_back(pt);
     162
     163for(i=0;i<mNVar;i++) strcpy(mNames+i*LENNAME1,NT.NomIndex(i));
     164
     165if(NT.mInfo!=NULL) {mInfo = new DVList; *mInfo = *(NT.mInfo);}
     166
     167if(NT.mNEnt<=0) return *this;
     168for(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.
     172return *this;
    105173}
    106174
     
    167235}
    168236
    169 /* --Methode-- */
    170 //++
    171 string NTuple::VarList_C(const char* nomx)  const
    172 //
    173 //      Retourne une chaine de caracteres avec la declaration des noms de
    174 //      variables. si "nomx!=NULL" , des instructions d'affectation
    175 //      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 }
    198237 
    199238/* --Methode-- */
     
    231270}
    232271
    233 /* --Methode-- */
    234 //++
    235 void  NTuple::GetMinMax(int k, float& min, float& max)  const
     272
     273
     274/* --Methode-- */
     275//++
     276DVList&  NTuple::Info()
     277//
     278//      Renvoie une référence sur l'objet DVList Associé
     279//--
     280{
     281if (mInfo == NULL)  mInfo = new DVList;
     282return(*mInfo);
     283}
     284
     285/* --Methode-- */
     286//++
     287void  NTuple::Print(int num, int nmax)  const
     288//
     289//      Imprime `nmax' evenements a partir du numero `num'.
     290//--
     291{
     292int i,j;
     293
     294printf("Num     ");
     295for(i=0; i<mNVar; i++)  printf("%8s ", mNames+i*LENNAME1);
     296putchar('\n');
     297
     298if (nmax <= 0)  nmax = 1;
     299if (num < 0)  num = 0;
     300nmax += num;
     301if (nmax > mNEnt) nmax = mNEnt;
     302for(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}
     308return;
     309}
     310
     311/* --Methode-- */
     312//++
     313void  NTuple::Show(ostream& os)  const
     314//
     315//      Imprime l'information generale sur le ntuple.
     316//--
     317{
     318os << "NTuple: NVar= " << mNVar << " NEnt=" << mNEnt 
     319   << " (Blk Sz,Nb= " << mBlk << " ," << mNBlk << ")\n";
     320os << "            Variables       Min      Max       \n";
     321int i;
     322double min, max;
     323char buff[128];
     324for(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  }
     329os << endl;
     330}
     331
     332
     333/* --Methode-- */
     334//++
     335int  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{
     341if (NbColumns() < 1)  {
     342  cout << "NTuple::FillFromASCIIFile() Ntuple has " << NbColumns() << " columns" << endl;
     343  return(-1);
     344  }
     345FILE * fip = fopen(fn.c_str(), "r");
     346if (fip == NULL) {
     347  cout << "NTuple::FillFromASCIIFile() Error opening file " << fn << endl;
     348  return(-2);
     349  }
     350
     351char lineb[4096];
     352char *line;
     353char buff[64];
     354char* ccp;
     355int i,j,l,kk;
     356int postab, posb;
     357float* xv = new float[NbColumns()];
     358
     359int nlread = 0;
     360int nvar = NbColumns();
     361// On boucle sur toutes les lignes
     362while (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
     392delete[] xv;
     393cout << "NTuple::FillFromASCIIFile( " << fn << ") " << nlread << " fill from file " << endl;
     394return(nlread);
     395}
     396
     397
     398// ------- Implementation de  l interface NTuple  ---------
     399
     400/* --Methode-- */
     401uint_4 NTuple::NbLines() const
     402{
     403return(NEntry());
     404}
     405/* --Methode-- */
     406uint_4 NTuple::NbColumns() const
     407{
     408return(NVar());
     409}
     410
     411/* --Methode-- */
     412r_8 * NTuple::GetLineD(int n) const
     413{
     414return(GetVecD(n));
     415}
     416
     417/* --Methode-- */
     418r_8 NTuple::GetCell(int n, int k) const
     419{
     420return(GetVal(n, k));
     421}
     422
     423/* --Methode-- */
     424r_8 NTuple::GetCell(int n, string const & nom) const
     425{
     426return(GetVal(n, nom.c_str()));
     427}
     428
     429/* --Methode-- */
     430//++
     431void  NTuple::GetMinMax(int k, double& min, double& max)  const
    236432//
    237433//      Retourne le minimum et le maximum de la variable `k'.
     
    241437if ( (k < 0) || (k >= mNVar) )    return;
    242438int jb,ib,i;
    243 float x;
     439double x;
    244440i=0;
    245441for(jb=0; jb< mNBlk; jb++)
     
    256452
    257453/* --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 }
     454void NTuple::GetMinMax(string const & nom, double& min, double& max)   const
     455{
     456GetMinMax(IndexNom(nom.c_str()), min, max);
     457}
     458
     459/* --Methode-- */
     460int NTuple::ColumnIndex(string const & nom)  const
     461{
     462return(IndexNom(nom.c_str()));
     463}
     464
     465/* --Methode-- */
     466string NTuple::ColumnName(int k) const
     467{
     468return(NomIndex(k));
     469}
     470
     471/* --Methode-- */
     472//++
     473string 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{
     480string rets="";
     481int i;
     482for(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  }
     488rets += "; \n";
     489if (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
     498return(rets);
     499}
     500
     501
     502/* --Methode-- */
     503//++
     504string NTuple::LineHeaderToString() const
     505//      Retourne une chaine de caracteres avec la liste des noms de 
     506//      variables, utilisables pour une impression
     507//--
     508{
     509char buff[32];
     510string rets=" Num    ";
     511for(int i=0; i<mNVar; i++) {
     512  sprintf(buff, "%8s ", mNames+i*LENNAME1);
     513  rets += buff;
     514  }
     515rets += '\n';
     516return(rets);
     517}
     518
     519/* --Methode-- */
     520//++
     521string 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{
     526char buff[32];
     527double* val;
     528val = GetLineD(n);
     529sprintf(buff,"%6d: ",n); 
     530string rets=buff;
     531int i;
     532for(i=0; i<mNVar; i++) {
     533  sprintf(buff, "%8.3g ", val[i]);
     534  rets += buff;
     535  }
     536rets += '\n';
     537return(rets);
     538}
     539
     540
     541/* --Methode-- */
     542//++
     543void   ObjFileIO<NTuple>::WriteSelf(POutPersist& s)  const
     544//
     545//      Ecriture ppersist du ntuple.
     546//--
     547{
     548char strg[256];
     549if (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);
     551else sprintf(strg, "NVar=%6d  NEnt=%9d  BlkSz=%6d NBlk=%6d ",
     552                   (int)dobj->mNVar, (int)dobj->mNEnt, (int)dobj->mBlk, (int)dobj->mNBlk);
     553s.PutLine(strg);
     554s.PutI4(dobj->mNVar);
     555s.PutBytes(dobj->mNames, dobj->mNVar*LENNAME1);
     556s.PutI4(dobj->mNEnt);
     557s.PutI4(dobj->mBlk);
     558s.PutI4(dobj->mNBlk);
     559if (dobj->mInfo)  s << (*(dobj->mInfo));
     560int jb;
     561for(jb=0; jb<dobj->mNBlk; jb++)
     562  s.PutR4s(dobj->mPtr[jb], dobj->mNVar*dobj->mBlk);
    291563return;
    292564}
     
    294566/* --Methode-- */
    295567//++
    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 {
     568void  ObjFileIO<NTuple>::ReadSelf(PInPersist& s)
     569//
     570//      Lecture ppersist du ntuple.
     571//--
     572{
     573
     574dobj->Clean();
     575
    323576char 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 }
     577s.GetLine(strg, 255);
     578// Pour savoir s'il y avait un DVList Info associe
     579bool hadinfo = false;
     580if (strncmp(strg+strlen(strg)-7, "HasInfo", 7) == 0)  hadinfo = true;
     581
     582s.GetI4(dobj->mNVar);
     583dobj->mNames = new char[dobj->mNVar*LENNAME1];
     584dobj->mVar = new r_4[dobj->mNVar];
     585dobj->mVarD = new r_8[dobj->mNVar];
     586s.GetBytes(dobj->mNames, dobj->mNVar*LENNAME1);
     587s.GetI4(dobj->mNEnt);
     588s.GetI4(dobj->mBlk);
     589s.GetI4(dobj->mNBlk);
     590
     591if (hadinfo) {    // Lecture eventuelle du DVList Info
     592  if (dobj->mInfo == NULL)  dobj->mInfo = new DVList;
     593  s >> (*(dobj->mInfo));
     594  }
     595
     596int jb;
     597for(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)
     610template class ObjFileIO<NTuple>;
     611#endif
  • trunk/SophyaLib/NTools/ntuple.h

    r475 r490  
     1// This may look like C code, but it is really -*- C++ -*-
    12// Class NTuple
    23//  CMV+Reza     Juillet 97
    34//  CEA-DAPNIA      LAL-IN2P3/CNRS
    4 //  added overloading of operator =      F. Touze, Guy Le Meur 19-OCT-99
    55
    66#ifndef NTUPLE_H_SEEN
    77#define NTUPLE_H_SEEN
     8
     9#include "objfio.h"
    810
    911#include <iostream.h>
     
    1113#include <vector>
    1214
    13 #if defined(__KCC__)
    14 using std::string ;
    15 #include <vector.h>
    16 #endif
    17 
     15#include "ntupintf.h"
    1816#include "ppersist.h"
    1917#include "dvlist.h"
    2018
     19namespace PlanckDPC {
    2120
    22 class NTuple : public PPersist {
     21class NTuple : public AnyDataObj , public NTupleInterface {
    2322public:
    24   enum {classId = ClassId_NTuple };
     23//  enum {classId = ClassId_NTuple };
    2524
    2625                    NTuple(int nvar, char** noms, int blk=512);
    2726                    NTuple();
     27                    NTuple(const NTuple& NT);
    2828                    NTuple(char* flnm);
    2929  virtual           ~NTuple();
    3030
    31   NTuple &operator=(const NTuple &ntpl);
    32 
     31  NTuple&           operator = (const NTuple& NT);
     32 
    3333  void              Fill(r_4* x);
    3434
    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() ?
    3839
    3940  float             GetVal(int n, int k)   const;
    40   inline float      GetVal(int n, char* nom) const
    41                          { return(GetVal(n, IndexNom(nom)) ); }
     41  inline float      GetVal(int n, const char* nom) const
     42                            { return(GetVal(n, IndexNom(nom)) ); }
    4243  int               IndexNom(const char* nom)  const ;
    4344  char*             NomIndex(int k) const;
    44   string            VarList_C(const char* nomx=NULL)  const;
    4545
    4646  r_4*              GetVec(int n, r_4* ret=NULL)  const ;
    4747  r_8*              GetVecD(int n, r_8* ret=NULL)  const ;
    4848
    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
    5350  void              Print(int num, int nmax=1)  const ;
    5451  void              Show(ostream& os) const;
     
    5754  DVList&           Info();
    5855
    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.);
    6158
    62   virtual void      WriteSelf(POutPersist&) const;
    63   virtual void      ReadSelf(PInPersist&);
    6459
     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> ;
    6576
    6677private:
     
    8192  {  nt.Show(s);  return(s);  }
    8293
     94inline POutPersist& operator << (POutPersist& os, NTuple & obj)
     95{ ObjFileIO<NTuple> fio(&obj);  fio.Write(os);  return(os); }
     96inline 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
    83102#ifdef __MWERKS__
    84103__MSL_FIX_ITERATORS__(r_4*);
    85104#endif
    86105
     106} // namespace PlanckDPC
     107
    87108#endif
    88109 
  • trunk/SophyaLib/NTools/outilsinit.cc

    r307 r490  
    1313#include "ntuple.h"
    1414#include "generaldata.h"
     15#include "tmatrix.h"
     16#include "tvector.h"
    1517
    1618#include "cimage.h"
     
    3537  PPRegister(Poly2);
    3638  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
    4268
    4369  PPRegister(RzImage);
  • trunk/SophyaLib/NTools/pclassids.h

    r253 r490  
    2929   ClassId_HProf    = 0x0203,
    3030   ClassId_NTuple   = 0x0210,
    31  
     31   ClassId_XNTuple  = 0x0211,
     32
    3233   ClassId_GeneralFitData  = 0x0290,
    3334
  • trunk/SophyaLib/NTools/poly.cc

    r244 r490  
    566566  maxDegY = degreY;
    567567
    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++)
    570574      Coef(i,j) = tmp.Coef(i,j);
    571575}
  • trunk/SophyaLib/NTools/pversion.h

    r220 r490  
    22#define PVERSION_H
    33
    4 #define PEIDA_VERSION   4.0
    5 #define PEIDA_REVISION  1
    6 #define PEIDA_TAG       "V_Avr99"
     4#define PEIDA_VERSION   1.0
     5#define PEIDA_REVISION  6
     6#define PEIDA_TAG       "V_Nov99"
    77
    88#endif
  • trunk/SophyaLib/NTools/simplesort.h

    r220 r490  
    11// This may look like C code, but it is really -*- C++ -*-
    22//
    3 // $Id: simplesort.h,v 1.1.1.1 1999-04-09 17:57:58 ansari Exp $
     3// $Id: simplesort.h,v 1.2 1999-10-21 15:25:52 ansari Exp $
    44//
    55
     
    6161#include <functional>
    6262#include <algorithm>
    63 #if defined(__KCC__)
    64 #include <functional.h>
    65 #include <algorithm.h>
    66 #endif
    6763
    6864
  • trunk/SophyaLib/NTools/tmatrix.h

    r307 r490  
    194194  bool ownobj;
    195195};
     196
     197template <class T>
     198inline POutPersist& operator << (POutPersist& os, TMatrix<T> & obj)
     199{ FIO_TMatrix<T> fio(&obj);  fio.Write(os);  return(os); }
     200template <class T>
     201inline PInPersist& operator >> (PInPersist& is, TMatrix<T> & obj)
     202{ FIO_TMatrix<T> fio(&obj);  fio.Read(is);  return(is); }
    196203
    197204/////////////////////////////////////////////////////////////////////////
  • trunk/SophyaLib/NTools/tvector.h

    r307 r490  
    9292};
    9393
     94template <class T>
     95inline POutPersist& operator << (POutPersist& os, TVector<T> & obj)
     96{ FIO_TVector<T> fio(&obj);  fio.Write(os);  return(os); }
     97template <class T>
     98inline PInPersist& operator >> (PInPersist& is, TVector<T> & obj)
     99{ FIO_TVector<T> fio(&obj);  fio.Read(is);  return(is); }
     100
    94101} // Fin du namespace
    95102
  • trunk/SophyaLib/NTools/utils.h

    r244 r490  
    11// This may look like C code, but it is really -*- C++ -*-
    22//
    3 // $Id: utils.h,v 1.2 1999-04-22 16:18:52 ansari Exp $
     3// $Id: utils.h,v 1.3 1999-10-21 15:25:53 ansari Exp $
    44//
    55
     
    1313#include <stdio.h>
    1414
    15 #if defined(__KCC__)
    16 using std::string ;
    17 #endif
    1815
    1916// MemCpy marche meme en cas de recouvrement.
Note: See TracChangeset for help on using the changeset viewer.