BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
ROOT::Fit::Chi2FCN< DerivFunType, ModelFunType > Class Template Reference

Description

template<class DerivFunType, class ModelFunType = ROOT::Math::IParamMultiFunction>
class ROOT::Fit::Chi2FCN< DerivFunType, ModelFunType >

Chi2FCN class for binnned fits using the least square methods

Definition at line 49 of file Chi2FCN.h.

Inheritance diagram for ROOT::Fit::Chi2FCN< DerivFunType, ModelFunType >:
[legend]
Collaboration diagram for ROOT::Fit::Chi2FCN< DerivFunType, ModelFunType >:
[legend]

Public Types

typedef BasicFCN< DerivFunType, ModelFunType, BinDataBaseFCN
 
typedef BaseObjFunction::BaseFunction BaseFunction
 
typedef ::ROOT::Math::BasicFitMethodFunction< DerivFunType > BaseObjFunction
 
typedef ::ROOT::Math::IParamMultiFunctionTempl< TIModelFunction
 
typedef ModelFunType::BackendType T
 
typedef BaseObjFunction::Type_t Type_t
 

Public Member Functions

 Chi2FCN (const BinData &data, const IModelFunction &func, const ::ROOT::Fit::ExecutionPolicy &executionPolicy=::ROOT::Fit::ExecutionPolicy::kSerial)
 
 Chi2FCN (const Chi2FCN &f)
 
 Chi2FCN (const std::shared_ptr< BinData > &data, const std::shared_ptr< IModelFunction > &func, const ::ROOT::Fit::ExecutionPolicy &executionPolicy=::ROOT::Fit::ExecutionPolicy::kSerial)
 
virtual ~Chi2FCN ()
 
virtual BaseFunctionClone () const
 
virtual double DataElement (const double *x, unsigned int i, double *g) const
 i-th chi-square residual More...
 
virtual void Gradient (const double *x, double *g) const
 
Chi2FCNoperator= (const Chi2FCN &rhs)
 
virtual BaseObjFunction::Type_t Type () const
 get type of fit method function More...
 

Protected Member Functions

virtual void SetNFitPoints (unsigned int n) const
 set number of fit points (need to be called in const methods, make it const) More...
 

Private Member Functions

virtual double DoDerivative (const double *x, unsigned int icoord) const
 
virtual double DoEval (const double *x) const
 

Private Attributes

::ROOT::Fit::ExecutionPolicy fExecutionPolicy
 
std::vector< double > fGrad
 
unsigned int fNEffPoints
 

Member Typedef Documentation

◆ BaseFCN

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
typedef BasicFCN<DerivFunType, ModelFunType, BinData> ROOT::Fit::Chi2FCN< DerivFunType, ModelFunType >::BaseFCN

Definition at line 54 of file Chi2FCN.h.

◆ BaseFunction

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
typedef BaseObjFunction::BaseFunction ROOT::Fit::Chi2FCN< DerivFunType, ModelFunType >::BaseFunction

Definition at line 57 of file Chi2FCN.h.

◆ BaseObjFunction

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
typedef ::ROOT::Math::BasicFitMethodFunction<DerivFunType> ROOT::Fit::Chi2FCN< DerivFunType, ModelFunType >::BaseObjFunction

Definition at line 56 of file Chi2FCN.h.

◆ IModelFunction

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
typedef ::ROOT::Math::IParamMultiFunctionTempl<T> ROOT::Fit::Chi2FCN< DerivFunType, ModelFunType >::IModelFunction

Definition at line 60 of file Chi2FCN.h.

◆ T

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
typedef ModelFunType::BackendType ROOT::Fit::Chi2FCN< DerivFunType, ModelFunType >::T

Definition at line 53 of file Chi2FCN.h.

◆ Type_t

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
typedef BaseObjFunction::Type_t ROOT::Fit::Chi2FCN< DerivFunType, ModelFunType >::Type_t

Definition at line 61 of file Chi2FCN.h.

Constructor & Destructor Documentation

◆ Chi2FCN() [1/3]

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
ROOT::Fit::Chi2FCN< DerivFunType, ModelFunType >::Chi2FCN ( const std::shared_ptr< BinData > &  data,
const std::shared_ptr< IModelFunction > &  func,
const ::ROOT::Fit::ExecutionPolicy &  executionPolicy = ::ROOT::Fit::ExecutionPolicy::kSerial 
)
inline

Constructor from data set (binned ) and model function

Definition at line 66 of file Chi2FCN.h.

