| 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 | 
 | 
|---|
| 12 | //! 1 dimension profile histograms
 | 
|---|
| 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 UpdateHisto() const;
 | 
|---|
| 25 |   void SetErrOpt(bool spread = true);
 | 
|---|
| 26 |   void Zero();
 | 
|---|
| 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
 | 
|---|
| 31 |   //! Retourne true si l'histogramme est a jours, false sinon.
 | 
|---|
| 32 |   inline bool IsOk() const {return Ok;}
 | 
|---|
| 33 |   //! Retourne l'histogramme de profil.
 | 
|---|
| 34 |   inline Histo GetHisto()
 | 
|---|
| 35 |                {if(!Ok) UpdateHisto(); return (Histo) *this;}
 | 
|---|
| 36 |   //! Retourne le contenu de la moyenne dans le vecteur v
 | 
|---|
| 37 |   inline void GetValue(TVector<r_8>& v)
 | 
|---|
| 38 |               {if(!Ok) UpdateHisto(); Histo::GetValue(v);}
 | 
|---|
| 39 |   //! Retourne le contenu au carre de la dispersion/erreur dans le vecteur v
 | 
|---|
| 40 |   inline void GetError2(TVector<r_8>& v)
 | 
|---|
| 41 |               {if(!Ok) UpdateHisto(); Histo::GetError2(v);}
 | 
|---|
| 42 |   //! Retourne le contenu au carre de la dispersion/erreur dans le vecteur v
 | 
|---|
| 43 |   inline void GetError(TVector<r_8>& v)
 | 
|---|
| 44 |               {if(!Ok) UpdateHisto(); Histo::GetError(v);}
 | 
|---|
| 45 |   //! Retourne le contenu du bin i
 | 
|---|
| 46 |   inline float operator()(int i) const
 | 
|---|
| 47 |                {if(!Ok) UpdateHisto(); return data[i];}
 | 
|---|
| 48 |   //! Retourne le carre de la dispersion/erreur du bin i
 | 
|---|
| 49 |   inline double Error2(int i) const
 | 
|---|
| 50 |          {if(!Ok) UpdateHisto(); return (float) err2[i];}
 | 
|---|
| 51 |   //! Retourne la dispersion/erreur du bin i
 | 
|---|
| 52 |   inline float Error(int i) const
 | 
|---|
| 53 |          {if(!Ok) UpdateHisto();
 | 
|---|
| 54 |           return (err2[i]>0.) ? (float) sqrt(err2[i]) : 0.f;}
 | 
|---|
| 55 | 
 | 
|---|
| 56 |   // Operators
 | 
|---|
| 57 |   HProf& operator = (const HProf& h);
 | 
|---|
| 58 |   HProf& operator += (const HProf& a);
 | 
|---|
| 59 | 
 | 
|---|
| 60 |   // Info, statistique et calculs sur les histogrammes
 | 
|---|
| 61 |   virtual void HRebin(int nbinew);
 | 
|---|
| 62 | 
 | 
|---|
| 63 |   // Fit
 | 
|---|
| 64 |   //! Fit du profile par ``gfit''.
 | 
|---|
| 65 |   inline int Fit(GeneralFit& gfit)
 | 
|---|
| 66 |          {if(!Ok) UpdateHisto(); return Histo::Fit(gfit,0);}
 | 
|---|
| 67 |   //! Retourne l'Histogramme des residus par ``gfit''.
 | 
|---|
| 68 |   inline Histo FitResidus(GeneralFit& gfit)
 | 
|---|
| 69 |          {if(!Ok) UpdateHisto(); return Histo::FitResidus(gfit);}
 | 
|---|
| 70 |   //! Retourne l'Histogramme de la fonction fittee par ``gfit''.
 | 
|---|
| 71 |   inline Histo FitFunction(GeneralFit& gfit)
 | 
|---|
| 72 |          {if(!Ok) UpdateHisto(); return Histo::FitFunction(gfit);}
 | 
|---|
| 73 | 
 | 
|---|
| 74 |   // Print
 | 
|---|
| 75 |   //! Print, voir detail dans Histo::Print
 | 
|---|
| 76 |   inline void Print(int dyn=100,float hmin=1.,float hmax=-1.
 | 
|---|
| 77 |                    ,int pflag=0,int il=1,int ih=-1)
 | 
|---|
| 78 |          {if(!Ok) UpdateHisto(); Histo::Print(dyn,hmin,hmax,pflag,il,ih);}
 | 
|---|
| 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)
 | 
|---|
| 82 |          {if(!Ok) UpdateHisto(); Histo::PrintF(fp,dyn,hmin,hmax,pflag,il,ih);}
 | 
|---|
| 83 | 
 | 
|---|
| 84 | protected:
 | 
|---|
| 85 |   void Delete();
 | 
|---|
| 86 | 
 | 
|---|
| 87 |   double*        SumY;  //!< somme
 | 
|---|
| 88 |   double*        SumY2; //!< somme des carres
 | 
|---|
| 89 |   double*        SumW;  //!< somme des poids
 | 
|---|
| 90 |   bool           Ok;    //!< true if update fait
 | 
|---|
| 91 |   float          YMin;  //!< limite minimum Y pour somme
 | 
|---|
| 92 |   float          YMax;  //!< limite maximum Y pour somme
 | 
|---|
| 93 |   uint_2         Opt;   //!< options pour les erreurs
 | 
|---|
| 94 | };
 | 
|---|
| 95 | 
 | 
|---|
| 96 | 
 | 
|---|
| 97 | /*! \ingroup HiStats \fn operator<<(POuttPersist&, HProf)
 | 
|---|
| 98 |   \brief Persistance management */
 | 
|---|
| 99 | inline POutPersist& operator << (POutPersist& os, HProf & obj)
 | 
|---|
| 100 | { ObjFileIO<HProf> fio(&obj);  fio.Write(os);  return(os); }
 | 
|---|
| 101 | /*! \ingroup HiStats \fn operator>>(PInPersist&, HProf)
 | 
|---|
| 102 |   \brief Persistance management */
 | 
|---|
| 103 | inline PInPersist& operator >> (PInPersist& is, HProf & obj)
 | 
|---|
| 104 | { ObjFileIO<HProf> fio(&obj);  fio.Read(is);  return(is); }
 | 
|---|
| 105 | // Classe pour la gestion de persistance
 | 
|---|
| 106 | // ObjFileIO<HProf>
 | 
|---|
| 107 | 
 | 
|---|
| 108 | /*! \ingroup HiStats \fn operator+(const HProf&, const HProf&)
 | 
|---|
| 109 |   \brief Operateur H = H1 + H2
 | 
|---|
| 110 |   \warning Meme commentaire que pour l'operateur +=
 | 
|---|
| 111 | */
 | 
|---|
| 112 | inline HProf operator + (const HProf& a, const HProf& b)
 | 
|---|
| 113 | {
 | 
|---|
| 114 | if (b.NBins()!=a.NBins()) THROW(sizeMismatchErr);
 | 
|---|
| 115 | HProf c(a);
 | 
|---|
| 116 | return (c += b);
 | 
|---|
| 117 | }
 | 
|---|
| 118 | 
 | 
|---|
| 119 | } // Fin du namespace
 | 
|---|
| 120 | 
 | 
|---|
| 121 | #endif // HISPROF_SEEN
 | 
|---|