41 int MnPrint::SetLevel(
int level) {
42 int prevLevel = gPrintLevel;
47 int MnPrint::Level( ) {
51 void MnPrint::PrintFcn(std::ostream & os,
double value,
bool endline) {
52 int pr = os.precision(PRECISION);
54 if (endline) os << std::endl;
58 void MnPrint::PrintState(std::ostream & os,
const MinimumState & state,
const char * msg,
int iter) {
60 MnPrint::PrintState(os, state.Fval(), state.Edm(), state.NFcn(), msg, iter);
63 void MnPrint::PrintState(std::ostream & os,
double fval,
double edm,
int ncalls,
const char * msg,
int iter) {
66 if (iter>=0) os << std::setw(3) << iter;
67 int pr = os.precision(PRECISION);
68 const int width = PRECISION+3;
69 os <<
" - FCN = " << std::setw(width) << fval;
71 os <<
" Edm = " << std::setw(12) << edm <<
" NCalls = " << std::setw(6) << ncalls;
76 std::ostream& operator<<(std::ostream& os,
const LAVector& vec) {
78 os <<
"LAVector parameters:" << std::endl;
79 int pr = os.precision(PRECISION);
81 int nrow = vec.size();
82 for (
int i = 0; i < nrow; i++) {
84 os << vec(i) << std::endl;
91 std::ostream& operator<<(std::ostream& os,
const LASymMatrix& matrix) {
93 os <<
"LASymMatrix parameters:" << std::endl;
94 int pr = os.precision(8);
97 int n = matrix.Nrow();
98 for (
int i = 0; i < n; i++) {
99 for (
int j = 0; j < n; j++) {
100 os.width(15); os << matrix(i,j);
109 std::ostream& operator<<(std::ostream& os,
const MnUserParameters& par) {
113 os <<
"# ext. |" <<
"| Name |" <<
"| type |" <<
"| Value |" <<
"| Error +/- " << std::endl;
116 int pr = os.precision();
118 bool atLoLim =
false;
119 bool atHiLim =
false;
120 for(std::vector<MinuitParameter>::const_iterator ipar = par.Parameters().begin(); ipar != par.Parameters().end(); ++ipar) {
121 os << std::setw(4) << (*ipar).Number() << std::setw(5) <<
"||";
122 os << std::setw(10) << (*ipar).Name() << std::setw(3) <<
"||";
123 if((*ipar).IsConst()) {
124 os <<
" const ||" << std::setprecision(PRECISION) << std::setw(WIDTH) << (*ipar).Value() <<
" ||" << std::endl;
125 }
else if((*ipar).IsFixed()) {
126 os <<
" fixed ||" << std::setprecision(PRECISION) << std::setw(WIDTH) << (*ipar).Value() <<
" ||" << std::endl;
127 }
else if((*ipar).HasLimits()) {
128 if((*ipar).Error() > 0.) {
129 os <<
" limited ||" << std::setprecision(PRECISION) << std::setw(WIDTH) << (*ipar).Value();
130 if(fabs((*ipar).Value() - (*ipar).LowerLimit()) < par.Precision().Eps2()) {
134 if(fabs((*ipar).Value() - (*ipar).UpperLimit()) < par.Precision().Eps2()) {
138 os <<
" ||" << std::setw(12) << (*ipar).Error() << std::endl;
140 os <<
" free ||" << std::setprecision(PRECISION) << std::setw(WIDTH) << (*ipar).Value() <<
" ||" << std::setw(12) <<
"no" << std::endl;
142 if((*ipar).Error() > 0.)
143 os <<
" free ||" << std::setprecision(PRECISION) << std::setw(WIDTH) << (*ipar).Value() <<
" ||" << std::setw(12) << (*ipar).Error() << std::endl;
145 os <<
" free ||" << std::setprecision(PRECISION) << std::setw(WIDTH) << (*ipar).Value() <<
" ||" << std::setw(12) <<
"no" << std::endl;
150 if(atLoLim) os <<
"* Parameter is at Lower limit" << std::endl;
151 if(atHiLim) os <<
"** Parameter is at Upper limit" << std::endl;
158 std::ostream& operator<<(std::ostream& os,
const MnUserCovariance& matrix) {
162 os <<
"MnUserCovariance: " << std::endl;
163 int pr = os.precision(6);
166 unsigned int n = matrix.Nrow();
167 for (
unsigned int i = 0; i < n; i++) {
168 for (
unsigned int j = 0; j < n; j++) {
169 os.width(13); os << matrix(i,j);
176 os <<
"MnUserCovariance Parameter correlations: " << std::endl;
180 unsigned int n = matrix.Nrow();
181 for (
unsigned int i = 0; i < n; i++) {
182 double di = matrix(i,i);
183 for (
unsigned int j = 0; j < n; j++) {
184 double dj = matrix(j,j);
185 os.width(13); os << matrix(i,j)/sqrt(fabs(di*dj));
195 std::ostream& operator<<(std::ostream& os,
const MnGlobalCorrelationCoeff& coeff) {
199 os <<
"MnGlobalCorrelationCoeff: " << std::endl;
200 int pr = os.precision(6);
203 for (
unsigned int i = 0; i < coeff.GlobalCC().size(); i++) {
204 os.width(13); os << coeff.GlobalCC()[i];
213 std::ostream& operator<<(std::ostream& os,
const MnUserParameterState& state) {
217 if(!state.IsValid()) {
219 os <<
"WARNING: MnUserParameterState is not valid."<<std::endl;
222 int pr = os.precision(PRECISION);
224 os <<
"# of function calls: "<<state.NFcn()<<std::endl;
225 os <<
"function Value: " << state.Fval()<<std::endl;
226 os <<
"expected distance to the Minimum (edm): " << state.Edm()<<std::endl;
227 os <<
"external parameters: "<<state.Parameters()<<std::endl;
228 os <<
"covariance matrix status: " << state.CovarianceStatus() << std::endl;
229 if(state.HasCovariance())
230 os <<
"covariance matrix: "<<state.Covariance()<<std::endl;
232 os <<
"covariance matrix is not present or not valid "<<std::endl;
233 if(state.HasGlobalCC())
234 os <<
"global correlation coefficients : "<<state.GlobalCC()<<std::endl;
237 os <<
"WARNING: MnUserParameterState is not valid."<<std::endl;
245 std::ostream& operator<<(std::ostream& os,
const FunctionMinimum& min) {
249 os <<
"WARNING: Minuit did not converge."<<std::endl;
252 os <<
"Minuit did successfully converge."<<std::endl;
254 int pr = os.precision(PRECISION);
256 os <<
"# of function calls: "<<min.NFcn()<<std::endl;
257 os <<
"minimum function Value: " << min.Fval()<<std::endl;
258 os <<
"minimum edm: " << min.Edm()<<std::endl;
259 os <<
"minimum internal state vector: "<<min.Parameters().Vec()<<std::endl;
260 if(min.HasValidCovariance())
261 os <<
"minimum internal covariance matrix: "<<min.Error().Matrix()<<std::endl;
263 os << min.UserParameters() << std::endl;
268 os <<
"WARNING: FunctionMinimum is invalid: " << std::endl;
269 if ( !min.State().IsValid() )
270 os <<
"\t State is invalid" << std::endl;
271 if ( min.IsAboveMaxEdm() )
272 os <<
"\t Edm is above max" << std::endl;
273 if ( min.HasReachedCallLimit() )
274 os <<
"\t Reached call limit" << std::endl;
284 std::ostream& operator<<(std::ostream& os,
const MinimumState& min) {
287 int pr = os.precision(PRECISION);
289 os <<
"minimum function Value: " << min.Fval()<<std::endl;
290 os <<
"minimum edm: " << min.Edm()<<std::endl;
291 os <<
"minimum internal state vector: "<<min.Vec()<<std::endl;
292 os <<
"minimum internal Gradient vector: "<<min.Gradient().Vec()<<std::endl;
293 if(min.HasCovariance())
294 os <<
"minimum internal covariance matrix: "<<min.Error().Matrix()<<std::endl;
302 std::ostream& operator<<(std::ostream& os,
const MnMachinePrecision& prec) {
306 int pr = os.precision(PRECISION);
307 os <<
"current machine precision is set to "<<prec.Eps()<<std::endl;
315 std::ostream& operator<<(std::ostream& os,
const MinosError& me) {
319 os <<
"Minos # of function calls: "<<me.NFcn()<<std::endl;
322 os <<
"Minos Error is not valid." <<std::endl;
324 os <<
"lower Minos Error is not valid." <<std::endl;
326 os <<
"upper Minos Error is not valid." <<std::endl;
327 if(me.AtLowerLimit())
328 os <<
"Minos Error is Lower limit of Parameter "<<me.Parameter()<<
"." <<std::endl;
329 if(me.AtUpperLimit())
330 os <<
"Minos Error is Upper limit of Parameter "<<me.Parameter()<<
"." <<std::endl;
331 if(me.AtLowerMaxFcn())
332 os <<
"Minos number of function calls for Lower Error exhausted."<<std::endl;
333 if(me.AtUpperMaxFcn())
334 os <<
"Minos number of function calls for Upper Error exhausted."<<std::endl;
335 if(me.LowerNewMin()) {
336 os <<
"Minos found a new Minimum in negative direction."<<std::endl;
337 os << me.LowerState() <<std::endl;
339 if(me.UpperNewMin()) {
340 os <<
"Minos found a new Minimum in positive direction."<<std::endl;
341 os << me.UpperState() <<std::endl;
344 int pr = os.precision();
346 os <<
"# ext. |" <<
"| Name |" <<
"| Value@min |" <<
"| negative |" <<
"| positive " << std::endl;
347 os << std::setw(4) << me.Parameter() << std::setw(5) <<
"||";
348 os << std::setw(10) << me.LowerState().Name(me.Parameter()) << std::setw(3) <<
"||";
349 os << std::setprecision(PRECISION) << std::setw(WIDTH) << me.Min() <<
" ||" << std::setprecision(PRECISION) << std::setw(WIDTH) << me.Lower() <<
" ||" << std::setw(WIDTH) << me.Upper() << std::endl;
357 std::ostream& operator<<(std::ostream& os,
const ContoursError& ce) {
360 os <<
"Contours # of function calls: "<<ce.NFcn()<<std::endl;
361 os <<
"MinosError in x: "<<std::endl;
362 os << ce.XMinosError() << std::endl;
363 os <<
"MinosError in y: "<<std::endl;
364 os << ce.YMinosError() << std::endl;
366 plot(ce.XMin(), ce.YMin(), ce());
367 for(std::vector<std::pair<double,double> >::const_iterator ipar = ce().begin(); ipar != ce().end(); ++ipar) {
368 os << ipar - ce().begin() <<
" "<< (*ipar).first <<
" "<< (*ipar).second <<std::endl;