[220] | 1 | #ifndef HISPROF_SEEN
|
---|
| 2 | #define HISPROF_SEEN
|
---|
| 3 |
|
---|
| 4 | #include <stdio.h>
|
---|
| 5 | #include "peida.h"
|
---|
| 6 | #include "cvector.h"
|
---|
| 7 | #include "ppersist.h"
|
---|
| 8 | #include "histos.h"
|
---|
| 9 |
|
---|
[307] | 10 | namespace PlanckDPC {
|
---|
| 11 |
|
---|
[220] | 12 | class HProf : public Histo {
|
---|
[307] | 13 | friend class FIO_HProf;
|
---|
[220] | 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);}
|
---|
[307] | 46 | inline Histo FitResidus(GeneralFit& gfit)
|
---|
[220] | 47 | {if(!Ok) UpdateHisto(); return Histo::FitResidus(gfit);}
|
---|
[307] | 48 | inline Histo FitFunction(GeneralFit& gfit)
|
---|
[220] | 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 |
|
---|
[307] | 67 | /////////////////////////////////////////////////////////////////////////
|
---|
| 68 | // Classe pour la gestion de persistance
|
---|
| 69 | class FIO_HProf : public PPersist {
|
---|
| 70 | public:
|
---|
| 71 | FIO_HProf();
|
---|
| 72 | FIO_HProf(string const & filename);
|
---|
| 73 | FIO_HProf(const HProf & obj);
|
---|
| 74 | FIO_HProf(HProf * obj);
|
---|
| 75 | virtual ~FIO_HProf();
|
---|
| 76 | virtual AnyDataObj* DataObj();
|
---|
| 77 | inline operator HProf() { return(*dobj); }
|
---|
| 78 | protected :
|
---|
| 79 | virtual void ReadSelf(PInPersist&);
|
---|
| 80 | virtual void WriteSelf(POutPersist&) const;
|
---|
| 81 | HProf * dobj;
|
---|
| 82 | bool ownobj;
|
---|
| 83 | };
|
---|
| 84 |
|
---|
| 85 | } // Fin du namespace
|
---|
| 86 |
|
---|
[220] | 87 | #endif // HISPROF_SEEN
|
---|