Roofit under root6.32

Dear root experts,

I recently migrated from ROOT5 to ROOT6 (v6.32). The same fit macro that worked perfectly under ROOT5 now has issues under ROOT6. I cannot identify the problem. It seems the fit is just not working, as the parameters remain at their initial values. I as showing my code below (I am a new user can not upload files), and I hope someone can assist me with this.
There are three signal pdfs plus a 3rd order Chebychev background. The ‘bwd_c0’ and ‘Res’ are the Breit-Wigner and resolution (three Gaussians) defined by my self.

Additionally, the output from RooFit under ROOT6 seems different. Under ROOT5, I could see the status from MIGRAD and HESSE, but under ROOT6, the output from MIGRAD is missing. Is there a way to revert to the previous output format?

Thank you!

+++below is my fit macro+++

R__LOAD_LIBRARY(MyBW_cxx.so)
R__LOAD_LIBRARY(MyGGG_cxx.so)

#include "math.h"
#include "RooRealVar.h"
#include "RooDataSet.h"
#include "RooGaussian.h"
#include "TCanvas.h"
#include "TAxis.h"
#include "RooPlot.h"
#include "RooClassFactory.h"
#include "TROOT.h"
#include "MyBW.h"
#include "MyGGG.h"

void fit09data_709(){
using namespace RooFit;
//

double xl=3.32;
double xh=3.60;
auto nbin = 100.;

//*************** import data *********************

TChain *td1 = new TChain("wjpsi");
td1->Add("./ee_09-1.root");

TH1F *hdata=new TH1F("hdata","hdata",nbin,xl,xh);
td1->Draw("RM_ee>>hdata");


RooRealVar RM_ee("RM_ee","RM_ee",xl,xh);

RooDataHist *data1=new RooDataHist("data1","data1",RM_ee, hdata);

//*************** build pdf ***********************
// MC file

TChain *tkkc1 = new TChain("wjpsi");
tkkc1->Add("./sig09-c1-cut.root");

TChain *tkkc2 = new TChain("wjpsi");
tkkc2->Add("./sig09-c2-cut.root");


auto nbin1=80.;

// hist pdf kkc2
TH1F *hmc2=new TH1F("hmc2","hmc2",nbin1,xl,xh);
//tkkc2->Draw("mat_rm_ee>>hmc2");
tkkc2->Draw("RM_ee>>hmc2");
RooDataHist mc_kkc2("mc_kkc2","mc_kkc2",RM_ee,hmc2);
RooHistPdf mcpdf_kkc2("mcpdf_kkc2","mcpdf_kkc2",RM_ee,mc_kkc2,2);

// hist pdf kkc1
TH1F *hmc1=new TH1F("hmc1","hmc1",nbin1,xl,xh);
//tkkc1->Draw("mat_rm_ee>>hmc1");
tkkc1->Draw("RM_ee>>hmc1");
RooDataHist mc_kkc1("mc_kkc1","mc_kkc1",RM_ee,hmc1);
RooHistPdf mcpdf_kkc1("mcpdf_kkc1","mcpdf_kkc1",RM_ee,mc_kkc1,3);

RooRealVar mean1("mean1","mean1",-0.00061);
RooRealVar mean2("mean2","mean2",-0.00013);
RooRealVar mean3("mean3","mean3",0.00095);
RooRealVar mean4("mean4","mean4",-2.6e-04);
RooRealVar mean5("mean5","mean5",0.);
RooRealVar mean6("mean6","mean6",0.);

RooRealVar sigma1("sigma1","sigma1",8.01e-04);
RooRealVar sigma2("sigma2","sigma2",1.83e-03);
RooRealVar sigma3("sigma3","sigma3",5.93e-03);
RooRealVar sigma4("sigma4","sigma4",0.0026);
RooRealVar sigma5("sigma5","sigma5",0.0015);
RooRealVar sigma6("sigma6","sigma6",0.0018);

RooGaussian gauss1("gauss1","gauss1",RM_ee,mean1,sigma1);
RooGaussian gauss2("gauss2","gauss2",RM_ee,mean2,sigma2);
RooGaussian gauss3("gauss3","gauss3",RM_ee,mean3,sigma3);
RooGaussian gauss4("gauss4","gauss4",RM_ee,mean4,sigma4);
RooGaussian gauss5("gauss5","gauss5",RM_ee,mean5,sigma5);
RooGaussian gauss6("gauss6","gauss6",RM_ee,mean6,sigma6);

RooFormulaVar mean11("mean11","mean1+mean4",RooArgList(mean1,mean4));
RooFormulaVar sigma11("sigma11","sqrt(sigma1*sigma1+sigma4*sigma4)",RooArgList(sigma1,sigma4));

RooFormulaVar mean22("mean22","mean2+mean4",RooArgList(mean2,mean4));
RooFormulaVar sigma22("sigma22","sqrt(sigma2*sigma2+sigma4*sigma4)",RooArgList(sigma2,sigma4));

RooFormulaVar mean33("mean33","mean3+mean4",RooArgList(mean3,mean4));
RooFormulaVar sigma33("sigma33","sqrt(sigma3*sigma3+sigma4*sigma4)",RooArgList(sigma3,sigma4));

//  gROOT->ProcessLineSync(".x MyBW.cxx+") ;
//  gROOT->ProcessLineSync(".x MyGGG.cxx+") ;

  RooRealVar frac1("frac1","frac1",0.308493);
  RooRealVar frac2("frac2","frac2",0.332063);

  RooRealVar mc0("mc0","mc0",3.41573);
  RooRealVar wc0("wc0","wc0",12.33e-03);
  MyBW bwd_c0("bwd_c0","bwd_c0",RM_ee,mc0,wc0);

  MyGGG Res("Res","Res",RM_ee, mean11, sigma11, mean22, sigma22, mean33, sigma33, frac1, frac2);
  //MyGGG Res("Res","Res",RM_ee, mean1, sigma1, mean2, sigma2, mean3, sigma3, frac1, frac2);


// bkg term


RooRealVar a0("a0","a0",-0.5,-5.,5.);
RooRealVar a1("a1","a1",-0.5,-5.,5.);
RooRealVar a2("a2","a2",-0.5,-5.,5.);
//RooRealVar a0("a0","a0",-0.29);
//RooRealVar a1("a1","a1",-0.35);
//RooRealVar a2("a2","a2",-0.20);

RooChebychev bkg_kk("bkg_kk", "bkg_kk",RM_ee,RooArgList(a0,a1,a2));
//RooPolynomial bkg_kk("bkg_kk", "Background",RM_ee,RooArgList(a0,a1,a2));


// convolving
RM_ee.setBins(10000,"cache");

// signal pdf
RooFFTConvPdf pdf_kkc0("pdf_kkc0", "pdf_kkc0", RM_ee, bwd_c0, Res);
RooFFTConvPdf pdf_kkc1("pdf_kkc1", "pdf_kkc1", RM_ee, mcpdf_kkc1, gauss5);
RooFFTConvPdf pdf_kkc2("pdf_kkc2", "pdf_kkc2", RM_ee, mcpdf_kkc2, gauss6);

// event number 
RooRealVar nkkc0("nkkc0", "nkkc0",9100.,5000.,20000.);
RooRealVar nkkc1("nkkc1", "nkkc1",6100.,1000.,20000.);
RooRealVar nkkc2("nkkc2", "nkkc2",3100.,1000.,20000.);
RooRealVar nbkg_kk("nbkg_kk", "nbkg_kk",51000.,20000.,100000.);


// total pdf
RooAddPdf model_kk(  "model_kk",   "model_kk",  RooArgList(pdf_kkc0,pdf_kkc1,pdf_kkc2,bkg_kk),RooArgList(nkkc0,nkkc1,nkkc2,nbkg_kk));


//*************** end pdf ***********************

// fit
  RooFitResult *r = model_kk.fitTo(*data1,Save(kTRUE),Extended()) ;
  r->Print("v");



  RooPlot* frame1 = RM_ee.frame(Bins(nbin),Title("fit")) ;


  data1->plotOn(frame1) ;

  model_kk.plotOn(frame1) ;
  model_kk.plotOn(frame1,Components("pdf_kkc0"),LineStyle(kDashed),LineColor(kRed)) ;
  model_kk.plotOn(frame1,Components("pdf_kkc1"),LineStyle(kDashed),LineColor(kBlue)) ;
  model_kk.plotOn(frame1,Components("pdf_kkc2"),LineStyle(kDashed),LineColor(kGreen)) ;
  model_kk.plotOn(frame1,Components("bkg_kk"),LineStyle(kDashed),LineColor(6)) ;


  TCanvas* c = new TCanvas("c","c",800,600) ;
  frame1->GetXaxis()->SetTitle("RM(e^{+}e^{-}) (GeV/c^{2})"); frame1->Draw() ;
  
}

