Dear developers,
I have a question regardin writing a TF3 object to a root file.
I have a macro foo.C:
[code]
double hc = 0.197327;
double C3FitFunc3D(double x, double par)
{
double Ri12Q = x[0]par[3]/hc;
double Ri23Q = x[1]par[3]/hc;
double Ri31Q = x[2]par[3]/hc;
double Rp12Q = x[0]50/hc;
double Rp23Q = x[1]50/hc;
double Rp31Q = x[2]50/hc;
double fc = par[1];
double pc = par[2];
double a = par[4];
double Si12 = exp(-0.5pow(abs(Ri12Q),a));
double Si23 = exp(-0.5pow(abs(Ri23Q),a));
double Si31 = exp(-0.5pow(abs(Ri31Q),a));
double Sp12 = exp(-0.5pow(abs(Rp12Q),a));
double Sp23 = exp(-0.5pow(abs(Rp23Q),a));
double Sp31 = exp(-0.5pow(abs(Rp31Q),a));
return par[0]+fcfc(1-pc)((1-pc)Si12Si12+2pcSi12Sp12+
(1-pc)Si23Si23+2pcSi23Sp23+
(1-pc)Si31Si31+2pcSi31Sp31)+
2fcfcfc(1-pc)(1-pc)((1-pc)Si12Si23Si31+
pc(Si12Si23Sp31+Si12Sp23Si31+Sp12Si23Si31));
}[/code]
I do in root interactively:
root [0] .L foo.C
root [1] TF3 * c3func = new TF3("c3func",C3FitFunc3D,0,0.15,0,0.15,0$
root [2] c3func->SetParameters(1.0,1.0,0.276299,6.34383,1.74912);
root [3] cerr << c3func->Eval(0.01,0.01,0.01) << endl;
3.71442
root [4] cerr << c3func->Eval(0.1,0.1,0.1) << endl;
1.00172
root [5] f = new TFile("try3.root","RECREATE");
root [6] c3func->Write();
root [7] f.Write();
root [8] .ls
TFile** try3.root
TFile* try3.root
KEY: TF3 c3func;1 C3FitFunc3D
root [9] .q
After that:
root [0] new TFile("try3.root");
root [1] .ls
TFile** try3.root
TFile* try3.root
KEY: TF3 c3func;1 C3FitFunc3D
root [2] cerr << c3func->Eval(0.1,0.1,0.1) << endl;
1.92592
root [3] cerr << c3func->Eval(0.01,0.01,0.01) << endl;
4.27538
How can that be? How can a different function in the written file than it was before?
I also tried c3func->Save(0,0.15,0,0.15,0,0.15), but it did not help. But the saved function seems not to be ‘completely random’, but something like 2x the original one.
It would be great if you could tell me why this is happening, or (more importantly), how to fix this behavior.
I use ROOT 4.01/02 under Scientific Linux 3.0.1.
Thanks,
Mate Csanad