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

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

Creation module DPC/NTools Reza 09/04/99

File size: 2.2 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
10class HProf : public Histo {
11
12public:
13 enum {classId = ClassId_HProf };
14
15 // CREATOR / DESTRUCTOR
16 HProf();
17 HProf(float xMin, float xMax, int nBin=100, float yMin=1., float yMax=-1.);
18 HProf(char *flnm);
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 int_4 ClassId() const { return classId; }
56 static PPersist* Create() { return new HProf;}
57
58 virtual void WriteSelf(POutPersist&) const;
59 virtual void ReadSelf(PInPersist&);
60
61
62protected:
63 void Delete();
64
65 double* SumY;
66 double* SumY2;
67 double* SumW;
68 bool Ok;
69 float YMin;
70 float YMax;
71 uint_2 Opt;
72};
73
74#endif // HISPROF_SEEN
Note: See TracBrowser for help on using the repository browser.