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

Detailed Description

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

[#1] INFO:Minimization -- p.d.f. provides expected number of events, including extended term in likelihood.
[#1] INFO:Fitting -- RooAbsPdf::fitTo(sum) 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_sum_sumData) Summation contains a RooNLLVar, using its error level
[#1] INFO:Minimization -- RooAbsMinimizerFcn::setOptimizeConst: activating const optimization
Minuit2Minimizer: Minimize with max-calls 2500 convergence for edm < 1 strategy 1
Minuit2Minimizer : Valid minimum - status = 0
FVAL = -18178.1839194288186
Edm = 7.6129471840253625e-05
Nfcn = 112
argpar = -22.9054 +/- 3.42143 (limited)
mean = 5.27987 +/- 0.000215769 (limited)
nbkg = 1612.74 +/- 44.6723 (limited)
nsig = 387.37 +/- 27.7674 (limited)
width = 0.00300965 +/- 0.000199023 (limited)
[#1] INFO:Minimization -- RooAbsMinimizerFcn::setOptimizeConst: deactivating const optimization
[#1] INFO:Plotting -- RooAbsPdf::plotOn(sum) directly selected PDF components: (argus)
[#1] INFO:Plotting -- RooAbsPdf::plotOn(sum) indirectly selected PDF components: ()
#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;
{
// --- Build the datacard and dump to file---
TString card_name("HLFavtoryexample.rs");
ofstream ofile(card_name);
ofile << "// The simplest card\n\n"
<< "gauss = Gaussian(mes[5.20,5.30],mean[5.28,5.2,5.3],width[0.0027,0.001,1]);\n"
<< "argus = ArgusBG(mes,5.291,argpar[-20,-100,-1]);\n"
<< "sum = SUM(nsig[200,0,10000]*gauss,nbkg[800,0,10000]*argus);\n\n";
ofile.close();
HLFactory hlf("HLFavtoryexample", card_name, false);
// --- Take elements out of the internal workspace ---
auto w = hlf.GetWs();
auto mes = dynamic_cast<RooRealVar *>(w->arg("mes"));
auto sum = dynamic_cast<RooAbsPdf *>(w->pdf("sum"));
auto argus = dynamic_cast<RooAbsPdf *>(w->pdf("argus"));
// --- Generate a toyMC sample from composite PDF ---
auto data = sum->generate(*mes, 2000);
// --- Perform extended ML fit of composite PDF to toy data ---
sum->fitTo(*data);
// --- Plot toy data and composite PDF overlaid ---
auto mesframe = mes->frame();
data->plotOn(mesframe);
sum->plotOn(mesframe);
sum->plotOn(mesframe, Components(*argus), LineStyle(kDashed));
gROOT->SetStyle("Plain");
mesframe->Draw();
}
@ kDashed
Definition TAttLine.h:48
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
#define gROOT
Definition TROOT.h:406
Abstract interface for all probability density functions.
Definition RooAbsPdf.h:40
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
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
static uint64_t sum(uint64_t i)
Definition Factory.cxx:2345
Author
Danilo Piparo

Definition in file rs601_HLFactoryexample.C.