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

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

cmv 7/7/2000

hisprof.cc,h:

fonction IsOk()
GetMean -> GetValue (mauvais nom)
float Error2() -> double Error2()
nouveau: GetError(TVector<r_8>& v)
HProf::PrintF() sur-ecriture de Histo::PrintF
protection dans createur par copie dans alloc

SumY... pour le cas ou H.bins==0

protection dans UpdateHisto pour HProf cree par defaut (bins==0)
Dans WriteSelf UpdateHisto appele que si necessaire (IsOk()?)

histos2.cc : le Print() dit si les erreurs ont ete demandees
histos.cc,h:

protection dans createur par copie dans alloc

pour le cas ou H.bins==0

protection dans Zero() pour Histo cree par defaut (bins==0)
protection dans operator=() pour Histo cree par defaut (bins==0)
le Print() dit si les erreurs ont ete demandees

cmv 7/7/2000

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