18
18
#include " Minuit2/FunctionMinimum.h"
19
19
#include " Minuit2/MnHesse.h"
20
20
#include " Minuit2/MnPrint.h"
21
+ #include " Minuit2/MnMatrix.h"
21
22
#include " optimizers/Exception.h"
22
23
#include " optimizers/OutOfBounds.h"
23
24
#include " StMnMinos.h"
@@ -300,6 +301,18 @@ namespace optimizers {
300
301
return grad;
301
302
}
302
303
304
+ const ROOT::Minuit2::MnUserParameterState& NewMinuit::userState () const {
305
+ static const ROOT::Minuit2::MnUserParameterState null_state;
306
+ return m_min == 0 ? null_state : m_min->UserState ();
307
+ }
308
+
309
+
310
+ const ROOT::Minuit2::MinimumError& NewMinuit::minuitError () const {
311
+ static const ROOT::Minuit2::MinimumError null_error (1 );
312
+ return m_min == 0 ? null_error : m_min->Error ();
313
+ }
314
+
315
+
303
316
// Get the uncertainty values from covariance matrix
304
317
const std::vector<double > & NewMinuit::getUncertainty (bool useBase) {
305
318
std::vector<double > parValues;
@@ -324,6 +337,58 @@ namespace optimizers {
324
337
return s;
325
338
}
326
339
340
+ std::vector<std::vector<double > > NewMinuit::userCovariance () const {
341
+ std::vector<std::vector<double > > cov;
342
+ if ( m_min == 0 ) return cov;
343
+ const ROOT::Minuit2::MnUserCovariance& userCov = m_min->UserState ().Covariance ();
344
+
345
+ for (unsigned int x = 0 ; x < userCov.Nrow (); ++x) {
346
+ std::vector<double > vec;
347
+ for (unsigned int y = 0 ; y < userCov.Nrow (); ++y) {
348
+ vec.push_back (userCov (x,y));
349
+ }
350
+ cov.push_back (vec);
351
+ }
352
+ return cov;
353
+ }
354
+
355
+ const std::vector<double >& NewMinuit::userGlobalCC () const {
356
+ static const std::vector<double > null_globalcc;
357
+ return m_min == 0 ? null_globalcc : m_min->UserState ().GlobalCC ().GlobalCC ();
358
+ }
359
+
360
+
361
+ std::vector<std::vector<double > > NewMinuit::userHessian () const {
362
+ std::vector<std::vector<double > > hesse;
363
+ if ( m_min == 0 ) return hesse;
364
+ ROOT::Minuit2::MnUserCovariance mn_hesse (m_min->UserState ().Hessian ());
365
+
366
+ for (unsigned int x = 0 ; x < mn_hesse.Nrow (); ++x) {
367
+ std::vector<double > vec;
368
+ for (unsigned int y = 0 ; y < mn_hesse.Nrow (); ++y) {
369
+ vec.push_back (mn_hesse (x,y));
370
+ }
371
+ hesse.push_back (vec);
372
+ }
373
+ return hesse;
374
+ }
375
+
376
+
377
+ std::vector<std::vector<double > > NewMinuit::minuitInvHessian () const {
378
+ std::vector<std::vector<double > > inv_hesse;
379
+ if ( m_min == 0 ) return inv_hesse;
380
+ const ROOT::Minuit2::MnAlgebraicSymMatrix& inv_mat = m_min->Error ().InvHessian ();
381
+
382
+ for (unsigned int x = 0 ; x < inv_mat.Nrow (); ++x) {
383
+ std::vector<double > vec;
384
+ for (unsigned int y = 0 ; y < inv_mat.Nrow (); ++y) {
385
+ vec.push_back (inv_mat (x,y));
386
+ }
387
+ inv_hesse.push_back (vec);
388
+ }
389
+ return inv_hesse;
390
+ }
391
+
327
392
std::vector<std::vector<double > > NewMinuit::covarianceMatrix () const {
328
393
std::vector<double > parValues;
329
394
m_stat->getFreeParamValues (parValues);
0 commit comments