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");
w->Print();
RooRealVar *m = w->var("m");
m->setRange("mregion1", 4, 9);
m->setRange("mregion2", 11, 30);
RooRealVar *pt = w->var("pt");
m->setBins(Binning_m);
pt->setBins(Binning_pt);
RooCategory sample("sample", "sample");
sample.defineType("mass");
sample.defineType("transversemomentum");
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,

Michele