source: trunk/MagicSoft/Mars/mhflux/MAlphaFitter.h@ 5059

Last change on this file since 5059 was 5012, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 2.8 KB
Line 
1#ifndef MARS_MAlphaFitter
2#define MARS_MAlphaFitter
3
4#ifndef MARS_MParContainer
5#include "MParContainer.h"
6#endif
7
8#ifndef ROOT_TArrayD
9#include <TArrayD.h>
10#endif
11
12#ifndef ROOT_TF1
13#include <TF1.h>
14#endif
15
16class TH1D;
17
18class MAlphaFitter : public MParContainer
19{
20private:
21 TF1 *fFunc;
22
23 Float_t fSigInt;
24 Float_t fSigMax;
25 Float_t fBgMin;
26 Float_t fBgMax;
27 Int_t fPolynomOrder;
28
29 Double_t fSignificance;
30 Double_t fEventsExcess;
31 Double_t fEventsSignal;
32 Double_t fEventsBackground;
33
34 Double_t fChiSqSignal;
35 Double_t fChiSqBg;
36 Double_t fIntegralMax;
37
38 TArrayD fCoefficients;
39
40public:
41 // Implementing the function yourself is only about 5% faster
42 MAlphaFitter() : fFunc(new TF1("", "gaus(0) + pol1(3)", 0, 90)), fSigInt(10), fSigMax(75), fBgMin(45), fBgMax(85), fPolynomOrder(1), fCoefficients(3+fPolynomOrder+1)
43 {
44 }
45
46 MAlphaFitter(const MAlphaFitter &f) : fFunc(0)
47 {
48 f.Copy(*this);
49 }
50 ~MAlphaFitter()
51 {
52 delete fFunc;
53 }
54
55 void Copy(TObject &o) const
56 {
57 MAlphaFitter &f = static_cast<MAlphaFitter&>(o);
58
59 f.fSigInt = fSigInt;
60 f.fSigMax = fSigMax;
61 f.fBgMin = fBgMin;
62 f.fBgMax = fBgMax;
63 f.fPolynomOrder = fPolynomOrder;
64 f.fCoefficients.Set(fCoefficients.GetSize());
65 f.fCoefficients.Reset();
66
67 TF1 *fcn = f.fFunc;
68 f.fFunc = new TF1(*fFunc);
69 delete fcn;
70 }
71
72 void SetSignalIntegralMax(Float_t s) { fSigInt = s; }
73 void SetSignalFitMax(Float_t s) { fSigMax = s; }
74 void SetBackgroundFitMin(Float_t s) { fBgMin = s; }
75 void SetBackgroundFitMax(Float_t s) { fBgMax = s; }
76 void SetPolynomOrder(Int_t s) { fPolynomOrder = s; delete fFunc; fFunc=new TF1 ("", Form("gaus(0) + pol%d(3)", s)); fCoefficients.Set(3+s+1); fCoefficients.Reset(); }
77
78 Double_t GetEventsExcess() const { return fEventsExcess; }
79 Double_t GetEventsSignal() const { return fEventsSignal; }
80 Double_t GetEventsBackground() const { return fEventsBackground; }
81
82 Double_t GetSignificance() const { return fSignificance; }
83 Double_t GetChiSqSignal() const { return fChiSqSignal; }
84 Double_t GetChiSqBg() const { return fChiSqBg; }
85
86 Double_t GetGausSigma() const { return fCoefficients[2]; }
87 Double_t GetGausMu() const { return fCoefficients[1]; }
88 Double_t GetGausA() const { return fCoefficients[0]; }
89 Double_t GetCoefficient(Int_t i) const { return fCoefficients[i]; }
90 const TArrayD &GetCoefficients() const { return fCoefficients; }
91
92 void PaintResult(Float_t x=0.04, Float_t y=0.94, Float_t size=0.035) const;
93
94 Bool_t Fit(TH1D &h, Bool_t paint=kFALSE);
95
96 ClassDef(MAlphaFitter, 1)
97};
98
99#endif
Note: See TracBrowser for help on using the repository browser.