| 1 | // @(#)root/minuit2:$Id$cxx . . $ `<file>/extern/root/math/minuit2/inc/Minuit2/MnPrint.h`/ |
| 2 | // Authors: M. Winkler, F. James, L. Moneta, A. Zsenei 2003-2005 |
| 3 | |
| 4 | /********************************************************************** |
| 5 | * * |
| 6 | * Copyright (c) 2005 LCG ROOT Math team, CERN/PH-SFT * |
| 7 | * * |
| 8 | **********************************************************************/ |
| 9 | |
| 10 | #ifndef ROOT_Minuit2_MnPrint |
| 11 | #define ROOT_Minuit2_MnPrintcxx . . $ `extern/root/math/minuit2/inc/Minuit2/MnPrint.h:11:9`! |
| 12 | |
| 13 | #include "Minuit2/MnConfig.h"cxx . . $ `<file>/extern/root/math/minuit2/inc/Minuit2/MnConfig.h`/ |
| 14 | |
| 15 | #include <sstream> |
| 16 | #include <utility> |
| 17 | #include <cassert> |
| 18 | #include <string> |
| 19 | #include <ios> |
| 20 | |
| 21 | namespace ROOTcxx . . $ ROOT/ { |
| 22 | namespace Minuit2cxx . . $ ROOT/Minuit2/ { |
| 23 | |
| 24 | /** |
| 25 | define std::ostream operators for output |
| 26 | */ |
| 27 | |
| 28 | class FunctionMinimumcxx . . $ ROOT/Minuit2/FunctionMinimum#; |
| 29 | stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &operatorcxx . . $ ROOT/Minuit2/`operator<<`(6bbd8ab2d2012a0a).<<(stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &, const FunctionMinimumcxx . . $ ROOT/Minuit2/FunctionMinimum# &); |
| 30 | |
| 31 | class MinimumStatecxx . . $ ROOT/Minuit2/MinimumState#; |
| 32 | stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &operatorcxx . . $ ROOT/Minuit2/`operator<<`(15213f707a02a406).<<(stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &, const MinimumStatecxx . . $ ROOT/Minuit2/MinimumState# &); |
| 33 | |
| 34 | class LAVectorcxx . . $ ROOT/Minuit2/LAVector#; |
| 35 | stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &operatorcxx . . $ ROOT/Minuit2/`operator<<`(3fc734aa9e7aa6a5).<<(stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &, const LAVectorcxx . . $ ROOT/Minuit2/LAVector# &); |
| 36 | |
| 37 | class LASymMatrixcxx . . $ ROOT/Minuit2/LASymMatrix#; |
| 38 | stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &operatorcxx . . $ ROOT/Minuit2/`operator<<`(d9856d9fb1525c07).<<(stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &, const LASymMatrixcxx . . $ ROOT/Minuit2/LASymMatrix# &); |
| 39 | |
| 40 | class MnUserParameterscxx . . $ ROOT/Minuit2/MnUserParameters#; |
| 41 | stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &operatorcxx . . $ ROOT/Minuit2/`operator<<`(d0ad47e6a7da7957).<<(stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &, const MnUserParameterscxx . . $ ROOT/Minuit2/MnUserParameters# &); |
| 42 | |
| 43 | class MnUserCovariancecxx . . $ ROOT/Minuit2/MnUserCovariance#; |
| 44 | stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &operatorcxx . . $ ROOT/Minuit2/`operator<<`(26498392745fb61a).<<(stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &, const MnUserCovariancecxx . . $ ROOT/Minuit2/MnUserCovariance# &); |
| 45 | |
| 46 | class MnGlobalCorrelationCoeffcxx . . $ ROOT/Minuit2/MnGlobalCorrelationCoeff#; |
| 47 | stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &operatorcxx . . $ ROOT/Minuit2/`operator<<`(dd7bf330abd20b57).<<(stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &, const MnGlobalCorrelationCoeffcxx . . $ ROOT/Minuit2/MnGlobalCorrelationCoeff# &); |
| 48 | |
| 49 | class MnUserParameterStatecxx . . $ ROOT/Minuit2/MnUserParameterState#; |
| 50 | stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &operatorcxx . . $ ROOT/Minuit2/`operator<<`(d95d34bee13781e6).<<(stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &, const MnUserParameterStatecxx . . $ ROOT/Minuit2/MnUserParameterState# &); |
| 51 | |
| 52 | class MnMachinePrecisioncxx . . $ ROOT/Minuit2/MnMachinePrecision#; |
| 53 | stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &operatorcxx . . $ ROOT/Minuit2/`operator<<`(35abc715b7f14038).<<(stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &, const MnMachinePrecisioncxx . . $ ROOT/Minuit2/MnMachinePrecision# &); |
| 54 | |
| 55 | class MinosErrorcxx . . $ ROOT/Minuit2/MinosError#; |
| 56 | stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &operatorcxx . . $ ROOT/Minuit2/`operator<<`(5bc519eb48156a67).<<(stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &, const MinosErrorcxx . . $ ROOT/Minuit2/MinosError# &); |
| 57 | |
| 58 | class ContoursErrorcxx . . $ ROOT/Minuit2/ContoursError#; |
| 59 | stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &operatorcxx . . $ ROOT/Minuit2/`operator<<`(67016d4dbbbc39e3).<<(stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &, const ContoursErrorcxx . . $ ROOT/Minuit2/ContoursError# &); |
| 60 | |
| 61 | // std::pair<double, double> is used by MnContour |
| 62 | stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &operatorcxx . . $ ROOT/Minuit2/`operator<<`(a2833a9ffc12866b).<<(stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &os, const stdcxx . . $ std/::paircxx . . $ std/pair#<double, double> &point); |
| 63 | |
| 64 | /* Design notes: 1) We want to delay the costly conversion from object references to |
| 65 | strings to a point after we have decided whether or not to |
| 66 | show that string to the user at all. 2) We want to offer a customization point for |
| 67 | external libraries that want to replace the MnPrint logging. The actual |
| 68 | implementation is in a separate file, MnPrintImpl.cxx file that external libraries |
| 69 | can replace with their own implementation. |
| 70 | */ |
| 71 | |
| 72 | // logging class for messages of varying severity |
| 73 | class MnPrintcxx . . $ ROOT/Minuit2/MnPrint# { |
| 74 | public: |
| 75 | // want this to be an enum class for strong typing... |
| 76 | enum class Verbositycxx . . $ ROOT/Minuit2/MnPrint#Verbosity# { Errorcxx . . $ ROOT/Minuit2/MnPrint#Verbosity#Error. = 0, Warncxx . . $ ROOT/Minuit2/MnPrint#Verbosity#Warn. = 1, Infocxx . . $ ROOT/Minuit2/MnPrint#Verbosity#Info. = 2, Debugcxx . . $ ROOT/Minuit2/MnPrint#Verbosity#Debug. = 3, Tracecxx . . $ ROOT/Minuit2/MnPrint#Verbosity#Trace. = 4 }; |
| 77 | |
| 78 | // ...but also want the values accessible from MnPrint scope for convenience |
| 79 | static constexpr auto eErrorcxx . . $ ROOT/Minuit2/MnPrint#eError. = Verbositycxx . . $ ROOT/Minuit2/MnPrint#Verbosity#::Errorcxx . . $ ROOT/Minuit2/MnPrint#Verbosity#Error.; |
| 80 | static constexpr auto eWarncxx . . $ ROOT/Minuit2/MnPrint#eWarn. = Verbositycxx . . $ ROOT/Minuit2/MnPrint#Verbosity#::Warncxx . . $ ROOT/Minuit2/MnPrint#Verbosity#Warn.; |
| 81 | static constexpr auto eInfocxx . . $ ROOT/Minuit2/MnPrint#eInfo. = Verbositycxx . . $ ROOT/Minuit2/MnPrint#Verbosity#::Infocxx . . $ ROOT/Minuit2/MnPrint#Verbosity#Info.; |
| 82 | static constexpr auto eDebugcxx . . $ ROOT/Minuit2/MnPrint#eDebug. = Verbositycxx . . $ ROOT/Minuit2/MnPrint#Verbosity#::Debugcxx . . $ ROOT/Minuit2/MnPrint#Verbosity#Debug.; |
| 83 | static constexpr auto eTracecxx . . $ ROOT/Minuit2/MnPrint#eTrace. = Verbositycxx . . $ ROOT/Minuit2/MnPrint#Verbosity#::Tracecxx . . $ ROOT/Minuit2/MnPrint#Verbosity#Trace.; |
| 84 | |
| 85 | // used for one-line printing of fcn minimum state |
| 86 | class Onelinecxx . . $ ROOT/Minuit2/MnPrint#Oneline# { |
| 87 | public: |
| 88 | Onelinecxx . . $ ROOT/Minuit2/MnPrint#Oneline#Oneline(93362482a90980bd).(double fcn, double edm, int ncalls, int iter = -1); |
| 89 | Onelinecxx . . $ ROOT/Minuit2/MnPrint#Oneline#Oneline(13fbde569fad7fa).(const MinimumStatecxx . . $ ROOT/Minuit2/MinimumState# &state, int iter = -1); |
| 90 | Onelinecxx . . $ ROOT/Minuit2/MnPrint#Oneline#Oneline(5134b5793e47ad1a).(const FunctionMinimumcxx . . $ ROOT/Minuit2/FunctionMinimum# &fmin, int iter = -1); |
| 91 | |
| 92 | private: |
| 93 | double fFcncxx . . $ ROOT/Minuit2/MnPrint#Oneline#fFcn., fEdmcxx . . $ ROOT/Minuit2/MnPrint#Oneline#fEdm.; |
| 94 | int fNcallscxx . . $ ROOT/Minuit2/MnPrint#Oneline#fNcalls., fItercxx . . $ ROOT/Minuit2/MnPrint#Oneline#fIter.; |
| 95 | |
| 96 | friend stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &operatorcxx . . $ ROOT/Minuit2/`operator<<`(b03a31b984b218ae).<<(stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &os, const Onelinecxx . . $ ROOT/Minuit2/MnPrint#Oneline# &x); |
| 97 | }; |
| 98 | |
| 99 | MnPrintcxx . . $ ROOT/Minuit2/MnPrint#MnPrint(34d26762b42c433a).(const char *prefix, int level = MnPrintcxx . . $ ROOT/Minuit2/MnPrint#::GlobalLevelcxx . . $ ROOT/Minuit2/MnPrint#GlobalLevel(b126dc7c1de90089).()); |
| 100 | ~cxx . . $ ROOT/Minuit2/MnPrint#`~MnPrint`(49f6e7a06ebc5aa8).MnPrintcxx . . $ ROOT/Minuit2/MnPrint#(); |
| 101 | |
| 102 | // set global print level and return the previous one |
| 103 | static int SetGlobalLevelcxx . . $ ROOT/Minuit2/MnPrint#SetGlobalLevel(7864480464b09eea).(int level); |
| 104 | |
| 105 | // return current global print level |
| 106 | static int GlobalLevelcxx . . $ ROOT/Minuit2/MnPrint#GlobalLevel(b126dc7c1de90089).(); |
| 107 | |
| 108 | // Whether to show the full prefix stack or only the end |
| 109 | static void ShowPrefixStackcxx . . $ ROOT/Minuit2/MnPrint#ShowPrefixStack(b45ddcbc8423892c).(bool yes); |
| 110 | |
| 111 | static void AddFiltercxx . . $ ROOT/Minuit2/MnPrint#AddFilter(85c52e162fed56f9).(const char *prefix); |
| 112 | static void ClearFiltercxx . . $ ROOT/Minuit2/MnPrint#ClearFilter(49f6e7a06ebc5aa8).(); |
| 113 | |
| 114 | // Whether to cut the maximum number of parameters shown for vector and matrices |
| 115 | // set maximum number of printed parameters and return previous value |
| 116 | // A negative value will mean all parameters are printed |
| 117 | static int SetMaxNPcxx . . $ ROOT/Minuit2/MnPrint#SetMaxNP(7864480464b09eea).(int value); |
| 118 | |
| 119 | // retrieve maximum number of printed parameters |
| 120 | static int MaxNPcxx . . $ ROOT/Minuit2/MnPrint#MaxNP(b126dc7c1de90089).(); |
| 121 | |
| 122 | // set print level and return the previous one |
| 123 | int SetLevelcxx . . $ ROOT/Minuit2/MnPrint#SetLevel(7864480464b09eea).(int level); |
| 124 | |
| 125 | // return current print level |
| 126 | int Levelcxx . . $ ROOT/Minuit2/MnPrint#Level(455f465bc33b4cdf).() const; |
| 127 | |
| 128 | template <class... Ts> |
| 129 | void Errorcxx . . $ ROOT/Minuit2/MnPrint#Error(3eb398314feba58b).(const Ts &... args) |
| 130 | { |
| 131 | Logcxx . . $ ROOT/Minuit2/MnPrint#Log(1a4eabb5837474df).(eErrorcxx . . $ ROOT/Minuit2/MnPrint#eError., args...); |
| 132 | } |
| 133 | |
| 134 | template <class... Ts> |
| 135 | void Warncxx . . $ ROOT/Minuit2/MnPrint#Warn(3eb398314feba58b).(const Ts &... args) |
| 136 | { |
| 137 | Logcxx . . $ ROOT/Minuit2/MnPrint#Log(1a4eabb5837474df).(eWarncxx . . $ ROOT/Minuit2/MnPrint#eWarn., args...); |
| 138 | } |
| 139 | |
| 140 | template <class... Ts> |
| 141 | void Infocxx . . $ ROOT/Minuit2/MnPrint#Info(3eb398314feba58b).(const Ts &... args) |
| 142 | { |
| 143 | Logcxx . . $ ROOT/Minuit2/MnPrint#Log(1a4eabb5837474df).(eInfocxx . . $ ROOT/Minuit2/MnPrint#eInfo., args...); |
| 144 | } |
| 145 | |
| 146 | template <class... Ts> |
| 147 | void Debugcxx . . $ ROOT/Minuit2/MnPrint#Debug(3eb398314feba58b).(const Ts &... args) |
| 148 | { |
| 149 | Logcxx . . $ ROOT/Minuit2/MnPrint#Log(1a4eabb5837474df).(eDebugcxx . . $ ROOT/Minuit2/MnPrint#eDebug., args...); |
| 150 | } |
| 151 | |
| 152 | template <class... Ts> |
| 153 | void Tracecxx . . $ ROOT/Minuit2/MnPrint#Trace(3eb398314feba58b).(const Ts &... args) |
| 154 | { |
| 155 | Logcxx . . $ ROOT/Minuit2/MnPrint#Log(1a4eabb5837474df).(eTracecxx . . $ ROOT/Minuit2/MnPrint#eTrace., args...); |
| 156 | } |
| 157 | |
| 158 | private: |
| 159 | // low level logging |
| 160 | template <class... Ts> |
| 161 | void Logcxx . . $ ROOT/Minuit2/MnPrint#Log(1a4eabb5837474df).(Verbositycxx . . $ ROOT/Minuit2/MnPrint#Verbosity# level, const Ts &... args) |
| 162 | { |
| 163 | if (Levelcxx . . $ ROOT/Minuit2/MnPrint#Level(455f465bc33b4cdf).() < static_cast<int>(level)) |
| 164 | return; |
| 165 | if (Hiddencxx . . $ ROOT/Minuit2/MnPrint#Hidden(c9857a73d68e59ba).()) |
| 166 | return; |
| 167 | |
| 168 | stdcxx . . $ std/::ostringstreamcxx . . $ std/ostringstream# oscxx . . $ std/__cxx11/basic_ostringstream#basic_ostringstream(49f6e7a06ebc5aa8).; |
| 169 | StreamPrefixcxx . . $ ROOT/Minuit2/MnPrint#StreamPrefix(ed89a3598fa22faa).(os); |
| 170 | StreamArgscxx . . $ ROOT/Minuit2/MnPrint#StreamArgs(4b47c8c44220ce22).(os, args...); |
| 171 | Implcxx . . $ ROOT/Minuit2/MnPrint#Impl(bd6013e3bd016fe9).(level, os.strcxx . . $ std/__cxx11/basic_ostringstream#str(d33e1a6fd36255f7).()); |
| 172 | } |
| 173 | |
| 174 | static void StreamPrefixcxx . . $ ROOT/Minuit2/MnPrint#StreamPrefix(ed89a3598fa22faa).(stdcxx . . $ std/::ostringstreamcxx . . $ std/ostringstream# &os); |
| 175 | |
| 176 | // returns true if filters are installed and message is not selected by any filter |
| 177 | static bool Hiddencxx . . $ ROOT/Minuit2/MnPrint#Hidden(c9857a73d68e59ba).(); |
| 178 | |
| 179 | // see MnPrintImpl.cxx |
| 180 | static void Implcxx . . $ ROOT/Minuit2/MnPrint#Impl(bd6013e3bd016fe9).(Verbositycxx . . $ ROOT/Minuit2/MnPrint#Verbosity# level, const stdcxx . . $ std/::stringcxx . . $ std/string# &s); |
| 181 | |
| 182 | // TMP to handle lambda argument correctly, exploiting overload resolution rules |
| 183 | template <class T> |
| 184 | static auto HandleLambdacxx . . $ ROOT/Minuit2/MnPrint#HandleLambda(aff9548426556cba).(stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &os, const T &t, int) -> decltype(t(os), void()) |
| 185 | { |
| 186 | t(os); |
| 187 | } |
| 188 | |
| 189 | template <class T> |
| 190 | static void HandleLambdacxx . . $ ROOT/Minuit2/MnPrint#HandleLambda(22c9de7acf09e2a).(stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &os, const T &t, float) |
| 191 | { |
| 192 | os <<cxx . . $ ROOT/Minuit2/`operator<<`(6bbd8ab2d2012a0a). t; |
| 193 | } |
| 194 | |
| 195 | static void StreamArgscxx . . $ ROOT/Minuit2/MnPrint#StreamArgs(ed89a3598fa22faa).(stdcxx . . $ std/::ostringstreamcxx . . $ std/ostringstream# &) {} |
| 196 | |
| 197 | // end of recursion |
| 198 | template <class T> |
| 199 | static void StreamArgscxx . . $ ROOT/Minuit2/MnPrint#StreamArgs(9dd55aa138aed310).(stdcxx . . $ std/::ostringstreamcxx . . $ std/ostringstream# &os, const T &t) |
| 200 | { |
| 201 | os <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " "; |
| 202 | HandleLambdacxx . . $ ROOT/Minuit2/MnPrint#HandleLambda(22c9de7acf09e2a).(os, t, 0); |
| 203 | } |
| 204 | |
| 205 | template <class T, class... Ts> |
| 206 | static void StreamArgscxx . . $ ROOT/Minuit2/MnPrint#StreamArgs(4b47c8c44220ce22).(stdcxx . . $ std/::ostringstreamcxx . . $ std/ostringstream# &os, const T &t, const Ts &... ts) |
| 207 | { |
| 208 | os <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " " <<cxx . . $ ROOT/Minuit2/`operator<<`(26498392745fb61a). t; |
| 209 | StreamArgscxx . . $ ROOT/Minuit2/MnPrint#StreamArgs(4b47c8c44220ce22).(os, ts...); |
| 210 | } |
| 211 | |
| 212 | int fLevelcxx . . $ ROOT/Minuit2/MnPrint#fLevel.; |
| 213 | }; |
| 214 | |
| 215 | } // namespace Minuit2 |
| 216 | } // namespace ROOT |
| 217 | |
| 218 | #endif // ROOT_Minuit2_MnPrint |