I have been using the Integrator function from Mathmore as part of a maximum likelihood fitting program that also uses Minuit. Occasionally the integrator gives me this error:
"gsl: qags.c:543: ERROR: number of iterations was insufficient
Default GSL error handler invoked."
The program then exits.
Is there a way of stopping my code from exiting when this error is encountered? If the integral fails I would like to record that it has and move on to the next fit in my program. I tried using the .Status() however my program stops running before it gets a chance to print that out.
Here is my current code. First I have a class that the integrator calls.
[code]//______________________________________________________________________________
// Calculate convolution of exp(-gamma * time) with a gaussian
class ConvExpG
{
public:
ConvExpG();
ConvExpG(double newGamma, double newSigma);
~ConvExpG();
double operator() (double time){ return 0.5TMath::Exp(pow(gammasigma,2)/2 - gammatime) * (1 + TMath::Erf( (time/sigma - gammasigma)/sqrt(2) )); };
void SetGamma( double newGamma) { gamma = newGamma; }
void SetSigma( double newSigma) { sigma = newSigma; }
protected:
double gamma, sigma;
};
ConvExpG::ConvExpG(){
gamma = 1;
sigma = 1;
}
ConvExpG::ConvExpG(double newGamma, double newSigma){
gamma = newGamma;
sigma = newSigma;
}
ConvExpG::~ConvExpG(){}
//______________________________________________________________________________
[/code]
and then in my main program I have:
[code]// Initialize exponential function to be passed to the integrator
ConvExpG decay(gammaL, sigma);
ROOT::Math::WrappedFunction wConvExpG(decay);
// Initialize integrator
ROOT::Math::Integrator ig(wConvExpG);
// Calculate integral from tMin to infinity of the convolution of exp(-gammaL * time) with a gaussian
cout << “Computing value of convExpGL” << endl;
double convExpGL = ig.IntegralUp(tMin);
cout << "Status of code " << ig.Status() << endl;
[/code]
I usually get:
“Computing value of convExpGL
Status of code 0”
but occasionally I get:
“Computing value of convExpGL
gsl: qags.c:543: ERROR: number of iterations was insufficient
Default GSL error handler invoked.
-bash-3.00$”