Fitting with fitpanel removes text from canvas

Hello,

I have the problem that fitting with the Fitpanel removes the text from the canvas written with TText.
As an example I modified the myfit.C macro from the tutorial
by adding:

hpx->FitPanel();
TText *text = new TText(0, 0, “”);
text->DrawTextNDC(0.25,0.01,“test”);


Double_t fitf(Double_t *x, Double_t *par)
{
Double_t arg = 0;
if (par[2] != 0) arg = (x[0] - par[1])/par[2];

Double_t fitval = par[0]TMath::Exp(-0.5arg*arg);
return fitval;
}
void myfit()
{
TString dir = gSystem->UnixPathName(gInterpreter->GetCurrentMacroName());
dir.ReplaceAll(“myfit.C”,"…/hsimple.C");
dir.ReplaceAll("/./","/");
if (!gInterpreter->IsLoaded(dir.Data())) gInterpreter->LoadMacro(dir.Data());
TFile hsimple = (TFile)gROOT->ProcessLineFast(“hsimple(1)”);
if (!hsimple) return;

TCanvas *c1 = new TCanvas(“c1”,“the fit canvas”,500,400);

TH1F hpx = (TH1F)hsimple->Get(“hpx”);

// Creates a Root function based on function fitf above
TF1 *func = new TF1(“fitf”,fitf,-2,2,3);

// Sets initial values and parameter names
func->SetParameters(100,0,1);
func->SetParNames(“Constant”,“Mean_value”,“Sigma”);

// Fit histogram in range defined by function
hpx->Fit(func,“r”);
hpx->FitPanel();
TText *text = new TText(0, 0, “”);
text->DrawTextNDC(0.25,0.01,“test”);

// Gets integral of function between fit limits
printf(“Integral of function = %g\n”,func->Integral(-2,2));
}

Clicking on Fit will remove the text. How can I avoid that?

Thank You,

Bertrand Roessli

Seems to me it is because the fit panels redraws the canvas…
Which is normal I guess…