source: trunk/MagicSoft/Mars/mhcalib/MHGausEvents.h@ 5071

Last change on this file since 5071 was 4994, checked in by gaug, 21 years ago
*** empty log message ***
File size: 8.3 KB
Line 
1#ifndef MARS_MHGausEvents
2#define MARS_MHGausEvents
3
4#ifndef ROOT_TH1
5#include <TH1.h>
6#endif
7
8#ifndef MARS_MH
9#include "MH.h"
10#endif
11
12#ifndef MARS_MArrayF
13#include "MArrayF.h"
14#endif
15
16class TVirtualPad;
17class TGraph;
18class MArrayF;
19class TH1F;
20class TH1I;
21class TF1;
22class MHGausEvents : public MH
23{
24private:
25
26 const static Int_t fgNDFLimit; //! Default for fNDFLimit (now set to: 2)
27 const static Float_t fgProbLimit; //! Default for fProbLimit (now set to: 0.001)
28 const static Int_t fgPowerProbabilityBins; //! Default for fPowerProbabilityBins (now set to: 20)
29
30 Float_t *CreateEventXaxis(Int_t n); // Create an x-axis for the Event TGraphs
31 Float_t *CreatePSDXaxis(Int_t n); // Create an x-axis for the PSD TGraphs
32
33protected:
34
35 Float_t fEventFrequency; // Event frequency in Hertz (to be set)
36
37 Int_t fBinsAfterStripping; // Bins for the Gauss Histogram after stripping off the zeros at both ends
38 UInt_t fCurrentSize; // Current size of the array fEvents
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 *fFGausFit; // Gauss fit for fHGausHist
52 TF1 *fFExpFit; // Exponential fit for FHPowerProbability
53 Axis_t fFirst; // Lower histogram edge for fHGausHist (used by InitBins())
54 TGraph *fGraphEvents; //! TGraph to display the event array (will not be cloned!!)
55 TGraph *fGraphPowerSpectrum; //! TGraph to display the power spectrum array (will not be cloned!!)
56 TH1F fHGausHist; // Histogram to hold the Gaussian distribution
57 Axis_t fLast; // Upper histogram edge for fHGausHist (used by InitBins())
58 Double_t fMean; // Mean of the Gauss fit
59 Double_t fMeanErr; // Error of the mean of the Gauss fit
60 Int_t fNbins; // Number histogram bins for fHGausHist (used by InitBins())
61 Int_t fNDFLimit; // NDF limit for judgement if fit is OK
62 Double_t fSigma; // Sigma of the Gauss fit
63 Double_t fSigmaErr; // Error of the sigma of the Gauss fit
64 Double_t fProb; // Probability of the Gauss fit
65 Float_t fProbLimit; // Probability limit for judgement if fit is OK
66
67 void DrawPowerSpectrum(TVirtualPad &pad, Int_t i); // Draw graph of fPowerSpectrum and fHPowerProbability
68
69 // Setters
70 void SetBinsAfterStripping ( const Int_t nbins=0 ) { fBinsAfterStripping =nbins; }
71 void SetPowerProbabilityBins ( const Int_t nbins=fgPowerProbabilityBins ) { fPowerProbabilityBins=nbins; }
72
73public:
74
75 MHGausEvents(const char* name=NULL, const char* title=NULL);
76 ~MHGausEvents();
77
78 TObject *Clone(const char* name="") const;
79
80 void Clear(Option_t *o="");
81 void Reset();
82
83 // Draws
84 void Draw(Option_t *option=""); // Default Draw
85 void DrawEvents(Option_t *option=""); // Draw graph of fEvents
86
87 // Inits
88 virtual void InitBins();
89
90 // Getters
91 const Double_t GetChiSquare() const;
92 const Double_t GetExpChiSquare() const;
93 const Int_t GetExpNdf() const;
94 const Double_t GetExpProb() const;
95 MArrayF *GetEvents() { return &fEvents; }
96 const MArrayF *GetEvents() const { return &fEvents; }
97 const Float_t GetEventFrequency () const { return fEventFrequency; }
98 TF1 *GetFExpFit() { return fFExpFit; }
99 const TF1 *GetFExpFit() const { return fFExpFit; }
100 TF1 *GetFGausFit() { return fFGausFit; }
101 const TF1 *GetFGausFit() const { return fFGausFit; }
102 TGraph *GetGraphEvents() { return fGraphEvents; }
103 const Double_t GetFirst() const { return fFirst; }
104 const Double_t GetLast () const { return fLast ; }
105 const TGraph *GetGraphEvents() const { return fGraphEvents; }
106 TGraph *GetGraphPowerSpectrum() { return fGraphPowerSpectrum; }
107 const TGraph *GetGraphPowerSpectrum() const { return fGraphPowerSpectrum; }
108 TH1F *GetHGausHist() { return &fHGausHist; }
109 const TH1F *GetHGausHist() const { return &fHGausHist; }
110 TH1I *GetHPowerProbability() { return fHPowerProbability; }
111 const TH1I *GetHPowerProbability() const { return fHPowerProbability; }
112 const Double_t GetMean() const { return fMean; }
113 const Double_t GetMeanErr() const { return fMeanErr; }
114 const Int_t GetNdf() const;
115 const Int_t GetNbins() const { return fNbins; }
116 const Double_t GetOffset() const;
117 MArrayF *GetPowerSpectrum() { return fPowerSpectrum; }
118 const MArrayF *GetPowerSpectrum() const { return fPowerSpectrum; }
119 const Double_t GetProb() const { return fProb; }
120 const Double_t GetSigma() const { return fSigma; }
121 const Double_t GetSigmaErr() const { return fSigmaErr; }
122 const Double_t GetSlope() const;
123
124 const Bool_t IsExcluded() const;
125 const Bool_t IsExpFitOK() const;
126 const Bool_t IsEmpty() const;
127 const Bool_t IsFourierSpectrumOK() const;
128 const Bool_t IsGausFitOK() const;
129 const Bool_t IsOnlyOverflow() const;
130 const Bool_t IsOnlyUnderflow() const;
131
132 // Fill
133 void FillArray ( const Float_t f ); // Fill only the array fEvents
134 Bool_t FillHist ( const Float_t f ); // Fill only the histogram HGausHist
135 Bool_t FillHistAndArray( const Float_t f ); // Fill bothe the array fEvents and the histogram HGausHist
136
137 // Fits
138 Bool_t FitGaus( Option_t *option="RQ0",
139 const Double_t xmin=0.,
140 const Double_t xmax=0.); // Fit the histogram HGausHist with a Gaussian
141
142 // Prints
143 virtual void Print(const Option_t *o="") const; // Default Print
144
145 // Setters
146 void SetEventFrequency ( const Float_t f ) { fEventFrequency = f; }
147 void SetExcluded ( const Bool_t b=kTRUE );
148 void SetExpFitOK ( const Bool_t b=kTRUE );
149 void SetFourierSpectrumOK( const Bool_t b=kTRUE );
150 void SetGausFitOK ( const Bool_t b=kTRUE );
151 void SetLast ( const Double_t d ) { fLast = d; }
152 void SetFirst ( const Double_t d ) { fFirst = d; }
153 void SetMean ( const Double_t d ) { fMean = d; }
154 void SetMeanErr ( const Double_t d ) { fMeanErr = d; }
155 void SetNbins ( const Int_t i ) { fNbins = i; }
156 void SetNDFLimit ( const Int_t lim=fgNDFLimit ) { fNDFLimit = lim; }
157 void SetProb ( const Double_t d ) { fProb = d; }
158 void SetProbLimit ( const Float_t lim=fgProbLimit ) { fProbLimit = lim; }
159 void SetSigma ( const Double_t d ) { fSigma = d; }
160 void SetSigmaErr ( const Double_t d ) { fSigmaErr = d; }
161
162 void CreateFourierSpectrum(); // Create the fourier spectrum out of fEvents
163 void CreateGraphEvents(); // Create the TGraph fGraphEvents of fEvents
164 void CreateGraphPowerSpectrum(); // Create the TGraph fGraphPowerSpectrum out of fPowerSpectrum
165
166 ClassDef(MHGausEvents, 1) // Base class for events with Gaussian distributed values
167};
168
169#endif
Note: See TracBrowser for help on using the repository browser.