Attach a RooNumConvPdf to a RooWorkspace

Hello,

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. );
m_RooFitWorkspace->import(mean);
RooRealVar width(“width”,“width”, 2.495, 0.,5.);
m_RooFitWorkspace->import(width);
RooBreitWigner* Model= new RooBreitWigner(“Model”,“Model”,x,mean,width);
m_RooFitWorkspace->import(Model);
//Defining the “detector resolution” function
RooRealVar mean2(“mean2”,“mean2”,0.); //, -0.2, 0.2
m_RooFitWorkspace->import(mean2);
RooRealVar ResSigma(“ResSigma”,“ResSigma”,2.,0.,6.);
m_RooFitWorkspace->import(ResSigma);
RooRealVar alfa (“alfa”,“alfa”,0.6,0.,10.);
m_RooFitWorkspace->import(alfa);
RooRealVar n(“n”,“n”,2., 0.,50.);
m_RooFitWorkspace->import(n);
RooCBShape* ResModel= new RooCBShape (“ResModel”,“ResModel”,x, mean2, ResSigma, alfa, n);
m_RooFitWorkspace->import(ResModel);
// convolute signal with resolution (40 is the integration range scale)
RooNumConvPdf* SigModel= new RooNumConvPdf (“SigModel”, “SigModel”, x, *Model, *ResModel);
m_RooFitWorkspace->import(SigModel);
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
m_RooFitWorkspace->get(“SigModel”)->fitTo(m_RooFitWorkspace->get(“mydata”));

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.