Problem with simultaneous fit in two subranges on multiple variables

Dear experts,

I’m trying to perform a simultaneous fit over two distinct variables (mass and transverse momentum).
Initially, I faced no problems working in two specific mass and transverse momentum regions. The problems arise when I want to extend the mass region, selecting two specific ranges, with the following error:

RooAbsTestStatistic::initSimMode: creating slave calculator #1 for state transversemomentum (73504 dataset entries)
terminate called after throwing an instance of ‘std::runtime_error’
what(): Error in RooAbsData::reduce! The ranges mregion1,mregion2 are overlapping!

In the following I attach the small version of the code that I’m using:

RooWorkspace *w = (RooWorkspace *)fIn->Get("w");

  RooRealVar *m = w->var("m");
  m->setRange("mregion1", 4, 9);
  m->setRange("mregion2", 11, 30);
  RooRealVar *pt = w->var("pt");

  RooCategory sample("sample", "sample");
  TFile *fIn_data = new TFile("~/dimuon_HF_pp/data/LHC18p/Hist_AOD/3_11_2022/TreeResults_merged.root", "READ");

  // Taking data saved in tree
  TTree *tree_data = (TTree *)fIn_data->Get(Form("rec_data_tree%s", mass_range_data.Data()));
  RooDataSet *unbinned_M_Dimu_data = new RooDataSet("M_Dimu_data", "M_Dimu_data", RooArgSet(*m), Import(*tree_data), Cut("m<9 || (m>11 && m<30)"));
  RooDataSet *unbinned_Pt_Dimu_data = new RooDataSet("Pt_Dimu_data", "Pt_Dimu_data", RooArgSet(*pt), Import(*tree_data)); // 5
  RooDataSet *unbinned_combData_set = new RooDataSet("combData", "combined data", RooArgSet(*m, *pt), Index(sample), Import("mass", *unbinned_M_Dimu_data), Import("transversemomentum", *unbinned_Pt_Dimu_data));

RooAddPdf *m_model = new RooAddPdf("m_model", "n_charm_output*dimuMassFromC + n_beauty_output*dimuMassFromB + n_mixed_output*dimuMassFromMixed", RooArgList(*pdfDimuMassFromBeauty, *pdfDimuMassFromCharm, *pdfDimuMassFromMixed), RooArgList(*normForB, *normForC, *normForMixed));
RooAddPdf *pt_model = new RooAddPdf("pt_model", "n_charm_output*dimuPtFromC + n_beauty_output*dimuPtFromB + n_mixed_output*dimuPtFromMixed", RooArgList(*pdfDimuPtFromBeauty, *pdfDimuPtFromCharm, *pdfDimuPtFromMixed), RooArgList(*normForB, *normForC, *normForMixed));

RooSimultaneous simPdf("simPdf", "simultaneous pdf", sample);
simPdf.addPdf(*m_model, "mass");
simPdf.addPdf(*pt_model, "transversemomentum");
RooFitResult *r = simPdf.fitTo(*unbinned_combData_set, Minimizer("Minuit2"), Range("mregion1,mregion2"), Save(), SumW2Error(true));

Thanks in advance for any help,


The ranges defined as in the code seem not to overlap. Strange you are getting that error. Maybe @jonas can investigate this in more detail. Probably we would need access to your Workspace and input data file to reproduce the problem

Best regards


Dear Lorenzo,

Thanks a lot for answering.
Indeed, I found it a bit weird myself. When I try to perform the fit only on the mass component, this problem doesn’t arise for some reason, so I would say it is somewhat related to using the RooSimultaneous. I tried to debug it a bit, but I found it beyond my RooFit knowledge.

Kind Regards,

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