void rootForum_20899() { auto x = new RooRealVar("x", "x", -1.0, 1.0); auto y = new RooRealVar("y", "y", -1.0, 1.0); // Basic functions that use x,y auto P_1_x = new RooLegendre("P_1_x", "P_1_x", *x, 1, 0); auto P_1_y = new RooLegendre("P_1_y", "P_1_y", *y, 1, 0); // Some coefficient auto C_1_2 = new RooRealVar("C_1_2", "C_1_2", 2.0); // Main function that in theory is made of several combinations of Legendre polynomials auto combLeg = new RooFormulaVar("combLeg","C_1_2*P_1_x*P_1_y", RooArgList(*C_1_2, *P_1_x, *P_1_y)); // Finally, I want to project either x/y results into a histogra, e.g.: // project for some sensible y value (e.g. y=0.5) y->setVal(0.5); auto pdf = combLeg->createHistogram("pdf", *x, RooFit::Binning(80)); pdf->Draw(); }