Simultaneous fit to weighted and unweighted datasets

Dear Experts,

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?

thank you in advance for any hints

Hi @ibelyaev ,

this looks like a question for @jonas , let’s ping him.


Hi @ibelyaev,

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"};

dataWeighted.add(x, 0.5);

// Define category to distinguish weighted and unweighted samples
RooCategory sample("sample", "sample");

// Construct combined dataset in (x,sample)
RooDataSet combData("combData",
                    "combined data",
                    {x, weight},
                    Import({{"weighted", &dataWeighted},
                            {"unweighted", &dataUnweighted}}),

std::cout << "Weight for event 0: " << combData.weight() << std::endl;

std::cout << "Weight for event 1: " << combData.weight() << std::endl;

Hope this helps!

Dear Jonas,
Thank you very much!
I’ll make a try asap.
Cheers, Vanya

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