Extracting fitted bin counts from RooFit PDF


Having performed a fit with RooFit, it is often required to extract the fitted event count in each bin. This is possible, as shown in the example below. The input variables are:

fitMin The lower edge of the fitted region
fitMax The upper edge of the fitted region
observable The observable parameter of the fit (i.e. x-axis of 1D PDF)
fittedPdf A fitted PDF
lowBinEdge The lower edge of the bin of interest
highBinEdge The upper edge of the bin of interest
numEventsInFitRange The number of events in the fitted data between fitMin and fitMax

Code example

observable->setRange("bin", fitMin, fitMax);
RooAbsReal* intPdf = fittedPdf->createIntegral(*observable, Range("bin"));
double scaling = numEventsInFitRange / intPdf->getVal();
observable->setRange("bin", lowBinEdge, highBinEdge);
double binCount = intPdf->getVal() * scaling;
Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r2 - 2009-05-26 - JamesJackson
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    CMSPublic All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback