1 #ifndef _utl_ExponentialFitter_h_
2 #define _utl_ExponentialFitter_h_
4 #include <utl/ExponentialFitData.h>
5 #include <utl/AugerException.h>
17 template<
class Histogram>
18 class ExponentialFitter {
21 const int startBin,
const int stopBin)
24 if (fStartBin < 0 || fStopBin >= histogram.GetNBins())
31 const double xStart,
const double xStop)
32 :
fStartBin(histogram.GetBinIndex(xStart)),
33 fStopBin(histogram.GetBinIndex(xStop)),
43 GetSlope(
double& slopeError,
const double offset = 0)
57 const double y = (counts - offset) / width;
59 const double invSigmaz2 = counts;
60 const double z = log(y);
63 const double s2x = invSigmaz2 * x;
67 fSumz += invSigmaz2 * z;
81 fDet = slopeError = 0;
86 GetFit(
double& amplitude,
double& amplitudeError,
87 double& slope,
double& slopeError,
88 const double offset = 0)
90 slope =
GetSlope(slopeError, offset);
101 GetFit(
double& amplitude,
double& amplitudeError,
102 double& slope,
double& slopeError,
103 double& chi2,
int& ndof,
104 const double offset = 0)
106 GetFit(amplitude, amplitudeError, slope, slopeError, offset);
108 const double linOffset = log(amplitude);
141 template<
class Histogram,
typename T>
145 const T& start,
const T& stop)
151 template<
class Histogram,
typename T>
153 ExponentialFitter<Histogram>
155 const std::pair<T, T>& startStop)
void GetFit(double &litude, double &litudeError, double &slope, double &slopeError, double &chi2, int &ndof, const double offset=0)
ExponentialFitter(const Histogram &histogram, const int startBin, const int stopBin)
constexpr T Sqr(const T &x)
Fit exponential function.
Exception for reporting variable out of valid range.
ExponentialFitter(const Histogram &histogram, const double xStart, const double xStop)
const BinType & GetBin(const size_t i) const
ExponentialFitter< Histogram > MakeExponentialFitter(const Histogram &histogram, const T &start, const T &stop)
void GetFit(ExponentialFitData &ef, const double offset=0)
double GetSlope(double &slopeError, const double offset=0)
const Histogram & fHistogram
void GetFit(double &litude, double &litudeError, double &slope, double &slopeError, const double offset=0)
double GetBinCenter(const size_t bin) const