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

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

bug ds xntuple.cc , petites correction ds virtual Histo/HProf::UpdateHisto() - Reza 23/8/2000

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