66  :
67  BaseFCN( data, func),
68  fNEffPoints(0),
69  fGrad ( std::vector<double> ( func->NPar() ) ),
70  fExecutionPolicy(executionPolicy)
71  { }
unsigned int fNEffPoints
Definition: Chi2FCN.h:162
std::vector< double > fGrad
Definition: Chi2FCN.h:164
BasicFCN< DerivFunType, ModelFunType, BinData > BaseFCN
Definition: Chi2FCN.h:54
::ROOT::Fit::ExecutionPolicy fExecutionPolicy
Definition: Chi2FCN.h:165

Referenced by ROOT::Fit::Chi2FCN< DerivFunType, ModelFunType >::Clone().

◆ Chi2FCN() [2/3]

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
ROOT::Fit::Chi2FCN< DerivFunType, ModelFunType >::Chi2FCN ( const BinData data,
const IModelFunction func,
const ::ROOT::Fit::ExecutionPolicy &  executionPolicy = ::ROOT::Fit::ExecutionPolicy::kSerial 
)
inline

Same Constructor from data set (binned ) and model function but now managed by the user we clone the function but not the data

Definition at line 77 of file Chi2FCN.h.

77  :
78  BaseFCN(std::shared_ptr<BinData>(const_cast<BinData*>(&data), DummyDeleter<BinData>()), std::shared_ptr<IModelFunction>(dynamic_cast<IModelFunction*>(func.Clone() ) ) ),
79  fNEffPoints(0),
80  fGrad ( std::vector<double> ( func.NPar() ) ),
81  fExecutionPolicy(executionPolicy)
82  { }
::ROOT::Math::IParamMultiFunctionTempl< T > IModelFunction
Definition: Chi2FCN.h:60

◆ ~Chi2FCN()

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
virtual ROOT::Fit::Chi2FCN< DerivFunType, ModelFunType >::~Chi2FCN ( )
inlinevirtual

Destructor (no operations)

Definition at line 87 of file Chi2FCN.h.

87 {}

◆ Chi2FCN() [3/3]

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
ROOT::Fit::Chi2FCN< DerivFunType, ModelFunType >::Chi2FCN ( const Chi2FCN< DerivFunType, ModelFunType > &  f)
inline

Copy constructor

Definition at line 91 of file Chi2FCN.h.

91  :
92  BaseFCN(f.DataPtr(), f.ModelFunctionPtr() ),
93  fNEffPoints( f.fNEffPoints ),
94  fGrad( f.fGrad),
95  fExecutionPolicy(f.fExecutionPolicy)
96  { }

Member Function Documentation

◆ Clone()

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
virtual BaseFunction* ROOT::Fit::Chi2FCN< DerivFunType, ModelFunType >::Clone ( ) const
inlinevirtual

Definition at line 111 of file Chi2FCN.h.

111  {
112  return new Chi2FCN(*this);
113  }
Chi2FCN(const std::shared_ptr< BinData > &data, const std::shared_ptr< IModelFunction > &func, const ::ROOT::Fit::ExecutionPolicy &executionPolicy=::ROOT::Fit::ExecutionPolicy::kSerial)
Definition: Chi2FCN.h:66

References ROOT::Fit::Chi2FCN< DerivFunType, ModelFunType >::Chi2FCN().

Here is the call graph for this function:

◆ DataElement()

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
virtual double ROOT::Fit::Chi2FCN< DerivFunType, ModelFunType >::DataElement ( const double *  x,
unsigned int  i,
double *  g 
) const
inlinevirtual

i-th chi-square residual

Definition at line 121 of file Chi2FCN.h.

121  {
122  if (i==0) this->UpdateNCalls();
123  return FitUtil::Evaluate<T>::EvalChi2Residual(BaseFCN::ModelFunction(), BaseFCN::Data(), x, i, g);
124  }
static double EvalChi2Residual(const IModelFunctionTempl< double > &func, const BinData &data, const double *p, unsigned int i, double *g=0)
Definition: FitUtil.h:1486

References ROOT::Fit::FitUtil::Evaluate< T >::EvalChi2Residual().

Here is the call graph for this function:

◆ DoDerivative()

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
virtual double ROOT::Fit::Chi2FCN< DerivFunType, ModelFunType >::DoDerivative ( const double *  x,
unsigned int  icoord 
) const
inlineprivatevirtual

Definition at line 156 of file Chi2FCN.h.

156  {
157  Gradient(x, fGrad.data());
158  return fGrad[icoord];
159  }
virtual void Gradient(const double *x, double *g) const
Definition: Chi2FCN.h:127

References ROOT::Fit::Chi2FCN< DerivFunType, ModelFunType >::fGrad, and ROOT::Fit::Chi2FCN< DerivFunType, ModelFunType >::Gradient().

Here is the call graph for this function:

◆ DoEval()

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
virtual double ROOT::Fit::Chi2FCN< DerivFunType, ModelFunType >::DoEval ( const double *  x) const
inlineprivatevirtual

Evaluation of the function (required by interface)

