Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-16 09:08:15

0001 // @(#)root/minuit2:$Id$
0002 // Author: L. Moneta    10/2006
0003 
0004 /**********************************************************************
0005  *                                                                    *
0006  * Copyright (c) 2006 ROOT Foundation,  CERN/PH-SFT                   *
0007  *                                                                    *
0008  **********************************************************************/
0009 
0010 #ifndef ROOT_Minuit2_FCNAdapter
0011 #define ROOT_Minuit2_FCNAdapter
0012 
0013 #include "Minuit2/FCNBase.h"
0014 
0015 #include <ROOT/RSpan.hxx>
0016 
0017 #include <vector>
0018 
0019 namespace ROOT {
0020 
0021 namespace Minuit2 {
0022 
0023 /**
0024 
0025 
0026 template wrapped class for adapting to FCNBase signature
0027 
0028 @author Lorenzo Moneta
0029 
0030 @ingroup Minuit
0031 
0032 */
0033 
0034 template <class Function>
0035 class FCNAdapter : public FCNBase {
0036 
0037 public:
0038    FCNAdapter(const Function &f, double up = 1.) : fFunc(f), fUp(up) {}
0039 
0040    double operator()(std::vector<double> const& v) const override { return fFunc.operator()(&v[0]); }
0041    double operator()(const double *v) const { return fFunc.operator()(v); }
0042    double Up() const override { return fUp; }
0043 
0044    void SetErrorDef(double up) override { fUp = up; }
0045 
0046 private:
0047    const Function &fFunc;
0048    double fUp;
0049 };
0050 
0051 } // end namespace Minuit2
0052 
0053 } // end namespace ROOT
0054 
0055 #endif // ROOT_Minuit2_FCNAdapter