# Fumili subfunction

Dear Rooters:
I have about 1000 sets of experimental data. each set of data has 6~10 points. The 1st point equals to the sum of other points multiplied by the coefficients. I know there is a subfunction called Fumili written in Fortran. You can call this Fumili subfunction to get the coefficients by minimizing chi2 distribution. Is there a c++ example for this function in root?

Thanks.

Hi,
in ROOT is possible to use the Fumili algorithm. It has been implemented both in the TFumili class and also in the Minuit2 package.
You can easly use for fitting an histogram or graph by switching the minimizer. Otherwise, for customized chi2 functions, I have already posted some examples in an old thread in the forum: root.cern.ch/phpBB2/viewtopic.php?t=7821

Please let me know if you have further questions,

Best Regards

Lorenzo

Hi, Lorenzo:
I want to do a calibration. I have total 20 PMTs and each physical event will fire 6~8 PMTs. The energy of this event will be deposited in these fired PMTs completely. I know the total energy of each event and the deposited energy in each PMT. If I want to get the coefficient of each PMT, I can let the total energy equal to the sum of the energy in each PMT multiplied by an initial coefficient. Then use Fumili to get the real coefficient. It seems difficulty to fit them in a histogram or graph.

Thanks,
Bo

In your case you can write a chi2 from the difference between the total energy (ETOT) and the reconstructed one (EREC). EREC will depend on the calibration constants which are the parameters of your fit.
If you have a linear dependency on these constant you can do a simple linear fitter, which is the fastest one, or using Fumili with a user provided chi2 function as in the example exampleFumili.C provided in the old forum thread ( root.cern.ch/phpBB2/download.php?id=3525 )

Best Regards

Lorenzo

Yes, it is linear dependency on these constants. I check the example of fitLinear2.C and make a simple test. Unfortunately, it seems not working.
test.C (831 Bytes)

HI,

you example does not work because you have some errors in your macro.
The array e[] and x[] is not correctly defined, it should be:

`````` double y[5] = {1.1, 2.1, 2.9, 4.05, 5.1};
double e[5] = {0.1, 0.1, 0.1, 0.1, 0.1};

for(int i=0; i<NN; i++)
for(int j=0; j<Ndim; j++)
x[j+i*Ndim]  = i+1;``````

However, with this data the linear fitter for f(x,y) = Ax+By will fail because the matrix is singular, since for every point x = y and A is 100% correlated with y. So you can reduce this problem to a simple fit for f(x) = Ax
If x is independent of y, the linear fit will work

Best Regards

Lorenzo
Lorenzo