// @(#)root/mathcore:$Id$
// Author: L. Moneta 25 Nov 2014

/**********************************************************************
 *                                                                    *
 * Copyright (c) 2006  LCG ROOT Math Team, CERN/PH-SFT                *
 *                                                                    *
 *                                                                    *
 **********************************************************************/

// Header file for class BasicFCN

#ifndef ROOT_Fit_BasicFCN
#define ROOT_Fit_BasicFCN

#ifndef ROOT_Math_FitMethodFunction
#include "Math/FitMethodFunction.h"
#endif

#ifndef ROOT_Math_IParamFunction
#include "Math/IParamFunction.h"
#endif


#include <memory>



namespace ROOT {


   namespace Fit {



//___________________________________________________________________________________
/**
   BasicFCN class: base class  for the objective functions used in the fits 
   It has a reference to the data and th emodel function used in the fit. 
   It cannot be instantiated but constructed from the derived classes 
*/
template<class FunType, class DataType>
class BasicFCN : public ::ROOT::Math::BasicFitMethodFunction<FunType> {

protected:

   
   typedef  ::ROOT::Math::BasicFitMethodFunction<FunType> BaseObjFunction;
   typedef typename  BaseObjFunction::BaseFunction BaseFunction;

   typedef  ::ROOT::Math::IParamMultiFunction IModelFunction;

   /**
      Constructor from data set  and model function
   */
   BasicFCN (const std::shared_ptr<DataType> & data, const std::shared_ptr<IModelFunction> & func) :
      BaseObjFunction(func->NPar(), data->Size() ),
      fData(data),
      fFunc(func)
   { }


   
   /**
      Destructor (no operations)
   */
   virtual ~BasicFCN ()  {}

public:


   /// access to const reference to the data
   virtual const DataType & Data() const { return *fData; }

   /// access to data pointer
   std::shared_ptr<DataType> DataPtr() const { return fData; }
   
   /// access to const reference to the model function
   virtual const IModelFunction & ModelFunction() const { return *fFunc; }

   /// access to function pointer 
   std::shared_ptr<IModelFunction> ModelFunctionPtr() const { return fFunc; }

   

protected:


   /// Set the data pointer
   void SetData(const std::shared_ptr<DataType> & data) { fData = data; }

      /// Set the function pointer
   void SetModelFunction(const std::shared_ptr<IModelFunction> & func) { fFunc = func; }


   std::shared_ptr<DataType>  fData;
   std::shared_ptr<IModelFunction>  fFunc;



};



   } // end namespace Fit

} // end namespace ROOT


#endif /* ROOT_Fit_BasicFCN */
 BasicFCN.h:1
 BasicFCN.h:2
 BasicFCN.h:3
 BasicFCN.h:4
 BasicFCN.h:5
 BasicFCN.h:6
 BasicFCN.h:7
 BasicFCN.h:8
 BasicFCN.h:9
 BasicFCN.h:10
 BasicFCN.h:11
 BasicFCN.h:12
 BasicFCN.h:13
 BasicFCN.h:14
 BasicFCN.h:15
 BasicFCN.h:16
 BasicFCN.h:17
 BasicFCN.h:18
 BasicFCN.h:19
 BasicFCN.h:20
 BasicFCN.h:21
 BasicFCN.h:22
 BasicFCN.h:23
 BasicFCN.h:24
 BasicFCN.h:25
 BasicFCN.h:26
 BasicFCN.h:27
 BasicFCN.h:28
 BasicFCN.h:29
 BasicFCN.h:30
 BasicFCN.h:31
 BasicFCN.h:32
 BasicFCN.h:33
 BasicFCN.h:34
 BasicFCN.h:35
 BasicFCN.h:36
 BasicFCN.h:37
 BasicFCN.h:38
 BasicFCN.h:39
 BasicFCN.h:40
 BasicFCN.h:41
 BasicFCN.h:42
 BasicFCN.h:43
 BasicFCN.h:44
 BasicFCN.h:45
 BasicFCN.h:46
 BasicFCN.h:47
 BasicFCN.h:48
 BasicFCN.h:49
 BasicFCN.h:50
 BasicFCN.h:51
 BasicFCN.h:52
 BasicFCN.h:53
 BasicFCN.h:54
 BasicFCN.h:55
 BasicFCN.h:56
 BasicFCN.h:57
 BasicFCN.h:58
 BasicFCN.h:59
 BasicFCN.h:60
 BasicFCN.h:61
 BasicFCN.h:62
 BasicFCN.h:63
 BasicFCN.h:64
 BasicFCN.h:65
 BasicFCN.h:66
 BasicFCN.h:67
 BasicFCN.h:68
 BasicFCN.h:69
 BasicFCN.h:70
 BasicFCN.h:71
 BasicFCN.h:72
 BasicFCN.h:73
 BasicFCN.h:74
 BasicFCN.h:75
 BasicFCN.h:76
 BasicFCN.h:77
 BasicFCN.h:78
 BasicFCN.h:79
 BasicFCN.h:80
 BasicFCN.h:81
 BasicFCN.h:82
 BasicFCN.h:83
 BasicFCN.h:84
 BasicFCN.h:85
 BasicFCN.h:86
 BasicFCN.h:87
 BasicFCN.h:88
 BasicFCN.h:89
 BasicFCN.h:90
 BasicFCN.h:91
 BasicFCN.h:92
 BasicFCN.h:93
 BasicFCN.h:94
 BasicFCN.h:95
 BasicFCN.h:96
 BasicFCN.h:97
 BasicFCN.h:98
 BasicFCN.h:99
 BasicFCN.h:100
 BasicFCN.h:101
 BasicFCN.h:102
 BasicFCN.h:103
 BasicFCN.h:104
 BasicFCN.h:105
 BasicFCN.h:106
 BasicFCN.h:107
 BasicFCN.h:108
 BasicFCN.h:109
 BasicFCN.h:110