Hello and welcome to the forum! Let me add @jonas Rembser who is our RooFit expert.

I have a similar problem, with a more complicated model.

I get several warnings and errors that with previous version (6.24.08) I didn’t get; here is the beginning of the messages:

Minuit2Minimizer: Minimize with max-calls 3500 convergence for edm < 1 strategy 2
Info in : MnSeedGenerator Computing seed using NumericalGradient calculator
[#0] WARNING:Eval – RooAddPdf::updateCoefCache(model) WARNING: sum of coefficients is zero 0
RooAbsMinimizerFcn: Minimized function has error status.
Returning maximum FCN so far (-inf) to force MIGRAD to back out of this region. Error log follows.
Parameter values: Av_N_ph=1.9 Delta=119 cTalk=0.03 eff_1=0.995 pedestal=0 s0=10 s1=1.1
RooAddPdf::model[ myFunc_1 * gs_1_over_gs_1_Int + myFunc_2 * gs_2_over_gs_2_Int + myFunc_3 * gs_3_over_gs_3_Int + myFunc_4 * gs_4_over_gs_4_Int + myFunc_5 * gs_5_over_gs_5_Int + myFunc_6 * gs_6_over_gs_6_Int + myFunc_7 * gs_7_over_gs_7_Int ]
getLogVal() top-level p.d.f not greater than zero @ !refCoefNorm=(x = 480.2), !pdfs=(gs_1_over_gs_1_Int = 1.9897e-285,gs_2_over_gs_2_Int = 1.4818e-105,gs_3_over_gs_3_Int = 2.34718e-24,gs_4_over_gs_4_Int = 0.0285367,gs_5_over_gs_5_Int = 4.37995e-16,gs_6_over_gs_6_Int = 1.01055e-51,gs_7_over_gs_7_Int = 1.98363e-100), !coefficients=(myFunc_1 = 0.274277,myFunc_2 = 0.270142,myFunc_3 = 0.175949,myFunc_4 = 0.0879103,myFunc_5 = 0.0357352,myFunc_6 = 0.012242,myFunc_7 = 0.0036177)

Thanks for your help

Roberto

Now I can upload my macro and root data, as you can check, thank you!
test.zip (1.2 MB)

Anyone can give a hand?

Hello!

ROOT 6.32 made a lot of changes to likelihood evaluation under the hood, as you can read in the release notes.

You can however change back to the old backend, as explained in the documentation for RooAbsPdf::createNLL().

In the case of your script, you can do it with:

// fit
  RooFitResult *r = model_kk.fitTo(*data1,Save(kTRUE),Extended(), EvalBackend("legacy")) ;

Does your fit give the correct answer with the legacy backend, but not the new one?
Then I would appreciate if you could open a bug report on GitHub, providing the reproducer and linking to this forum post.

Thanks a lot for your feedback on the new ROOT versions, and let us know if you have more questions here!

Cheers,
Jonas

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.