ROOT  6.06/09
Reference Guide
BasicFCN.h
Go to the documentation of this file.
1 // @(#)root/mathcore:$Id$
2 // Author: L. Moneta 25 Nov 2014
3 
4 /**********************************************************************
5  * *
6  * Copyright (c) 2006 LCG ROOT Math Team, CERN/PH-SFT *
7  * *
8  * *
9  **********************************************************************/
10 
11 // Header file for class BasicFCN
12 
13 #ifndef ROOT_Fit_BasicFCN
14 #define ROOT_Fit_BasicFCN
15 
16 #ifndef ROOT_Math_FitMethodFunction
17 #include "Math/FitMethodFunction.h"
18 #endif
19 
20 #ifndef ROOT_Math_IParamFunction
21 #include "Math/IParamFunction.h"
22 #endif
23 
24 
25 #include <memory>
26 
27 
28 
29 namespace ROOT {
30 
31 
32  namespace Fit {
33 
34 
35 
36 //___________________________________________________________________________________
37 /**
38  BasicFCN class: base class for the objective functions used in the fits
39  It has a reference to the data and th emodel function used in the fit.
40  It cannot be instantiated but constructed from the derived classes
41 */
42 template<class FunType, class DataType>
44 
45 protected:
46 
47 
48  typedef ::ROOT::Math::BasicFitMethodFunction<FunType> BaseObjFunction;
50 
52 
53  /**
54  Constructor from data set and model function
55  */
56  BasicFCN (const std::shared_ptr<DataType> & data, const std::shared_ptr<IModelFunction> & func) :
57  BaseObjFunction(func->NPar(), data->Size() ),
58  fData(data),
59  fFunc(func)
60  { }
61 
62 
63 
64  /**
65  Destructor (no operations)
66  */
67  virtual ~BasicFCN () {}
68 
69 public:
70 
71 
72  /// access to const reference to the data
73  virtual const DataType & Data() const { return *fData; }
74 
75  /// access to data pointer
76  std::shared_ptr<DataType> DataPtr() const { return fData; }
77 
78  /// access to const reference to the model function
79  virtual const IModelFunction & ModelFunction() const { return *fFunc; }
80 
81  /// access to function pointer
82  std::shared_ptr<IModelFunction> ModelFunctionPtr() const { return fFunc; }
83 
84 
85 
86 protected:
87 
88 
89  /// Set the data pointer
90  void SetData(const std::shared_ptr<DataType> & data) { fData = data; }
91 
92  /// Set the function pointer
93  void SetModelFunction(const std::shared_ptr<IModelFunction> & func) { fFunc = func; }
94 
95 
96  std::shared_ptr<DataType> fData;
97  std::shared_ptr<IModelFunction> fFunc;
98 
99 
100 
101 };
102 
103 
104 
105  } // end namespace Fit
106 
107 } // end namespace ROOT
108 
109 
110 #endif /* ROOT_Fit_BasicFCN */
::ROOT::Math::BasicFitMethodFunction< FunType > BaseObjFunction
Definition: BasicFCN.h:48
Namespace for new ROOT classes and functions.
Definition: ROOT.py:1
virtual const IModelFunction & ModelFunction() const
access to const reference to the model function
Definition: BasicFCN.h:79
const char * Size
Definition: TXMLSetup.cxx:56
void SetModelFunction(const std::shared_ptr< IModelFunction > &func)
Set the function pointer.
Definition: BasicFCN.h:93
virtual const DataType & Data() const
access to const reference to the data
Definition: BasicFCN.h:73
BasicFCN(const std::shared_ptr< DataType > &data, const std::shared_ptr< IModelFunction > &func)
Constructor from data set and model function.
Definition: BasicFCN.h:56
std::shared_ptr< DataType > fData
Definition: BasicFCN.h:96
std::shared_ptr< IModelFunction > fFunc
Definition: BasicFCN.h:97
void SetData(const std::shared_ptr< DataType > &data)
Set the data pointer.
Definition: BasicFCN.h:90
BasicFCN class: base class for the objective functions used in the fits It has a reference to the dat...
Definition: BasicFCN.h:43
FitMethodFunction class Interface for objective functions (like chi2 and likelihood used in the fit) ...
Definition: Fitter.h:57
TFitResultPtr Fit(FitObject *h1, TF1 *f1, Foption_t &option, const ROOT::Math::MinimizerOptions &moption, const char *goption, ROOT::Fit::DataRange &range)
Definition: HFitImpl.cxx:132
double func(double *x, double *p)
Definition: stressTF1.cxx:213
std::shared_ptr< IModelFunction > ModelFunctionPtr() const
access to function pointer
Definition: BasicFCN.h:82
::ROOT::Math::IParamMultiFunction IModelFunction
Definition: BasicFCN.h:51
IParametricFunctionMultiDim IParamMultiFunction
const int NPar
BaseObjFunction::BaseFunction BaseFunction
Definition: BasicFCN.h:49
std::shared_ptr< DataType > DataPtr() const
access to data pointer
Definition: BasicFCN.h:76
virtual ~BasicFCN()
Destructor (no operations)
Definition: BasicFCN.h:67