ATTPCROOT  0.3.0-alpha
A ROOT-based framework for analyzing data from active target detectors
lmfit.cxx
Go to the documentation of this file.
1 /*
2  * Project: LevenbergMarquardtLeastSquaresFitting
3  * code obtained from http://sourceforge.net/projects/lmfit/
4  * Contents: optimize p to fit CRDC data y(x)
5  * sechs: p(0)/cosh((log(sqrt(2)+1)/sqrt(2*log(2)))*((x-p(1))/p(2))^2
6  * gaussian: p(0)*exp(-(x-p(1))^2/(2*p(2)^2))
7  * height: p(0), centroid: p(1), FWHM: 2*sqrt(2*log(2))*p(3)
8  * Author: Shumpei Noji
9  */
10 
11 #include "lmfit.h"
12 
13 #include <cmath>
14 
15 double sechs(double x, const double *p)
16 {
17  // return p[0] / pow( cosh( M_PI * ( (x - p[1]) / p[2] ) ), 2 );
18  return p[0] / pow(cosh((log(sqrt(2) + 1) / sqrt(2 * log(2))) * ((x - p[1]) / p[2])), 2);
19 }
20 
21 double gauss(double x, const double *p)
22 {
23  return p[0] * exp(-pow((x - p[1]), 2) / (2 * pow(p[2], 2)));
24 }
sechs
double sechs(double x, const double *p)
Definition: lmfit.cxx:15
lmfit.h
gauss
double gauss(double x, const double *p)
Definition: lmfit.cxx:21