SPlot tutorial
This tutorial shows an example of using SPlot to unfold two distributions. The physics context for the example is that we want to know the isolation distribution for real electrons from Z events and fake electrons from QCD. Isolation is our 'control' variable To unfold them, we need a model for an uncorrelated variable that discriminates between Z and QCD. To do this, we use the invariant mass of two electrons. We model the Z with a Gaussian and the QCD with a falling exponential.
Note, since we don't have real data in this tutorial, we need to generate toy data. To do that we need a model for the isolation variable for both Z and QCD. This is only used to generate the toy data, and would not be needed if we had real data.
Processing /mnt/build/workspace/root-makedoc-v608/rootspi/rdoc/src/v6-08-00-patches/tutorials/roostats/rs301_splot.C...
void rs301_splot()
{
AddModel(wspace);
AddData(wspace);
DoSPlot(wspace);
MakePlots(wspace);
delete wspace;
}
Double_t lowRange = 00, highRange = 200;
RooRealVar invMass(
"invMass",
"M_{inv}", lowRange, highRange,
"GeV");
RooRealVar isolation(
"isolation",
"isolation", 0., 20.,
"GeV");
std::cout << "make z model" << std::endl;
RooRealVar mZ(
"mZ",
"Z Mass", 91.2, lowRange, highRange);
RooRealVar sigmaZ(
"sigmaZ",
"Width of Gaussian", 2,0,10,
"GeV");
RooGaussian mZModel(
"mZModel",
"Z+jets Model", invMass, mZ, sigmaZ);
mZ.setConstant();
"z isolation decay constant", -1);
RooExponential zIsolationModel(
"zIsolationModel",
"z isolation model",
isolation, zIsolDecayConst);
std::cout << "make qcd model" << std::endl;
"Decay const for QCD mass spectrum",
-0.01, -100, 100,"1/GeV");
invMass, qcdMassDecayConst);
"Et resolution constant", -.1);
RooExponential qcdIsolationModel(
"qcdIsolationModel",
"QCD isolation model",
isolation, qcdIsolDecayConst);
RooProdPdf qcdModel(
"qcdModel",
"2-d model for QCD",
RooRealVar zYield(
"zYield",
"fitted yield for Z",50 ,0.,1000) ;
RooRealVar qcdYield(
"qcdYield",
"fitted yield for QCD", 100 ,0.,1000) ;
std::cout << "make full model" << std::endl;
std::cout << "import model" << std::endl;
}
std::cout << "make data set and import to workspace" << std::endl;
}
std::cout << "Calculate sWeights" << std::endl;
std::cout << "Check SWeights:" << std::endl;
std::cout << std::endl << "Yield of Z is "
<< zYield->
getVal() <<
". From sWeights it is " std::cout << "Yield of QCD is "
<< qcdYield->
getVal() <<
". From sWeights it is " << std::endl;
for(
Int_t i=0; i < 10; i++)
{
std::cout <<
"z Weight " << sData->
GetSWeight(i,
"zYield")
<<
" qcd Weight " << sData->
GetSWeight(i,
"qcdYield")
<< std::endl;
}
std::cout << std::endl;
std::cout << "import new dataset with sWeights" << std::endl;
}
std::cout << "make plots" << std::endl;
frame->
SetTitle(
"Fit of model to discriminating variable");
frame2->
SetTitle(
"isolation distribution for Z");
frame2->Draw() ;
frame3->
SetTitle(
"isolation distribution for QCD");
frame3->Draw() ;
}
- Author
- Kyle Cranmer
Definition in file rs301_splot.C.