Examples: Plotting

Once a PDF has been constructed using the AFitMaster (or any other route), it is possble to extract the sub-component you are interested in and plot only that. For example if we use the muon lifetime example one can extract the signal component from the model by entering the following in ROOT:

   RooAbsPdf * sigpdf=(RooAbsPdf*)pdf->findServer("signal")
 

Now it is possible to plot the signal pdf onto a frame with

   RooArgSet * compSet = pdf->getComponents();
   RooArgSet * parSet  = pdf->getParameters(compSet);
   RooRealVar * t = (RooRealVar*)parSet->find("t");
   RooPlot * frame = t.frame()
   sigpdf.plotOn(frame)
   frame.Draw()
 

which outputs the plot shown in Figure 1.

.
Fig 1: The signal component PDF obtained from a muon decay experiment.

For more complicated fit models it is possible to extract the appropriate PDF for a given discriminating variable. In this example, this would be using the t component of signal which can obtained with

   RooAbsPdf * sigpdf_t=(RooAbsPdf*)compSet->find("signal_t")
 

Note that here one uses the component set 'compSet' to find the PDF of interest. If you have a RooDataSet that you want to plot onto the frame, this can be done in the usual way with

   data->plotOn(frame)

prior to plotting the PDF on the frame. More sophisticated interfaces to plotting exist in AFit and are described in the user guide.

This page is maintained by Adrian Bevan.