## From \$ROOTSYS/tutorials/roofit/rf304_uncorrprod.C

```/////////////////////////////////////////////////////////////////////////
//
// 'MULTIDIMENSIONAL MODELS' RooFit tutorial macro #304
//
// Simple uncorrelated multi-dimensional p.d.f.s
//
// pdf = gauss(x,mx,sx) * gauss(y,my,sy)
//
//
// 07/2008 - Wouter Verkerke
//
/////////////////////////////////////////////////////////////////////////

#ifndef __CINT__
#include "RooGlobalFunc.h"
#endif
#include "RooRealVar.h"
#include "RooDataSet.h"
#include "RooGaussian.h"
#include "RooProdPdf.h"
#include "TCanvas.h"
#include "TAxis.h"
#include "RooPlot.h"
using namespace RooFit ;

void rf304_uncorrprod()
{

// C r e a t e   c o m p o n e n t   p d f s   i n   x   a n d   y
// ----------------------------------------------------------------

// Create two p.d.f.s gaussx(x,meanx,sigmax) gaussy(y,meany,sigmay) and its variables
RooRealVar x("x","x",-5,5) ;
RooRealVar y("y","y",-5,5) ;

RooRealVar meanx("mean1","mean of gaussian x",2) ;
RooRealVar meany("mean2","mean of gaussian y",-2) ;
RooRealVar sigmax("sigmax","width of gaussian x",1) ;
RooRealVar sigmay("sigmay","width of gaussian y",5) ;

RooGaussian gaussx("gaussx","gaussian PDF",x,meanx,sigmax) ;
RooGaussian gaussy("gaussy","gaussian PDF",y,meany,sigmay) ;

// C o n s t r u c t   u n c o r r e l a t e d   p r o d u c t   p d f
// -------------------------------------------------------------------

// Multiply gaussx and gaussy into a two-dimensional p.d.f. gaussxy
RooProdPdf  gaussxy("gaussxy","gaussx*gaussy",RooArgList(gaussx,gaussy)) ;

// S a m p l e   p d f ,   p l o t   p r o j e c t i o n   o n   x   a n d   y
// ---------------------------------------------------------------------------

// Generate 10000 events in x and y from gaussxy
RooDataSet *data = gaussxy.generate(RooArgSet(x,y),10000) ;

// Plot x distribution of data and projection of gaussxy on x = Int(dy) gaussxy(x,y)
RooPlot* xframe = x.frame(Title("X projection of gauss(x)*gauss(y)")) ;
data->plotOn(xframe) ;
gaussxy.plotOn(xframe) ;

// Plot x distribution of data and projection of gaussxy on y = Int(dx) gaussxy(x,y)
RooPlot* yframe = y.frame(Title("Y projection of gauss(x)*gauss(y)")) ;
data->plotOn(yframe) ;
gaussxy.plotOn(yframe) ;

// Make canvas and draw RooPlots
TCanvas *c = new TCanvas("rf304_uncorrprod","rf304_uncorrprod",800, 400);
c->Divide(2);
c->cd(1) ; gPad->SetLeftMargin(0.15) ; xframe->GetYaxis()->SetTitleOffset(1.4) ; xframe->Draw() ;
c->cd(2) ; gPad->SetLeftMargin(0.15) ; yframe->GetYaxis()->SetTitleOffset(1.4) ; yframe->Draw() ;

}

```
rf304_uncorrprod.C:1
rf304_uncorrprod.C:2
rf304_uncorrprod.C:3
rf304_uncorrprod.C:4
rf304_uncorrprod.C:5
rf304_uncorrprod.C:6
rf304_uncorrprod.C:7
rf304_uncorrprod.C:8
rf304_uncorrprod.C:9
rf304_uncorrprod.C:10
rf304_uncorrprod.C:11
rf304_uncorrprod.C:12
rf304_uncorrprod.C:13
rf304_uncorrprod.C:14
rf304_uncorrprod.C:15
rf304_uncorrprod.C:16
rf304_uncorrprod.C:17
rf304_uncorrprod.C:18
rf304_uncorrprod.C:19
rf304_uncorrprod.C:20
rf304_uncorrprod.C:21
rf304_uncorrprod.C:22
rf304_uncorrprod.C:23
rf304_uncorrprod.C:24
rf304_uncorrprod.C:25
rf304_uncorrprod.C:26
rf304_uncorrprod.C:27
rf304_uncorrprod.C:28
rf304_uncorrprod.C:29
rf304_uncorrprod.C:30
rf304_uncorrprod.C:31
rf304_uncorrprod.C:32
rf304_uncorrprod.C:33
rf304_uncorrprod.C:34
rf304_uncorrprod.C:35
rf304_uncorrprod.C:36
rf304_uncorrprod.C:37
rf304_uncorrprod.C:38
rf304_uncorrprod.C:39
rf304_uncorrprod.C:40
rf304_uncorrprod.C:41
rf304_uncorrprod.C:42
rf304_uncorrprod.C:43
rf304_uncorrprod.C:44
rf304_uncorrprod.C:45
rf304_uncorrprod.C:46
rf304_uncorrprod.C:47
rf304_uncorrprod.C:48
rf304_uncorrprod.C:49
rf304_uncorrprod.C:50
rf304_uncorrprod.C:51
rf304_uncorrprod.C:52
rf304_uncorrprod.C:53
rf304_uncorrprod.C:54
rf304_uncorrprod.C:55
rf304_uncorrprod.C:56
rf304_uncorrprod.C:57
rf304_uncorrprod.C:58
rf304_uncorrprod.C:59
rf304_uncorrprod.C:60
rf304_uncorrprod.C:61
rf304_uncorrprod.C:62
rf304_uncorrprod.C:63
rf304_uncorrprod.C:64
rf304_uncorrprod.C:65
rf304_uncorrprod.C:66
rf304_uncorrprod.C:67
rf304_uncorrprod.C:68
rf304_uncorrprod.C:69
rf304_uncorrprod.C:70
rf304_uncorrprod.C:71
rf304_uncorrprod.C:72
rf304_uncorrprod.C:73
rf304_uncorrprod.C:74
rf304_uncorrprod.C:75
rf304_uncorrprod.C:76
rf304_uncorrprod.C:77
rf304_uncorrprod.C:78
rf304_uncorrprod.C:79
rf304_uncorrprod.C:80
rf304_uncorrprod.C:81
rf304_uncorrprod.C:82
rf304_uncorrprod.C:83
rf304_uncorrprod.C:84