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

Last change on this file since 1109 was 1109, checked in by ansari, 25 years ago

on vire FitResidus/Function -> cf objfitter cmv 28/7/00

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