source: tags/Mars-V0.9.4.1/mhcalib/MHGausEvents.h

Last change on this file was 7189, checked in by tbretz, 19 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
34 Float_t *CreateEventXaxis(Int_t n); // Create an x-axis for the Event TGraphs
35 Float_t *CreatePSDXaxis (Int_t n); // Create an x-axis for the PSD TGraphs
36
37protected:
38
39 Int_t fBinsAfterStripping; // Bins for the Gauss Histogram after stripping off the zeros at both ends
40 UInt_t fCurrentSize; // Current size of the array fEvents
41 Float_t fEventFrequency; // Event frequency in Hertz (to be set)
42 Byte_t fFlags; // Bit field for the fit result bits
43 Int_t fPowerProbabilityBins; // Bins for the projected power spectrum
44
45 TH1I *fHPowerProbability; //! Fourier transform of fEvents projected on y-axis
46 MArrayF *fPowerSpectrum; //! Fourier transform of fEvents
47
48 enum { kGausFitOK,
49 kExpFitOK,
50 kFourierSpectrumOK,
51 kExcluded }; // Bits for information about fit results
52
53 MArrayF fEvents; // Array which holds the entries of GausHist
54 TF1 *fFGausFit; // Gauss fit for fHGausHist
55 TF1 *fFExpFit; // Exponential fit for FHPowerProbability
56 Axis_t fFirst; // Lower histogram edge for fHGausHist (used by InitBins())
57 TGraph *fGraphEvents; //! TGraph to display the event array
58 TGraph *fGraphPowerSpectrum; //! TGraph to display the power spectrum array
59 TH1F fHGausHist; // Histogram to hold the Gaussian distribution
60 Axis_t fLast; // Upper histogram edge for fHGausHist (used by InitBins())
61 Double_t fMean; // Mean of the Gauss fit
62 Double_t fMeanErr; // Error of the mean of the Gauss fit
63 Int_t fNbins; // Number histogram bins for fHGausHist (used by InitBins())
64 Int_t fNDFLimit; // NDF limit for judgement if fit is OK
65 Double_t fSigma; // Sigma of the Gauss fit
66 Double_t fSigmaErr; // Error of the sigma of the Gauss fit
67 Double_t fProb; // Probability of the Gauss fit
68 Float_t fProbLimit; // Probability limit for judgement if fit is OK
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 GetChiSquare() const { return ( fFGausFit ? fFGausFit->GetChisquare() : 0.); }
107 const Double_t GetExpChiSquare() const { return ( fFExpFit ? fFExpFit->GetChisquare() : 0.); }
108 const Int_t GetExpNdf() const { return ( fFExpFit ? fFExpFit->GetNDF() : 0 ); }
109 const Double_t GetExpProb() const { return ( fFExpFit ? fFExpFit->GetProb() : 0.); }
110 MArrayF *GetEvents() { return &fEvents; }
111 const MArrayF *GetEvents() const { return &fEvents; }
112 const Float_t GetEventFrequency () const { return fEventFrequency; }
113 TF1 *GetFExpFit() { return fFExpFit; }
114 const TF1 *GetFExpFit() const { return fFExpFit; }
115 TF1 *GetFGausFit() { return fFGausFit; }
116 const TF1 *GetFGausFit() const { return fFGausFit; }
117 TGraph *GetGraphEvents() { return fGraphEvents; }
118 const Double_t GetFirst() const { return fFirst; }
119 const Double_t GetLast () const { return fLast ; }
120 const TGraph *GetGraphEvents() const { return fGraphEvents; }
121 TGraph *GetGraphPowerSpectrum() { return fGraphPowerSpectrum; }
122 const TGraph *GetGraphPowerSpectrum() const { return fGraphPowerSpectrum; }
123 TH1F *GetHGausHist() { return &fHGausHist; }
124 const TH1F *GetHGausHist() const { return &fHGausHist; }
125 TH1I *GetHPowerProbability() { return fHPowerProbability; }
126 const TH1I *GetHPowerProbability() const { return fHPowerProbability; }
127 const Double_t GetHistRms() const { return fHGausHist.GetRMS(); }
128 const Double_t GetMean() const { return fMean; }
129 const Double_t GetMeanErr() const { return fMeanErr; }
130 const Int_t GetNdf() const { return ( fFGausFit ? fFGausFit->GetNDF() : 0); }
131 const Int_t GetNbins() const { return fNbins; }
132 const Double_t GetOffset() const { return ( fFExpFit ? fFExpFit->GetParameter(0) : 0.); }
133 MArrayF *GetPowerSpectrum() { return fPowerSpectrum; }
134 const MArrayF *GetPowerSpectrum() const { return fPowerSpectrum; }
135 const Double_t GetProb() const { return fProb; }
136 const Double_t GetSigma() const { return fSigma; }
137 const Double_t GetSigmaErr() const { return fSigmaErr; }
138 const Double_t GetSlope() const { return ( fFExpFit ? fFExpFit->GetParameter(1) : 0.); }
139
140 const Bool_t IsExcluded() const { return TESTBIT(fFlags,kExcluded); }
141 const Bool_t IsExpFitOK() const { return TESTBIT(fFlags,kExpFitOK); }
142 const Bool_t IsEmpty() const { return !(fHGausHist.GetEntries()); }
143 const Bool_t IsFourierSpectrumOK() const { return TESTBIT(fFlags,kFourierSpectrumOK); }
144 const Bool_t IsGausFitOK() const { return TESTBIT(fFlags,kGausFitOK); }
145 const Bool_t IsOnlyOverflow() const { return fHGausHist.GetEntries() == fHGausHist.GetBinContent(fNbins+1); }
146 const Bool_t IsOnlyUnderflow() const { return fHGausHist.GetEntries() == fHGausHist.GetBinContent(0); }
147
148 // Prints
149 void Print(const Option_t *o="") const; // *MENU*
150
151 // Setters
152 void SetEventFrequency ( const Float_t f ) { fEventFrequency = f; }
153 void SetExcluded ( const Bool_t b=kTRUE ) { b ? SETBIT(fFlags,kExcluded) : CLRBIT(fFlags,kExcluded); }
154 void SetExpFitOK ( const Bool_t b=kTRUE ) { b ? SETBIT(fFlags,kExpFitOK) : CLRBIT(fFlags,kExpFitOK); }
155 void SetFourierSpectrumOK( const Bool_t b=kTRUE ) { b ? SETBIT(fFlags,kFourierSpectrumOK) : CLRBIT(fFlags,kFourierSpectrumOK); }
156 void SetGausFitOK ( const Bool_t b=kTRUE ) { b ? SETBIT(fFlags,kGausFitOK) : CLRBIT(fFlags,kGausFitOK);}
157 void SetLast ( const Double_t d ) { fLast = d; }
158 void SetFirst ( const Double_t d ) { fFirst = d; }
159 void SetMean ( const Double_t d ) { fMean = d; }
160 void SetMeanErr ( const Double_t d ) { fMeanErr = d; }
161 void SetNbins ( const Int_t i ) { fNbins = i; }
162 void SetNDFLimit ( const Int_t lim=fgNDFLimit ) { fNDFLimit = lim; }
163 void SetProb ( const Double_t d ) { fProb = d; }
164 void SetProbLimit ( const Float_t lim=fgProbLimit ) { fProbLimit = lim; }
165 void SetSigma ( const Double_t d ) { fSigma = d; }
166 void SetSigmaErr ( const Double_t d ) { fSigmaErr = d; }
167
168 // Simulates
169 void SimulateGausEvents(const Float_t mean, const Float_t sigma, const Int_t nevts=4096); // *MENU*
170
171 ClassDef(MHGausEvents, 4) // Base class for events with Gaussian distributed values
172};
173
174#endif
Note: See TracBrowser for help on using the repository browser.