Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:22:07

0001 // @(#)root/mathmore:$Id$
0002 // Author: L. Moneta 2009
0003 
0004 /**********************************************************************
0005  *                                                                    *
0006  * Copyright (c) 2006  LCG ROOT Math Team, CERN/PH-SFT                *
0007  *                                                                    *
0008  *                                                                    *
0009  **********************************************************************/
0010 // Header file for class MinimizerVariable
0011 
0012 #ifndef ROOT_Math_MinimizerVariable
0013 #define ROOT_Math_MinimizerVariable
0014 
0015 #include "MinimizerVariableTransformation.h"
0016 
0017 #include <memory>
0018 
0019 namespace ROOT {
0020 
0021    namespace Math {
0022 
0023       /**
0024          Enumeration describing the status of the variable
0025          The enumeration are used in the minimizer classes to categorize the variables
0026       */
0027       enum EMinimVariableType {
0028          kDefault,    ///< free variable (unlimited)
0029          kFix,        ///< fixed variable
0030          kBounds,     ///<  variable has two bounds
0031          kLowBound,   ///< variable has a lower bound
0032          kUpBound     ///< variable has an upper bounds
0033       };
0034 
0035 
0036 
0037 /**
0038    MinimTransformVariable class
0039    Contains meta information of the variables such as bounds, fix flags and
0040    deals with transformation of the variable
0041    The class does not contain the values and the step size (error) of the variable
0042    This is an internal class used by the MinimTransformFunction class
0043 
0044    @ingroup MultiMin
0045 */
0046 
0047 
0048 class MinimTransformVariable {
0049 
0050 public:
0051 
0052    /**
0053      Default Constructor for  an unlimited variable
0054    */
0055    MinimTransformVariable () :
0056       fFix(false), fLowBound(false), fUpBound(false), fBounds(false),
0057       fLower(1), fUpper(0)
0058    {}
0059 
0060    // constructor for fixed variable
0061    MinimTransformVariable (double value) :
0062       fFix(true), fLowBound(false), fUpBound(false), fBounds(false),
0063       fLower(value), fUpper(value)
0064    {}
0065 
0066    // constructor for double bound variable
0067    MinimTransformVariable (double lower, double upper, SinVariableTransformation * trafo) :
0068       fFix(false), fLowBound(false), fUpBound(false), fBounds(true),
0069       fTransform(trafo),
0070       fLower(lower), fUpper(upper)
0071    {   }
0072 
0073    // constructor for lower bound variable
0074    MinimTransformVariable (double lower, SqrtLowVariableTransformation * trafo) :
0075       fFix(false), fLowBound(true), fUpBound(false), fBounds(false),
0076       fTransform(trafo), fLower(lower), fUpper(lower)
0077    {}
0078 
0079    // constructor for upper bound variable
0080    MinimTransformVariable (double upper, SqrtUpVariableTransformation * trafo) :
0081       fFix(false), fLowBound(true), fUpBound(false), fBounds(false),
0082       fTransform(trafo), fLower(upper), fUpper(upper)
0083    {}
0084 
0085    // copy constructor
0086    MinimTransformVariable (const MinimTransformVariable & rhs) :
0087       fFix(rhs.fFix), fLowBound(rhs.fLowBound), fUpBound(rhs.fUpBound), fBounds(rhs.fBounds),
0088       fLower(rhs.fLower), fUpper(rhs.fUpper)
0089    {
0090       // swap unique_ptr
0091       fTransform.swap( const_cast<MinimTransformVariable &>( rhs).fTransform) ;
0092    }
0093 
0094    // assignment
0095    MinimTransformVariable & operator= (const MinimTransformVariable & rhs) {
0096       if (&rhs == this) return *this;
0097       fFix = rhs.fFix;
0098       fLowBound = rhs.fLowBound;
0099       fUpBound  = rhs.fUpBound;
0100       fBounds   = rhs.fBounds;
0101       fLower = rhs.fLower;  fUpper = rhs.fUpper;
0102 
0103       // swap unique_ptr
0104       fTransform.swap( const_cast<MinimTransformVariable &>( rhs).fTransform) ;
0105       return *this;
0106    }
0107 
0108 
0109    bool IsFixed() const { return fFix; }
0110 
0111    bool IsLimited() const { return fBounds || fLowBound || fUpBound; }
0112 
0113    bool HasLowerBound() const { return fLowBound || fBounds; }
0114 
0115    bool HasUpperBound() const { return fUpBound || fBounds; }
0116 
0117    double LowerBound() const { return fLower; }
0118 
0119    double UpperBound() const { return fUpper; }
0120 
0121    double FixValue() const { return fLower; }
0122 
0123    // internal to external transformation
0124    double InternalToExternal( double x) const {
0125       return (fTransform.get() ) ? fTransform->Int2ext(x, fLower, fUpper) : x;
0126    }
0127 
0128    // derivative of the internal to external transformation ( d Int2Ext / d int )
0129    double DerivativeIntToExt ( double x) const {
0130       return (fTransform.get() ) ? fTransform->DInt2Ext( x, fLower, fUpper) : 1.0;
0131    }
0132 
0133    // external to internal transformation
0134    double ExternalToInternal(double x) const {
0135       return (fTransform.get() ) ? fTransform->Ext2int(x, fLower, fUpper) : x;
0136    }
0137 
0138 private:
0139 
0140    bool fFix;         ///< fix variable
0141    bool fLowBound;    ///< has lower bound
0142    bool fUpBound;     ///< has upper bound param
0143    bool fBounds;      ///< has double bound
0144    std::unique_ptr< MinimizerVariableTransformation> fTransform; ///< pointer to the minimizer transformation
0145    double fLower;     ///< lower parameter limit
0146    double fUpper;     ///< upper parameter limit
0147 
0148 };
0149 
0150    } // end namespace Math
0151 
0152 } // end namespace ROOT
0153 
0154 
0155 #endif /* ROOT_Math_MinimTransformVariable */
0156 
0157