Hi @pkalbhor,
thanks for the clarification, I misunderstood what you wanted. So if I understand correctly, your question is actually the same one as asked here in 2013: Create RooDataSet with RooFormulaVar as weight
Since the RooDataSet doesn’t support non-fundamental variables, you can’t create a new derived variable like the product of your two weights and set it as the weight of the data set.
You’d have to calculate your final weight product before entering RooFit land and creating the DataSet. If you fill your dataset values in the macro, you can do it like this:
void example1() {
using namespace RooFit;
RooRealVar x("x","x",-10,10);
RooRealVar s("s","s",1,1,10);
RooRealVar m("m","m",0,-10,10);
RooGaussian g("gauss","gauss(x,m,s)",x,m,s);
RooRealVar w1("w1","w1",0,20);
RooRealVar w2("w2","w2",0,20);
RooRealVar w3("w3","w3",0,20);
RooArgSet columns{x, w1, w2, w3};
RooDataSet dataSet1("dataSet1","dataSet1",columns,WeightVar(w3));
for (Int_t j=0; j<10000; ++j){
x.setVal(gRandom->Gaus(0,1));
w1.setVal(10 + gRandom->Gaus(0,1));
w2.setVal((10 + gRandom->Gaus(0,1)) / 2.0);
w3.setVal(w1.getVal() * w2.getVal());
dataSet1.add(columns);
}
dataSet1.Print();
}
If you get your data from the TTree or from some file in general, it is probably more complicated. Let me know if this is the case and we can find a solution.
Cheers,
Jonas