void ProdModel() { RooRealVar x("x","x",0,6); RooRealVar y("y","y",3.95,4.05); RooRealVar a0("a0","a0",.60); RooRealVar a1("a1","a1",0.50); // Create f(y) RooPolyVar fy("fy","fy",y,RooArgSet(a0,a1)) ; // Create CB(x,f(y),s,alpha,n) RooCBShape model("model","Crystal ball with shifting mean",x,fy,RooFit::RooConst(.1),RooFit::RooConst(1),RooFit::RooConst(1)) ; //Create "flat" PDF in y: g(y) RooPolynomial gy("gy","Model for y",y); // Create plain 2D pdf model(x,sx|y) * g(y) RooProdPdf condprod("condprod","model(x|y)*gy(y)",gy,RooFit::Conditional(model,x)) ; //Generate pseudo-data with plain pdf Int_t nEvents(1000000); RooDataSet* Data = condprod.generate(RooArgSet(x,y),nEvents); // Plot Data and PDF RooPlot* xFrame=x.frame(); RooPlot* xFrameZoom=x.frame(2,3); RooPlot* yFrame=y.frame(); Data->plotOn(xFrame); Data->plotOn(xFrameZoom); Data->plotOn(yFrame); RooAbsReal* condprod_x = condprod.createProjection(y); RooAbsReal* condprod_y = condprod.createProjection(x); condprod_x->plotOn(xFrame); condprod_x->plotOn(xFrameZoom); condprod_y->plotOn(yFrame); TCanvas* cy= new TCanvas("cy","cy",350,50,750,550); yFrame->Draw(); TCanvas* cx= new TCanvas("cx","cx",350,50,750,550); cx->Divide(2); cx->cd(1); xFrame->Draw(); cx->cd(2); xFrameZoom->Draw(); }