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