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 | template <class T> class FitsHandler;
|
---|
13 |
|
---|
14 | //! 1 dimension profile histograms
|
---|
15 | class HProf : public Histo {
|
---|
16 | friend class ObjFileIO<HProf>;
|
---|
17 | friend class FitsHandler<Histo>;
|
---|
18 | public:
|
---|
19 |
|
---|
20 | // CREATOR / DESTRUCTOR
|
---|
21 | HProf();
|
---|
22 | HProf(r_8 xMin, r_8 xMax, int_4 nBin=100, r_8 yMin=1., r_8 yMax=-1.);
|
---|
23 | HProf(r_4 xMin, r_4 xMax, int_4 nBin=100, r_4 yMin=1., r_4 yMax=-1.);
|
---|
24 | HProf(const HProf& H);
|
---|
25 | virtual ~HProf();
|
---|
26 |
|
---|
27 | // UPDATING or SETTING
|
---|
28 | virtual void UpdateHisto(bool force=false) const;
|
---|
29 |
|
---|
30 | void SetErrOpt(bool spread = true);
|
---|
31 | void Zero();
|
---|
32 | void Add(r_8 x, r_8 y, r_8 w = 1.);
|
---|
33 | void AddBin(int_4 numBin, r_8 y, r_8 w = 1.);
|
---|
34 |
|
---|
35 | // Acces a l information
|
---|
36 | //! Retourne l'histogramme de profil.
|
---|
37 | inline Histo GetHisto()
|
---|
38 | {UpdateHisto(); return (Histo) *this;}
|
---|
39 | //! Retourne le contenu de la moyenne dans le vecteur v
|
---|
40 | inline void GetValue(TVector<r_8>& v)
|
---|
41 | {UpdateHisto(); Histo::GetValue(v);}
|
---|
42 | //! Retourne le contenu au carre de la dispersion/erreur dans le vecteur v
|
---|
43 | inline void GetError2(TVector<r_8>& v)
|
---|
44 | {UpdateHisto(); Histo::GetError2(v);}
|
---|
45 | //! Retourne le contenu au carre de la dispersion/erreur dans le vecteur v
|
---|
46 | inline void GetError(TVector<r_8>& v)
|
---|
47 | {UpdateHisto(); Histo::GetError(v);}
|
---|
48 | //! Retourne le contenu du bin i
|
---|
49 | inline r_8 operator()(int_4 i) const
|
---|
50 | {UpdateHisto(); return mData[i];}
|
---|
51 | //! Retourne le carre de la dispersion/erreur du bin i
|
---|
52 | inline r_8 Error2(int_4 i) const
|
---|
53 | {UpdateHisto(); return mErr2[i];}
|
---|
54 | //! Retourne la dispersion/erreur du bin i
|
---|
55 | inline r_8 Error(int_4 i) const
|
---|
56 | {UpdateHisto();
|
---|
57 | return (mErr2[i]>0.) ? sqrt(mErr2[i]) : 0.;}
|
---|
58 | //! Retourne le carre de la dispersion/erreur du bin i
|
---|
59 | inline r_8 SumW(int_4 i) const {return mSumW[i];}
|
---|
60 |
|
---|
61 | // Operators
|
---|
62 | HProf& operator = (const HProf& h);
|
---|
63 | HProf& operator += (const HProf& a);
|
---|
64 |
|
---|
65 | // Info, statistique et calculs sur les histogrammes
|
---|
66 | virtual void HRebin(int_4 nbinew);
|
---|
67 |
|
---|
68 | virtual void Show(ostream& os) const;
|
---|
69 | inline void Show() const { Show(cout); }
|
---|
70 | //! Print, voir detail dans Histo::Print
|
---|
71 | inline void Print(int_4 dyn=100,r_8 hmin=1.,r_8 hmax=-1.
|
---|
72 | ,int_4 pflag=0,int_4 il=1,int_4 ih=-1)
|
---|
73 | {UpdateHisto(); Histo::Print(dyn,hmin,hmax,pflag,il,ih);}
|
---|
74 |
|
---|
75 | protected:
|
---|
76 | void CreateOrResize(r_8 xMin, r_8 xMax, int_4 nBin, r_8 yMin=1., r_8 yMax=-1.);
|
---|
77 | void Delete();
|
---|
78 | void updatehisto() const;
|
---|
79 |
|
---|
80 | r_8* mSumY; //!< somme
|
---|
81 | r_8* mSumY2; //!< somme des carres
|
---|
82 | r_8* mSumW; //!< somme des poids
|
---|
83 | mutable bool Ok; //!< true if update fait
|
---|
84 | r_8 YMin; //!< limite minimum Y pour somme
|
---|
85 | r_8 YMax; //!< limite maximum Y pour somme
|
---|
86 | uint_2 Opt; //!< options pour les erreurs
|
---|
87 | };
|
---|
88 |
|
---|
89 | /*! Prints histogram information on stream \b s (h.Show(s)) */
|
---|
90 | inline ostream& operator << (ostream& s, HProf const & h)
|
---|
91 | { h.Show(s); return(s); }
|
---|
92 |
|
---|
93 | /*! \ingroup HiStats \fn operator<<(POuttPersist&, HProf)
|
---|
94 | \brief Persistance management */
|
---|
95 | inline POutPersist& operator << (POutPersist& os, HProf & obj)
|
---|
96 | { ObjFileIO<HProf> fio(&obj); fio.Write(os); return(os); }
|
---|
97 | /*! \ingroup HiStats \fn operator>>(PInPersist&, HProf)
|
---|
98 | \brief Persistance management */
|
---|
99 | inline PInPersist& operator >> (PInPersist& is, HProf & obj)
|
---|
100 | { ObjFileIO<HProf> fio(&obj); is.SkipToNextObject(); fio.Read(is); return(is); }
|
---|
101 | // Classe pour la gestion de persistance
|
---|
102 | // ObjFileIO<HProf>
|
---|
103 |
|
---|
104 | /*! \ingroup HiStats \fn operator+(const HProf&, const HProf&)
|
---|
105 | \brief Operateur H = H1 + H2
|
---|
106 | \warning Meme commentaire que pour l'operateur +=
|
---|
107 | */
|
---|
108 | inline HProf operator + (const HProf& a, const HProf& b)
|
---|
109 | {
|
---|
110 | if (b.NBins()!=a.NBins()) throw SzMismatchError("HProf::operator +");
|
---|
111 | HProf c(a);
|
---|
112 | return (c += b);
|
---|
113 | }
|
---|
114 |
|
---|
115 | } // Fin du namespace
|
---|
116 |
|
---|
117 | #endif // HISPROF_SEEN
|
---|