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

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

doc + vire warning cmv 18/04/00

File size: 3.3 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()
33 {if(!Ok) UpdateHisto(); return (Histo) *this;}
34 //! Retourne le contenu de la moyenne dans le vecteur v
35 inline void GetMean(TVector<r_8>& v)
36 {if(!Ok) UpdateHisto(); Histo::GetValue(v);}
37 //! Retourne le contenu au carre de la dispersion/erreur dans le vecteur v
38 inline void GetError2(TVector<r_8>& v)
39 {if(!Ok) UpdateHisto(); Histo::GetError2(v);}
40 //! Retourne le contenu du bin i
41 inline float operator()(int i) const
42 {if(!Ok) UpdateHisto(); return data[i];}
43 //! Retourne le carre de la dispersion/erreur du bin i
44 inline float Error2(int i) const
45 {if(!Ok) UpdateHisto(); return (float) err2[i];}
46 //! Retourne la dispersion/erreur du bin i
47 inline float Error(int i) const
48 {if(!Ok) UpdateHisto();
49 return err2[i]>0. ? (float) sqrt(err2[i]) : 0.f;}
50
51 // Operators
52 HProf& operator = (const HProf& h);
53 HProf& operator += (const HProf& a);
54 friend HProf operator + (const HProf& a, const HProf& b);
55
56 // Fit
57 //! Fit du profile par ``gfit''.
58 inline int Fit(GeneralFit& gfit)
59 {if(!Ok) UpdateHisto(); return Histo::Fit(gfit,0);}
60 //! Retourne l'Histogramme des residus par ``gfit''.
61 inline Histo FitResidus(GeneralFit& gfit)
62 {if(!Ok) UpdateHisto(); return Histo::FitResidus(gfit);}
63 //! Retourne l'Histogramme de la fonction fittee par ``gfit''.
64 inline Histo FitFunction(GeneralFit& gfit)
65 {if(!Ok) UpdateHisto(); return Histo::FitFunction(gfit);}
66
67 // Print
68 //! Print, voir detail dans Histo::Print
69 inline void Print(int dyn=100,float hmin=1.,float hmax=-1.,int pflag=0,int il=1,int ih=-1)
70 {if(!Ok) UpdateHisto(); Histo::Print(dyn,hmin,hmax,pflag,il,ih);}
71
72protected:
73 void Delete();
74
75 double* SumY; //!< somme
76 double* SumY2; //!< somme des carres
77 double* SumW; //!< somme des poids
78 bool Ok; //!< true isiupdate fait
79 float YMin; //!< limite minimum Y pour somme
80 float YMax; //!< limite maximum Y pour somme
81 uint_2 Opt; //!< options pour les erreurs
82};
83
84
85/*! \ingroup HiStats \fn operator<<(POuttPersist&, HProf)
86 \brief Persistance management */
87inline POutPersist& operator << (POutPersist& os, HProf & obj)
88{ ObjFileIO<HProf> fio(&obj); fio.Write(os); return(os); }
89/*! \ingroup HiStats \fn operator>>(PInPersist&, HProf)
90 \brief Persistance management */
91inline PInPersist& operator >> (PInPersist& is, HProf & obj)
92{ ObjFileIO<HProf> fio(&obj); fio.Read(is); return(is); }
93// Classe pour la gestion de persistance
94// ObjFileIO<HProf>
95
96
97} // Fin du namespace
98
99#endif // HISPROF_SEEN
Note: See TracBrowser for help on using the repository browser.