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
RevLine 
[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
10namespace SOPHYA {
11
[3049]12template <class T> class FitsHandler;
13
[926]14//! 1 dimension profile histograms
[763]15class HProf : public Histo {
16 friend class ObjFileIO<HProf>;
[3049]17 friend class FitsHandler<Histo>;
[763]18public:
19
20 // CREATOR / DESTRUCTOR
21 HProf();
[1092]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.);
[763]24 HProf(const HProf& H);
25 virtual ~HProf();
26
27 // UPDATING or SETTING
[1135]28 virtual void UpdateHisto(bool force=false) const;
29
[1056]30 void SetErrOpt(bool spread = true);
31 void Zero();
[1092]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.);
[763]34
35 // Acces a l information
[914]36 //! Retourne l'histogramme de profil.
[943]37 inline Histo GetHisto()
[1089]38 {UpdateHisto(); return (Histo) *this;}
[914]39 //! Retourne le contenu de la moyenne dans le vecteur v
[1056]40 inline void GetValue(TVector<r_8>& v)
[1089]41 {UpdateHisto(); Histo::GetValue(v);}
[914]42 //! Retourne le contenu au carre de la dispersion/erreur dans le vecteur v
[943]43 inline void GetError2(TVector<r_8>& v)
[1089]44 {UpdateHisto(); Histo::GetError2(v);}
[1056]45 //! Retourne le contenu au carre de la dispersion/erreur dans le vecteur v
46 inline void GetError(TVector<r_8>& v)
[1089]47 {UpdateHisto(); Histo::GetError(v);}
[914]48 //! Retourne le contenu du bin i
[1092]49 inline r_8 operator()(int_4 i) const
50 {UpdateHisto(); return mData[i];}
[914]51 //! Retourne le carre de la dispersion/erreur du bin i
[1092]52 inline r_8 Error2(int_4 i) const
53 {UpdateHisto(); return mErr2[i];}
[914]54 //! Retourne la dispersion/erreur du bin i
[1092]55 inline r_8 Error(int_4 i) const
[1089]56 {UpdateHisto();
[1092]57 return (mErr2[i]>0.) ? sqrt(mErr2[i]) : 0.;}
[763]58
59 // Operators
60 HProf& operator = (const HProf& h);
61 HProf& operator += (const HProf& a);
62
[1058]63 // Info, statistique et calculs sur les histogrammes
[1092]64 virtual void HRebin(int_4 nbinew);
[1058]65
[1413]66 virtual void Show(ostream& os) const;
[914]67 //! Print, voir detail dans Histo::Print
[1092]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)
[1089]70 {UpdateHisto(); Histo::Print(dyn,hmin,hmax,pflag,il,ih);}
[763]71
72protected:
73 void Delete();
[1089]74 void updatehisto() const;
[763]75
[1092]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
[763]83};
84
85
[958]86/*! \ingroup HiStats \fn operator<<(POuttPersist&, HProf)
87 \brief Persistance management */
[763]88inline POutPersist& operator << (POutPersist& os, HProf & obj)
89{ ObjFileIO<HProf> fio(&obj); fio.Write(os); return(os); }
[958]90/*! \ingroup HiStats \fn operator>>(PInPersist&, HProf)
91 \brief Persistance management */
[763]92inline PInPersist& operator >> (PInPersist& is, HProf & obj)
[2479]93{ ObjFileIO<HProf> fio(&obj); is.SkipToNextObject(); fio.Read(is); return(is); }
[763]94// Classe pour la gestion de persistance
95// ObjFileIO<HProf>
96
[1053]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{
[2507]103if (b.NBins()!=a.NBins()) throw SzMismatchError("HProf::operator +");
[1053]104HProf c(a);
105return (c += b);
106}
[763]107
108} // Fin du namespace
109
110#endif // HISPROF_SEEN
Note: See TracBrowser for help on using the repository browser.