MINUIT2 passing gradient to Mnmigrad

I have a function which returns an std::vector. It is a 1 dimensional simulated spectrum (x,y) which I fit to a measured spectrum. The simplex method works well but I would like to try it with gradients for better error estimation. I could not get the migrad calculate (segmentation fault) the numerical gradients so I would like to feed the numerical gradient myself. I tried to implement it as FCNGradientBase class but I get an error message that my_new_gradient_class cannot be converted to FCNGradientBase. Does The FCNGradientBase class have to have the FCNBase function repeated in it or it is enough to “include” it amnog the includes. My numerical gradient functions is very similar to the one among the examples MnTutorials/QUAD4F.h but I am returning again std::vector containing the gradient of the spectrum. Can you return vectors in FCNBase and FCNGradientBase classes or in the function to be minimized?

Thansk

I have figured out that the answer for the above question is that one has to define the FCNGradientBase with the FCNBase in it. I have function implemented as a calss. It looks like this in a nutshell:

class spectrum_generator

spectrum_generator(params_to_fit){

calculate spectrum and return a output_spectrum as std:vector
}

I have got the operator() operator implemented:

double opertor()(int x){

double AAA = output_spectrum[x]
return AAA
}
In my FCNBase I have this function combined with measurement data. If I run the SIMPLEX minimization it does a good job and runs well.

I have a similar function calculating the gradient of the same spectrum. How do I add that into the FCNBase. If I rebuild it as FCNGradientBase then how do I add the gradient function (my gradient determined nummerically) Is it the Getgradient function or only the gradient(int x)?

Thanks

Zolo