91 Double_t lowRange = 0., highRange = 200.;
94 RooRealVar invMass(
"invMass",
"M_{inv}", lowRange, highRange,
"GeV");
95 RooRealVar isolation(
"isolation",
"isolation", 0., 20.,
"GeV");
101 std::cout <<
"make z model" << std::endl;
103 RooRealVar mZ(
"mZ",
"Z Mass", 91.2, lowRange, highRange);
104 RooRealVar sigmaZ(
"sigmaZ",
"Width of Gaussian", 2, 0, 10,
"GeV");
105 RooGaussian mZModel(
"mZModel",
"Z+jets Model", invMass, mZ, sigmaZ);
114 RooConstVar zIsolDecayConst(
"zIsolDecayConst",
"z isolation decay constant", -1);
115 RooExponential zIsolationModel(
"zIsolationModel",
"z isolation model", isolation, zIsolDecayConst);
123 std::cout <<
"make qcd model" << std::endl;
129 RooRealVar qcdMassDecayConst(
"qcdMassDecayConst",
"Decay const for QCD mass spectrum", -0.01, -100, 100,
"1/GeV");
130 RooExponential qcdMassModel(
"qcdMassModel",
"qcd Mass Model", invMass, qcdMassDecayConst);
136 RooConstVar qcdIsolDecayConst(
"qcdIsolDecayConst",
"Et resolution constant", -.1);
137 RooExponential qcdIsolationModel(
"qcdIsolationModel",
"QCD isolation model", isolation, qcdIsolDecayConst);
140 RooProdPdf qcdModel(
"qcdModel",
"2-d model for QCD",
RooArgSet(qcdMassModel, qcdIsolationModel));
147 RooRealVar zYield(
"zYield",
"fitted yield for Z", 500, 0., 5000);
148 RooRealVar qcdYield(
"qcdYield",
"fitted yield for QCD", 1000, 0., 10000);
151 std::cout <<
"make full model" << std::endl;
152 RooAddPdf model(
"model",
"z+qcd background models", {zModel, qcdModel}, {zYield, qcdYield});
153 RooAddPdf massModel(
"massModel",
"z+qcd invariant mass model", {mZModel, qcdMassModel}, {zYield, qcdYield});
158 std::cout <<
"import model" << std::endl;
175 std::cout <<
"make data set and import to workspace" << std::endl;
176 std::unique_ptr<RooDataSet>
data{model->
generate({*invMass, *isolation})};
185 std::cout <<
"Calculate sWeights" << std::endl;
208 std::cout <<
"\n\n------------------------------------------\nThe dataset before creating sWeights:\n";
217 std::cout <<
"\n\nThe dataset after creating sWeights:\n";
222 std::cout <<
"\n\n------------------------------------------\n\nCheck SWeights:" << std::endl;
224 std::cout << std::endl
225 <<
"Yield of Z is\t" << zYield->
getVal() <<
". From sWeights it is "
226 << sData.GetYieldFromSWeight(
"zYield") << std::endl;
228 std::cout <<
"Yield of QCD is\t" << qcdYield->
getVal() <<
". From sWeights it is "
229 << sData.GetYieldFromSWeight(
"qcdYield") << std::endl
232 for (
Int_t i = 0; i < 10; i++) {
233 std::cout <<
"z Weight for event " << i << std::right << std::setw(12) << sData.GetSWeight(i,
"zYield") <<
" qcd Weight"
234 << std::setw(12) << sData.GetSWeight(i,
"qcdYield") <<
" Total Weight" << std::setw(12) << sData.GetSumOfEventSWeight(i)
238 std::cout << std::endl;
241 std::cout <<
"import new dataset with sWeights" << std::endl;
252 std::cout <<
"make plots" << std::endl;
281 RooPlot *frame = invMass->
frame(
Title(
"Fit of model to discriminating variable"));
288 leg.AddEntry(frame->
findObject(
"FullModel"),
"Full model",
"L");
290 leg.AddEntry(frame->
findObject(
"QCDModel"),
"QCD model",
"L");
291 leg.SetBorderSize(0);
308 RooPlot *frame2 = isolation->
frame(
Title(
"Isolation distribution with s weights to project out Z"));
320 RooPlot *frame3 = isolation->
frame(
Title(
"Isolation distribution with s weights to project out QCD"));
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
void graphVizTree(const char *fileName, const char *delimiter="\n", bool useTitle=false, bool useLatex=false)
Create a GraphViz .dot file visualizing the expression tree headed by this RooAbsArg object.
Abstract interface for all probability density functions.
RooPlot * plotOn(RooPlot *frame, const RooCmdArg &arg1={}, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={}, const RooCmdArg &arg6={}, const RooCmdArg &arg7={}, const RooCmdArg &arg8={}, const RooCmdArg &arg9={}, const RooCmdArg &arg10={}) const override
Helper calling plotOn(RooPlot*, RooLinkedList&) const.
RooFit::OwningPtr< RooDataSet > generate(const RooArgSet &whatVars, Int_t nEvents, const RooCmdArg &arg1, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={})
See RooAbsPdf::generate(const RooArgSet&,const RooCmdArg&,const RooCmdArg&,const RooCmdArg&,...
RooPlot * frame(const RooCmdArg &arg1, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={}, const RooCmdArg &arg6={}, const RooCmdArg &arg7={}, const RooCmdArg &arg8={}) const
Create a new RooPlot on the heap with a drawing frame initialized for this object,...
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Efficient implementation of a sum of PDFs of the form.
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Represents a constant real-valued object.
Container class to hold unbinned data.
static RooMsgService & instance()
Return reference to singleton instance.
void setGlobalKillBelow(RooFit::MsgLevel level)
void setSilentMode(bool flag)
Plot frame and a container for graphics objects within that frame.
TObject * findObject(const char *name, const TClass *tClass=nullptr) const
Find the named object in our list of items and return a pointer to it.
void Draw(Option_t *options=nullptr) override
Draw this plot and all of the elements it contains.
Efficient implementation of a product of PDFs of the form.
Variable that can be changed from the outside.
A class to calculate "sWeights" used to create an "sPlot".
Persistable container for RooFit projects.
RooAbsPdf * pdf(RooStringView name) const
Retrieve p.d.f (RooAbsPdf) with given name. A null pointer is returned if not found.
RooRealVar * var(RooStringView name) const
Retrieve real-valued variable (RooRealVar) with given name. A null pointer is returned if not found.
RooAbsData * data(RooStringView name) const
Retrieve dataset (binned or unbinned) with given name. A null pointer is returned if not found.
bool import(const RooAbsArg &arg, const RooCmdArg &arg1={}, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={}, const RooCmdArg &arg6={}, const RooCmdArg &arg7={}, const RooCmdArg &arg8={}, const RooCmdArg &arg9={})
Import a RooAbsArg object, e.g.
TVirtualPad * cd(Int_t subpadnumber=0) override
Set current canvas & pad.
This class displays a legend box (TPaveText) containing several legend entries.
void Divide(Int_t nx=1, Int_t ny=1, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color=0) override
Automatic pad generation by division.
RooCmdArg RecycleConflictNodes(bool flag=true)
RooCmdArg Rename(const char *suffix)
RooCmdArg WeightVar(const char *name="weight", bool reinterpretAsWeight=false)
RooCmdArg Import(const char *state, TH1 &histo)
RooCmdArg DataError(Int_t)
RooCmdArg Components(Args_t &&... argsOrArgSet)
RooCmdArg LineColor(Color_t color)
RooCmdArg LineStyle(Style_t style)
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Namespace for the RooStats classes.