Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
17
18#include "Math/IParamFunction.h"
19
21
22#include <memory>
23
24
25
26namespace 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 the model function used in the fit.
37 It cannot be instantiated but constructed from the derived classes
38*/
39template<class DerivFunType, class ModelFunType, class DataType>
40class BasicFCN : public ::ROOT::Math::BasicFitMethodFunction<DerivFunType> {
41
42protected:
43
44 typedef typename ModelFunType::BackendType T;
45
46 typedef ::ROOT::Math::BasicFitMethodFunction<DerivFunType> BaseObjFunction;
48
49 typedef ::ROOT::Math::IParamMultiFunctionTempl<T> IModelFunction;
50 typedef ::ROOT::Math::IParametricGradFunctionMultiDimTempl<T> IGradModelFunction;
51
52 /**
53 Constructor from data set and model function
54 */
55 BasicFCN (const std::shared_ptr<DataType> & data, const std::shared_ptr<IModelFunction> & func) :
56 BaseObjFunction(func->NPar(), data->Size() ),
57 fData(data),
58 fFunc(func)
59 { }
60
61
62
63 /**
64 Destructor (no operations)
65 */
66 virtual ~BasicFCN () {}
67
68public:
69
70
71 /// access to const reference to the data
72 virtual const DataType & Data() const { return *fData; }
73
74 /// access to data pointer
75 std::shared_ptr<DataType> DataPtr() const { return fData; }
76
77 /// access to const reference to the model function
78 virtual const IModelFunction & ModelFunction() const { return *fFunc; }
79
80 /// access to function pointer
81 std::shared_ptr<IModelFunction> ModelFunctionPtr() const { return fFunc; }
82
83 /// flag to indicate if can compute Hessian
84 virtual bool HasHessian() const {
85 if (!BaseObjFunction::IsAGradFCN()) return false;
86 auto gfunc = dynamic_cast<const IGradModelFunction *>( fFunc.get());
87 if (!gfunc) return false;
88 return gfunc->HasParameterHessian();
89 }
90
91
92
93
94protected:
95
96
97 /// Set the data pointer
98 void SetData(const std::shared_ptr<DataType> & data) { fData = data; }
99
100 /// Set the function pointer
101 void SetModelFunction(const std::shared_ptr<IModelFunction> & func) { fFunc = func; }
102
103
104 std::shared_ptr<DataType> fData;
105 std::shared_ptr<IModelFunction> fFunc;
106
107
108
109};
110
111
112
113 } // end namespace Fit
114
115} // end namespace ROOT
116
117
118#endif /* ROOT_Fit_BasicFCN */
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
BasicFCN class: base class for the objective functions used in the fits It has a reference to the dat...
Definition BasicFCN.h:40
void SetData(const std::shared_ptr< DataType > &data)
Set the data pointer.
Definition BasicFCN.h:98
std::shared_ptr< IModelFunction > ModelFunctionPtr() const
access to function pointer
Definition BasicFCN.h:81
::ROOT::Math::IParamMultiFunctionTempl< T > IModelFunction
Definition BasicFCN.h:49
void SetModelFunction(const std::shared_ptr< IModelFunction > &func)
Set the function pointer.
Definition BasicFCN.h:101
virtual const DataType & Data() const
access to const reference to the data
Definition BasicFCN.h:72
::ROOT::Math::BasicFitMethodFunction< DerivFunType > BaseObjFunction
Definition BasicFCN.h:46
std::shared_ptr< IModelFunction > fFunc
Definition BasicFCN.h:105
::ROOT::Math::IParametricGradFunctionMultiDimTempl< T > IGradModelFunction
Definition BasicFCN.h:50
BaseObjFunction::BaseFunction BaseFunction
Definition BasicFCN.h:47
virtual bool HasHessian() const
flag to indicate if can compute Hessian
Definition BasicFCN.h:84
virtual ~BasicFCN()
Destructor (no operations)
Definition BasicFCN.h:66
ModelFunType::BackendType T
Definition BasicFCN.h:44
std::shared_ptr< DataType > fData
Definition BasicFCN.h:104
BasicFCN(const std::shared_ptr< DataType > &data, const std::shared_ptr< IModelFunction > &func)
Constructor from data set and model function.
Definition BasicFCN.h:55
std::shared_ptr< DataType > DataPtr() const
access to data pointer
Definition BasicFCN.h:75
virtual const IModelFunction & ModelFunction() const
access to const reference to the model function
Definition BasicFCN.h:78
FitMethodFunction class Interface for objective functions (like chi2 and likelihood used in the fit) ...
static bool IsAGradFCN()
Static function to indicate if a function is supporting gradient.
IParamFunction interface (abstract class) describing multi-dimensional parametric functions It is a d...
Interface (abstract class) for parametric gradient multi-dimensional functions providing in addition ...
TFitResultPtr Fit(FitObject *h1, TF1 *f1, Foption_t &option, const ROOT::Math::MinimizerOptions &moption, const char *goption, ROOT::Fit::DataRange &range)
Definition HFitImpl.cxx:133
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...