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

Detailed Description

View in nbviewer Open in SWAN
Organization and simultaneous fits: operator expressions and expression-based basic pdfs in the workspace factory syntax

#include "RooRealVar.h"
#include "RooDataSet.h"
#include "RooGaussian.h"
#include "RooChebychev.h"
#include "RooAddPdf.h"
#include "RooWorkspace.h"
#include "RooPlot.h"
#include "TCanvas.h"
#include "TAxis.h"
using namespace RooFit;
{
// You can define typedefs for even shorter construction semantics
w->factory("$Typedef(Gaussian,Gaus)");
w->factory("$Typedef(Chebychev,Cheby)");
// O p e r a t o r p . d . f . e x a m p l e s
// ------------------------------------------------
// PDF addition is done with SUM (coef1*pdf1,pdf2)
w->factory("SUM::summodel( f[0,1]*Gaussian::gx(x[-10,10],m[0],1.0), Chebychev::ch(x,{0.1,0.2,-0.3}) )");
// Extended PDF addition is done with SUM (yield1*pdf1,yield2*pdf2)
w->factory("SUM::extsummodel( Nsig[0,1000]*gx, Nbkg[0,1000]*ch )");
// PDF multiplication is done with PROD ( pdf1, pdf2 )
w->factory("PROD::gxz( gx, Gaussian::gz(z[-10,10],0,1) )");
// Conditional pdf multiplication is done with PROD ( pdf1|obs, pdf2 )
w->factory("Gaussian::gy( y[-10,10], x, 1.0 )");
w->factory("PROD::gxycond( gy|x, gx )");
// Convolution (numeric/ fft) is done with NCONV/FCONV (obs,pdf1,pdf2)
w->factory("FCONV::lxg( x, Gaussian::g(x,mg[0],1), Landau::lc(x,0,1) )");
// Simultaneous pdfs are constructed with SIMUL( index, state1=pdf1, state2=pdf2,...)
w->factory("SIMUL::smodel( c[A=0,B=1], A=Gaussian::gs(x,m,s[1.0, 0.01, 10.0]), B=Landau::ls(x,0,1) )");
// O p e r a t o r f u n c t i o n e x a m p l e s
// ---------------------------------------------------
// Function multiplication is done with prod (func1, func2,...)
w->factory("prod::uv(u[10],v[10])");
// Function addition is done with sum(func1,func2)
w->factory("sum::uv2(u,v)");
// Lagrangian morphing function for the example shown in rf711_lagrangianmorph
std::string infilename = std::string(gROOT->GetTutorialDir()) + "/roofit/input_histos_rf_lagrangianmorph.root";
w->factory(("lagrangianmorph::morph($fileName('"+infilename+"'),$observableName('pTV'),$couplings({cHq3[0,1],SM[1]}),$NewPhysics(cHq3=1,SM=0),$folders({'SM_NPsq0','cHq3_NPsq1','cHq3_NPsq2'}))").c_str());
// Taylor expansion is done with taylorexpand(func,{var1,var2,...},val,order)
w->factory("taylorexpand::te(expr::poly('x^4+5*x^3+2*x^2+x+1',x),{x},0.0,2)");
// I n t e r p r e t e d a n d c o m p i l e d e x p r e s s i o n b a s e d p . d . f . s .
// ---------------------------------------------------------------------------------------------------
// Create a RooGenericPdf interpreted pdf You can use single quotes to pass the expression string argument
w->factory("EXPR::G('x*x+1',x)");
// Create a custom compiled pdf similar to the above interpreted pdf
// The code required to make this pdf is automatically embedded in the workspace
w->factory("CEXPR::GC('x*x+a',{x,a[1]})");
// Compiled and interpreted functions (rather than pdfs) can be made with the lower case
// 'expr' and 'cexpr' types
// Print workspace contents
w->Print();
// Make workspace visible on command line
gDirectory->Add(w);
}
#define gDirectory
Definition TDirectory.h:384
#define gROOT
Definition TROOT.h:406
Persistable container for RooFit projects.
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Definition JSONIO.h:26
[#1] INFO:Caching -- Changing internal binning of variable 'x' in FFT 'lxg' from 100 to 930 to improve the precision of the numerical FFT. This can be done manually by setting an additional binning named 'cache'.
[#0] PROGRESS:InputArguments -- initializing physics inputs from file /home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master.build/tutorials/roofit/input_histos_rf_lagrangianmorph.root with object name(s) 'pTV'
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing dataset dh_SM_NPsq0_morph
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing dataset dh_cHq3_NPsq1_morph
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing dataset dh_cHq3_NPsq2_morph
[#1] INFO:ObjectHandling -- RooWorkspace::autoImportClass(w) importing code of class RooCFAuto000Pdf from /home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master/documentation/doxygen/RooCFAuto000Pdf.cxx and RooCFAuto000Pdf.h
RooWorkspace(w) w contents
variables
---------
(Nbkg,Nsig,SM,a,binWidth_pTV,c,cHq3,f,m,mg,nNP0,nNP1,nNP2,nNP3,nNP4,pTV,s,te_c0,te_c1,te_c2,te_x^0,te_x^1,te_x^2,u,v,x,y,z)
p.d.f.s
-------
RooGenericPdf::G[ actualVars=(x) formula="x[0]*x[0]+1" ] = 1
RooCFAuto000Pdf::GC[ x=x a=a ] = 1
RooChebychev::ch[ x=x coefList=(0.1,0.2,-0.3) ] = 0.8
RooAddPdf::extsummodel[ Nsig * gx + Nbkg * ch ] = 0.9/1
RooGaussian::g[ x=x mean=mg sigma=1 ] = 1
RooGaussian::gs[ x=x mean=m sigma=s ] = 1
RooGaussian::gx[ x=x mean=m sigma=1 ] = 1
RooProdPdf::gxycond[ gx * gy|x ] = 1
RooProdPdf::gxz[ gx * gz ] = 1
RooGaussian::gy[ x=y mean=x sigma=1 ] = 1
RooGaussian::gz[ x=z mean=0 sigma=1 ] = 1
RooLandau::lc[ x=x mean=0 sigma=1 ] = 0.178854
RooLandau::ls[ x=x mean=0 sigma=1 ] = 0.178854
RooFFTConvPdf::lxg[ g(x) (*) lc(x) ] = 375639
RooSimultaneous::smodel[ indexCat=c A=gs B=ls ] = 1
RooAddPdf::summodel[ f * gx + [%] * ch ] = 0.9/1
functions
--------
RooLagrangianMorphFunc::morph[ physics=(phys_SM_NPsq0_morph,phys_cHq3_NPsq1_morph,phys_cHq3_NPsq2_morph) operators=(cHq3,SM) observables=(pTV) binWidths=(binWidth_pTV) flags=(nNP0,nNP1,nNP2,nNP3,nNP4) binWidth_pTV * SM_NPsq0_morph + binWidth_pTV * cHq3_NPsq1_morph + binWidth_pTV * cHq3_NPsq2_morph ] = 35.9835
RooHistFunc::phys_SM_NPsq0_morph[ depList=(pTV) ] = 65.1309
RooHistFunc::phys_cHq3_NPsq1_morph[ depList=(pTV) ] = 544.966
RooHistFunc::phys_cHq3_NPsq2_morph[ depList=(pTV) ] = 1528.22
RooFormulaVar::poly[ actualVars=(x) formula="x^4+5*x^3+2*x^2+x+1" ] = 1
RooPolyFunc::te[ vars=(x) te_t0=(te_x^0,te_c0) te_t1=(te_x^1,te_c1) te_t2=(te_x^2,te_c2) ] = 1
RooProduct::uv[ u * v ] = 100
RooAddition::uv2[ u + v ] = 20
embedded datasets (in pdfs and functions)
-----------------------------------------
RooDataHist::dh_SM_NPsq0_morph(pTV)
RooDataHist::dh_cHq3_NPsq1_morph(pTV)
RooDataHist::dh_cHq3_NPsq2_morph(pTV)
embedded class code
-------------------
RooCFAuto000Pdf
embedded precalculated expensive components
-------------------------------------------
uid = 0 key=lxg_g_CONV_lc_CACHEHIST_Obs[x]_BufFrac0.1_BufStrat0 value=RooDataHist::lxg_g_CONV_lc_CACHEHIST_Obs[x]_BufFrac0.1_BufStrat0 parameters=( mg=0 )
Date
July 2009
Author
Wouter Verkerke

Definition in file rf512_wsfactory_oper.C.