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