Macros | Functions
gausTF1.cxx File Reference
#include "TF1.h"
#include <string>

Go to the source code of this file.

Macros

#define gausTF1_H
 

Functions

double gausFunction (double *x, double *pars)
 
TF1 * gausTF1 (double heightIn, double meanIn, double sigmaIn, std::string fname)
 

Macro Definition Documentation

#define gausTF1_H

Definition at line 11 of file gausTF1.cxx.

Function Documentation

double gausFunction ( double *  x,
double *  pars 
)

Definition at line 18 of file gausTF1.cxx.

18  {
19  double pos = x[0];
20  double height = pars[0];
21  double mean = pars[1];
22  double sigma = pars[2];
23  if ( sigma <= 0.0 ) return 0;
24  double rat = (pos-mean)/sigma;
25  return height*exp(-0.5*rat*rat);
26 }
list x
Definition: train.py:276
double mean(sqlite3 *db, std::string const &table_name, std::string const &column_name)
Definition: statistics.cc:16
TF1* gausTF1 ( double  heightIn,
double  meanIn,
double  sigmaIn,
std::string  fname 
)

Definition at line 28 of file gausTF1.cxx.

28  {
29  double height = heightIn != 0.0 ? heightIn : 1.0;
30  double sigma = sigmaIn > 0.0 ? sigmaIn : 1.0;
31  double mean = meanIn;
32  string sform = "[0]*exp(-0.5*((x-[1])/[2])*((x-[1])/[2]))";
33  TF1* pf = new TF1(fname.c_str(), sform.c_str(), -10, 10);
34  //TF1* pf = new TF1(fname.c_str(), gausFunction, -10, 10, 3);
35  pf->SetParName(0, "Height");
36  pf->SetParName(1, "Mean");
37  pf->SetParName(2, "Sigma");
38  pf->SetParameter(0, height);
39  pf->SetParameter(1, mean);
40  pf->SetParameter(2, sigma);
41  double sigmaMin = 0.0;
42  double sigmaMax = 1.e10;
43  if ( sigmaIn > 0.0 ) {
44  sigmaMin = 0.1*sigmaIn;
45  sigmaMax = 10.0*sigmaIn;
46  }
47  pf->SetParLimits(2, sigmaMin, sigmaMax);
48  if ( sigmaIn > 0.0 ) pf->SetParLimits(2, 0.1*sigma, 10*sigma);
49  return pf;
50 }
double mean(sqlite3 *db, std::string const &table_name, std::string const &column_name)
Definition: statistics.cc:16