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

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

define module HiStats in Doc cmv 13/4/00

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