source: trunk/Mars/mhist/MHFindSignificance.h@ 10083

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