Hi - I am using ROOT5 34/36 version.
I have a histogram I would like to fit with a linear combination of four other histograms, like h = ah1+bh2+ch3+dh4, with a,b,c,d fitting parameters

Anybody has an simple/elegant example of how to do it?

I have googled the “fitting ROOT histograms with histograms”. Essentially,
I would like a fitting function to be represented as an linear combination of
4 histograms. I found the expression:

what are you exactly trying to achieve here? Are you sure, even if we manage to build a “histpdf” (and we can), that the fit will converge to something meaningful?

it is sim0ple - in Geant4 simulation I have an energy spectrum.
I have flagged the 4 different process that have different energy spectra
(electron contained in the detector, electron entered and then reflected form a detector, bremsstrahlung process in the detector, etc.
I can flag it in simulation, but I cannot know what process was effective
in real measurement. Rather then trying to find the analytic function
that somewhat describes the spectrum, I want to use the simulated energy
spectrum in GEANT4 and see that the fit of the measured spectrum gives
the same fractions of each process as in Mothe Carlo. The Monte Carlo spectrum should be fitted perfectly (within the statistics, if I use different MC runs
for total histogram and component individual-process histograms.

If you have multiple histograms that describe how your categories should look like and want to find out their relative fraction in some data histogram, you can use TFractionFitter.

It takes into account the limited statistics of your MC histograms as well.