Fit Simulation to Data by scaling the spectrum (TH1)

Hi there,

I’m currently trying to fit an obtained data spectrum (TH1) with two simulated spectra (each a TH1) that have different distinct peaks. So in principal I’d like to fit both MC spectra to the data by scaling in order to derive the fraction of SimSpectrum1 to SimSpectrum2.

I guess that the appropriate way is to minimize the residuals between Data and SimSpectrum1+SimSpectrum2.
Does such a fitting algorithm/method already exist in ROOT?
Or can you use TH1::Fit somehow, i.e. create a user-defined function aSimSpectrum1(TH1) + bSimSpectrum2(TH1)?

I have the feeling that the answer should be easy, however I couldn’t find anything in the Class References or by using Google.

Thank you very much!

Allright, I think I’ve solved it in analogy to root.cern.ch/root/htmldoc/tutor … ist.C.html (just without the additional function, line 24-31).

Now I have another short question: Is there a fast method to change the definition of the ChiSquare (i.e the equation used for calculating the ChiSquare) that is used for the fitting?
I’ve small statistics, so I’d like to change the gaussian distribution in the ChiSquare definition with a poisson one (complicated to explain in a short sentence).

Or do I have to use TMinuit manually :cry: