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

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