Adding multiple weights variables to RooDataSet

Hi @jonas,
Thanks for the solution. Yes, I get my data from TTree which is saved in a root file. I do it this way:

void Example(){
	TFile *_file0 = new TFile("InputFile.root", "READ");
	TTree *tree=(TTree*)_file0->Get("tree");
	RooRealVar x = RooRealVar("x", "x", 5.1, 5.6);
	RooRealVar weight1 = RooRealVar("weight1", "weight1", 0, 5);
	RooRealVar weight2 = RooRealVar("weight2", "weight2", 0, 100);
	RooRealVar NewWeight = RooRealVar("NewWeight", "NewWeight", 0, 20);
	RooArgSet columns{x, NewWeight};
	RooDataSet *tempData = new RooDataSet("tempData", "temporary dataset", RooArgSet(x, weight1, weight2), RooFit::Import(*tree), RooFit::Cut("1"));
	RooDataSet *finalDataset = new RooDataSet("finalDataset","finalDatset", columns, RooFit::WeightVar("NewWeight"));
	for(Int_t j=0; j<tempData->numEntries(); j++){ 
		    RooArgSet *args = (RooArgSet*)tempData->get(j);
		    Float_t xx = ((RooRealVar*)args->find("x"))->getVal();
		    Float_t myweight = ((RooRealVar*)args->find("weight1"))->getVal()*((RooRealVar*)args->find("weight2"))->getVal();
		    x.setVal(xx);
		    NewWeight.setVal(myweight);
		    finalDataset->add(columns, myweight);
		}
	finalDataset->Print();
}

Please let me know if I can reduce the number of lines from this code. Can there be a smarter implemention of this?