Problem when convolving RooHistPdf with Gaussian

Hi,

I met this problem when trying to convolve a RooHistPdf with a Gaussian and then to fit a RooDataSet using such function. The code is as follows:

    TFile* f=new TFile("/users/zhangfz/testarea/Zmumu/fit/fit_tmp.root");
    TTree *t = f->Get("Z_mumu");
    TH1F  *h = new TH1F("h","h",200,66.,116.);
    t->Project("h","z_mass");
    RooDataHist tmp("tmp","tmp",x,h);

    RooRealVar mean("mean","mean",91.1876,80,100) ;
    RooRealVar sigma("sigma","sigma",4.3,1,6);
    RooGaussian gauss("gauss","signal pdf 1",x,mean,sigma) ;
    RooHistPdf Z("Z","Z theoretical lineshape",x,tmp,2);
    RooNumConvPdf sig1("sig1","theoretical linshape (X) Guassian",x,Z,gauss);

    RooFitResult *fitresult = sig1.fitTo(data, Save(kTRUE),NumCPU(4));

After when after the fitting, there is nothing but the following error information:

[#0] ERROR:Eval -- RooAbsReal::logEvalError(sig1) evaluation error, 
 origin       : RooNumConvPdf::sig1[ Z(x) (*) gauss(x) ]
 message      : getLogVal() top-level p.d.f evaluates to zero or negative number
 server values: !origVar=x=90.9191, !origPdf=Z=128140/574857, !origModel=gauss=0.559062
[#0] ERROR:Eval -- RooAbsReal::logEvalError(sig1) evaluation error, 
 origin       : RooNumConvPdf::sig1[ Z(x) (*) gauss(x) ]
 message      : p.d.f normalization integral is zero
 server values: !origVar=x=89.2949, !origPdf=Z=50404.6/574857, !origModel=gauss=0.782325
[#0] ERROR:Eval -- RooAbsReal::logEvalError(sig1) evaluation error, 
 origin       : RooNumConvPdf::sig1[ Z(x) (*) gauss(x) ]
 message      : getLogVal() top-level p.d.f evaluates to zero or negative number
 server values: !origVar=x=89.2949, !origPdf=Z=50404.6/574857, !origModel=gauss=0.782325
RooRealMPFE::initialize(nll_sig1_data_b16f990_MPFE1) server process terminating
RooRealMPFE::initialize(nll_sig1_data_b16f990_MPFE2) server process terminating
[#1] INFO:NumericIntegration -- RooRealIntegral::init(sig1_Int[x]) using numeric integrator RooIntegrator1D to calculate Int(x)
[#0] ERROR:Eval -- RooAbsReal::logEvalError(sig1) evaluation error, 
 origin       : RooNumConvPdf::sig1[ Z(x) (*) gauss(x) ]
 message      : p.d.f normalization integral is zero
 server values: !origVar=x=83.7134, !origPdf=Z=7416.25, !origModel=gauss=0.836615
[#0] WARNING:Plotting -- At observable [x]=66 RooNumConvPdf::sig1[ Z(x) (*) gauss(x) ]
     p.d.f normalization integral is zero @ !origVar=x=66, !origPdf=Z=1407.5, !origModel=gauss=1.47581e-05
[#0] WARNING:Plotting -- At observable [x]=66.5 RooNumConvPdf::sig1[ Z(x) (*) gauss(x) ]
     p.d.f normalization integral is zero @ !origVar=x=66.5, !origPdf=Z=1380.62, !origModel=gauss=2.5368e-05
[#0] WARNING:Plotting -- At observable [x]=67 RooNumConvPdf::sig1[ Z(x) (*) gauss(x) ]

I have tried both RooNumConvPdf and RooFFTConvPdf, but the result is the same. Would you please help me with this? Many thanks in advance.

Cheers,
Fangzhou

I had a similar task. The solution is to use the RooGaussModel to smear and to have the correct ordering of variables:

    RooRealVar bias("bias","bias",-2,2) ;
    RooRealVar sigma("sigma","sigma",4.3,1,6);
    RooGaussModel gaussM("gaussM","signal pdf 1",x,bias,sigma) ;
    RooHistPdf Z("Z","Z theoretical lineshape",x,tmp,2);
    RooNumConvPdf sig1("sig1","theoretical lineshape (X) Gaussian",x,gaussM,Z);

Also works:

  x.setBins(10000,"fft");
  RooFFTConvPdf sig2("sig2","smeared distribution",x,Z,gaussM);

Cheers,
Andrius