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