Definition at line 147 of file Chi2FCN.h.

147  {
148  this->UpdateNCalls();
149  if (BaseFCN::Data().HaveCoordErrors() || BaseFCN::Data().HaveAsymErrors())
150  return FitUtil::Evaluate<T>::EvalChi2Effective(BaseFCN::ModelFunction(), BaseFCN::Data(), x, fNEffPoints);
151  else
152  return FitUtil::Evaluate<T>::EvalChi2(BaseFCN::ModelFunction(), BaseFCN::Data(), x, fNEffPoints, fExecutionPolicy);
153  }
static double EvalChi2Effective(const IModelFunctionTempl< double > &func, const BinData &data, const double *p, unsigned int &nPoints)
Definition: FitUtil.h:1475
static double EvalChi2(const IModelFunction &func, const BinData &data, const double *p, unsigned int &nPoints, ROOT::Fit::ExecutionPolicy executionPolicy, unsigned nChunks=0)
Definition: FitUtil.h:1447

References ROOT::Fit::FitUtil::Evaluate< T >::EvalChi2(), ROOT::Fit::FitUtil::Evaluate< T >::EvalChi2Effective(), ROOT::Fit::Chi2FCN< DerivFunType, ModelFunType >::fExecutionPolicy, and ROOT::Fit::Chi2FCN< DerivFunType, ModelFunType >::fNEffPoints.

Here is the call graph for this function:

◆ Gradient()

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
virtual void ROOT::Fit::Chi2FCN< DerivFunType, ModelFunType >::Gradient ( const double *  x,
double *  g 
) const
inlinevirtual

Definition at line 127 of file Chi2FCN.h.

127  {
128  // evaluate the chi2 gradient
129  FitUtil::Evaluate<T>::EvalChi2Gradient(BaseFCN::ModelFunction(), BaseFCN::Data(), x, g, fNEffPoints,
131  }
static void EvalChi2Gradient(const IModelFunctionTempl< double > &func, const BinData &data, const double *p, double *g, unsigned int &nPoints, ROOT::Fit::ExecutionPolicy executionPolicy=ROOT::Fit::ExecutionPolicy::kSerial, unsigned nChunks=0)
Definition: FitUtil.h:1479

References ROOT::Fit::FitUtil::Evaluate< T >::EvalChi2Gradient(), ROOT::Fit::Chi2FCN< DerivFunType, ModelFunType >::fExecutionPolicy, and ROOT::Fit::Chi2FCN< DerivFunType, ModelFunType >::fNEffPoints.

Referenced by ROOT::Fit::Chi2FCN< DerivFunType, ModelFunType >::DoDerivative().

Here is the call graph for this function:

◆ operator=()

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
Chi2FCN& ROOT::Fit::Chi2FCN< DerivFunType, ModelFunType >::operator= ( const Chi2FCN< DerivFunType, ModelFunType > &  rhs)
inline

Assignment operator

Definition at line 101 of file Chi2FCN.h.

101  {
102  SetData(rhs.DataPtr() );
103  SetModelFunction(rhs.ModelFunctionPtr() );
104  fNEffPoints = rhs.fNEffPoints;
105  fGrad = rhs.fGrad;
106  }

References ROOT::Fit::Chi2FCN< DerivFunType, ModelFunType >::fGrad, and ROOT::Fit::Chi2FCN< DerivFunType, ModelFunType >::fNEffPoints.

◆ SetNFitPoints()

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
virtual void ROOT::Fit::Chi2FCN< DerivFunType, ModelFunType >::SetNFitPoints ( unsigned int  n) const
inlineprotectedvirtual

set number of fit points (need to be called in const methods, make it const)

Definition at line 140 of file Chi2FCN.h.

140 { fNEffPoints = n; }

References ROOT::Fit::Chi2FCN< DerivFunType, ModelFunType >::fNEffPoints.

◆ Type()

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
virtual BaseObjFunction::Type_t ROOT::Fit::Chi2FCN< DerivFunType, ModelFunType >::Type ( ) const
inlinevirtual

get type of fit method function

Definition at line 134 of file Chi2FCN.h.

References ROOT::Math::BasicFitMethodFunction< FunctionType >::kLeastSquare.

Member Data Documentation

◆ fExecutionPolicy

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
::ROOT::Fit::ExecutionPolicy ROOT::Fit::Chi2FCN< DerivFunType, ModelFunType >::fExecutionPolicy
private

◆ fGrad

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
std::vector<double> ROOT::Fit::Chi2FCN< DerivFunType, ModelFunType >::fGrad
mutableprivate

◆ fNEffPoints

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
unsigned int ROOT::Fit::Chi2FCN< DerivFunType, ModelFunType >::fNEffPoints
mutableprivate

The documentation for this class was generated from the following file: