File indexing completed on 2025-01-30 10:22:12
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef ROOT_Minuit2_MinosError
0011 #define ROOT_Minuit2_MinosError
0012
0013 #include "Minuit2/MnCross.h"
0014 #include <utility>
0015
0016 namespace ROOT {
0017
0018 namespace Minuit2 {
0019
0020
0021
0022
0023
0024
0025 class MinosError {
0026
0027 public:
0028 MinosError() : fParameter(0), fMinParValue(0.), fUpper(MnCross()), fLower(MnCross()) {}
0029
0030 MinosError(unsigned int par, double value, const MnCross &low, const MnCross &up)
0031 : fParameter(par), fMinParValue(value), fUpper(up), fLower(low)
0032 {
0033 }
0034
0035 ~MinosError() {}
0036
0037 MinosError(const MinosError &err)
0038 : fParameter(err.fParameter), fMinParValue(err.fMinParValue), fUpper(err.fUpper), fLower(err.fLower)
0039 {
0040 }
0041
0042 MinosError &operator=(const MinosError &) = default;
0043
0044 MinosError &operator()(const MinosError &err)
0045 {
0046 fParameter = err.fParameter;
0047 fMinParValue = err.fMinParValue;
0048 fUpper = err.fUpper;
0049 fLower = err.fLower;
0050 return *this;
0051 }
0052
0053 std::pair<double, double> operator()() const { return std::pair<double, double>(Lower(), Upper()); }
0054 double Lower() const
0055 {
0056 if (AtLowerLimit())
0057 return LowerState().Parameter(Parameter()).LowerLimit() - fMinParValue;
0058 if (LowerValid()) {
0059
0060
0061 double err = LowerState().Error(Parameter());
0062
0063 if (LowerState().Parameter(Parameter()).HasLowerLimit())
0064 err = std::min(err, fMinParValue - LowerState().Parameter(Parameter()).LowerLimit());
0065 return -1. * err * (1. + fLower.Value());
0066 }
0067
0068 return -LowerState().Error(Parameter());
0069 }
0070 double Upper() const
0071 {
0072 if (AtUpperLimit())
0073 return UpperState().Parameter(Parameter()).UpperLimit() - fMinParValue;
0074 if (UpperValid()) {
0075
0076
0077 double err = UpperState().Error(Parameter());
0078 if (UpperState().Parameter(Parameter()).HasUpperLimit())
0079 err = std::min(err, UpperState().Parameter(Parameter()).UpperLimit() - fMinParValue);
0080 return err * (1. + fUpper.Value());
0081 }
0082
0083 return UpperState().Error(Parameter());
0084 }
0085 unsigned int Parameter() const { return fParameter; }
0086 const MnUserParameterState &LowerState() const { return fLower.State(); }
0087 const MnUserParameterState &UpperState() const { return fUpper.State(); }
0088 bool IsValid() const { return fLower.IsValid() && fUpper.IsValid(); }
0089 bool LowerValid() const { return fLower.IsValid(); }
0090 bool UpperValid() const { return fUpper.IsValid(); }
0091 bool AtLowerLimit() const { return fLower.AtLimit(); }
0092 bool AtUpperLimit() const { return fUpper.AtLimit(); }
0093 bool AtLowerMaxFcn() const { return fLower.AtMaxFcn(); }
0094 bool AtUpperMaxFcn() const { return fUpper.AtMaxFcn(); }
0095 bool LowerNewMin() const { return fLower.NewMinimum(); }
0096 bool UpperNewMin() const { return fUpper.NewMinimum(); }
0097 unsigned int NFcn() const { return fUpper.NFcn() + fLower.NFcn(); }
0098
0099 double Min() const { return fMinParValue; }
0100
0101 private:
0102 unsigned int fParameter;
0103 double fMinParValue;
0104 MnCross fUpper;
0105 MnCross fLower;
0106 };
0107
0108 }
0109
0110 }
0111
0112 #endif