Attach a RooNumConvPdf to a RooWorkspace


My problem is that
1-I’m a beginner in RooFit :wink:
2-I don’t manage to attach a function to a workspace.
Below is part of the code I wrote (and which does not compile) :

  RooWorkspace m_RooFitWorkspace = new RooWorkspace("EfficiencyWorkspace","EfficiencyWorkspace") ;

//Defining the “physics signal” function
RooRealVar mean(“mean”,“mean”,90.2, 80.,120. );
RooRealVar width(“width”,“width”, 2.495, 0.,5.);
RooBreitWigner* Model= new RooBreitWigner(“Model”,“Model”,x,mean,width);
//Defining the “detector resolution” function
RooRealVar mean2(“mean2”,“mean2”,0.); //, -0.2, 0.2
RooRealVar ResSigma(“ResSigma”,“ResSigma”,2.,0.,6.);
RooRealVar alfa (“alfa”,“alfa”,0.6,0.,10.);
RooRealVar n(“n”,“n”,2., 0.,50.);
RooCBShape* ResModel= new RooCBShape (“ResModel”,“ResModel”,x, mean2, ResSigma, alfa, n);
// convolute signal with resolution (40 is the integration range scale)
RooNumConvPdf* SigModel= new RooNumConvPdf (“SigModel”, “SigModel”, x, *Model, *ResModel);
SigModel->setConvolutionWindow(mean2, ResSigma, 40.);

What I’d like to do is to attach the SigModel object to the workspace in order to allow for, from the workspace itself (i.e. outside the c++ function where SigModel is defined), being able to use this function (SigModel) to fit some data with a line like

I don’t know if this is clear…
Anyway, my main problem is that I don’t manage to attach a complex object like RooNumConvPdf (or even simpler objects like RooExponentials…) to a RooWorkspace.

Could you please provide any help to a newbie like I am ?

Thank you, Olivier.

I found the problem. It was a stupid c++ mistake, I forgot to add a * before the pointers to the functions…

Sorry for the noise, Olivier.