source: branches/Corsika7500Compatibility/mhcalib/MHGausEvents.h@ 20051

Last change on this file since 20051 was 9157, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 9.2 KB
Line 
1#ifndef MARS_MHGausEvents
2#define MARS_MHGausEvents
3
4#ifndef ROOT_TH1
5#include <TH1.h>
6#endif
7
8#ifndef ROOF_TF1
9#include <TF1.h>
10#endif
11
12#ifndef MARS_MH
13#include "MH.h"
14#endif
15
16#ifndef MARS_MArrayF
17#include "MArrayF.h"
18#endif
19
20class TVirtualPad;
21class TGraph;
22class TH1F;
23class TH1I;
24class TF1;
25
26class MHGausEvents : public MH
27{
28private:
29
30 const static Int_t fgNDFLimit; //! Default for fNDFLimit (now set to: 2)
31 const static Float_t fgProbLimit; //! Default for fProbLimit (now set to: 0.001)
32 const static Int_t fgPowerProbabilityBins; //! Default for fPowerProbabilityBins (now set to: 20)
33
34private:
35
36 Int_t fBinsAfterStripping; // Bins for the Gauss Histogram after stripping off the zeros at both ends
37 UInt_t fCurrentSize; // Current size of the array fEvents
38 Float_t fEventFrequency; // Event frequency in Hertz (to be set)
39 Byte_t fFlags; // Bit field for the fit result bits
40 Int_t fPowerProbabilityBins; // Bins for the projected power spectrum
41
42 TH1I *fHPowerProbability; //! Fourier transform of fEvents projected on y-axis
43 MArrayF *fPowerSpectrum; //! Fourier transform of fEvents
44
45 enum { kGausFitOK,
46 kExpFitOK,
47 kFourierSpectrumOK,
48 kExcluded }; // Bits for information about fit results
49
50 MArrayF fEvents; // Array which holds the entries of GausHist
51 TF1 *fFExpFit; // Exponential fit for FHPowerProbability
52 TGraph *fGraphEvents; //! TGraph to display the event array
53 TGraph *fGraphPowerSpectrum; //! TGraph to display the power spectrum array
54 Axis_t fFirst; // Lower histogram edge for fHGausHist (used by InitBins())
55 Axis_t fLast; // Upper histogram edge for fHGausHist (used by InitBins())
56 Int_t fNbins; // Number histogram bins for fHGausHist (used by InitBins())
57 Int_t fNDFLimit; // NDF limit for judgement if fit is OK
58 Float_t fProbLimit; // Probability limit for judgement if fit is OK
59
60protected:
61 TF1 *fFGausFit; // Gauss fit for fHGausHist
62 TH1F fHGausHist; // Histogram to hold the Gaussian distribution
63
64 Double_t fMean; // Mean of the Gauss fit
65 Double_t fMeanErr; // Error of the mean of the Gauss fit
66 Double_t fSigma; // Sigma of the Gauss fit
67 Double_t fSigmaErr; // Error of the sigma of the Gauss fit
68 Double_t fProb; // Probability of the Gauss fit
69
70 // Setters
71 void SetBinsAfterStripping ( const Int_t nbins=0 ) { fBinsAfterStripping =nbins; }
72 void SetPowerProbabilityBins ( const Int_t nbins=fgPowerProbabilityBins ) { fPowerProbabilityBins=nbins; }
73
74public:
75
76 MHGausEvents(const char* name=NULL, const char* title=NULL);
77 ~MHGausEvents();
78
79 void Clear(Option_t *o="");
80 void Reset();
81
82 void CreateFourierSpectrum();
83 void CreateGraphEvents();
84 void CreateGraphPowerSpectrum();
85
86 // Draws
87 void Draw ( Option_t *option="" ); // *MENU*
88 void DrawEvents ( Option_t *option="" ); // *MENU*
89 void DrawPowerSpectrum ( Option_t *option="" ); // *MENU*
90 void DrawPowerProjection( Option_t *option="" ); // *MENU*
91
92 // Fill
93 void FillArray ( const Float_t f );
94 Bool_t FillHist ( const Float_t f );
95 Bool_t FillHistAndArray ( const Float_t f );
96
97 // Fits
98 Bool_t FitGaus ( Option_t *option="RQ0",
99 const Double_t xmin=0.,
100 const Double_t xmax=0.); // *MENU*
101
102 // Inits
103 virtual void InitBins();
104
105 // Getters
106 const Double_t GetEntries() const { return fHGausHist.GetEntries(); }
107 const Double_t GetChiSquare() const { return ( fFGausFit ? fFGausFit->GetChisquare() : 0.); }
108 const Double_t GetExpChiSquare() const { return ( fFExpFit ? fFExpFit->GetChisquare() : 0.); }
109 const Int_t GetExpNdf() const { return ( fFExpFit ? fFExpFit->GetNDF() : 0 ); }
110 const Double_t GetExpProb() const { return ( fFExpFit ? fFExpFit->GetProb() : 0.); }
111 MArrayF *GetEvents() { return &fEvents; }
112 const MArrayF *GetEvents() const { return &fEvents; }
113 const Float_t GetEventFrequency () const { return fEventFrequency; }
114 TF1 *GetFExpFit() { return fFExpFit; }
115 const TF1 *GetFExpFit() const { return fFExpFit; }
116 TF1 *GetFGausFit() { return fFGausFit; }
117 const TF1 *GetFGausFit() const { return fFGausFit; }
118 TGraph *GetGraphEvents() { return fGraphEvents; }
119 const Double_t GetFirst() const { return fFirst; }
120 const Double_t GetLast () const { return fLast ; }
121 const TGraph *GetGraphEvents() const { return fGraphEvents; }
122 TGraph *GetGraphPowerSpectrum() { return fGraphPowerSpectrum; }
123 const TGraph *GetGraphPowerSpectrum() const { return fGraphPowerSpectrum; }
124 TH1F *GetHGausHist() { return &fHGausHist; }
125 const TH1F *GetHGausHist() const { return &fHGausHist; }
126 TH1I *GetHPowerProbability() { return fHPowerProbability; }
127 const TH1I *GetHPowerProbability() const { return fHPowerProbability; }
128 const Double_t GetHistRms() const { return fHGausHist.GetRMS(); }
129 const Double_t GetMean() const { return fMean; }
130 const Double_t GetMeanErr() const { return fMeanErr; }
131 const Int_t GetNdf() const { return ( fFGausFit ? fFGausFit->GetNDF() : 0); }
132 const Int_t GetNbins() const { return fNbins; }
133 const Double_t GetOffset() const { return ( fFExpFit ? fFExpFit->GetParameter(0) : 0.); }
134 MArrayF *GetPowerSpectrum() { return fPowerSpectrum; }
135 const MArrayF *GetPowerSpectrum() const { return fPowerSpectrum; }
136 const Double_t GetProb() const { return fProb; }
137 const Double_t GetSigma() const { return fSigma; }
138 const Double_t GetSigmaErr() const { return fSigmaErr; }
139 const Double_t GetSlope() const { return ( fFExpFit ? fFExpFit->GetParameter(1) : 0.); }
140 const Int_t GetNDFLimit() const { return fNDFLimit; }
141 const Float_t GetProbLimit() const { return fProbLimit; }
142
143 const Bool_t IsValid() const { return fMean!=0 || fSigma!=0; }
144 const Bool_t IsExcluded() const { return TESTBIT(fFlags,kExcluded); }
145 const Bool_t IsExpFitOK() const { return TESTBIT(fFlags,kExpFitOK); }
146 const Bool_t IsEmpty() const { return !(fHGausHist.GetEntries()); }
147 const Bool_t IsFourierSpectrumOK() const { return TESTBIT(fFlags,kFourierSpectrumOK); }
148 const Bool_t IsGausFitOK() const { return TESTBIT(fFlags,kGausFitOK); }
149 const Bool_t IsOnlyOverflow() const { return fHGausHist.GetEntries()>0 && fHGausHist.GetEntries() == fHGausHist.GetBinContent(fNbins+1); }
150 const Bool_t IsOnlyUnderflow() const { return fHGausHist.GetEntries()>0 && fHGausHist.GetEntries() == fHGausHist.GetBinContent(0); }
151
152 // Prints
153 void Print(const Option_t *o="") const; // *MENU*
154
155 // Setters
156 void SetEventFrequency ( const Float_t f ) { fEventFrequency = f; }
157 void SetExcluded ( const Bool_t b=kTRUE ) { b ? SETBIT(fFlags,kExcluded) : CLRBIT(fFlags,kExcluded); }
158 void SetExpFitOK ( const Bool_t b=kTRUE ) { b ? SETBIT(fFlags,kExpFitOK) : CLRBIT(fFlags,kExpFitOK); }
159 void SetFourierSpectrumOK( const Bool_t b=kTRUE ) { b ? SETBIT(fFlags,kFourierSpectrumOK) : CLRBIT(fFlags,kFourierSpectrumOK); }
160 void SetGausFitOK ( const Bool_t b=kTRUE ) { b ? SETBIT(fFlags,kGausFitOK) : CLRBIT(fFlags,kGausFitOK);}
161 void SetMean ( const Double_t d ) { fMean = d; }
162 void SetMeanErr ( const Double_t d ) { fMeanErr = d; }
163 void SetNDFLimit ( const Int_t lim=fgNDFLimit ) { fNDFLimit = lim; }
164 void SetProb ( const Double_t d ) { fProb = d; }
165 void SetProbLimit ( const Float_t lim=fgProbLimit ) { fProbLimit = lim; }
166 void SetSigma ( const Double_t d ) { fSigma = d; }
167 void SetSigmaErr ( const Double_t d ) { fSigmaErr = d; }
168
169 void SetBinning(Int_t i, Axis_t lo, Axis_t up) { fNbins=i; fFirst=lo; fLast=up; }
170
171 // Simulates
172 void SimulateGausEvents(const Float_t mean, const Float_t sigma, const Int_t nevts=4096); // *MENU*
173
174 ClassDef(MHGausEvents, 4) // Base class for events with Gaussian distributed values
175};
176
177#endif
Note: See TracBrowser for help on using the repository browser.