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