I observe something very strange: I divide a canvas into 4 pads and then use a custom fit to fit and draw 4 different distributions. When the macro is finished everythings looks fine, the plots are ok. But when I save the canvas as .eps file (File->Save as…) then in 2 pads (first and third) the fit (the line) decreases in height on the canvas and also inside the file (the fit values in the stat box don’t change).
Can anybody explain this behaviour and tell me a way around it?
Thanks,
Gerolf
Ps: I use ROOT 4.03/04
the last part of the macro:
TCanvas *cTile = new TCanvas(“ctile”,“ctile”,1);
cTile->Divide(2,2);
gStyle->SetOptFit(1);
here is an example. If you run the macro you should get 4 distributions fitted with a landau convoluted gaussian.
If you then choose File->Save->xxx.ps then the fit on the pad 1 and 3 changes.
I gzipped the files.
If you have problems running it, please tell me.
Thank you!
Gerolf
PS: Here is the simple macro:
void simpel()
{
TFile * f = TFile::Open(“Tile_muon_ene.root”);
gSystem->Load(“glfit_cpp.so”);
TCanvas *cTile = new TCanvas(“ctile”,“ctile”,1);
cTile->Divide(2,2);
gStyle->SetOptFit(1);
Your function glconv depends on a static global “Norm”.
When the function is evaluated (when the Paint function is called),
the latest value of Norm is used.
Instead you should introduce an additional parameter to your function
and fix it at the time you compute the effective value of Norm, ie
[code]void glfitmake(TH1F *h)
{
// Double_t par[4] = {1000.,0.001,0.0004,0.0005};
func = new TF1(“gslan2”,gslan2,0,1,4);
TF1 *funfit = new TF1(“glconv”,glconv,0,1,5);
Norm = (((Double_t) h->GetBinLowEdge(h->GetNbinsX()+1))-
((Double_t) h->GetBinLowEdge(1)))/h->GetNbinsX();
gBenchmark->Reset();
gBenchmark->Start(“glfit”);
funfit->SetParameters(par[0],par[1],par[2],par[3],Norm);
funfit->FixParameter(4,Norm);
funfit->SetParNames(“Constant”,“LandauMOP”,“LandauWidth”,“GaussSigma”,“Norm”);
printf(“Starting the fit with parameter values: %f %f %f %f\n”,par[0],par[1],par[2],par[3]);
h->Fit(“glconv”);
gBenchmark->Show(“glfit”);
}