using namespace RooFit ; void ex5() { // Make model // A workspace is a container class for RooFit data modeling objects // (variables, functions, probability density functions etc...) // Here we make an empty workspace RooWorkspace w("w") ; // Now we use the 'factory' to fill the workspace with the definition // of three variables (x,mean and sigma) and the definition of a Gaussian // probability density function 'g' in terms of (x,mean,sigma)s w.factory("Gaussian::g(x[-10,10],mean[-10,10],sigma[3,0.1,10])") ; // Generate an unbinned toy dataset // of 10000 events in observable x from pdf g RooDataSet* data = w->pdf("g")->generate(*w->var("x"),10000) ; // Fit model g to the data using an unbinned ML fit RooFitResult* r = w->pdf("g")->fitTo(*data,Save()) ; // Make plot // First make a plot frame in x, then plot the data on that frame, // and finally overlay the fitted pdf over the data RooPlot* frame = w.var("x")->frame(100) ; data->plotOn(frame) ; w.pdf("g")->plotOn(frame) ; frame->Draw() ; // // BLOCK 1 // cout << "the correlation matrix" << endl ; // r->correlationMatrix().Print() ; // cout << "the covariance matrix" << endl ; // r->covarianceMatrix().Print() ; // // BLOCK 2 // w.pdf("g")->plotOn(frame,VisualizeError(*r),MoveToBack()) ; // frame->Draw() ; // // BLOCK 3 // w.pdf("g")->plotOn(frame,VisualizeError(*r,*w.var("mean")),FillColor(kBlue),Name("mean_only")) ; // frame->Draw() ; }