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

Last change on this file since 5198 was 5114, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 2.9 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 Float_t fSigInt;
22 Float_t fSigMax;
23 Float_t fBgMin;
24 Float_t fBgMax;
25 Int_t fPolynomOrder;
26
27 Double_t fSignificance;
28 Double_t fEventsExcess;
29 Double_t fEventsSignal;
30 Double_t fEventsBackground;
31
32 Double_t fChiSqSignal;
33 Double_t fChiSqBg;
34 Double_t fIntegralMax;
35
36 TArrayD fCoefficients;
37
38 TF1 *fFunc;
39
40public:
41 // Implementing the function yourself is only about 5% faster
42 MAlphaFitter(const char *name=0, const char *title=0) : fSigInt(15), fSigMax(75), fBgMin(45), fBgMax(85), fPolynomOrder(2), fCoefficients(3+fPolynomOrder+1), fFunc(new TF1("", Form("gaus(0) + pol%d(3)", fPolynomOrder), 0, 90))
43 {
44 fName = name ? name : "MAlphaFitter";
45 fTitle = title ? title : "Fit alpha";
46
47 gROOT->GetListOfFunctions()->Remove(fFunc);
48 fFunc->SetName("Dummy");
49 }
50
51 MAlphaFitter(const MAlphaFitter &f) : fFunc(0)
52 {
53 f.Copy(*this);
54 }
55 ~MAlphaFitter()
56 {
57 delete fFunc;
58 }
59
60 void Print(Option_t *o=0) const;
61 void Copy(TObject &o) const;
62 /*
63 TObject *Clone(const char *name) const
64 {
65 return new MAlphaFitter(*this);
66 }
67 */
68
69 void SetSignalIntegralMax(Float_t s) { fSigInt = s; }
70 void SetSignalFitMax(Float_t s) { fSigMax = s; }
71 void SetBackgroundFitMin(Float_t s) { fBgMin = s; }
72 void SetBackgroundFitMax(Float_t s) { fBgMax = s; }
73 void SetPolynomOrder(Int_t s) { fPolynomOrder = s; delete fFunc; fFunc=new TF1 ("", Form("gaus(0) + pol%d(3)", s));
74 gROOT->GetListOfFunctions()->Remove(fFunc);
75 fFunc->SetName("Dummy");
76 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.