[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 |
|
---|
| 10 | namespace SOPHYA {
|
---|
| 11 |
|
---|
[914] | 12 | /*!
|
---|
| 13 | Classe de profil d'histogrammes.
|
---|
| 14 | */
|
---|
[763] | 15 | class HProf : public Histo {
|
---|
| 16 | friend class ObjFileIO<HProf>;
|
---|
| 17 | public:
|
---|
| 18 |
|
---|
| 19 | // CREATOR / DESTRUCTOR
|
---|
| 20 | HProf();
|
---|
| 21 | HProf(float xMin, float xMax, int nBin=100, float yMin=1., float yMax=-1.);
|
---|
| 22 | HProf(const HProf& H);
|
---|
| 23 | virtual ~HProf();
|
---|
| 24 |
|
---|
| 25 | // UPDATING or SETTING
|
---|
| 26 | void Zero();
|
---|
| 27 | void UpdateHisto() const;
|
---|
| 28 | void SetErrOpt(bool spread = true);
|
---|
| 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
|
---|
[914] | 33 | //! Retourne l'histogramme de profil.
|
---|
[763] | 34 | inline Histo GetHisto() {if(!Ok) UpdateHisto(); return (Histo) *this;}
|
---|
[914] | 35 | //! Retourne le contenu de la moyenne dans le vecteur v
|
---|
[763] | 36 | inline void GetMean(Vector& v) {if(!Ok) UpdateHisto(); Histo::GetValue(v);}
|
---|
[914] | 37 | //! Retourne le contenu au carre de la dispersion/erreur dans le vecteur v
|
---|
[763] | 38 | inline void GetError2(Vector& v) {if(!Ok) UpdateHisto(); Histo::GetError2(v);}
|
---|
[914] | 39 | //! Retourne le contenu du bin i
|
---|
[763] | 40 | inline float operator()(int i) const {if(!Ok) UpdateHisto(); return data[i];}
|
---|
[914] | 41 | //! Retourne le carre de la dispersion/erreur du bin i
|
---|
[763] | 42 | inline float Error2(int i) const {if(!Ok) UpdateHisto(); return (float) err2[i];}
|
---|
[914] | 43 | //! Retourne la dispersion/erreur du bin i
|
---|
[763] | 44 | inline float Error(int i) const
|
---|
| 45 | {if(!Ok) UpdateHisto(); return err2[i]>0. ? (float) sqrt(err2[i]) : 0.f;}
|
---|
| 46 |
|
---|
| 47 | // Operators
|
---|
| 48 | HProf& operator = (const HProf& h);
|
---|
| 49 | HProf& operator += (const HProf& a);
|
---|
| 50 | friend HProf operator + (const HProf& a, const HProf& b);
|
---|
| 51 |
|
---|
| 52 | // Fit
|
---|
[914] | 53 | //! Fit du profile par ``gfit''.
|
---|
[763] | 54 | inline int Fit(GeneralFit& gfit)
|
---|
| 55 | {if(!Ok) UpdateHisto(); return Histo::Fit(gfit,0);}
|
---|
[914] | 56 | //! Retourne l'Histogramme des residus par ``gfit''.
|
---|
[763] | 57 | inline Histo FitResidus(GeneralFit& gfit)
|
---|
| 58 | {if(!Ok) UpdateHisto(); return Histo::FitResidus(gfit);}
|
---|
[914] | 59 | //! Retourne l'Histogramme de la fonction fittee par ``gfit''.
|
---|
[763] | 60 | inline Histo FitFunction(GeneralFit& gfit)
|
---|
| 61 | {if(!Ok) UpdateHisto(); return Histo::FitFunction(gfit);}
|
---|
| 62 |
|
---|
| 63 | // Print
|
---|
[914] | 64 | //! Print, voir detail dans Histo::Print
|
---|
[763] | 65 | inline void Print(int dyn=100,float hmin=1.,float hmax=-1.,int pflag=0,int il=1,int ih=-1)
|
---|
| 66 | {if(!Ok) UpdateHisto(); Histo::Print(dyn,hmin,hmax,pflag,il,ih);}
|
---|
| 67 |
|
---|
| 68 | protected:
|
---|
| 69 | void Delete();
|
---|
| 70 |
|
---|
[914] | 71 | double* SumY; //!< somme
|
---|
| 72 | double* SumY2; //!< somme des carres
|
---|
| 73 | double* SumW; //!< somme des poids
|
---|
| 74 | bool Ok; //!< true isiupdate fait
|
---|
| 75 | float YMin; //!< limite minimum Y pour somme
|
---|
| 76 | float YMax; //!< limite maximum Y pour somme
|
---|
| 77 | uint_2 Opt; //!< options pour les erreurs
|
---|
[763] | 78 | };
|
---|
| 79 |
|
---|
| 80 |
|
---|
| 81 | inline POutPersist& operator << (POutPersist& os, HProf & obj)
|
---|
| 82 | { ObjFileIO<HProf> fio(&obj); fio.Write(os); return(os); }
|
---|
| 83 | inline PInPersist& operator >> (PInPersist& is, HProf & obj)
|
---|
| 84 | { ObjFileIO<HProf> fio(&obj); fio.Read(is); return(is); }
|
---|
| 85 | // Classe pour la gestion de persistance
|
---|
| 86 | // ObjFileIO<HProf>
|
---|
| 87 |
|
---|
| 88 |
|
---|
| 89 | } // Fin du namespace
|
---|
| 90 |
|
---|
| 91 | #endif // HISPROF_SEEN
|
---|