Changeset 307 in Sophya for trunk/SophyaLib/NTools/hisprof.cc
- Timestamp:
- May 19, 1999, 5:58:06 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/NTools/hisprof.cc
r244 r307 7 7 #include "cvector.h" 8 8 9 using namespace PlanckDPC; 10 9 11 //++ 10 12 // Class HProf … … 47 49 Histo::Errors(); 48 50 Zero(); 49 END_CONSTRUCTOR50 }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);63 51 END_CONSTRUCTOR 64 52 } … … 261 249 //-- 262 250 { 263 if (b. bins!=a.bins) THROW(sizeMismatchErr);251 if (b.NBins()!=a.NBins()) THROW(sizeMismatchErr); 264 252 HProf c(a); 265 253 return (c += b); 266 254 } 267 255 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 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) 274 341 { 275 342 char strg[256]; 276 343 277 UpdateHisto(); 344 if(dobj==NULL) dobj=new HProf; 345 else dobj->Delete(); 346 347 // Lecture entete 348 is.GetLine(strg,255); 349 350 // Ecriture des valeurs 351 is.Get(dobj->bins); 352 is.Get(dobj->YMin); 353 is.Get(dobj->YMax); 354 is.Get(dobj->Opt); 355 dobj->Ok = true; 356 357 // Ecriture des donnees propres a l'histogramme de profil. 358 is.GetLine(strg,255); 359 dobj->SumY = new double[dobj->bins]; 360 dobj->SumY2 = new double[dobj->bins]; 361 dobj->SumW = new double[dobj->bins]; 362 is.Get(dobj->SumY, dobj->bins); 363 is.Get(dobj->SumY2, dobj->bins); 364 is.Get(dobj->SumW, dobj->bins); 365 366 // Ecriture de l'histogramme 367 FIO_Histo fio_h((Histo&)dobj); 368 fio_h.Read(is); 369 370 return; 371 } 372 373 void FIO_HProf::WriteSelf(POutPersist& os) const 374 { 375 if (dobj == NULL) return; 376 char strg[256]; 377 378 dobj->UpdateHisto(); 278 379 279 380 // Ecriture entete pour identifier facilement 280 sprintf(strg,"HProf: YMin=%f YMax=%f Opt=%1d", YMin,YMax,Opt);281 s.PutLine(strg);381 sprintf(strg,"HProf: YMin=%f YMax=%f Opt=%1d",dobj->YMin,dobj->YMax,dobj->Opt); 382 os.PutLine(strg); 282 383 283 384 // Ecriture des valeurs 284 s.PutI4(bins);285 s.PutR4(YMin);286 s.PutR4(YMax);287 s.PutU2(Opt);385 os.Put(dobj->bins); 386 os.Put(dobj->YMin); 387 os.Put(dobj->YMax); 388 os.Put(dobj->Opt); 288 389 289 390 // Ecriture des donnees propres a l'histogramme de profil. 290 391 sprintf(strg,"HProf: SumY SumY2 SumW"); 291 s.PutLine(strg);292 s.PutR8s(SumY,bins);293 s.PutR8s(SumY2,bins);294 s.PutR8s(SumW,bins);392 os.PutLine(strg); 393 os.Put(dobj->SumY, dobj->bins); 394 os.Put(dobj->SumY2, dobj->bins); 395 os.Put(dobj->SumW, dobj->bins); 295 396 296 397 // Ecriture de l'histogramme 297 Histo::WriteSelf(s); 398 FIO_Histo fio_h((Histo&)dobj); 399 fio_h.Write(os); 298 400 299 401 return; 300 402 } 301 302 /********* Methode *********/303 //++304 void HProf::ReadSelf(PInPersist& s)305 //306 // Lecture ppersist307 //--308 {309 char strg[256];310 311 Delete();312 313 // Lecture entete314 s.GetLine(strg,255);315 316 // Ecriture des valeurs317 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'histogramme333 Histo::ReadSelf(s);334 335 return;336 }337 338 339 // Rappel des inlines functions pour commentaires340 //++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 v347 //--348 //++349 // inline void GetError2(Vector& v)350 // Retourne le contenu au carre de la dispersion/erreur dans le vecteur v351 //--352 //++353 // inline float operator()(int i) const354 // Retourne le contenu du bin i355 //--356 //++357 // inline float Error2(int i) const358 // Retourne le carre de la dispersion/erreur du bin i359 //--360 //++361 // inline float Error(int i) const362 // Retourne la dispersion/erreur du bin i363 //--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::Print379 //--
Note:
See TracChangeset
for help on using the changeset viewer.