1#ifndef __JROOT__JROOTFIT__ 
    2#define __JROOT__JROOTFIT__ 
   28namespace JPP { 
using namespace JROOT; }
 
   55      return range_type(pAxis->GetXmin(), pAxis->GetXmax());
 
 
   90      return std::numeric_limits<double>::min();
 
 
  100    inline double getRho(
const double z)
 const 
 
  114    inline double getPsi(
const double z)
 const 
 
 
  144            const double error) :
 
 
  156    inline double getRho(
const double z)
 const 
 
  170    inline double getPsi(
const double z)
 const 
  174      return -0.5 * u / 
error;
 
 
 
  238    m_2d(
const double x, 
const double y, 
const T& v) :
 
 
 
  275    m_3d(
const double x, 
const double y, 
const double z, 
const T& v) :
 
 
 
  343    for (Int_t ix = 1; ix <= h1.GetXaxis()->GetNbins(); ++ix) {
 
  345      const double x     = h1.GetXaxis()->GetBinCenter(ix);
 
  346      const size_t count = h1.GetBinContent(ix);
 
 
  365    for (Int_t ix = 1; ix <= h1.GetXaxis()->GetNbins(); ++ix) {
 
  367      const double x     = h1.GetXaxis()->GetBinCenter(ix);
 
  368      const double value = h1.GetBinContent(ix);
 
  369      const double error = h1.GetBinError  (ix);
 
  371      if (X(x) && error > 0.0) {
 
 
  432    for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
 
  433      for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
 
  435        const double x     = h2.GetXaxis()->GetBinCenter(ix);
 
  436        const double y     = h2.GetYaxis()->GetBinCenter(iy);
 
  437        const size_t count = h2.GetBinContent(ix,iy);
 
 
  459    for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
 
  460      for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
 
  462        const double x     = h2.GetXaxis()->GetBinCenter(ix);
 
  463        const double y     = h2.GetYaxis()->GetBinCenter(iy);
 
  464        const double value = h2.GetBinContent(ix,iy);
 
  465        const double error = h2.GetBinError  (ix,iy);
 
  467        if (X(x) && Y(y) && error > 0.0) {
 
 
  535    for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
 
  536      for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
 
  537        for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
 
  539          const double x     = h3.GetXaxis()->GetBinCenter(ix);
 
  540          const double y     = h3.GetYaxis()->GetBinCenter(iy);
 
  541          const double z     = h3.GetZaxis()->GetBinCenter(iz);
 
  542          const size_t count = h3.GetBinContent(ix,iy,iz);
 
  544          if (X(x) && Y(y) && Z(z)) {
 
 
  567    for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
 
  568      for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
 
  569        for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
 
  571          const double x     = h3.GetXaxis()->GetBinCenter(ix);
 
  572          const double y     = h3.GetYaxis()->GetBinCenter(iy);
 
  573          const double z     = h3.GetZaxis()->GetBinCenter(iz);
 
  574          const double value = h3.GetBinContent(ix,iy,iz);
 
  575          const double error = h3.GetBinError  (ix,iy,iz);
 
  577          if (X(x) && Y(y) && Z(z) && error > 0.0) {
 
 
  599    template<
class JF1_t>
 
  600    JF1(
const char* 
const name,
 
 
  616    template<
class JF1_t>
 
  639        setParameters(
this, parameters);
 
  641        return this->getValue(x[0]);
 
 
 
 
  661    template<
class JF2_t>
 
  662    JF2(
const char* 
const name,
 
 
  682    template<
class JF2_t>
 
  705        setParameters(
this, parameters);
 
  707        return this->getValue(x[0], x[1]);
 
 
 
 
  728    template<
class JF3_t>
 
  729    JF3(
const char* 
const name,
 
 
  753    template<
class JF3_t>
 
  776        setParameters(
this, parameters);
 
  778        return this->getValue(x[0], x[1], x[2]);
 
 
 
 
  803      std::set<size_t>(indices)
 
 
  815      for (
size_t i = 0; i != T::parameters.size(); ++i) {
 
  816        if (std::find(parameters.begin(), parameters.end(), T::parameters[i]) != parameters.end()) {
 
 
 
  827  template<
class JFs_t>
 
  863      return JFs_t::parameters.size();
 
 
  918      return getParameter(this->
value, i);
 
 
  929      return getParameter(this->
error, i);
 
 
 
  937  template<
class JFs_t>
 
  993      (*this)(*h1, f1, type, ls, X);
 
  995      h1->GetListOfFunctions()->Add(
new JF1(
"f1",
 
 
 1047      (*this)(*h2, f2, type, ls, X, Y);
 
 1049      h2->GetListOfFunctions()->Add(
new JF2(
"f2",
 
 
 1106      (*this)(*h3, 
f3, type, ls, X, Y, Z);
 
 1108      h3->GetListOfFunctions()->Add(
new JF3(
"f3",
 
 
 1142      for (
size_t i = 0; i != JFs_t::parameters.size(); ++i) {
 
 1143        if (ls.count(i) == 0) {
 
 1144          this->
parameters.push_back(JFs_t::parameters[i]);
 
 1149      this->
npx   = data.size();
 
 
 1173        const double y   = fs.getValue(mp.
x);
 
 
 1193        const double y   = fs.getValue(mp.
x, mp.
y);
 
 
 1213        const double y   = fs.getValue(mp.
x, mp.
y, mp.
z);
 
 
 
 
 1231  template<
class JFs_t>
 
 1246  template<
class T, 
class JF1_t>
 
 1268  template<
class T, 
class JF1_t>
 
 1290  template<
class T, 
class JF2_t>
 
 1314  template<
class T, 
class JF2_t>
 
 1338  template<
class T, 
class JF3_t>
 
 1364  template<
class T, 
class JF3_t>
 
Auxiliary methods for mathematics.
 
double f3(const double x, const double y, const double z)
3D function.
 
Auxiliary class to define a range between two values.
 
Fit method based on the Levenberg-Marquardt method.
 
std::vector< parameter_type > parameters
fit parameters
 
Base class for result of ROOT Fit.
 
JRootfit_t()
Default constructor.
 
const JFs_t & getFunction() const
Get function.
 
int getNDF() const
Get number of degrees of freedom.
 
size_t getNumberOfParameters() const
Get number of parameters.
 
double getChi2() const
Get chi2.
 
double getValue(size_t i) const
Get value of parameter at given index.
 
double getError(size_t i) const
Get error of parameter at given index.
 
size_t getNumberOfFreeParameters() const
Get number of free parameters.
 
size_t getN() const
Get number of data points.
 
size_t npx
number of data points
 
static JRootfit Fit
Global fit object.
 
const result_type & operator()(TH3 *h3, const JFs_t &f3, const T &type, const index_list &ls=index_list(), const range_type &X=range_type(), const range_type &Y=range_type(), const range_type &Z=range_type())
Fit.
 
const result_type & operator()(TH1 *h1, const JFs_t &f1, const T &type, const index_list &ls=index_list(), const range_type &X=range_type())
Fit.
 
const result_type & operator()(const TH3 &h3, const JFs_t &f3, const T &type, const index_list &ls=index_list(), const range_type &X=range_type(), const range_type &Y=range_type(), const range_type &Z=range_type())
Fit.
 
size_t getNumberOfFreeParameters()
 
const result_type & operator()(TH2 *h2, const JFs_t &f2, const T &type, const index_list &ls=index_list(), const range_type &X=range_type(), const range_type &Y=range_type())
Fit.
 
const result_type & operator()(const TH2 &h2, const JFs_t &f2, const T &type, const index_list &ls=index_list(), const range_type &X=range_type(), const range_type &Y=range_type())
Fit.
 
const struct JROOT::JRootfit::function_type fit
 
const result_type & operator()(const TH1 &h1, const JFs_t &f1, const T &type, const index_list &ls=index_list(), const range_type &X=range_type())
Fit.
 
JRootfit_t< JFs_t > result_type
 
const result_type & eval(const JFs_t &fs, const index_list &ls, const data_type< T > &data)
Evaluate fit.
 
JRootfit()
Default constructor.
 
size_t getNumberOfParameters()
Get number of parameters.
 
void setParameters(JF1_t *f1, const double *values)
Set values of all parameters.
 
double getParameter(const JF1_t &f1, const size_t i)
Get value of parameter at given index.
 
double poisson(const size_t n, const double mu)
Poisson probability density distribution.
 
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
 
Auxiliary classes and methods for ROOT I/O.
 
JTOOLS::JRange< double > range_type
Type definiton of abscissa range.
 
JRootfit_t< JF1_t > Fit(const TH1 &h1, const JF1_t &f1, const index_list &ls=index_list(), const range_type &X=range_type())
Global fit fuction.
 
range_type getRange(TAxis *pAxis)
Get range of given axis.
 
Data structure for return value of fit function.
 
JModel_t gradient
partial derivatives of chi2
 
Auxiliary data structure for list of parameters.
 
double operator()(const double *x, const double *parameters)
ROOT compatible function call.
 
helper(const JF1_t &f1)
Constructor.
 
Wrapper data structure to build ROOT 1D function.
 
JF1(const char *const name, const JF1_t &f1, const range_type &X=range_type())
Constructor.
 
double operator()(const double *x, const double *parameters)
ROOT compatible function call.
 
helper(const JF2_t &f2)
Constructor.
 
Wrapper data structure to build ROOT 2D function.
 
JF2(const char *const name, const JF2_t &f2, const range_type &X=range_type(), const range_type &Y=range_type())
Constructor.
 
helper(const JF3_t &f3)
Constructor.
 
double operator()(const double *x, const double *parameters)
ROOT compatible function call.
 
Wrapper data structure to build ROOT 3D function.
 
JF3(const char *const name, const JF3_t &f3, const range_type &X=range_type(), const range_type &Y=range_type(), const range_type &Z=range_type())
Constructor.
 
Auxiliary data structure for fit functions.
 
JGandalf< JFs_t >::result_type result_type
 
const result_type & operator()(const JFs_t &fs, const m_1d< T > &mp) const
Fit function.
 
const result_type & operator()(const JFs_t &fs, const m_2d< T > &mp) const
Fit function.
 
const result_type & operator()(const JFs_t &fs, const m_3d< T > &mp) const
Fit function.
 
data_type(const TH1 &h1, const range_type &X=range_type())
Unpack constructor.
 
void unpack(const TH1 &h1, const range_type &X=range_type())
Unpack 1D-histogram.
 
data_type()
Default constructor.
 
void unpack(const TH2 &h2, const range_type &X=range_type(), const range_type &Y=range_type())
Unpack 2D-histogram.
 
data_type()
Default constructor.
 
data_type(const TH2 &h2, const range_type &X=range_type(), const range_type &Y=range_type())
Unpack constructor.
 
data_type()
Default constructor.
 
data_type(const TH3 &h3, const range_type &X=range_type(), const range_type &Y=range_type(), const range_type &Z=range_type())
Unpack constructor.
 
void unpack(const TH3 &h3, const range_type &X=range_type(), const range_type &Y=range_type(), const range_type &Z=range_type())
Unpack 3D-histogram.
 
Template definition of data structure for set of data points.
 
void unpack(const TH1 &h1, const range_type &X)
Unpack 1D-histogram.
 
Auxiliary data structure for list of fixed parameters.
 
index_list(const std::initializer_list< size_t > &indices)
Constructor.
 
index_list()
Default constructor.
 
index_list(const std::initializer_list< double T::* > ¶meters)
Conversion constructor.
 
m_1d()
Default constructor.
 
m_1d(const double x, const T &v)
Constructor.
 
m_2d(const double x, const double y, const T &v)
Constructor.
 
m_2d()
Default constructor.
 
m_3d(const double x, const double y, const double z, const T &v)
Constructor.
 
m_3d()
Default constructor.
 
Data point for counting measurement.
 
double getPsi(const double z) const
Get derivative of chi2.
 
double getRho(const double z) const
Get chi2.
 
static double epsilon()
Minimal value for numerical computations.
 
m_count()
Default constructor.
 
m_count(const size_t count)
Constructor.
 
Data point for value with error.
 
double getRho(const double z) const
Get chi2.
 
m_value(const double value, const double error)
Constructor.
 
m_value()
Default constructor.
 
double getPsi(const double z) const
Get derivative of chi2.