Hello root experts,
I’m trying to build a pdf using RooGenericPdf, and then generate data using the new pdf. Hence, I would like to get the following 10 parameters: a1, a2, a3, b1, b2, b3, b4, c1, c2, c3, and c4. But I had no luck with it. Here’s what I’m trying to do:
#include "RooFormulaVar.h"
#include "RooGenericPdf.h"
#include "RooRealVar.h"
#include "RooArgSet.h"
#include "RooConstVar.h"
#include "RooProduct.h"
using namespace RooFit ;
void read(){
RooRealVar* m4l = new RooRealVar("m4l","m4l",200, 2000);
RooConstVar* m0 = new RooConstVar("m0","m0", 265);
RooConstVar a1("a1","a1", 100);
RooConstVar a2("a2","a2", 100);
RooConstVar a3("a3","a3", 100);
RooConstVar b1("b1","b1", 0.5);
RooConstVar b2("b2","b2", 0.5);
RooConstVar b3("b3","b3", 0.5);
RooConstVar c1("c1","c1", 0.0005);
RooConstVar c2("c2","c2",-0.0003);
RooConstVar c3("c3","c3", 0.00001);
RooConstVar c4("c4","c4", 0.0005);
RooFormulaVar* f1m4l = new RooFormulaVar("f1m4l","(0.5+0.5*TMath::Erf((@0-@1)/@2))*(1./(1.0+TMath::Exp((@0-@1)/@3)))", RooArgList(*m4l,a1,a2,a3));
RooFormulaVar* f1m0 = new RooFormulaVar("f1m0", "(0.5+0.5*TMath::Erf((@0-@1)/@2))*(1./(1.0+TMath::Exp((@0-@1)/@3)))", RooArgList(*m0,a1,a2,a3));
RooFormulaVar* f2m4l = new RooFormulaVar("f2m4l","TMath::Exp(@1+@2*@0)", RooArgList(*m4l,b1,b2));
RooFormulaVar* f2m0 = new RooFormulaVar("f2m0", "TMath::Exp(@1+@2*@0)", RooArgList(*m0 ,b1,b2));
RooFormulaVar* f3m4l = new RooFormulaVar("f2m4l","TMath::Exp(@1+@2*@0+@3*TMath::Power(@0,2.0)+@4*TMath::Power(@0,2))", RooArgList(*m4l,c1,c2,c3,c4));
RooFormulaVar* f3m0 = new RooFormulaVar("f2m0", "TMath::Exp(@1+@2*@0+@3*TMath::Power(@0,2.0)+@4*TMath::Power(@0,2))", RooArgList(*m0 ,c1,c2,c3,c4));
RooFormulaVar* Cnorm = new RooFormulaVar("Cnorm","@2/(@0+@1)", RooArgList(*f1m0,*f2m0,*f3m0));
RooFormulaVar* StepFuncLow = new RooFormulaVar("StepFuncLow" ,"1.0*(@0<@1)", RooArgList(*m4l, *m0));
RooFormulaVar* StepFuncHigh = new RooFormulaVar("StepFuncHigh","1.0*(@0>=@1)",RooArgList(*m4l, *m0));
RooFormulaVar* fm4l = new RooFormulaVar("fm4l","(@0+@1)*@2*@3 + @4*@5",RooArgList(*f1m4l, *f2m4l, *StepFuncLow, *Cnorm, *f3m4l, *StepFuncHigh));
RooGenericPdf* func = new RooGenericPdf("func","@0",RooArgList(*fm4l));
f1m4l->Print();
f1m0->Print();
f2m4l->Print();
f2m0->Print();
f3m4l->Print();
f3m0->Print();
func->Print();
RooDataSet *data = func->generate(*m4l, 20000);
RooPlot* frame = m4l->frame();
func->fitTo(*data);
data->plotOn(frame);
func->plotOn(frame);
}
Any help will be very much appriciated.
Cheers,
Abdualazem.