Per-event fit using multi-dim gaussian consraint

Dear experts,

I am trying to perform a per-event mass fit using the kinematics of final state particles, and I use a pdf that is a product of

  • Analytical pdf that describes the distribution of some of the refitted derived variables
  • A product of multivariable gaussians that receive the covariance matrices from each of the final state particles and their measured 4-momenta to create Gaus( \vec{x_refit - x^bar_measured} C^-1 \vec{x_refit-x^bar_measured} )
  • Heaviside functions to have hard cuts on some derived variables after refit
  • Delta functions for (x_measured - x^bar_measured)

While performing the fit, x^bar_measured is fixed to x_measured in the data, and x_measured is used as the variable taken from the data. If I remove the delta functions and only keep x_measured (replacing x^bar_measured with x_measured everywhere), RooFit tries to integrate over x_measured, which is not what I want considering that the measured paramater in the gaussian has to remain fixed (it is defined per-event, and changing it to some other value does not make much sense).

When I get the fit result, I see

============== Second derivative zero for parameter1

and the second parameter always returns identical to the input (x_refit=x_measured==x^bar_measured).

How would I work around this issue?

I also have another question: I want to make this PDF conditional on a variable derived as a RooformulaVar from the fitted variables, which are RooRealVars. I added

RooArgSet conditionals;
conditionals.add((m[2])); // THIS IS THE ROOFORMULAVAR
RooCmdArg condObsArg = RooFit::ConditionalObservables(conditionals); cmdList.Add((TObject
and pass cmdList as
fitResult = activePDF->fitTo(*data, cmdList);

Would this method actually ensure the pdf is conditional on m[2], even though it is a RooFormulaVar from the actual refitted objects?

Thank you vey much for your support in advance,