Trouble running minuit2 and fumili2

Hi everyone,

I am trying to use Minuit2 within ROOT (5.18), using the attached script. I create the minimizer as follows:

TVirtualFitter::SetDefaultFitter(“Minuit2”);
TObject * fitter;
TVirtualFitter * minimizer = TVirtualFitter::Fitter(fitter, num_params);

It works on my windows XP based desktop, but not on my Unix machine (running Ubuntu). The error messages are that Minuit2 is not found, etc. When I check the status of plugins, (using the command gPluginMgr->Print();), it tells me the plugins for Minuit2 and Fumili2 are not available.

Any advice would be greatly appreciated.
Thanks,
Warren

#include “TSystem.h”
#include “TVirtualFitter.h”
#include “TMath.h”
#include “TH2D.h”
#include “TFile.h”
#include “TTree.h”
#include “likelihood_fcn.c”
#include “FC_toy_mc.c”

void FC_analyzer()
{
TFile nugen = new TFile(“nugen_std.root”);
TTree
nugen_tree = (TTree*)nugen->Get(“tree”);

int theta_c_steps=5;
int delta_c_steps=5;
const int fc_steps = 10; // change to 100 or 1000

int num_values = theta_c_steps*delta_c_steps;
const int num_params = 6;
int params_ = 6;

double x_crit;
double y_crit;
double R_crit_90;
double R_crit_95;
double R_crit_99;
double R_[fc_steps];
double quantiles[3];
double prob[3] = {.90, .95, .99};

TFile *fc_file = new TFile(“FC_crit_values.root”, “RECREATE”);
TTree *fc_tree = new TTree(“fc_tree”,“fc critical values tree”);
fc_tree->Branch(“R_crit_90”,&R_crit_90,“R_crit_90/D”);
fc_tree->Branch(“R_crit_95”,&R_crit_95,“R_crit_95/D”);
fc_tree->Branch(“R_crit_99”,&R_crit_99,“R_crit_99/D”);
fc_tree->Branch(“x_crit”,&x_crit,“x_crit/D”);
fc_tree->Branch(“y_crit”,&y_crit,“y_crit/D”);

double tolerance_ = 0.1;
double minuitStrategy_ = 1.;
double maxIterations_ = 1000.;
double arglist[10];
int ierflg;
const Double_t pii = TMath::Pi();

TVirtualFitter::SetDefaultFitter(“Minuit2”);
// TVirtualFitter::SetDefaultFitter(“Fumili2”);
TObject * fitter;
TVirtualFitter * minimizer = TVirtualFitter::Fitter(fitter, num_params);
minimizer->ExecuteCommand(“SET NOW”,arglist,1);
arglist[0]=minuitStrategy_;
minimizer->ExecuteCommand(“SET STR”,arglist,1);
arglist[0]=0; //maxIterations_;
arglist[1]=0; //tolerance_;
minimizer->SetFCN(likelihood_fcn);
minimizer->SetMaxIterations();
minimizer->SetPrecision();
minimizer->SetErrorDef();

minimizer->SetParameter(0,“deltac_c”,2.,0.2,0.,4.);
minimizer->SetParameter(1,“sin_2theta”,0.5,0.1,0.,1.);
minimizer->SetParameter(2,“d_gammac”,0.,0.1,-0.5,0.5);
minimizer->SetParameter(3,“d_gammap”,0.,0.1,-0.5,0.5);
minimizer->SetParameter(4,“A_c”,1.,.1,0.5,2.);
minimizer->SetParameter(5,“A_p”,1.,.1,0.5,2.);

double x,y;
double fval;
double *grad;
double par_values_hat[num_params];
double par_errors_hat[num_params];
double par_values_zero[num_params];
double par_errors_zero[num_params];
int flag = 3;
double neg_log_lhat, neg_log_lzero;

double d_gammac_def = 0.;
double d_gammap_def = 0.;
double Ac_def = 1.;
double Ap_def = 1.;
double alpha_cdef = 0.;
double alpha_pdef = 0.;
int k;

for (int i=0; i<theta_c_steps; i++)
{
x = 1.*i/(theta_c_steps-1.);
for (int j=0; j<delta_c_steps; j++)
{
y = 4.j/(delta_c_steps-1.);
TH2D
mu_ij = make_mu_ij(nugen_tree, pow(10.,-24-y), x, d_gammac_def, d_gammap_def, Ac_def, Ap_def, alpha_cdef, alpha_pdef);

  for (int m=0; m<fc_steps; m++)
    {
          FC_toy_mc(mu_ij);

          minimizer->ExecuteCommand("MIGRAD",arglist,2);
          par_values_hat[0] = minimizer->GetParameter(0);
          par_values_hat[1] = minimizer->GetParameter(1);
          par_values_hat[2] = minimizer->GetParameter(2);
          par_values_hat[3] = minimizer->GetParameter(3);
          par_values_hat[4] = minimizer->GetParameter(4);
          par_values_hat[5] = minimizer->GetParameter(5);
          likelihood_fcn(num_params, grad, fval, par_values_hat, flag);
          neg_log_lhat = fval;

          minimizer->SetParameter(0,"deltac_c",y,.2,0.,4.);
          minimizer->SetParameter(1,"sin_2theta",x,0.1,0.,1.);
          minimizer->FixParameter(0);
          minimizer->FixParameter(1);

          minimizer->ExecuteCommand("MIGRAD",arglist,2);
          par_values_zero[0] = minimizer->GetParameter(0);
          par_values_zero[1] = minimizer->GetParameter(1);
          par_values_zero[2] = minimizer->GetParameter(2);
          par_values_zero[3] = minimizer->GetParameter(3);
          par_values_zero[4] = minimizer->GetParameter(4);
          par_values_zero[5] = minimizer->GetParameter(5);
          likelihood_fcn(num_params, grad, fval, par_values_zero, flag);
          neg_log_lzero = fval;

          minimizer->ReleaseParameter(0);
          minimizer->ReleaseParameter(1);

          R_[m] = 2*(neg_log_lzero-neg_log_lhat);
   }
  delete mu_ij;

  TMath::Quantiles(fc_steps,3,R_,quantiles,prob,kFALSE);
      R_crit_90 = quantiles[0];
      R_crit_95 = quantiles[1];
      R_crit_99 = quantiles[2];
      x_crit = x;
      y_crit = -24-y;
      fc_tree->Fill();
  }

}

fc_file->cd();
fc_tree->Write();
fc_file->Close();
}

Hello,

you should configure ROOT on Linux with the option :

–enable-minuit2

Best Regards

Lorenzo

I’m up and running. Thanks for the fix!

Warren