Logo ROOT   6.10/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 #include "Math/FitMethodFunction.h"
17 
18 #include "Math/IParamFunction.h"
19 
20 #include "Math/IParamFunctionfwd.h"
21 
22 #include <memory>
23 
24 
25 
26 namespace ROOT {
27 
28 
29  namespace Fit {
30 
31 
32 
33 //___________________________________________________________________________________
34 /**
35  BasicFCN class: base class for the objective functions used in the fits
36  It has a reference to the data and th emodel function used in the fit.
37  It cannot be instantiated but constructed from the derived classes
38 */
39 template<class FunType, class DataType>
41 
42 protected:
43 
44 
45  typedef ::ROOT::Math::BasicFitMethodFunction<FunType> BaseObjFunction;
47 
49 
50  /**
51  Constructor from data set and model function
52  */
53  BasicFCN (const std::shared_ptr<DataType> & data, const std::shared_ptr<IModelFunction> & func) :
54  BaseObjFunction(func->NPar(), data->Size() ),
55  fData(data),
56  fFunc(func)
57  { }
58 
59 
60 
61  /**
62  Destructor (no operations)
63  */
64  virtual ~BasicFCN () {}
65 
66 public:
67 
68 
69  /// access to const reference to the data
70  virtual const DataType & Data() const { return *fData; }
71 
72  /// access to data pointer
73  std::shared_ptr<DataType> DataPtr() const { return fData; }
74 
75  /// access to const reference to the model function
76  virtual const IModelFunction & ModelFunction() const { return *fFunc; }
77 
78  /// access to function pointer
79  std::shared_ptr<IModelFunction> ModelFunctionPtr() const { return fFunc; }
80 
81 
82 
83 protected:
84 
85 
86  /// Set the data pointer
87  void SetData(const std::shared_ptr<DataType> & data) { fData = data; }
88 
89  /// Set the function pointer
90  void SetModelFunction(const std::shared_ptr<IModelFunction> & func) { fFunc = func; }
91 
92 
93  std::shared_ptr<DataType> fData;
94  std::shared_ptr<IModelFunction> fFunc;
95 
96 
97 
98 };
99 
100 
101 
102  } // end namespace Fit
103 
104 } // end namespace ROOT
105 
106 
107 #endif /* ROOT_Fit_BasicFCN */
::ROOT::Math::BasicFitMethodFunction< FunType > BaseObjFunction
Definition: BasicFCN.h:45
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
virtual const IModelFunction & ModelFunction() const
access to const reference to the model function
Definition: BasicFCN.h:76
const char * Size
Definition: TXMLSetup.cxx:56
void SetModelFunction(const std::shared_ptr< IModelFunction > &func)
Set the function pointer.
Definition: BasicFCN.h:90
BasicFCN(const std::shared_ptr< DataType > &data, const std::shared_ptr< IModelFunction > &func)
Constructor from data set and model function.
Definition: BasicFCN.h:53
std::shared_ptr< DataType > fData
Definition: BasicFCN.h:93
std::shared_ptr< IModelFunction > fFunc
Definition: BasicFCN.h:94
virtual const DataType & Data() const
access to const reference to the data
Definition: BasicFCN.h:70
void SetData(const std::shared_ptr< DataType > &data)
Set the data pointer.
Definition: BasicFCN.h:87
BasicFCN class: base class for the objective functions used in the fits It has a reference to the dat...
Definition: BasicFCN.h:40
std::shared_ptr< IModelFunction > ModelFunctionPtr() const
access to function pointer
Definition: BasicFCN.h:79
FitMethodFunction class Interface for objective functions (like chi2 and likelihood used in the fit) ...
Definition: Fitter.h:40
TFitResultPtr Fit(FitObject *h1, TF1 *f1, Foption_t &option, const ROOT::Math::MinimizerOptions &moption, const char *goption, ROOT::Fit::DataRange &range)
Definition: HFitImpl.cxx:134
double func(double *x, double *p)
Definition: stressTF1.cxx:213
::ROOT::Math::IParamMultiFunction IModelFunction
Definition: BasicFCN.h:48
IParametricFunctionMultiDim IParamMultiFunction
const int NPar
BaseObjFunction::BaseFunction BaseFunction
Definition: BasicFCN.h:46
std::shared_ptr< DataType > DataPtr() const
access to data pointer
Definition: BasicFCN.h:73
virtual ~BasicFCN()
Destructor (no operations)
Definition: BasicFCN.h:64