RooFit: Fit with custom PDF not working

Dear RooFit-experts,

I have just started to use RooFit, but am somehow stuck.
What I want to do is fitting distributions with an “exponentially modified Gaussian distribution” (http://en.wikipedia.org/wiki/Exponentially_modified_Gaussian_distribution). For this I have implemented my own pdf class (GaussExpConv), using the RooClassFactory. I implemented the evaluate() method accordingly, and I can plot the resulting pdfs with predefined parameters - they look reasonable.

 Double_t GaussExpConv::evaluate() const 
 { 
   double val1 = exp(0.5*tau*(2*mean+tau*sig*sig-2*x));
   double val2 = erfc((mean+tau*sig*sig-x)/(sqrt(2)*sig));
   return 0.5*tau*val1*val2;
 } 

However, fitting fails: In my python macro I do

rooFits[k] = ROOT.GaussExpConv("rooFit_%d"%k,"rooFit_%d"%k,rooX,rooMean,rooSig,rooTau)
rooMean.Print()
result = rooFits[k].fitTo(rooHist,
                          ROOT.RooCmdArg("Optimize",False),
                          ROOT.RooCmdArg("Save",True))
rooMean.Print()
result.Print()

The fits converge after ~50-100 calls, there are no errors printed, but the parameters are unchanged. The fit result is empty.

FCN=111.756 FROM MINOS     STATUS=SUCCESSFUL     21 CALLS         155 TOTAL
                     EDM=8.79738e-08    STRATEGY= 1      ERROR MATRIX ACCURATE 
  EXT PARAMETER                                   STEP         FIRST   
  NO.   NAME      VALUE            ERROR          SIZE      DERIVATIVE 
   1  p0           1.67404e+02   4.90268e+00  -3.20256e-02   3.33877e-05
   2  p1           1.07053e+00   4.04102e-03   1.52869e-05   6.91878e-02
   3  p2           1.50264e-01   2.75660e-03   2.75660e-03  -2.60437e-01
RooRealVar::rooMean_22 = 1.07967 C  L(-INF - +INF) 
[#1] INFO:NumericIntegration -- RooRealIntegral::init(rooFit_22_Int[p]) using numeric integrator RooIntegrator1D to calculate Int(p)

  RooFitResult: minimized FCN value: -554.283, estimated distance to minimum: -999
                covariance matrix quality: 
                Status : 

    Floating Parameter    FinalValue +/-  Error   
  --------------------  --------------------------

First suspecting the erfc implementation, I changed the evaluate() method to return a simple TMath::Gaus, with the same effect: Fitting does not alter the model parameters.

When replacing the custom PDF with one of the predefined, e.g. the RooGaussian, however, the fit has the expected effect. What is going wrong? Why is there no error printed? How can I get more feedback?

Looking forward for your input,

Q.

Nobody?

It would already help a lot if I knew how to convince RooFit to tell me what’s WRONG. The Verbose and PrintLevel options don’t provide any useful output.

Cheers

Q.

Q, I stumbled across your question as I was looking for something else. This doesn’t answer your question, but might offer a quick alternative – If you’re just trying to fit a (gauss)(x)(exp), and if built-in functions seem to work, can you not use the built-in RooGExpModel (see root.cern.ch/root/html532/RooGExpModel.html)?

Evan