Logo ROOT   6.08/07
Reference Guide
MnPrint.h
Go to the documentation of this file.
1 // @(#)root/minuit2:$Id$
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_MnPrint
12 
13 #include "Minuit2/MnConfig.h"
14 
15 //#define DEBUG
16 //#define WARNINGMSG
17 
18 #include <iostream>
19 
20 #ifdef DEBUG
21 #ifndef WARNINGMSG
22 #define WARNINGMSG
23 #endif
24 #endif
25 
26 
27 
28 
29 namespace ROOT {
30 
31  namespace Minuit2 {
32 
33 
34 /**
35  define std::ostream operators for output
36 */
37 
38 class FunctionMinimum;
39 std::ostream& operator<<(std::ostream&, const FunctionMinimum&);
40 
41 class MinimumState;
42 std::ostream& operator<<(std::ostream&, const MinimumState&);
43 
44 class LAVector;
45 std::ostream& operator<<(std::ostream&, const LAVector&);
46 
47 class LASymMatrix;
48 std::ostream& operator<<(std::ostream&, const LASymMatrix&);
49 
50 class MnUserParameters;
51 std::ostream& operator<<(std::ostream&, const MnUserParameters&);
52 
53 class MnUserCovariance;
54 std::ostream& operator<<(std::ostream&, const MnUserCovariance&);
55 
56 class MnGlobalCorrelationCoeff;
57 std::ostream& operator<<(std::ostream&, const MnGlobalCorrelationCoeff&);
58 
59 class MnUserParameterState;
60 std::ostream& operator<<(std::ostream&, const MnUserParameterState&);
61 
62 class MnMachinePrecision;
63 std::ostream& operator<<(std::ostream&, const MnMachinePrecision&);
64 
65 class MinosError;
66 std::ostream& operator<<(std::ostream&, const MinosError&);
67 
68 class ContoursError;
69 std::ostream& operator<<(std::ostream&, const ContoursError&);
70 
71 
72 // class define static print level values
73 
74 class MnPrint {
75 
76 public:
77  // set print level and return the previous one
78  static int SetLevel(int level);
79 
80  // return current level
81  static int Level();
82 
83  // print current minimization state
84  static void PrintState(std::ostream & os, const MinimumState & state, const char * msg, int iter = -1);
85 
86  // print current minimization state
87  static void PrintState(std::ostream & os, double fcn, double edm, int ncalls, const char * msg, int iter = -1);
88 
89  // print FCN value with right precision adding optionally end line
90  static void PrintFcn(std::ostream & os, double value, bool endline = true);
91 };
92 
93 
94 
95  } // namespace Minuit2
96 
97 } // namespace ROOT
98 
99 
100 // macro to report messages
101 
102 #ifndef USE_ROOT_ERROR
103 
104 #ifndef MNLOG
105 #define MN_OS std::cerr
106 #else
107 #define MN_OS MNLOG
108 #endif
109 
110 #define MN_INFO_MSG(str) \
111  if (MnPrint::Level() > 0) MN_OS << "Info: " << str \
112  << std::endl;
113 #define MN_ERROR_MSG(str) \
114  if (MnPrint::Level() >= 0) MN_OS << "Error: " << str \
115  << std::endl;
116 # define MN_INFO_VAL(x) \
117  if (MnPrint::Level() > 0) MN_OS << "Info: " << #x << " = " << (x) << std::endl;
118 # define MN_ERROR_VAL(x) \
119  if (MnPrint::Level() >= 0) MN_OS << "Error: " << #x << " = " << (x) << std::endl;
120 
121 
122 // same giving a location
123 
124 #define MN_INFO_MSG2(loc,str) \
125  if (MnPrint::Level() > 0) MN_OS << "Info in " << loc << " : " << str \
126  << std::endl;
127 #define MN_ERROR_MSG2(loc,str) \
128  if (MnPrint::Level() >= 0) MN_OS << "Error in " << loc << " : " << str \
129  << std::endl;
130 # define MN_INFO_VAL2(loc,x) \
131  if (MnPrint::Level() > 0) MN_OS << "Info in " << loc << " : " << #x << " = " << (x) << std::endl;
132 # define MN_ERROR_VAL2(loc,x) \
133  if (MnPrint::Level() >= 0) MN_OS << "Error in " << loc << " : " << #x << " = " << (x) << std::endl;
134 
135 
136 
137 #else
138 // use ROOT error reporting system
139 #include "TError.h"
140 #include "Math/Util.h"
141 
142 // this first two should be used only with string literals to
143 // avoid warning produced by the format in TError
144 #define MN_INFO_MSG(str) \
145  ::Info("Minuit2",str);
146 #define MN_ERROR_MSG(str) \
147  ::Error("Minuit2",str);
148 # define MN_INFO_VAL(x) \
149  {std::string str = std::string(#x) + std::string(" = ") + ROOT::Math::Util::ToString(x); \
150  ::Info("Minuit2","%s",str.c_str() );}
151 # define MN_ERROR_VAL(x) \
152  {std::string str = std::string(#x) + std::string(" = ") + ROOT::Math::Util::ToString(x); \
153  ::Error("Minuit2","%s",str.c_str() );}
154 
155 # define MN_INFO_MSG2(loc,txt) \
156  {std::string str = std::string(loc) + std::string(" : ") + std::string(txt); \
157  ::Info("Minuit2","%s",str.c_str() );}
158 # define MN_ERROR_MSG2(loc,txt) \
159  {std::string str = std::string(loc) + std::string(" : ") + std::string(txt); \
160  ::Error("Minuit2","%s",str.c_str() );}
161 
162 # define MN_INFO_VAL2(loc,x) \
163  {std::string str = std::string(loc) + std::string(" : ") + std::string(#x) + std::string(" = ") + ROOT::Math::Util::ToString(x); \
164  ::Info("Minuit2","%s",str.c_str() );}
165 # define MN_ERROR_VAL2(loc,x) \
166  {std::string str = std::string(loc) + std::string(" : ") + std::string(#x) + std::string(" = ") + ROOT::Math::Util::ToString(x); \
167  ::Error("Minuit2","%s",str.c_str() );}
168 
169 
170 
171 #endif
172 
173 
174 #endif // ROOT_Minuit2_MnPrint
This namespace contains pre-defined functions to be used in conjuction with TExecutor::Map and TExecu...
Definition: StringConv.hxx:21
static void PrintFcn(std::ostream &os, double value, bool endline=true)
Definition: MnPrint.cxx:51
static int Level()
Definition: MnPrint.cxx:47
static void PrintState(std::ostream &os, const MinimumState &state, const char *msg, int iter=-1)
Definition: MnPrint.cxx:58
static int SetLevel(int level)
Definition: MnPrint.cxx:41
std::ostream & operator<<(std::ostream &, const FunctionMinimum &)
Definition: MnPrint.cxx:245
MinimumState keeps the information (position, Gradient, 2nd deriv, etc) after one minimization step (...
Definition: MinimumState.h:29