Integral Error --- Have to coerce the answer out

Hello ROOT Experts,

This forum is great help. I have an odd issue coercing the Integral Error out of root for a fit…

This works:

 for i in xrange(3):
            for j in xrange(3):
                print "sub", i,j, fitEEOne['results'].GetCovarianceMatrix().GetSub(5,7,5,7)[i][j]

        print fitEEOne['fit'].Integral(60,120), fitEEOne['fit'].IntegralError(60,120)

        print fitEEOne['fit'].Integral(60,120), fitEEOne['fit'].IntegralError(60,120,fitEEOne['fit'].GetParameters(),fitEEOne['results'].GetCovarianceMatrix().GetMatrixArray())

        print integralEE_BG.Integral(60,120), integralEE_BG.IntegralError(60,120,integralEE_BG.GetParameters(),fitEEOne['results'].GetCovarianceMatrix().GetSub(5,7,5,7).GetMatrixArray())

and outputs…

sub 0 0 3.18299368645e-313 sub 0 1 -13.9635556879 sub 0 2 0.0773908824872 sub 1 0 -13.9635556879 sub 1 1 0.336395082676 sub 1 2 -0.00187012092587 sub 2 0 0.0773908824872 sub 2 1 -0.00187012092587 sub 2 2 1.04227241802e-05 Error in <TF1Helper::IntegralError>: Last used Fitter has different parameter values 5500.28551164 0.0 <--- This 0.0 and the line above is understood 5500.28551164 149.783022093 570.424583945 76.3280309576

However if I remove the line…

The output becomes…

sub 0 0 3.18299368645e-313 sub 0 1 -13.9635556879 sub 0 2 0.0773908824872 sub 1 0 -13.9635556879 sub 1 1 0.336395082676 sub 1 2 -0.00187012092587 sub 2 0 0.0773908824872 sub 2 1 -0.00187012092587 sub 2 2 1.04227241802e-05 5500.28551164 nan <--- Notice that NAN 570.424583945 76.3280309576

Finally if I remove…

[code] for i in xrange(3):
for j in xrange(3):
print “sub”, i,j, fitEEOne[‘results’].GetCovarianceMatrix().GetSub(5,7,5,7)[i][j]

print fitEEOne[‘fit’].Integral(60,120), fitEEOne[‘fit’].IntegralError(60,120,fitEEOne[‘fit’].GetParameters(),fitEEOne[‘results’].GetCovarianceMatrix().GetMatrixArray())
[/code]

The output becomes…

570.424583945 9.55588409826e-144 <--- Gibberish number

Thoughts?

Thanks,
Michael

Any ideas? Perhaps even an insight into if this is an error on my part or a bug in Root?

Thanks,
Michael

Still trying to work this out… before I was storing the fit results and trying to use them later on thinking the pointer might be corrupt/replaced. So I changed my code to try and use it immediately but still no luck… Sometimes it works sometimes it doesn’t.

[code] fitResults = plot.Fit(f1,“SQr”)

    bgFit = ROOT.TF1(name+"_bkg",backgroundFunction,60,120,3);
    bgFit.SetParameters(f1.GetParameter(5), f1.GetParameter(6), f1.GetParameter(7));
    bgFit.SetParError(0, f1.GetParError(5));  
    bgFit.SetParError(1, f1.GetParError(6)); 
    bgFit.SetParError(2, f1.GetParError(7));

    fullCovMatrix = fitResults.GetCovarianceMatrix().GetMatrixArray()
    subCovMatrix = fitResults.GetCovarianceMatrix().GetSub(5,7,5,7).GetMatrixArray()

    SG_Integral = f1.Integral(60,120);
    SG_IntegralError = f1.IntegralError(60,120,f1.GetParameters(),fullCovMatrix)
    
    BG_Integral = bgFit.Integral(60,120);
    BG_IntegralError = bgFit.IntegralError(60,120,bgFit.GetParameters(),subCovMatrix)

    print  {'SG_Integral': SG_Integral, 'SG_IntegralError': SG_IntegralError, 'BG_Integral': BG_Integral, 'BG_IntegralError': BG_IntegralError}

[/code]

My next step is just going to try and do it by hand following… root.cern.ch/root/html/tutorials … ral.C.html

Lorenzo will process your mail once he is back from Taiwan.
Rene

Hi Rene,

Thanks for the reply. Do you have an est time frame? Just seeing if I should seek an alternative method or not.

Thanks again,
Michael

Hi,

I would need your complete code to understand your problem. I suggest you to use the latest TF1::IntegralError method introduced in 5.27.06, which can take fit parameters and a covariance matrix as input. You can retrieve those from the TFitResult. This should work in your case

Lorenzo

Hi Lorenzo,

Thanks very much for taking the time to help. I checked out and compiled the Trunk as of earlier this week. I am using to the best of my knowledge the latest TF1::IntegralError function that takes fit parameters and a cov matrix. I have attached the code. It is part of a larger framework which fills the histograms but you should be able to see clearly the part I am referring to, though you won’t be able to run it straight up.

Thanks,
Michael
PixelMatchEff_CrystalBall_v2.py (16.5 KB)

Hi Lorenzo,

I was just checking in that and ensure you were able to parse my code. Thanks again for looking into this issue.

Michael

Hi,

it looks to me as a Python problem, something must be corrupted. I cannot run your script due to some missing modules, so I cannot help you very much. If you can reduce it to a simple script which can be run using only PyROOT I can have a look or ask Wim (the PyROOT expert) to have a look into it

Best Regards

Lorenzo

Hi,

same here, I’m at a loss for a possible cause, so either a simple script or providing the needed setup/extra modules to run the given one is needed.

Cheers,
Wim