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

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

Histos/Hprof/Histo2D en r_8 cmv 26/7/00

File size: 4.2 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(r_8 xMin, r_8 xMax, int_4 nBin=100, r_8 yMin=1., r_8 yMax=-1.);
20 HProf(r_4 xMin, r_4 xMax, int_4 nBin=100, r_4 yMin=1., r_4 yMax=-1.);
21 HProf(const HProf& H);
22 virtual ~HProf();
23
24 // UPDATING or SETTING
25 //! Calcul la partie histogramme du profile si elle n'est pas a jour.
26 virtual inline void UpdateHisto(bool force=false) const
27 {if(!Ok || force) updatehisto();}
28 void SetErrOpt(bool spread = true);
29 void Zero();
30 void Add(r_8 x, r_8 y, r_8 w = 1.);
31 void AddBin(int_4 numBin, r_8 y, r_8 w = 1.);
32
33 // Acces a l information
34 //! Retourne l'histogramme de profil.
35 inline Histo GetHisto()
36 {UpdateHisto(); return (Histo) *this;}
37 //! Retourne le contenu de la moyenne dans le vecteur v
38 inline void GetValue(TVector<r_8>& v)
39 {UpdateHisto(); Histo::GetValue(v);}
40 //! Retourne le contenu au carre de la dispersion/erreur dans le vecteur v
41 inline void GetError2(TVector<r_8>& v)
42 {UpdateHisto(); Histo::GetError2(v);}
43 //! Retourne le contenu au carre de la dispersion/erreur dans le vecteur v
44 inline void GetError(TVector<r_8>& v)
45 {UpdateHisto(); Histo::GetError(v);}
46 //! Retourne le contenu du bin i
47 inline r_8 operator()(int_4 i) const
48 {UpdateHisto(); return mData[i];}
49 //! Retourne le carre de la dispersion/erreur du bin i
50 inline r_8 Error2(int_4 i) const
51 {UpdateHisto(); return mErr2[i];}
52 //! Retourne la dispersion/erreur du bin i
53 inline r_8 Error(int_4 i) const
54 {UpdateHisto();
55 return (mErr2[i]>0.) ? sqrt(mErr2[i]) : 0.;}
56
57 // Operators
58 HProf& operator = (const HProf& h);
59 HProf& operator += (const HProf& a);
60
61 // Info, statistique et calculs sur les histogrammes
62 virtual void HRebin(int_4 nbinew);
63
64 // Fit
65 //! Fit du profile par ``gfit''.
66 inline int_4 Fit(GeneralFit& gfit)
67 {UpdateHisto(); return Histo::Fit(gfit,0);}
68 //! Retourne l'Histogramme des residus par ``gfit''.
69 inline Histo FitResidus(GeneralFit& gfit)
70 {UpdateHisto(); return Histo::FitResidus(gfit);}
71 //! Retourne l'Histogramme de la fonction fittee par ``gfit''.
72 inline Histo FitFunction(GeneralFit& gfit)
73 {UpdateHisto(); return Histo::FitFunction(gfit);}
74
75 // Print
76 //! Print, voir detail dans Histo::Print
77 inline void Print(int_4 dyn=100,r_8 hmin=1.,r_8 hmax=-1.
78 ,int_4 pflag=0,int_4 il=1,int_4 ih=-1)
79 {UpdateHisto(); Histo::Print(dyn,hmin,hmax,pflag,il,ih);}
80 //! PrintF, voir detail dans Histo::PrintF
81 inline void PrintF(FILE * fp,int_4 dyn=100,r_8 hmin=1.,r_8 hmax=-1.
82 ,int_4 pflag=0,int_4 il=1,int_4 ih=-1)
83 {UpdateHisto(); Histo::PrintF(fp,dyn,hmin,hmax,pflag,il,ih);}
84
85protected:
86 void Delete();
87 void updatehisto() const;
88
89 r_8* SumY; //!< somme
90 r_8* SumY2; //!< somme des carres
91 r_8* SumW; //!< somme des poids
92 mutable bool Ok; //!< true if update fait
93 r_8 YMin; //!< limite minimum Y pour somme
94 r_8 YMax; //!< limite maximum Y pour somme
95 uint_2 Opt; //!< options pour les erreurs
96};
97
98
99/*! \ingroup HiStats \fn operator<<(POuttPersist&, HProf)
100 \brief Persistance management */
101inline POutPersist& operator << (POutPersist& os, HProf & obj)
102{ ObjFileIO<HProf> fio(&obj); fio.Write(os); return(os); }
103/*! \ingroup HiStats \fn operator>>(PInPersist&, HProf)
104 \brief Persistance management */
105inline PInPersist& operator >> (PInPersist& is, HProf & obj)
106{ ObjFileIO<HProf> fio(&obj); fio.Read(is); return(is); }
107// Classe pour la gestion de persistance
108// ObjFileIO<HProf>
109
110/*! \ingroup HiStats \fn operator+(const HProf&, const HProf&)
111 \brief Operateur H = H1 + H2
112 \warning Meme commentaire que pour l'operateur +=
113*/
114inline HProf operator + (const HProf& a, const HProf& b)
115{
116if (b.NBins()!=a.NBins()) THROW(sizeMismatchErr);
117HProf c(a);
118return (c += b);
119}
120
121} // Fin du namespace
122
123#endif // HISPROF_SEEN
Note: See TracBrowser for help on using the repository browser.