Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
rs602_HLFactoryCombinationexample.C File Reference

Detailed Description

View in nbviewer Open in SWAN
High Level Factory: creation of a combined model

[#1] INFO:Minimization -- p.d.f. provides expected number of events, including extended term in likelihood.
[#1] INFO:Fitting -- RooAbsPdf::fitTo(HLFavtoryCombinationexample_sigbkg) fixing normalization set for coefficient determination to observables in data
[#1] INFO:Fitting -- using CPU computation library compiled with -mavx2
[#1] INFO:Fitting -- RooAddition::defaultErrorLevel(nll_HLFavtoryCombinationexample_sigbkg_hmaster) Summation contains a RooNLLVar, using its error level
[#1] INFO:Minimization -- RooAbsMinimizerFcn::setOptimizeConst: activating const optimization
Minuit2Minimizer: Minimize with max-calls 3000 convergence for edm < 1 strategy 1
Minuit2Minimizer : Valid minimum - status = 0
FVAL = 199.349002773493112
Edm = 3.00537727986692771e-05
Nfcn = 93
mean1 = 49.8783 +/- 0.42659 (limited)
mean2 = 79.8952 +/- 0.649972 (limited)
nbkg1 = 91.8179 +/- 10.6581 (limited)
nbkg2 = 82.5577 +/- 10.3903 (limited)
nsig1 = 119.174 +/- 11.8598 (limited)
nsig2 = 92.432 +/- 10.8502 (limited)
[#1] INFO:Minimization -- RooAbsMinimizerFcn::setOptimizeConst: deactivating const optimization
[#1] INFO:Plotting -- RooSimultaneous::plotOn(HLFavtoryCombinationexample_sigbkg) plot on x represents a slice in the index category (HLFavtoryCombinationexample_category)
[#1] INFO:Plotting -- RooAbsReal::plotOn(sb_model1) slice variable HLFavtoryCombinationexample_category was not projected anyway
[#1] INFO:Plotting -- RooSimultaneous::plotOn(HLFavtoryCombinationexample_sigbkg) plot on x represents a slice in the index category (HLFavtoryCombinationexample_category)
[#1] INFO:Plotting -- RooAbsReal::plotOn(sb_model2) slice variable HLFavtoryCombinationexample_category was not projected anyway
#include <fstream>
#include "TString.h"
#include "TROOT.h"
#include "RooGlobalFunc.h"
#include "RooWorkspace.h"
#include "RooRealVar.h"
#include "RooAbsPdf.h"
#include "RooDataSet.h"
#include "RooPlot.h"
// use this order for safety on library loading
using namespace RooFit;
using namespace RooStats;
using std::ofstream;
void rs602_HLFactoryCombinationexample()
{
// create a card
TString card_name("HLFavtoryCombinationexample.rs");
ofstream ofile(card_name);
ofile << "// The simplest card for combination\n\n"
<< "gauss1 = Gaussian(x[0,100],mean1[50,0,100],4);\n"
<< "flat1 = Polynomial(x,0);\n"
<< "sb_model1 = SUM(nsig1[120,0,300]*gauss1 , nbkg1[100,0,1000]*flat1);\n"
<< "gauss2 = Gaussian(x,mean2[80,0,100],5);\n"
<< "flat2 = Polynomial(x,0);\n"
<< "sb_model2 = SUM(nsig2[90,0,400]*gauss2 , nbkg2[80,0,1000]*flat2);\n";
ofile.close();
HLFactory hlf("HLFavtoryCombinationexample", card_name, false);
hlf.AddChannel("model1", "sb_model1", "flat1");
hlf.AddChannel("model2", "sb_model2", "flat2");
auto pdf = hlf.GetTotSigBkgPdf();
auto thecat = hlf.GetTotCategory();
auto x = static_cast<RooRealVar *>(hlf.GetWs()->arg("x"));
auto data = pdf->generate(RooArgSet(*x, *thecat), Extended());
// --- Perform extended ML fit of composite PDF to toy data ---
pdf->fitTo(*data);
// --- Plot toy data and composite PDF overlaid ---
auto xframe = x->frame();
data->plotOn(xframe);
thecat->setIndex(0);
pdf->plotOn(xframe, Slice(*thecat), ProjWData(*thecat, *data));
thecat->setIndex(1);
pdf->plotOn(xframe, Slice(*thecat), ProjWData(*thecat, *data));
gROOT->SetStyle("Plain");
xframe->Draw();
}
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
#define gROOT
Definition TROOT.h:406
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:55
Variable that can be changed from the outside.
Definition RooRealVar.h:37
HLFactory is an High Level model Factory allows you to describe your models in a configuration file (...
Definition HLFactory.h:29
Basic string class.
Definition TString.h:139
Double_t x[n]
Definition legend1.C:17
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Definition JSONIO.h:26
Namespace for the RooStats classes.
Definition Asimov.h:19
Author
Danilo Piparo

Definition in file rs602_HLFactoryCombinationexample.C.