source: Sophya/trunk/SophyaLib/HiStats/hisprof.h@ 914

Last change on this file since 914 was 914, checked in by ansari, 25 years ago

documentation cmv 13/4/00

File size: 3.0 KB
Line 
1#ifndef HISPROF_SEEN
2#define HISPROF_SEEN
3
4#include <stdio.h>
5#include "peida.h"
6#include "tvector.h"
7#include "ppersist.h"
8#include "histos.h"
9
10namespace SOPHYA {
11
12/*!
13 Classe de profil d'histogrammes.
14*/
15class HProf : public Histo {
16 friend class ObjFileIO<HProf>;
17public:
18
19 // CREATOR / DESTRUCTOR
20 HProf();
21 HProf(float xMin, float xMax, int nBin=100, float yMin=1., float yMax=-1.);
22 HProf(const HProf& H);
23 virtual ~HProf();
24
25 // UPDATING or SETTING
26 void Zero();
27 void UpdateHisto() const;
28 void SetErrOpt(bool spread = true);
29 void Add(float x, float y, float w = 1.);
30 void AddBin(int numBin, float y, float w = 1.);
31
32 // Acces a l information
33 //! Retourne l'histogramme de profil.
34 inline Histo GetHisto() {if(!Ok) UpdateHisto(); return (Histo) *this;}
35 //! Retourne le contenu de la moyenne dans le vecteur v
36 inline void GetMean(Vector& v) {if(!Ok) UpdateHisto(); Histo::GetValue(v);}
37 //! Retourne le contenu au carre de la dispersion/erreur dans le vecteur v
38 inline void GetError2(Vector& v) {if(!Ok) UpdateHisto(); Histo::GetError2(v);}
39 //! Retourne le contenu du bin i
40 inline float operator()(int i) const {if(!Ok) UpdateHisto(); return data[i];}
41 //! Retourne le carre de la dispersion/erreur du bin i
42 inline float Error2(int i) const {if(!Ok) UpdateHisto(); return (float) err2[i];}
43 //! Retourne la dispersion/erreur du bin i
44 inline float Error(int i) const
45 {if(!Ok) UpdateHisto(); return err2[i]>0. ? (float) sqrt(err2[i]) : 0.f;}
46
47 // Operators
48 HProf& operator = (const HProf& h);
49 HProf& operator += (const HProf& a);
50 friend HProf operator + (const HProf& a, const HProf& b);
51
52 // Fit
53 //! Fit du profile par ``gfit''.
54 inline int Fit(GeneralFit& gfit)
55 {if(!Ok) UpdateHisto(); return Histo::Fit(gfit,0);}
56 //! Retourne l'Histogramme des residus par ``gfit''.
57 inline Histo FitResidus(GeneralFit& gfit)
58 {if(!Ok) UpdateHisto(); return Histo::FitResidus(gfit);}
59 //! Retourne l'Histogramme de la fonction fittee par ``gfit''.
60 inline Histo FitFunction(GeneralFit& gfit)
61 {if(!Ok) UpdateHisto(); return Histo::FitFunction(gfit);}
62
63 // Print
64 //! Print, voir detail dans Histo::Print
65 inline void Print(int dyn=100,float hmin=1.,float hmax=-1.,int pflag=0,int il=1,int ih=-1)
66 {if(!Ok) UpdateHisto(); Histo::Print(dyn,hmin,hmax,pflag,il,ih);}
67
68protected:
69 void Delete();
70
71 double* SumY; //!< somme
72 double* SumY2; //!< somme des carres
73 double* SumW; //!< somme des poids
74 bool Ok; //!< true isiupdate fait
75 float YMin; //!< limite minimum Y pour somme
76 float YMax; //!< limite maximum Y pour somme
77 uint_2 Opt; //!< options pour les erreurs
78};
79
80
81inline POutPersist& operator << (POutPersist& os, HProf & obj)
82{ ObjFileIO<HProf> fio(&obj); fio.Write(os); return(os); }
83inline PInPersist& operator >> (PInPersist& is, HProf & obj)
84{ ObjFileIO<HProf> fio(&obj); fio.Read(is); return(is); }
85// Classe pour la gestion de persistance
86// ObjFileIO<HProf>
87
88
89} // Fin du namespace
90
91#endif // HISPROF_SEEN
Note: See TracBrowser for help on using the repository browser.