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

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

cmv 7/7/2000

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