source: Sophya/trunk/SophyaLib/NTools/hisprof.h@ 433

Last change on this file since 433 was 307, checked in by ansari, 26 years ago

FIO_... + grosses modifs cmv 19/5/99

File size: 2.5 KB
Line 
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
10namespace PlanckDPC {
11
12class HProf : public Histo {
13 friend class FIO_HProf;
14public:
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
55protected:
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// Classe pour la gestion de persistance
69class FIO_HProf : public PPersist {
70public:
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); }
78protected :
79 virtual void ReadSelf(PInPersist&);
80 virtual void WriteSelf(POutPersist&) const;
81 HProf * dobj;
82 bool ownobj;
83};
84
85} // Fin du namespace
86
87#endif // HISPROF_SEEN
Note: See TracBrowser for help on using the repository browser.