Novosibirsk.cxx
Go to the documentation of this file.
1 
12 #ifdef _MSC_VER
13 #include "msdevstudio/MSconfig.h"
14 #endif
15 
16 #include "Novosibirsk.h"
17 
18 #include "FunctionHelper.h"
19 
20 #include <cmath>
21 #include <cassert>
22 
23 using std::exp;
24 using std::vector;
25 
26 using namespace hippodraw;
27 
29 {
30  initialize ();
31 }
32 
33 Novosibirsk::Novosibirsk ( double n, double m, double s, double t )
34 {
35  initialize ();
36 
37  m_parms[norm] = n;
38  m_parms[mean] = m;
39  m_parms[sigma] = s;
40  m_parms[tail] = t;
41 }
42 
44 {
45  m_name = "Novosibirsk";
46 
47  m_parm_names.push_back ( "Norm" );
48  m_parm_names.push_back ( "Mean" );
49  m_parm_names.push_back ( "Sigma" );
50  m_parm_names.push_back ( "Tail" );
51 
52  resize ();
53 }
54 
56 {
57  return new Novosibirsk ( *this );
58 }
59 
60 double Novosibirsk::operator () ( double x ) const
61 {
62 //---- If tail is small then Gauss
63 
64  double qa=0,qb=0,qc=0,qx=0,qy=0;
65  double result=0;
66 
67  if(fabs(m_parms[tail]) < 1.e-7)
68  qc = 0.5*pow((( x -m_parms[mean])/m_parms[sigma]),2);
69  else {
70  qa = m_parms[tail]*sqrt(log(4.));
71  qb = sinh(qa)/qa;
72  qx = ( x - m_parms[mean])/m_parms[sigma]*qb;
73  qy = 1.+m_parms[tail]*qx;
74 
75  //---- Cutting curve from right side
76 
77  if( qy > 1.E-7)
78  qc = 0.5*(pow((log(qy)/m_parms[tail]),2) + m_parms[tail]*m_parms[tail]);
79  else
80  qc = 15.;
81  }
82  //----
83 
84  result = m_parms[norm] * exp(-qc);
85 
86  return result;
87 }
88 
89 void
92 {
93  double min_x = helper->minCoord ();
94  double max_x = helper->maxCoord ();
95  int size = helper->size();
96  double total = helper->getTotal ();
97 
98  m_parms[norm] = total * ( max_x - min_x ) / size;
99  m_parms[mean] = helper->meanCoord ();
100  m_parms[sigma] = helper->stdCoord ();
101  m_parms[tail] = 0.;
102 }
103 
104 double
106 derivByParm ( int , double ) const
107 {
108  assert ( false );
109  return 0.;
110 }
111 
112 bool
115 {
116  return false;
117 }
virtual double operator()(double x) const
The function call operator.
Definition: Novosibirsk.cxx:60
virtual FunctionBase * clone() const
Creates a new function object by copying an existing one.
Definition: Novosibirsk.cxx:55
virtual int size() const
Returns the number of parameters.
hippodraw::Novosibirsk class interface
FunctionHelper class interface.
Novosibirsk()
The default constructor.
Definition: Novosibirsk.cxx:28
virtual double derivByParm(int i, double x) const
Returns the function&#39;s derivative at the coordinate value x with respect to the i-th parameter...
std::vector< double > m_parms
The parameter values.
Definition: FunctionBase.h:109
virtual double minCoord() const =0
Returns the smallest coordinate value along the X axis in the data set.
virtual bool hasDerivatives() const
Returns false as this function has not implemented calculation of partial derivatives.
A function that can be added to a DataRep and used in a fitter.
Definition: FunctionBase.h:90
An abstract base class to help FunctionBase objects perform some operations.
virtual double stdCoord() const =0
Returns the standard deviation of the coordinates along a X axis in the data set. ...
virtual double maxCoord() const =0
Returns the largest coordinate value along the X axis in the data set.
std::string m_name
The name of the function.
Definition: FunctionBase.h:103
virtual double getTotal() const =0
Returns the sum of the values of the data set.
std::vector< std::string > m_parm_names
The names of the function parameters.
Definition: FunctionBase.h:106
virtual void initialize()
Initializes the function and parameter names.
Definition: Novosibirsk.cxx:43
virtual void resize()
Re-sizes the appropriate vectors maintained in this base class.
virtual void initialParameters(const FunctionHelper *helper)
Sets the FunctionHelper so that the function can calculate a reasonable set of initial parameter valu...
Definition: Novosibirsk.cxx:91
virtual double meanCoord() const =0
Returns the mean of the coordinates along a X axis in the data set.
virtual int size() const =0
Returns the number of points in the data set.

Generated for HippoDraw Class Library by doxygen