Changeset 307 in Sophya for trunk/SophyaLib/NTools/hisprof.cc


Ignore:
Timestamp:
May 19, 1999, 5:58:06 PM (26 years ago)
Author:
ansari
Message:

FIO_... + grosses modifs cmv 19/5/99

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/NTools/hisprof.cc

    r244 r307  
    77#include "cvector.h"
    88
     9using namespace PlanckDPC;
     10
    911//++
    1012// Class        HProf
     
    4749  Histo::Errors();
    4850  Zero();
    49   END_CONSTRUCTOR
    50 }
    51 
    52 /********* Methode *********/
    53 //++
    54 HProf::HProf(char *flnm)
    55 //
    56 //      Constructeur a partir d'un fichier ppersist.
    57 //--
    58 : Histo()
    59 , SumY(NULL), SumY2(NULL), SumW(NULL), Ok(false), YMin(1.), YMax(-1.), Opt(0)
    60 {
    61   PInPersist s(flnm);
    62   Read(s);
    6351  END_CONSTRUCTOR
    6452}
     
    261249//--
    262250{
    263 if (b.bins!=a.bins) THROW(sizeMismatchErr);
     251if (b.NBins()!=a.NBins()) THROW(sizeMismatchErr);
    264252HProf c(a);
    265253return (c += b);
    266254}
    267255
    268 /********* Methode *********/
    269 //++
    270 void  HProf::WriteSelf(POutPersist& s)  const
    271 //
    272 //      Ecriture ppersist
    273 //--
     256// Rappel des inlines functions pour commentaires
     257//++
     258//   inline Histo GetHisto()
     259//      Retourne l'histogramme de profil.
     260//--
     261//++
     262// inline void GetMean(Vector& v)
     263//      Retourne le contenu de la moyenne dans le vecteur v
     264//--
     265//++
     266// inline void GetError2(Vector& v)
     267//      Retourne le contenu au carre de la dispersion/erreur dans le vecteur v
     268//--
     269//++
     270// inline float operator()(int i) const
     271//      Retourne le contenu du bin i
     272//--
     273//++
     274// inline float Error2(int i) const
     275//      Retourne le carre de la dispersion/erreur du bin i
     276//--
     277//++
     278// inline float Error(int i) const
     279//      Retourne la dispersion/erreur du bin i
     280//--
     281//++
     282// inline int Fit(GeneralFit& gfit)
     283//      Fit du profile par ``gfit''.
     284//--
     285//++
     286// inline Histo* FitResidus(GeneralFit& gfit)
     287//      Retourne l'Histogramme des residus par ``gfit''.
     288//--
     289//++
     290// inline Histo* FitFunction(GeneralFit& gfit)
     291//      Retourne l'Histogramme de la fonction fittee par ``gfit''.
     292//--
     293//++
     294// inline void Print(int dyn,float hmin,float hmax,int pflag,int il,int ih)
     295//      Print, voir detail dans Histo::Print
     296//--
     297
     298
     299///////////////////////////////////////////////////////////
     300// --------------------------------------------------------
     301//   Les objets delegues pour la gestion de persistance
     302// --------------------------------------------------------
     303///////////////////////////////////////////////////////////
     304
     305FIO_HProf::FIO_HProf()
     306{
     307dobj=new HProf;
     308ownobj=true;
     309}
     310
     311FIO_HProf::FIO_HProf(string const & filename)
     312{
     313dobj=new HProf;
     314ownobj=true;
     315Read(filename);
     316}
     317
     318FIO_HProf::FIO_HProf(const HProf & obj)
     319{
     320dobj = new HProf(obj);
     321ownobj=true;
     322}
     323
     324FIO_HProf::FIO_HProf(HProf * obj)
     325{
     326dobj = obj;
     327ownobj=false;
     328}
     329
     330FIO_HProf::~FIO_HProf()
     331{
     332if (ownobj && dobj) delete dobj;
     333}
     334
     335AnyDataObj* FIO_HProf::DataObj()
     336{
     337return(dobj);
     338}
     339
     340void FIO_HProf::ReadSelf(PInPersist& is)
    274341{
    275342char strg[256];
    276343
    277 UpdateHisto();
     344if(dobj==NULL) dobj=new HProf;
     345  else         dobj->Delete();
     346
     347// Lecture entete
     348is.GetLine(strg,255);
     349
     350// Ecriture des valeurs
     351is.Get(dobj->bins);
     352is.Get(dobj->YMin);
     353is.Get(dobj->YMax);
     354is.Get(dobj->Opt);
     355dobj->Ok = true;
     356
     357// Ecriture des donnees propres a l'histogramme de profil.
     358is.GetLine(strg,255);
     359dobj->SumY  = new double[dobj->bins];
     360dobj->SumY2 = new double[dobj->bins];
     361dobj->SumW  = new double[dobj->bins];
     362is.Get(dobj->SumY,  dobj->bins);
     363is.Get(dobj->SumY2, dobj->bins);
     364is.Get(dobj->SumW,  dobj->bins);
     365
     366// Ecriture de l'histogramme
     367FIO_Histo fio_h((Histo&)dobj);
     368fio_h.Read(is);
     369
     370return;
     371}
     372
     373void FIO_HProf::WriteSelf(POutPersist& os) const
     374{
     375if (dobj == NULL)   return;
     376char strg[256];
     377
     378dobj->UpdateHisto();
    278379
    279380// Ecriture entete pour identifier facilement
    280 sprintf(strg,"HProf: YMin=%f  YMax=%f  Opt=%1d",YMin,YMax,Opt);
    281 s.PutLine(strg);
     381sprintf(strg,"HProf: YMin=%f  YMax=%f  Opt=%1d",dobj->YMin,dobj->YMax,dobj->Opt);
     382os.PutLine(strg);
    282383
    283384// Ecriture des valeurs
    284 s.PutI4(bins);
    285 s.PutR4(YMin);
    286 s.PutR4(YMax);
    287 s.PutU2(Opt);
     385os.Put(dobj->bins);
     386os.Put(dobj->YMin);
     387os.Put(dobj->YMax);
     388os.Put(dobj->Opt);
    288389
    289390// Ecriture des donnees propres a l'histogramme de profil.
    290391sprintf(strg,"HProf: SumY SumY2 SumW");
    291 s.PutLine(strg);
    292 s.PutR8s(SumY,  bins);
    293 s.PutR8s(SumY2, bins);
    294 s.PutR8s(SumW,  bins);
     392os.PutLine(strg);
     393os.Put(dobj->SumY,  dobj->bins);
     394os.Put(dobj->SumY2, dobj->bins);
     395os.Put(dobj->SumW,  dobj->bins);
    295396
    296397// Ecriture de l'histogramme
    297 Histo::WriteSelf(s);
     398FIO_Histo fio_h((Histo&)dobj);
     399fio_h.Write(os);
    298400
    299401return;
    300402}
    301 
    302 /********* Methode *********/
    303 //++
    304 void  HProf::ReadSelf(PInPersist& s)
    305 //
    306 //      Lecture ppersist
    307 //--
    308 {
    309 char strg[256];
    310 
    311 Delete();
    312 
    313 // Lecture entete
    314 s.GetLine(strg,255);
    315 
    316 // Ecriture des valeurs
    317 s.GetI4(bins);
    318 s.GetR4(YMin);
    319 s.GetR4(YMax);
    320 s.GetU2(Opt);
    321 Ok = true;
    322 
    323 // Ecriture des donnees propres a l'histogramme de profil.
    324 s.GetLine(strg,255);
    325 SumY  = new double[bins];
    326 SumY2 = new double[bins];
    327 SumW  = new double[bins];
    328 s.GetR8s(SumY,  bins);
    329 s.GetR8s(SumY2, bins);
    330 s.GetR8s(SumW,  bins);
    331 
    332 // Ecriture de l'histogramme
    333 Histo::ReadSelf(s);
    334 
    335 return;
    336 }
    337 
    338 
    339 // Rappel des inlines functions pour commentaires
    340 //++
    341 //   inline Histo GetHisto()
    342 //      Retourne l'histogramme de profil.
    343 //--
    344 //++
    345 // inline void GetMean(Vector& v)
    346 //      Retourne le contenu de la moyenne dans le vecteur v
    347 //--
    348 //++
    349 // inline void GetError2(Vector& v)
    350 //      Retourne le contenu au carre de la dispersion/erreur dans le vecteur v
    351 //--
    352 //++
    353 // inline float operator()(int i) const
    354 //      Retourne le contenu du bin i
    355 //--
    356 //++
    357 // inline float Error2(int i) const
    358 //      Retourne le carre de la dispersion/erreur du bin i
    359 //--
    360 //++
    361 // inline float Error(int i) const
    362 //      Retourne la dispersion/erreur du bin i
    363 //--
    364 //++
    365 // inline int Fit(GeneralFit& gfit)
    366 //      Fit du profile par ``gfit''.
    367 //--
    368 //++
    369 // inline Histo* FitResidus(GeneralFit& gfit)
    370 //      Retourne l'Histogramme des residus par ``gfit''.
    371 //--
    372 //++
    373 // inline Histo* FitFunction(GeneralFit& gfit)
    374 //      Retourne l'Histogramme de la fonction fittee par ``gfit''.
    375 //--
    376 //++
    377 // inline void Print(int dyn,float hmin,float hmax,int pflag,int il,int ih)
    378 //      Print, voir detail dans Histo::Print
    379 //--
Note: See TracChangeset for help on using the changeset viewer.