Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-13 09:09:59

0001 // @(#)root/minuit2:$Id$
0002 // Authors: M. Winkler, F. James, L. Moneta, A. Zsenei   2003-2005
0003 
0004 /**********************************************************************
0005  *                                                                    *
0006  * Copyright (c) 2005 LCG ROOT Math team,  CERN/PH-SFT                *
0007  *                                                                    *
0008  **********************************************************************/
0009 
0010 #ifndef ROOT_Minuit2_MnFcn
0011 #define ROOT_Minuit2_MnFcn
0012 
0013 #include "Minuit2/FCNBase.h"
0014 #include "Minuit2/MnMatrix.h"
0015 
0016 #include <vector>
0017 
0018 namespace ROOT {
0019 
0020 namespace Minuit2 {
0021 
0022 class MnUserTransformation;
0023 
0024 class FCNBase;
0025 /**
0026    Wrapper class to FCNBase interface used internally by Minuit.
0027    Apply conversion from calling the function from a Minuit Vector (MnAlgebraicVector) to a std::vector  for
0028    the function coordinates.
0029    The class counts also the number of function calls. By default counter start from zero, but a different value
0030    might be given if the class is  instantiated later on, for example for a set of different minimizaitons
0031    Normally the derived class MnUserFCN should be instantiated with performs in addition the transformatiopn
0032    internal-> external parameters
0033  */
0034 class MnFcn {
0035 
0036 public:
0037    explicit MnFcn(const FCNBase &fcn, int ncall = 0) : fFCN(fcn), fNumCall(ncall) {}
0038    explicit MnFcn(const FCNBase &fcn, const MnUserTransformation &trafo, int ncall = 0)
0039       : fFCN(fcn), fNumCall(ncall), fTransform(&trafo)
0040    {
0041    }
0042 
0043    unsigned int NumOfCalls() const { return fNumCall; }
0044 
0045    double ErrorDef() const
0046    {
0047       return fFCN.Up();
0048    }
0049 
0050    double Up() const
0051    {
0052       return fFCN.Up();
0053    }
0054 
0055    const FCNBase &Fcn() const { return fFCN; }
0056 
0057    // Access the parameter transformations.
0058    // For internal use in the Minuit2 implementation.
0059    const MnUserTransformation *Trafo() const { return fTransform; }
0060 
0061    double CallWithTransformedParams(std::vector<double> const &vpar) const;
0062    double CallWithoutDoingTrafo(const MnAlgebraicVector &) const;
0063 
0064 private:
0065    const FCNBase &fFCN;
0066    mutable int fNumCall;
0067    const MnUserTransformation *fTransform = nullptr;
0068 };
0069 
0070 // Helper class to call the MnFcn, caching the transformed parameters if necessary.
0071 class MnFcnCaller {
0072 public:
0073    MnFcnCaller(const MnFcn &mfcn);
0074 
0075    double operator()(const MnAlgebraicVector &v);
0076 
0077 private:
0078    MnFcn const &fMfcn;
0079    bool fDoInt2ext = false;
0080    std::vector<double> fLastInput;
0081    std::vector<double> fVpar;
0082 };
0083 
0084 } // namespace Minuit2
0085 
0086 } // namespace ROOT
0087 
0088 #endif // ROOT_Minuit2_MnFcn