RooFit Normailzations


 I have been working with RooFit now just a bit and am trying to do a simple thing.  I want to fit a function to one dataset (to get shape) and then fix all the parameters except for the norm and the refit to a new distribution.  I have found some strangeness and I am having a hard time getting answered in the documentation.

1: How can I plot the pdf as not normalized to 1.0

2: How can I plot the dataset that it was fit to and the function separate without the pdf being normalized to the number of events in the plotted histogram.


Hi Justace,

As you noticed the default behavior is when you plot a p.d.f. on an empty frame it is plotted with unit normalization. When you plot it on a frame with data in it, it will normalize to the number of events in that dataset.

You can override this choice of normalization as follows

to a specified number of events:

pdf->plotOn(frame,Normalization(234,RooAbsReal::NumEvent)) ;

to a number relative to the ‘default’ (depends on context)

pdf->plotOn(frame,Normalization(0.5,RooAbsReal::Relative)) ;

I’m not completely sure what you mean with 2). If you intend to plot in two different
frames you can do

RooPlot* frame1 = x.frame()
data->plotOn(frame1) ;
RooPlot* frame2 = x.frame()
pdf->plotOn(frame2) ;

and then show them on a canvas side by side

TCanvas* c = new TCanvas
c->Divide(2) ;
c->cd(1) ; frame1->Draw() ;
c->cd(2) ; frame2->Draw() ;

If you meant something else, let me know.



Sorry for the confusion. What I would like to have is both datasets plotted on the same frame in two different colors and then the pdf plotted on top of them without being normalized to either of the datasets and not normalized to one. Basically I just want to plot the fit function, using the parameters that was found during the fit.

Hi Justace,

The fit functions in RooFit are all probability density functions, which describe distributions, not event counts, and by definition normalized to one. There is no adjustable vertical scale parameter in probability density functions. P.d.f.s drawn on an empty frame are shown in their ‘natural’ unit-normalized form, when drawn on a frame with data, their are scaled to the event count of that dataset to facilitate comparison with distribution of the data.

In any case, a RooFit p.d.f. always reflect the shape with the ‘current’ parameters. If you do a fit to a p.d.f. the result of that fit is immediately reflected in a subsequent plotting operation of that p.d.f.


PS: An exception to this is if you define an extended p.d.f., which can be used to construct an extended likelihood that describes both a distribution and the total number of expected events. These are usually construct in RooFit using RooAddPdf where you provide an equal number of coefficients and p.d.f.s instead of one less coefficient.