source: Sophya/trunk/SophyaLib/HiStats/hisprof.h@ 3049

Last change on this file since 3049 was 3049, checked in by cmv, 19 years ago

Fits IO Histo,HProf,HistErr,Histo2D cmv 11/8/2006

File size: 3.5 KB
Line 
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
10namespace SOPHYA {
11
12template <class T> class FitsHandler;
13
14//! 1 dimension profile histograms
15class HProf : public Histo {
16 friend class ObjFileIO<HProf>;
17 friend class FitsHandler<Histo>;
18public:
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
59 // Operators
60 HProf& operator = (const HProf& h);
61 HProf& operator += (const HProf& a);
62
63 // Info, statistique et calculs sur les histogrammes
64 virtual void HRebin(int_4 nbinew);
65
66 virtual void Show(ostream& os) const;
67 //! Print, voir detail dans Histo::Print
68 inline void Print(int_4 dyn=100,r_8 hmin=1.,r_8 hmax=-1.
69 ,int_4 pflag=0,int_4 il=1,int_4 ih=-1)
70 {UpdateHisto(); Histo::Print(dyn,hmin,hmax,pflag,il,ih);}
71
72protected:
73 void Delete();
74 void updatehisto() const;
75
76 r_8* SumY; //!< somme
77 r_8* SumY2; //!< somme des carres
78 r_8* SumW; //!< somme des poids
79 mutable bool Ok; //!< true if update fait
80 r_8 YMin; //!< limite minimum Y pour somme
81 r_8 YMax; //!< limite maximum Y pour somme
82 uint_2 Opt; //!< options pour les erreurs
83};
84
85
86/*! \ingroup HiStats \fn operator<<(POuttPersist&, HProf)
87 \brief Persistance management */
88inline POutPersist& operator << (POutPersist& os, HProf & obj)
89{ ObjFileIO<HProf> fio(&obj); fio.Write(os); return(os); }
90/*! \ingroup HiStats \fn operator>>(PInPersist&, HProf)
91 \brief Persistance management */
92inline PInPersist& operator >> (PInPersist& is, HProf & obj)
93{ ObjFileIO<HProf> fio(&obj); is.SkipToNextObject(); fio.Read(is); return(is); }
94// Classe pour la gestion de persistance
95// ObjFileIO<HProf>
96
97/*! \ingroup HiStats \fn operator+(const HProf&, const HProf&)
98 \brief Operateur H = H1 + H2
99 \warning Meme commentaire que pour l'operateur +=
100*/
101inline HProf operator + (const HProf& a, const HProf& b)
102{
103if (b.NBins()!=a.NBins()) throw SzMismatchError("HProf::operator +");
104HProf c(a);
105return (c += b);
106}
107
108} // Fin du namespace
109
110#endif // HISPROF_SEEN
Note: See TracBrowser for help on using the repository browser.