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

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