Creating a PDF to fit many sub-datasets

Dear all,

My apologies for the list spam on this issue…

I am trying to use RooFit to code up the following pdf:


Clearly, for all i,j combinations, a new subdataset/pdf is required.

In previous HEP analyses, I coped with subdatasets/pdfs by using RooSimultaneous and manually defining subdatasets/pdfs:

RooCategory Category("Category","Category");
Category.defineType("PiPlusDataMagDown");
Category.defineType("PiMinusDataMagDown");

 map<std::string,RooDataHist*> myMap;
 myMap.insert( pair<std::string,RooDataHist*>("PiPlusDataMagDown",Data_Pi_Offline_Positive_Hist_MagDown) );
 myMap.insert( pair<std::string,RooDataHist*>("PiMinusDataMagDown",Data_Pi_Offline_Negative_Hist_MagDown) );

RooDataHist  combData("combData","combined data", RooArgList(rd_Dplus_Dplus_DTF_M), Category, myMap);

RooSimultaneous simPdf("simPdf","simultaneous pdf",Category) ;
simPdf.addPdf(*sumPDF_Pi_MagDown,"PiPlusDataMagDown") ;              // Pi plus data
simPdf.addPdf(*sumPDF_PiM_MagDown,"PiMinusDataMagDown") ;              // Pi minus data

With just a few subdatasets, this is clearly fine. However, in this case i and j run from 1-41 and so defining so many subdatasets/pdfs is clearly not viable. I kind of need a vector solution. I tried using RooSimPdfBuilder, but having chatted with Lorenzo (and others), it doesn’t seem to quite do what I need.

Could anyone offer any advice on how they would code up this pdf or point me to a similar tutorial/example?

Thank in advance,

Sam