'Bernstein Correction' RooStats tutorial macro
This tutorial shows usage of a the BernsteinCorrection utility in RooStats. The idea is that one has a distribution coming either from data or Monte Carlo (called "reality" in the macro) and a nominal model that is not sufficiently flexible to take into account the real distribution. One wants to take into account the systematic associated with this imperfect modeling by augmenting the nominal model with some correction term (in this case a polynomial). The BernsteinCorrection utility will import into your workspace a corrected model given by nominal(x) * poly_N(x), where poly_N is an n-th order polynomial in the Bernstein basis. The degree N of the polynomial is chosen by specifying the tolerance one has in adding an extra term to the polynomial. The Bernstein basis is nice because it only has positive-definite terms and works well with PDFs. Finally, the macro makes a plot of:
- the data (drawn from 'reality'),
- the best fit of the nominal model (blue)
- and the best fit corrected model.
Processing /mnt/build/workspace/root-makedoc-v610/rootspi/rdoc/src/v6-10-00-patches/tutorials/roostats/rs_bernsteinCorrection.C...
#include <string>
#include <vector>
#include <stdio.h>
#include <sstream>
#include <iostream>
void rs_bernsteinCorrection(){
Int_t degree = bernsteinCorrection.ImportCorrectedPdf(wks,
"nominal",
"x",
"data");
if (degree < 0) {
Error(
"rs_bernsteinCorrection",
"Bernstein correction failed ! ");
return;
}
cout << " Correction based on Bernstein Poly of degree " << degree << endl;
nominal.plotOn(frame);
if (!corrected) return;
if (poly)
bool checkSamplingDist = true;
int numToyMC = 20;
if(checkSamplingDist) {
}
if(checkSamplingDist) {
TH1F* samplingDist =
new TH1F(
"samplingDist",
"",20,0,10);
TH1F* samplingDistExtra =
new TH1F(
"samplingDistExtra",
"",20,0,10);
bernsteinCorrection.CreateQSamplingDist(wks,"nominal","x","data",samplingDist, samplingDistExtra, degree,numToyMC);
samplingDistExtra->
Draw();
samplingDist->
Draw(
"same");
}
}
- Author
- Kyle Cranmer
Definition in file rs_bernsteinCorrection.C.