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

Last change on this file since 3181 was 3057, checked in by cmv, 19 years ago
  • changement nom variables internes Histo...Histo2D
  • re-arrangement CreateOrResize et operator=
  • protection dans methodes (VMIN etc..) pour Histo 1d+2d vides

cmv 13/8/2006

File size: 3.9 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.;}
[3053]58 //! Retourne le carre de la dispersion/erreur du bin i
59 inline r_8 SumW(int_4 i) const {return mSumW[i];}
[763]60
61 // Operators
62 HProf& operator = (const HProf& h);
63 HProf& operator += (const HProf& a);
64
[1058]65 // Info, statistique et calculs sur les histogrammes
[1092]66 virtual void HRebin(int_4 nbinew);
[1058]67
[1413]68 virtual void Show(ostream& os) const;
[3053]69 inline void Show() const { Show(cout); }
[914]70 //! Print, voir detail dans Histo::Print
[1092]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)
[1089]73 {UpdateHisto(); Histo::Print(dyn,hmin,hmax,pflag,il,ih);}
[763]74
75protected:
[3053]76 void CreateOrResize(r_8 xMin, r_8 xMax, int_4 nBin, r_8 yMin=1., r_8 yMax=-1.);
[763]77 void Delete();
[1089]78 void updatehisto() const;
[763]79
[3053]80 r_8* mSumY; //!< somme
81 r_8* mSumY2; //!< somme des carres
82 r_8* mSumW; //!< somme des poids
[3057]83 mutable bool mOk; //!< true if update fait
84 r_8 mYMin; //!< limite minimum Y pour somme
85 r_8 mYMax; //!< limite maximum Y pour somme
86 uint_2 mOpt; //!< options pour les erreurs
[763]87};
88
[3053]89/*! Prints histogram information on stream \b s (h.Show(s)) */
90inline ostream& operator << (ostream& s, HProf const & h)
91 { h.Show(s); return(s); }
[763]92
[958]93/*! \ingroup HiStats \fn operator<<(POuttPersist&, HProf)
94 \brief Persistance management */
[763]95inline POutPersist& operator << (POutPersist& os, HProf & obj)
96{ ObjFileIO<HProf> fio(&obj); fio.Write(os); return(os); }
[958]97/*! \ingroup HiStats \fn operator>>(PInPersist&, HProf)
98 \brief Persistance management */
[763]99inline PInPersist& operator >> (PInPersist& is, HProf & obj)
[2479]100{ ObjFileIO<HProf> fio(&obj); is.SkipToNextObject(); fio.Read(is); return(is); }
[763]101// Classe pour la gestion de persistance
102// ObjFileIO<HProf>
103
[1053]104/*! \ingroup HiStats \fn operator+(const HProf&, const HProf&)
105 \brief Operateur H = H1 + H2
106 \warning Meme commentaire que pour l'operateur +=
107*/
108inline HProf operator + (const HProf& a, const HProf& b)
109{
[2507]110if (b.NBins()!=a.NBins()) throw SzMismatchError("HProf::operator +");
[1053]111HProf c(a);
112return (c += b);
113}
[763]114
115} // Fin du namespace
116
117#endif // HISPROF_SEEN
Note: See TracBrowser for help on using the repository browser.