Hey everyone,
I’m running ROOT 6.09 and I’m having some trouble when I try to integrate an interpolated function.
The code looks basically like this:
auto dIdzSpline = std::make_shared<TSpline3>("dI/dz Spline ", (double*)zGrid.data(),(double*)dIoverdz.data(), zGridSize);
std::vector<double> dNoverdE;
dNoverdE.resize(EGridSize*GammaGridSize);
TF1* dIdzdNdE = new TF1("Integrand dI/dz * dN/dE",
[dIdzSpline, source] (double* args, double* params)
{ return dIdzSpline->Eval(args[0]) * source->EnergySpectrum(params[0], args[0], params[1]); },
source->m_zBounds.first, source->m_zBounds.second, /*npar*/ 2);
for(int i = 0; i < EGridSize; i++)
{
for(int j = 0; j < GammaGridSize; j++)
{
dIdzdNdE->SetParameters(EGrid[i], GammaGrid[j]);
dNoverdE[i+j*GammaGridSize] = dIdzdNdE->Integral(source->m_zBounds.first, source->m_zBounds.second);
}
}
The execution fails with a Segmentation fault after a couple (~6) of loop iterations with the following call stack:
and error:
“received signal SIGSEGV, Segmentation fault.\n”
“malloc_consolidate (av=av@entry=0x7ffff6052b00 <main_arena>) at malloc.c:4216\n”
Is this my fault or is this a bug?
Thanks for your input,
Niklas