source: trunk/MagicSoft/Mars/mcalib/MHGausEvents.h@ 3614

Last change on this file since 3614 was 3611, checked in by gaug, 21 years ago
*** empty log message ***
File size: 6.8 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
12class TVirtualPad;
13class TGraph;
14class TArrayF;
15class TH1F;
16class TH1I;
17class TF1;
18class MHGausEvents : public MH
19{
20private:
21
22 const static Float_t fgProbLimit; // Default for fProbLimit (now 0.001)
23 const static Int_t fgNDFLimit; // Default for fNDFLimit (now 2)
24 const static Int_t fgPowerProbabilityBins; // Default for fPowerProbabilityBins (now 20)
25 const static Int_t fgBinsAfterStripping; // Default for fBinsAfterStripping (now 40)
26
27 Int_t fPowerProbabilityBins; // Bins for the projected power spectrum
28 Int_t fBinsAfterStripping; // Bins for the Gauss Histogram after stripping off the zeros at both ends
29 Float_t fEventFrequency; // Event frequency in Hertz (to be set)
30
31 TH1I *fHPowerProbability; // Fourier transform of fEvents projected on y-axis
32 TArrayF *fPowerSpectrum; // Fourier transform of fEvents
33
34 TGraph *fGraphEvents; //! TGraph to display the event array (will not be cloned!!)
35 TGraph *fGraphPowerSpectrum; //! TGraph to display the power spectrum array (will not be cloned!!)
36
37 Double_t fMean; // Mean of the Gauss fit
38 Double_t fSigma; // Sigma of the Gauss fit
39 Double_t fMeanErr; // Error of the mean of the Gauss fit
40 Double_t fSigmaErr; // Error of the sigma of the Gauss fit
41 Double_t fProb; // Probability of the Gauss fit (derived from Chi-Square and NDF
42
43 enum { kGausFitOK, kExpFitOK, kFourierSpectrumOK }; // Bits to hold information about fit results
44
45 Byte_t fFlags; // Byte to hold the bits fit result bits
46
47 Int_t fCurrentSize; // Current size of the array fEvents
48
49protected:
50
51 TH1F fHGausHist; // Histogram which should hold the Gaussian distribution
52 TArrayF fEvents; // Array which holds the entries of GausHist
53
54 TF1 *fFGausFit; // Gauss fit for fHGausHist
55 TF1 *fFExpFit; // Exponential fit for FHPowerProbability
56
57 Float_t fProbLimit; // Probability limit for judgement if fit is OK
58 Int_t fNDFLimit; // NDF limit for judgement if fit is OK
59
60 // Setters
61 void SetPowerProbabilityBins ( const Int_t nbins=fgPowerProbabilityBins ) { fPowerProbabilityBins = nbins; }
62 void SetBinsAfterStripping ( const Int_t nbins=fgBinsAfterStripping ) { fBinsAfterStripping = nbins; }
63
64 void DrawEvents(); // Draw a graph of the array fEvents
65 void DrawPowerSpectrum(TVirtualPad &pad, Int_t i); // Draw a graph of the array fPowerSpectrum and the hist fHPowerProbability
66
67 Float_t *CreateEventXaxis(Int_t n); // Create an x-axis for the Event TGraphs
68 Float_t *CreatePSDXaxis(Int_t n); // Create an x-axis for the PSD TGraphs
69
70public:
71
72 MHGausEvents(const char* name=NULL, const char* title=NULL);
73 ~MHGausEvents();
74
75 virtual void Clear(Option_t *o="");
76 virtual void Reset();
77
78 // Setters
79 void SetEventFrequency(const Float_t f) { fEventFrequency = f; }
80
81 void SetMean ( const Double_t d ) { fMean = d; }
82 void SetMeanErr ( const Double_t d ) { fMeanErr = d; }
83 void SetSigma ( const Double_t d ) { fSigma = d; }
84 void SetSigmaErr( const Double_t d ) { fSigmaErr = d; }
85 void SetProb ( const Double_t d ) { fProb = d; }
86
87 void SetProbLimit( const Float_t lim=fgProbLimit ) { fProbLimit = lim; }
88 void SetNDFLimit( const Int_t lim=fgNDFLimit ) { fNDFLimit = lim; }
89
90 // Setters ONLY for MC:
91 void SetGausFitOK( const Bool_t b );
92 void SetExpFitOK( const Bool_t b );
93 void SetFourierSpectrumOK( const Bool_t b );
94
95 // Getters
96 const Double_t GetMean() const { return fMean; }
97 const Double_t GetMeanErr() const { return fMeanErr; }
98 const Double_t GetSigma() const { return fSigma; }
99 const Double_t GetSigmaErr() const { return fSigmaErr; }
100 const Double_t GetChiSquare() const;
101 const Double_t GetProb() const { return fProb; }
102 const Int_t GetNdf() const;
103
104 const Double_t GetSlope() const;
105 const Double_t GetOffset() const;
106 const Double_t GetExpChiSquare() const;
107 const Double_t GetExpProb() const;
108 const Int_t GetExpNdf() const;
109
110 TH1F *GetHGausHist() { return &fHGausHist; }
111 const TH1F *GetHGausHist() const { return &fHGausHist; }
112
113 TArrayF *GetEvents() { return &fEvents; }
114 const TArrayF *GetEvents() const { return &fEvents; }
115
116 TArrayF *GetPowerSpectrum() { return fPowerSpectrum; }
117 const TArrayF *GetPowerSpectrum() const { return fPowerSpectrum; }
118
119 TF1 *GetFGausFit() { return fFGausFit; }
120 const TF1 *GetFGausFit() const { return fFGausFit; }
121
122 TH1I *GetHPowerProbability() { return fHPowerProbability; }
123 const TH1I *GetHPowerProbability() const { return fHPowerProbability; }
124
125 TF1 *GetFExpFit() { return fFExpFit; }
126 const TF1 *GetFExpFit() const { return fFExpFit; }
127
128 TGraph *GetGraphEvents() { return fGraphEvents; }
129 const TGraph *GetGraphEvents() const { return fGraphEvents; }
130
131 TGraph *GetGraphPowerSpectrum() { return fGraphPowerSpectrum; }
132 const TGraph *GetGraphPowerSpectrum() const { return fGraphPowerSpectrum; }
133
134 const Bool_t IsGausFitOK() const;
135 const Bool_t IsExpFitOK() const;
136 const Bool_t IsEmpty() const;
137 const Bool_t IsFourierSpectrumOK() const;
138
139 // Fill
140 void FillArray(const Float_t f); // Fill only the array fEvents
141 Bool_t FillHist(const Float_t f); // Fill only the histogram HGausHist
142 Bool_t FillHistAndArray(const Float_t f); // Fill bothe the array fEvents and the histogram HGausHist
143
144 // Fits
145 Bool_t FitGaus(Option_t *option="RQ0", const Double_t xmin=0., const Double_t xmax=0.); // Fit the histogram HGausHist with a Gaussian
146
147 // Draws
148 virtual void Draw(Option_t *option=""); // Default Draw
149
150 // Prints
151 virtual void Print(const Option_t *o="") const; // Default Print
152
153 // Miscelleaneous
154 void CreateFourierSpectrum(); // Create the fourier spectrum out of fEvents
155 void CreateGraphEvents(); // Create the TGraph fGraphEvents of fEvents
156 void CreateGraphPowerSpectrum(); // Create the TGraph fGraphPowerSpectrum out of fPowerSpectrum
157
158 ClassDef(MHGausEvents, 1) // Base class for events with Gaussian distributed values
159};
160
161#endif
Note: See TracBrowser for help on using the repository browser.