source: trunk/MagicSoft/Mars/mhist/MHFindSignificance.h@ 2308

Last change on this file since 2308 was 2300, checked in by wittek, 22 years ago
*** empty log message ***
File size: 6.1 KB
Line 
1#ifndef MARS_MHFindSignificance
2#define MARS_MHFindSignificance
3
4#ifdef MARS_MLogManip
5#error Please make ensure that MLogManip.h are included _after_ MHFindSignificance.h
6#endif
7
8
9#ifndef MARS_MH
10#include "MH.h"
11#endif
12
13#include <TArrayD.h>
14#include <TH1.h>
15#include <TCanvas.h>
16
17class TArrayD;
18class TF1;
19
20
21class MHFindSignificance : public MH
22{
23private:
24
25 TH1 *fHistOrig; // original plot of |alpha| (0.0 to 90.0 degrees)
26 TH1 *fHist; // copy of fHistOrig or rebinned histogram
27
28 TH1D *fSigVsAlpha;
29
30 Double_t fAlphamin; // requested lower limit of fit range
31 Double_t fAlphammm; // center of fit range
32 Double_t fAlphamax; // requested lower limit of fit range
33
34 Double_t fAlphami; // actual lower limit of fit range
35 Double_t fAlphamm; // actual center of fit range
36 Double_t fAlphama; // actual upper limit of fit range
37
38 Double_t fAlphasig; // requested signal range
39 Double_t fAlphasi; // actual signal range
40
41 Double_t fAlphalow; // requested lower edge of signal range
42 Double_t fAlphalo; // actual lower edge of signal range
43
44 Double_t fAlphahig; // requested upper edge of background range
45 Double_t fAlphahi; // actual upper edge of background range
46
47 // number of events in signal region
48 Double_t fNon; // total number of events in signal region
49 Double_t fNbg; // number of background events in signal region
50 Double_t fNex; // number of excess events in signal region
51
52 Double_t fdNon;
53 Double_t fdNbg;
54 Double_t fdNex;
55
56 // number of events in background region
57 Double_t fNbgtot; // total number of events in background region
58 Double_t fNbgtotFitted; // fitted total no. of events in background region
59 Double_t fdNbgtotFitted; // fitted error of this number
60
61 // effective number of background events
62 Double_t fNoff;
63 Double_t fGamma; // Nbg = Non - gamma * Noff
64
65 Double_t fSigLiMa; // significance of gamma signal according to Li & Ma
66
67 const static Double_t fEps = 1.e-4; // tolerance for floating point comparisons
68
69 Bool_t fDraw; // if true : draw plots
70 Bool_t fFitGauss; // if true : do the (polynomial+Gauss fit)
71 Bool_t fRebin; // if true : allow rebinning of the alpha plot
72 Bool_t fReduceDegree; // if true : allow reducing of the order of the polynomial
73
74 Bool_t fConstantBackg; // if set true if background fit is not possible
75 // due to low statistics
76
77 TCanvas *fCanvas;
78
79 Double_t fNexGauss; // total number of excess events
80 // (from fitted Gauss function)
81 Double_t fdNexGauss; // error of the total number of excess events
82
83 Double_t fSigmaGauss; // sigma of fitted Gauss function
84 Double_t fdSigmaGauss; // error of this sigma
85
86 //--------------------
87 TF1 *fPoly; // polynomial function
88 Int_t fFitBad; // if != 0 fit failed
89 Int_t fDegree; // degree of polynomial to be fitted to the background
90 Int_t fNdf; // number of degrees of freedom of polynomial fit
91 Double_t fChisq; // chi squared of polynomial fit
92 Double_t fProb; // chi squared probability ofg polynomial fit
93
94 TArrayD fValues;
95 TArrayD fErrors;
96
97 const static Int_t fNdim = 6;
98 Double_t fEmat[fNdim][fNdim];
99 Double_t fEma [fNdim][fNdim];
100 Double_t fCorr[fNdim][fNdim];
101
102 Int_t fMbins; // number of bins in the fit range
103 Int_t fMlow; // number of bins in the fit range with too few entries
104 Int_t fNzero; // number of bins in the fit range with zero entry
105 Int_t fIstat;
106
107 //--------------------
108
109 //--------------------
110 TF1 *fGPoly; // (Gauss+polynomial) function
111 TF1 *fGBackg; // polynomial part of (Gauss+polynomial) function
112 Int_t fGFitBad; // if != 0 fit failed
113 Int_t fGDegree; // degree of polynomial to be fitted to the background
114 Int_t fGNdf; // number of degrees of freedom of polynomial fit
115 Double_t fGChisq; // chi squared of polynomial fit
116 Double_t fGProb; // chi squared probability ofg polynomial fit
117
118 TArrayD fGValues;
119 TArrayD fGErrors;
120
121 const static Int_t fGNdim = 9;
122 Double_t fGEmat[fGNdim][fGNdim];
123 Double_t fGEma[fGNdim][fGNdim];
124 Double_t fGCorr[fGNdim][fGNdim];
125
126 Int_t fGMbins; // number of bins in the fit range
127 Int_t fGNzero; // numnber of bins in the fit range with zero entry
128 Int_t fGIstat;
129
130 //--------------------
131
132 static const TString gsDefName; //! Default Name
133 static const TString gsDefTitle; //! Default Title
134
135 Bool_t DetExcess();
136 Bool_t FitPolynomial();
137 Bool_t FitGaussPoly();
138 Bool_t RebinHistogram(Double_t x0, Int_t nrebin);
139
140public:
141 MHFindSignificance(const char *name=NULL, const char *title=NULL);
142 ~MHFindSignificance();
143
144 Bool_t FindSigma(TH1 *fhist, Double_t alphamin, Double_t alphamax,
145 Int_t degree, Double_t alphasig,
146 Bool_t drawpoly, Bool_t fitgauss, Bool_t print);
147
148 Bool_t SigmaLiMa(Double_t non, Double_t noff, Double_t gamma,
149 Double_t *siglima);
150
151 Bool_t SigmaVsAlpha(TH1 *fhist, Double_t alphamin, Double_t alphamax,
152 Int_t degree, Bool_t print);
153
154 Double_t GetSignificance() { return fSigLiMa; }
155
156 Bool_t DrawFit(Option_t *opt=NULL);
157
158 Float_t GetDegree() const { return fDegree; }
159 Float_t GetProb() const { return fProb; }
160 Float_t GetNdf() const { return fNdf; }
161 Float_t GetGamma() const { return fGamma; }
162 Float_t GetNon() const { return fNon; }
163 Float_t GetNex() const { return fNex; }
164 Float_t GetNbg() const { return fNbg; }
165 Float_t GetSigLiMa() const { return fSigLiMa; }
166 Float_t GetMbins() const { return fMbins; }
167 Float_t GetAlphasi() const { return fAlphasi; }
168
169 void SetRebin(Bool_t b=kTRUE);
170 void SetReduceDegree(Bool_t b=kTRUE);
171
172 void PrintPoly(Option_t *opt=NULL);
173 void PrintPolyGauss(Option_t *opt=NULL);
174
175 ClassDef(MHFindSignificance, 1) // Determine significance from alpha plot
176};
177
178#endif
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
Note: See TracBrowser for help on using the repository browser.