Generate with RooMultiVarGaussian gives vector type error

After a fit I need to define a multidimensional gaussian with a dimension per parameter and including all correlations. Then using RooAbsPdf::generate() I need to generate sets of random parameters with correlations.

In the allowing code “model” is the model I previously fit.

  RooArgSet * params = model->getParameters(RooDataSet("v","",RooArgSet(*var)));
  RooMultiVarGaussian * gauss = new RooMultiVarGaussian(
  RooDataSet * variations = gauss->generate(*params,nvariations);

All is ok up to the generate stage when I get this strange error (thousands of lines like this).

Error in <TVectorT::operator+=(const TVectorT &)>: vector’s not compatible
Error in <TVectorT::operator+=(const TVectorT &)>: vector’s not compatible

Any idea of what is the problem here?


Can you please provide us a running piece of code, so we can investigate this problem ?

Thank you


Hi Lorenzo,

I tried to make a basic example.

test.cpp (1.25 KB)

“Unfortunately” it works fine… but at least it makes clear what I want to do.
The actual code I’m running is part of a much more complex set of classes but in principle it does the same thing as the script.
Do you have any idea of what could cause that error in general?
It looks like a sort of type mismatch inside generate().



In the attached example no error is printed. I don’t understand why you are getting an error in a larger example. Unfortunately if I cannot reproduce the problem, there is little I can do to help you



I have understood what the problem is. It is happening when you fix one parameter and therefore the covariance matrix from the fit has a reduced size (it contains only the free parameters).
On the other hand you also do not want to generate variations for the fixed parameters, so you should remove them from the list of the parameters passed to generate().

You can see as example your modified test program

Best Regards


test.cpp (1.59 KB)

Hi Lorenzo,

yes I can confirm that that was one problem.
In addition a fit was failing with covQual=-1.
And therefore the MultiVarGaussian did not find a matrix.
Strange that it didn’t give a working though.

Thanks for your help,