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

Last change on this file since 5098 was 5080, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 3.0 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 gROOT->GetListOfFunctions()->Remove(fFunc);
45 }
46
47 MAlphaFitter(const MAlphaFitter &f) : fFunc(0)
48 {
49 f.Copy(*this);
50 }
51 ~MAlphaFitter()
52 {
53 delete fFunc;
54 }
55
56 void Copy(TObject &o) const
57 {
58 MAlphaFitter &f = static_cast<MAlphaFitter&>(o);
59
60 f.fSigInt = fSigInt;
61 f.fSigMax = fSigMax;
62 f.fBgMin = fBgMin;
63 f.fBgMax = fBgMax;
64 f.fPolynomOrder = fPolynomOrder;
65 f.fCoefficients.Set(fCoefficients.GetSize());
66 f.fCoefficients.Reset();
67
68 TF1 *fcn = f.fFunc;
69 f.fFunc = new TF1(*fFunc);
70 gROOT->GetListOfFunctions()->Remove(f.fFunc);
71 delete fcn;
72 }
73
74 void SetSignalIntegralMax(Float_t s) { fSigInt = s; }
75 void SetSignalFitMax(Float_t s) { fSigMax = s; }
76 void SetBackgroundFitMin(Float_t s) { fBgMin = s; }
77 void SetBackgroundFitMax(Float_t s) { fBgMax = s; }
78 void SetPolynomOrder(Int_t s) { fPolynomOrder = s; delete fFunc; fFunc=new TF1 ("", Form("gaus(0) + pol%d(3)", s));
79 gROOT->GetListOfFunctions()->Remove(fFunc);
80 fCoefficients.Set(3+s+1); fCoefficients.Reset(); }
81
82 Double_t GetEventsExcess() const { return fEventsExcess; }
83 Double_t GetEventsSignal() const { return fEventsSignal; }
84 Double_t GetEventsBackground() const { return fEventsBackground; }
85
86 Double_t GetSignificance() const { return fSignificance; }
87 Double_t GetChiSqSignal() const { return fChiSqSignal; }
88 Double_t GetChiSqBg() const { return fChiSqBg; }
89
90 Double_t GetGausSigma() const { return fCoefficients[2]; }
91 Double_t GetGausMu() const { return fCoefficients[1]; }
92 Double_t GetGausA() const { return fCoefficients[0]; }
93 Double_t GetCoefficient(Int_t i) const { return fCoefficients[i]; }
94 const TArrayD &GetCoefficients() const { return fCoefficients; }
95
96 void PaintResult(Float_t x=0.04, Float_t y=0.94, Float_t size=0.035) const;
97
98 Bool_t Fit(TH1D &h, Bool_t paint=kFALSE);
99
100 ClassDef(MAlphaFitter, 1)
101};
102
103#endif
Note: See TracBrowser for help on using the repository browser.