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
RevLine 
[763]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
[926]12//! 1 dimension profile histograms
[763]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
[914]31 //! Retourne l'histogramme de profil.
[943]32 inline Histo GetHisto()
33 {if(!Ok) UpdateHisto(); return (Histo) *this;}
[914]34 //! Retourne le contenu de la moyenne dans le vecteur v
[943]35 inline void GetMean(TVector<r_8>& v)
36 {if(!Ok) UpdateHisto(); Histo::GetValue(v);}
[914]37 //! Retourne le contenu au carre de la dispersion/erreur dans le vecteur v
[943]38 inline void GetError2(TVector<r_8>& v)
39 {if(!Ok) UpdateHisto(); Histo::GetError2(v);}
[914]40 //! Retourne le contenu du bin i
[943]41 inline float operator()(int i) const
42 {if(!Ok) UpdateHisto(); return data[i];}
[914]43 //! Retourne le carre de la dispersion/erreur du bin i
[943]44 inline float Error2(int i) const
45 {if(!Ok) UpdateHisto(); return (float) err2[i];}
[914]46 //! Retourne la dispersion/erreur du bin i
[763]47 inline float Error(int i) const
[943]48 {if(!Ok) UpdateHisto();
49 return err2[i]>0. ? (float) sqrt(err2[i]) : 0.f;}
[763]50
51 // Operators
52 HProf& operator = (const HProf& h);
53 HProf& operator += (const HProf& a);
54
55 // Fit
[914]56 //! Fit du profile par ``gfit''.
[763]57 inline int Fit(GeneralFit& gfit)
58 {if(!Ok) UpdateHisto(); return Histo::Fit(gfit,0);}
[914]59 //! Retourne l'Histogramme des residus par ``gfit''.
[763]60 inline Histo FitResidus(GeneralFit& gfit)
61 {if(!Ok) UpdateHisto(); return Histo::FitResidus(gfit);}
[914]62 //! Retourne l'Histogramme de la fonction fittee par ``gfit''.
[763]63 inline Histo FitFunction(GeneralFit& gfit)
64 {if(!Ok) UpdateHisto(); return Histo::FitFunction(gfit);}
65
66 // Print
[914]67 //! Print, voir detail dans Histo::Print
[763]68 inline void Print(int dyn=100,float hmin=1.,float hmax=-1.,int pflag=0,int il=1,int ih=-1)
[943]69 {if(!Ok) UpdateHisto(); Histo::Print(dyn,hmin,hmax,pflag,il,ih);}
[763]70
71protected:
72 void Delete();
73
[914]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
[763]81};
82
83
[958]84/*! \ingroup HiStats \fn operator<<(POuttPersist&, HProf)
85 \brief Persistance management */
[763]86inline POutPersist& operator << (POutPersist& os, HProf & obj)
87{ ObjFileIO<HProf> fio(&obj); fio.Write(os); return(os); }
[958]88/*! \ingroup HiStats \fn operator>>(PInPersist&, HProf)
89 \brief Persistance management */
[763]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
[1053]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}
[763]105
106} // Fin du namespace
107
108#endif // HISPROF_SEEN
Note: See TracBrowser for help on using the repository browser.