I need to perform a simultaneous fit for weighted (where sPlot was used to create weights) and non-weighed datasets. And I have a problem in preparation of the combined dataset. It is not clear for me how can I create it. Surely I can provide the non-weighted dataset with some “fictive” weight of 1, but it does not looks like a good solution. Is there some proper way to do it?
you can follow a similar strategy to what is shown in the rf501_simultaneouspdf.C tutorial. You can use this RooDataSet() constructor to build a composite dataset for a simultaneous fit with weighted and unweighted components. You just need to add the WeightVar command to the constructor.
Here is a minimal working example combining a weighted and unweighted dataset, doing some printouts in the end to show that the weights are as expected:
using namespace RooFit;
// Variables
RooRealVar x{"x", "x", 0};
RooRealVar weight{"weight", "weight", 1.0};
// Generate weighted data and unweighted data with one entry each
RooDataSet dataUnweighted{"data1", "data1", {x}};
RooDataSet dataWeighted{"data2", "data2", {x, weight}, "weight"};
dataUnweighted.add(x);
dataWeighted.add(x, 0.5);
// Define category to distinguish weighted and unweighted samples
RooCategory sample("sample", "sample");
sample.defineType("weighted");
sample.defineType("unweighted");
// Construct combined dataset in (x,sample)
RooDataSet combData("combData",
"combined data",
{x, weight},
Index(sample),
Import({{"weighted", &dataWeighted},
{"unweighted", &dataUnweighted}}),
WeightVar(weight));
combData.get(0);
std::cout << "Weight for event 0: " << combData.weight() << std::endl;
combData.get(1);
std::cout << "Weight for event 1: " << combData.weight() << std::endl;