1 #ifndef RAYLEIGH_HIST_H 2 #define RAYLEIGH_HIST_H 5 #include "RingBuffer.h" 6 #include <Math/Minimizer.h> 7 #include <Math/Factory.h> 8 #include <Math/Functor.h> 39 } ChiSquareErrorMethod;
44 virtual void Draw(Option_t* opt=
"");
45 virtual bool add(
double newAmp);
48 void fitRayleigh(
bool forGuiUpdateTF1=
true);
51 void fitRayleighAdaptive(
bool forGuiUpdateTF1=
true);
52 void fitRayleighScan(
bool forGuiUpdateTF1=
true);
53 void fitRayleighJustEvalGuess(
bool forGuiUpdateTF1=
true);
54 void fitRayleighTF1();
55 void fitRayleighMinuit(
bool forGuiUpdateTF1=
true);
57 static void guessMaxBinLimitAndSigmaFromMean(
double meanAmp,
double& maxAmp,
double& sigmaGuess,
double fracOfEventsInsideMaxAmp);
61 distAmp = distAmp < 0 ? fRayleighAmplitude : distAmp;
62 return exp((-0.5*amp*amp)/(distAmp*distAmp));
65 inline double getCDF(
double amp,
double distAmp = -1)
const{
66 distAmp = distAmp < 0 ? fRayleighAmplitude : distAmp;
69 inline double getAmplitude()
const {
return fRayleighAmplitude;}
74 virtual int Fill(
double amp,
double sign=1);
78 std::vector<double> binCentres;
79 std::vector<double> squaredBinCentres;
80 std::vector<int> binValues;
81 std::vector<double> squaredBinErrors;
97 double getRayleighChiSquare(
const double* params);
98 std::vector<double> theFitParams;
99 std::vector<double> theFitParamsSteps;
109 Double_t fRayleighAmplitude;
111 void updateParamsOfTF1();
112 std::vector<Double_t> fParamsTF1;
115 ChiSquareErrorMethod chiSquareErrorMethod;
116 const Int_t fFitEveryNAdds;
121 double fRayleighAmpGuess;
122 double fRayleighNorm;
double getOneMinusCDF(double amp, double distAmp=-1) const
void getRayleighFitParams(double &rayAmp, double &chiSquare, int &ndf)
Output Rayleigh distribution parameters.
Int_t fNx
The number of bins (faster than GetNbinsX())
A a glorified ring buffer of frequency amplitudes with a TSpectrum to look for CW spikes...
virtual bool add(double newAmp)
Input amplitudes events.
TGraph * grLastAddedAmp
A pretty visual representation of the last added amplitude.
Int_t fNumFitParams
Will be equal to one as we only try and fit the amplitude (normalization is fixed by fNumEvents and b...
TF1 * fRay
Pointer to the Rayeligh TF1 cloned from parent FourierBuffer.
double fracOfEventsWanted
Fraction of events to be in the histogram bin limits using the guessed amplitude (don't set to 1 as t...
Namespace which wraps everything in the library.
virtual int Fill(double amp, double sign=1)
Fill the histogram, this is called by add(double)
RingBuffer amplitudes
Tracks all the amplitudes.
Int_t fNumNonEmptyBins
Cache number of non empty bins.
void rebinAndRefill(double meanAmp)
Dynamically rebin and refill histogram with contents of RingBuffer of amplitudes. ...
ROOT::Math::Minimizer * fMinimizer
The minuit minimizer object.
double freqMHz
The frequency (MHz) of this Rayleigh distribution.
ROOT::Math::Functor fChiSquaredFunc
For minuit interface, will point to getRayelighChiSquare(const double*)
Int_t risingEdgeBins
Number of bins between 0 and where we guess the histogram peak is, for dynamic rebinning.
FourierBuffer * fParent
Daddy.
Int_t fNumEvents
Tracks the number of events in the RingBuffer/histogram (faster than integral)
bool axisRangeOK() const
Checks current axis range is reasonable.