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