Problem with TF1 with parameters

Dear ROOT experts,

I defined a C function that I use to create a TF1 with parameters. [*]
I store it in a root file to use it later in another code.

However when trying to use it with different sets of parameters, for a fixed input variable value, I get always the same output value.

It seems that it is blocked on one given set of parameters and does not take into account different parameters when trying “EvalPar” or “SetParameters” methods.

Would you have an idea of what is going on ?

Here is an extract of [*] :

[quote]Double_t myFuncTurnOnMu(Double_t *x, Double_t *par) {

Double_t pt = x[0];
Double_t eta = par[0];
Int_t run = (Int_t)par[1];
Int_t ratio = (Int_t)par[2];

const int nEta=6;
const int nRun=7;

ratioEfficiencyTest* fitEffMu[nRun][nEta];

fitEffMu[0][0] = new ratioEfficiencyTest(16.9993, 8.82202e-05, 7.91529e-08, 1.40792, 0.928102);
fitEffMu[0][1] = new ratioEfficiencyTest(16.9824, 0.0694986, 0.0186614, 1.66577, 0.908218);
// choose iEta //
int iEta;
if(eta < -1.2) iEta = 0;
if(ratio==0) return fitEffMu[run][iEta]->turnOn(pt) ;

else {
if(run>=0 && run<=3)
return fitEffMu[4][iEta]->turnOn(pt)!=0 ? fitEffMu[run][iEta]->turnOn(pt) / fitEffMu[4][iEta]->turnOn(pt) : 0;

Thanks in advance !

An additional detail : here is how I create the TF1 from the C function :

[quote] TF1 *turnOnMu = new TF1(“turnOnMu”, myFuncTurnOnMu, 0,800,3);

As far as I know, you are not allowed to “Clone” a TF1 function like yours. This might also mean that you are not allowed to “store” it in a root file (though I’m not sure about it).

Yes, I think that’s true since Clone should use the Streamer to make a copy. You can see that the function pointers in TF1 are marked //!, so they are not saved.

This is not surprising as ROOT would have to know how to copy the compiled code for the function, which, if possible, would not be platform independent. Your later code must redefine the TF1 itself.