[RooFit] Fit gives weird results

Dear Root / RooFit experts,

For our analysis, we are trying to fit a mass spectrum. What we are trying to do is :

  • First, fit the spectrum with background pdf only.
  • Set background pdf parameters as constant
  • Set signal pdf parameters as constant
  • Finally, Fit the spectrum with background + signal pdfs. This fit has only to floating parameters, number of expected signal events and number of expected background events.

The first fit works as expected, and give coherent results (data_2011_nominal_750_fitRes_crystalball_faltB_bkg_only.pdf (16.9 KB)). However, the second fit gives very weird results (data_2011_nominal_750_fitRes_crystalball_faltB.pdf (17.4 KB)). As you can see, RooFit fit no backgrounds and only signal. There’s no fit errors. Outputs :

First fit:

[code]Dataset entries: 12461

RooFitResult: minimized FCN value: 78249.4, estimated distance to minimum: 5.6447e-05
covariance matrix quality: Full, accurate covariance matrix
Status : MIGRAD=0 HESSE=0

Floating Parameter  InitialValue    FinalValue +/-  Error     GblCorr.

            muon_a    8.0000e+01    8.2559e+01 +/-  1.12e+01  <none>
            muon_b   -4.0000e+00   -3.9424e+00 +/-  7.51e-01  <none>
            muon_c    1.0000e+00    9.9810e-01 +/-  1.29e-01  <none>[/code]

Second fit:

[code]RooFitResult: minimized FCN value: -30667.7, estimated distance to minimum: 3.68337e-08
covariance matrix quality: Full, accurate covariance matrix
Status : MIGRAD=0 HESSE=0

Constant Parameter    Value     

            muon_a    8.2559e+01
        muon_alpha    3.2884e+00
            muon_b   -3.9424e+00
            muon_c    9.9810e-01
         muon_mean    7.3029e+02
            muon_n    2.4776e+00
        muon_sigma    8.0612e+01

Floating Parameter  InitialValue    FinalValue +/-  Error     GblCorr.

           nBkg_mu    1.2000e+04    1.3242e-08 +/-  1.21e+00  <none>
              nSig    0.0000e+00    1.2461e+04 +/-  1.12e+02  <none>[/code]

I forgot to tell that the signal pdf parameters are obtained fitting a MC signal.

A little bit of code:
Firt fit:

RooFitResult* fitResult = backgroundPdf.fitTo(*RedData, Save(), Optimize(1));

Second fit:

RooFitResult* fitResult = globalPdf.fitTo(*RedData, Save(), Optimize(1));

Does anybody have an idea or a solution ?

Many thanks,

Sébastien

It seems like I found the solution, even if I don’t really understand the difference :

Putting Optimize() to 0 on the second fit makes things work like we wanted!

It may be useful to someone else!

If someone can explain the differences between Optimize(1) and Optimize(0), and, more impostant, what kind of optimisation RooFit does which prevent the fit to works, it would be really great!

Many thanks!

Sébastien