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

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