[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
|
---|
[1089] | 24 | //! Calcul la partie histogramme du profile si elle n'est pas a jour.
|
---|
| 25 | virtual inline void UpdateHisto(bool force=false) const
|
---|
| 26 | {if(!Ok || force) updatehisto();}
|
---|
[1056] | 27 | void SetErrOpt(bool spread = true);
|
---|
| 28 | void Zero();
|
---|
| 29 | void Add(float x, float y, float w = 1.);
|
---|
| 30 | void AddBin(int numBin, float y, float w = 1.);
|
---|
[763] | 31 |
|
---|
| 32 | // Acces a l information
|
---|
[914] | 33 | //! Retourne l'histogramme de profil.
|
---|
[943] | 34 | inline Histo GetHisto()
|
---|
[1089] | 35 | {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)
|
---|
[1089] | 38 | {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)
|
---|
[1089] | 41 | {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)
|
---|
[1089] | 44 | {UpdateHisto(); Histo::GetError(v);}
|
---|
[914] | 45 | //! Retourne le contenu du bin i
|
---|
[943] | 46 | inline float operator()(int i) const
|
---|
[1089] | 47 | {UpdateHisto(); return data[i];}
|
---|
[914] | 48 | //! Retourne le carre de la dispersion/erreur du bin i
|
---|
[1056] | 49 | inline double Error2(int i) const
|
---|
[1089] | 50 | {UpdateHisto(); return (float) err2[i];}
|
---|
[914] | 51 | //! Retourne la dispersion/erreur du bin i
|
---|
[763] | 52 | inline float Error(int i) const
|
---|
[1089] | 53 | {UpdateHisto();
|
---|
| 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 |
|
---|
[1058] | 60 | // Info, statistique et calculs sur les histogrammes
|
---|
| 61 | virtual void HRebin(int nbinew);
|
---|
| 62 |
|
---|
[763] | 63 | // Fit
|
---|
[914] | 64 | //! Fit du profile par ``gfit''.
|
---|
[1056] | 65 | inline int Fit(GeneralFit& gfit)
|
---|
[1089] | 66 | {UpdateHisto(); return Histo::Fit(gfit,0);}
|
---|
[914] | 67 | //! Retourne l'Histogramme des residus par ``gfit''.
|
---|
[1056] | 68 | inline Histo FitResidus(GeneralFit& gfit)
|
---|
[1089] | 69 | {UpdateHisto(); return Histo::FitResidus(gfit);}
|
---|
[914] | 70 | //! Retourne l'Histogramme de la fonction fittee par ``gfit''.
|
---|
[1056] | 71 | inline Histo FitFunction(GeneralFit& gfit)
|
---|
[1089] | 72 | {UpdateHisto(); return Histo::FitFunction(gfit);}
|
---|
[763] | 73 |
|
---|
| 74 | // Print
|
---|
[914] | 75 | //! Print, voir detail dans Histo::Print
|
---|
[1056] | 76 | inline void Print(int dyn=100,float hmin=1.,float hmax=-1.
|
---|
| 77 | ,int pflag=0,int il=1,int ih=-1)
|
---|
[1089] | 78 | {UpdateHisto(); Histo::Print(dyn,hmin,hmax,pflag,il,ih);}
|
---|
[1056] | 79 | //! PrintF, voir detail dans Histo::PrintF
|
---|
| 80 | inline void PrintF(FILE * fp,int dyn=100,float hmin=1.,float hmax=-1.
|
---|
| 81 | ,int pflag=0,int il=1,int ih=-1)
|
---|
[1089] | 82 | {UpdateHisto(); Histo::PrintF(fp,dyn,hmin,hmax,pflag,il,ih);}
|
---|
[763] | 83 |
|
---|
| 84 | protected:
|
---|
| 85 | void Delete();
|
---|
[1089] | 86 | void updatehisto() const;
|
---|
[763] | 87 |
|
---|
[914] | 88 | double* SumY; //!< somme
|
---|
| 89 | double* SumY2; //!< somme des carres
|
---|
| 90 | double* SumW; //!< somme des poids
|
---|
[1089] | 91 | mutable bool Ok; //!< true if update fait
|
---|
[914] | 92 | float YMin; //!< limite minimum Y pour somme
|
---|
| 93 | float YMax; //!< limite maximum Y pour somme
|
---|
| 94 | uint_2 Opt; //!< options pour les erreurs
|
---|
[763] | 95 | };
|
---|
| 96 |
|
---|
| 97 |
|
---|
[958] | 98 | /*! \ingroup HiStats \fn operator<<(POuttPersist&, HProf)
|
---|
| 99 | \brief Persistance management */
|
---|
[763] | 100 | inline POutPersist& operator << (POutPersist& os, HProf & obj)
|
---|
| 101 | { ObjFileIO<HProf> fio(&obj); fio.Write(os); return(os); }
|
---|
[958] | 102 | /*! \ingroup HiStats \fn operator>>(PInPersist&, HProf)
|
---|
| 103 | \brief Persistance management */
|
---|
[763] | 104 | inline PInPersist& operator >> (PInPersist& is, HProf & obj)
|
---|
| 105 | { ObjFileIO<HProf> fio(&obj); fio.Read(is); return(is); }
|
---|
| 106 | // Classe pour la gestion de persistance
|
---|
| 107 | // ObjFileIO<HProf>
|
---|
| 108 |
|
---|
[1053] | 109 | /*! \ingroup HiStats \fn operator+(const HProf&, const HProf&)
|
---|
| 110 | \brief Operateur H = H1 + H2
|
---|
| 111 | \warning Meme commentaire que pour l'operateur +=
|
---|
| 112 | */
|
---|
| 113 | inline HProf operator + (const HProf& a, const HProf& b)
|
---|
| 114 | {
|
---|
| 115 | if (b.NBins()!=a.NBins()) THROW(sizeMismatchErr);
|
---|
| 116 | HProf c(a);
|
---|
| 117 | return (c += b);
|
---|
| 118 | }
|
---|
[763] | 119 |
|
---|
| 120 | } // Fin du namespace
|
---|
| 121 |
|
---|
| 122 | #endif // HISPROF_SEEN
|
---|