Hello Rooters,
I am using TH1::Fit to regress a complicated function on a histogram, like this:
Double_t yAll (Double_t*, Double_t*);
...
TF1 *fyAll = new TF1("fyAll", yAll, 0.0, tMax, nPars);
...
fyAll -> SetParameters(par);
...
TFitResultPtr fit = h1 -> Fit("fyAll", options);
...
Double_t yAll (Double_t *x, Double_t *p) { ...complicated function... }
The Fit routine, of course, starts with some values of the parameters, then evaluates fyAll on the domain (~1000 calls to yAll), then updates the parameters and re-evaluates fyAll on the domain, and so on.
My function yAll is complicated in the sense that it is the sum of many component functions. All of the component functions need access to a set of parameter-dependent values (PDV’s) that depend only on the parameters. Right now I am calculating the PDV’s in every component function, every time yAll is called. So the PDV’s are re-calculated many thousands of times for every one time that they actually change (ie. when the parameters are changed). This shortcut has turned into an appreciable amount of execution time.
My thought would be to make the PDV’s global and write a function that updates the PDV’s and is called immediately after the parameters are updated under Fit. Does ROOT provide a facility for doing this? I have not found such a thing described in the TH1 or TMinuit documentation. I have also tried looking through the source code a bit, but I’m not an expert programmer. Any help would be most appreciated!
I would be glad to make a code example if that would help.
Many thanks,
Shane