Simultaneous 1D likelihood fits in different observables, with multiple PDFs

Hello @ilam,

the labelling method is a bit inferior to making one dataset per category. I advise to try something like this:

   RooCategory sample("sample", "sample");
   ...

   RooArgSet setX(x1, x2, weight);
   RooDataSet datax("datax", "datax", setX, WeightVar(weight));
   for (int i=1; i <= histX->GetNbinsX()+1; ++i) {
    for (int j=1; .... y-coordinate loop) {
      x1.setVal(histX->GetBinCenter(i));
      x2.setVal(... j ...)
      datax.add(setX, histX->GetBinContent(i, j));
    }
   }
   [... Same with y, but one-dimensional. ]

   
   // Construct combined dataset
   RooArgSet datasetVars(x1, x2, y, weight, sample);
   std::map<std::string, RooDataSet*> sampleMap;
   sampleMap["xSampleName"] = &dataX;
   sampleMap["ySampleName"] = &dataY;
   ...
   RooDataSet combData("combData", "combined data", datasetVars, Index(sample), WeightVar(weight), Import(sampleMap));
   
   combData.Print("V");
   combData.get(0)->Print("V");

Check out the documentation of the RooDataSet constructor to see where I got the arguments from:
https://root.cern.ch/doc/master/classRooDataSet.html#aeea71f616bd2cc6743f6869d31a4dbd5