| 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 | 
 | 
|---|
| 10 | namespace SOPHYA {
 | 
|---|
| 11 | 
 | 
|---|
| 12 | class HProf : public Histo {
 | 
|---|
| 13 |   friend class ObjFileIO<HProf>;
 | 
|---|
| 14 | public:
 | 
|---|
| 15 | 
 | 
|---|
| 16 |   // CREATOR / DESTRUCTOR
 | 
|---|
| 17 |   HProf();
 | 
|---|
| 18 |   HProf(float xMin, float xMax, int nBin=100, float yMin=1., float yMax=-1.);
 | 
|---|
| 19 |   HProf(const HProf& H);
 | 
|---|
| 20 |   virtual ~HProf();
 | 
|---|
| 21 | 
 | 
|---|
| 22 |   // UPDATING or SETTING
 | 
|---|
| 23 |   void   Zero();
 | 
|---|
| 24 |   void   UpdateHisto() const;
 | 
|---|
| 25 |   void   SetErrOpt(bool spread = true);
 | 
|---|
| 26 |   void   Add(float x, float y, float w = 1.);
 | 
|---|
| 27 |   void   AddBin(int numBin, float y, float w = 1.);
 | 
|---|
| 28 |   
 | 
|---|
| 29 |   // Acces a l information
 | 
|---|
| 30 |   inline Histo GetHisto() {if(!Ok) UpdateHisto(); return (Histo) *this;}
 | 
|---|
| 31 |   inline void GetMean(Vector& v) {if(!Ok) UpdateHisto(); Histo::GetValue(v);}
 | 
|---|
| 32 |   inline void GetError2(Vector& v) {if(!Ok) UpdateHisto(); Histo::GetError2(v);}
 | 
|---|
| 33 |   inline float operator()(int i) const {if(!Ok) UpdateHisto(); return data[i];}
 | 
|---|
| 34 |   inline float Error2(int i) const {if(!Ok) UpdateHisto(); return (float) err2[i];}
 | 
|---|
| 35 |   inline float Error(int i) const
 | 
|---|
| 36 |          {if(!Ok) UpdateHisto(); return err2[i]>0. ? (float) sqrt(err2[i]) : 0.f;}
 | 
|---|
| 37 | 
 | 
|---|
| 38 |   // Operators
 | 
|---|
| 39 |   HProf& operator = (const HProf& h);
 | 
|---|
| 40 |   HProf& operator += (const HProf& a);
 | 
|---|
| 41 |   friend HProf operator + (const HProf& a, const HProf& b);
 | 
|---|
| 42 | 
 | 
|---|
| 43 |   // Fit
 | 
|---|
| 44 |   inline int    Fit(GeneralFit& gfit)
 | 
|---|
| 45 |          {if(!Ok) UpdateHisto(); return Histo::Fit(gfit,0);}
 | 
|---|
| 46 |   inline Histo  FitResidus(GeneralFit& gfit)
 | 
|---|
| 47 |          {if(!Ok) UpdateHisto(); return Histo::FitResidus(gfit);}
 | 
|---|
| 48 |   inline Histo  FitFunction(GeneralFit& gfit)
 | 
|---|
| 49 |          {if(!Ok) UpdateHisto(); return Histo::FitFunction(gfit);}
 | 
|---|
| 50 | 
 | 
|---|
| 51 |   // Print
 | 
|---|
| 52 |   inline void Print(int dyn=100,float hmin=1.,float hmax=-1.,int pflag=0,int il=1,int ih=-1)
 | 
|---|
| 53 |                            {if(!Ok) UpdateHisto(); Histo::Print(dyn,hmin,hmax,pflag,il,ih);}
 | 
|---|
| 54 | 
 | 
|---|
| 55 | protected:
 | 
|---|
| 56 |   void Delete();
 | 
|---|
| 57 | 
 | 
|---|
| 58 |   double*        SumY;
 | 
|---|
| 59 |   double*        SumY2;
 | 
|---|
| 60 |   double*        SumW;
 | 
|---|
| 61 |   bool           Ok;
 | 
|---|
| 62 |   float          YMin;
 | 
|---|
| 63 |   float          YMax;
 | 
|---|
| 64 |   uint_2         Opt;
 | 
|---|
| 65 | };
 | 
|---|
| 66 | 
 | 
|---|
| 67 | 
 | 
|---|
| 68 | inline POutPersist& operator << (POutPersist& os, HProf & obj)
 | 
|---|
| 69 | { ObjFileIO<HProf> fio(&obj);  fio.Write(os);  return(os); }
 | 
|---|
| 70 | inline PInPersist& operator >> (PInPersist& is, HProf & obj)
 | 
|---|
| 71 | { ObjFileIO<HProf> fio(&obj);  fio.Read(is);  return(is); }
 | 
|---|
| 72 | // Classe pour la gestion de persistance
 | 
|---|
| 73 | // ObjFileIO<HProf>
 | 
|---|
| 74 | 
 | 
|---|
| 75 | 
 | 
|---|
| 76 | } // Fin du namespace
 | 
|---|
| 77 | 
 | 
|---|
| 78 | #endif // HISPROF_SEEN
 | 
|---|