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

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

les friend operator ne marche plus ? passage en inline cmv 30/06/00

File size: 3.5 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
55 // Fit
56 //! Fit du profile par ``gfit''.
57 inline int Fit(GeneralFit& gfit)
58 {if(!Ok) UpdateHisto(); return Histo::Fit(gfit,0);}
59 //! Retourne l'Histogramme des residus par ``gfit''.
60 inline Histo FitResidus(GeneralFit& gfit)
61 {if(!Ok) UpdateHisto(); return Histo::FitResidus(gfit);}
62 //! Retourne l'Histogramme de la fonction fittee par ``gfit''.
63 inline Histo FitFunction(GeneralFit& gfit)
64 {if(!Ok) UpdateHisto(); return Histo::FitFunction(gfit);}
65
66 // Print
67 //! Print, voir detail dans Histo::Print
68 inline void Print(int dyn=100,float hmin=1.,float hmax=-1.,int pflag=0,int il=1,int ih=-1)
69 {if(!Ok) UpdateHisto(); Histo::Print(dyn,hmin,hmax,pflag,il,ih);}
70
71protected:
72 void Delete();
73
74 double* SumY; //!< somme
75 double* SumY2; //!< somme des carres
76 double* SumW; //!< somme des poids
77 bool Ok; //!< true isiupdate fait
78 float YMin; //!< limite minimum Y pour somme
79 float YMax; //!< limite maximum Y pour somme
80 uint_2 Opt; //!< options pour les erreurs
81};
82
83
84/*! \ingroup HiStats \fn operator<<(POuttPersist&, HProf)
85 \brief Persistance management */
86inline POutPersist& operator << (POutPersist& os, HProf & obj)
87{ ObjFileIO<HProf> fio(&obj); fio.Write(os); return(os); }
88/*! \ingroup HiStats \fn operator>>(PInPersist&, HProf)
89 \brief Persistance management */
90inline PInPersist& operator >> (PInPersist& is, HProf & obj)
91{ ObjFileIO<HProf> fio(&obj); fio.Read(is); return(is); }
92// Classe pour la gestion de persistance
93// ObjFileIO<HProf>
94
95/*! \ingroup HiStats \fn operator+(const HProf&, const HProf&)
96 \brief Operateur H = H1 + H2
97 \warning Meme commentaire que pour l'operateur +=
98*/
99inline HProf operator + (const HProf& a, const HProf& b)
100{
101if (b.NBins()!=a.NBins()) THROW(sizeMismatchErr);
102HProf c(a);
103return (c += b);
104}
105
106} // Fin du namespace
107
108#endif // HISPROF_SEEN
Note: See TracBrowser for help on using the repository browser.