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

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