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

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

updatehisto formalisation cmv 25/7/00

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