Hi
I am using root version v4-00-04 and I do multiple fits to a TH1F in one routine. Later on
I would like to draw the TH1F with the multiple fits. I think this is possible as the TH1F keeps the functions in a liist. When I do this I can only get the last function fitted.
The code below is a simple version on mine but exhibits the same behaviour - it complains about the existence of “formula” but not “fullformula”.
How can I retrieve both fits to draw them both in a later function?
Thanks,
Mark
[code]
void drawdouble()
{
TH1F* hist = new TH1F("hist","Test hist",100,-5,5);
hist->Sumw2();
hist->FillRandom("gaus",1000);
TF1* formula = new TF1("formula","[0]*exp(-0.5*((x-[1])/[2])**2)",-5,5);
TF1* fullformula = new TF1("fullformula","[0]*exp(-[2]*((x-[1]))**2)",-5,5);
hist->Fit("formula","R");
hist->Fit("fullformula","R");
Draw(hist);
}
void Draw(TH1F* hist)
{
TCanvas* c = new TCanvas("c","C");
((TF1*)hist->GetFunction("formula"))->SetLineColor(kBlue);
((TF1*)hist->GetFunction("formulafull"))->SetLineColor(kRed);
if (hist->GetFunction("formulafull")) ((TF1*)hist->GetFunction("formulafull"))->SetLineStyle(2);
hist->Draw();
if (hist->GetFunction("formula")) ((TF1*)hist->GetFunction("formula"))->Draw("same");
if (hist->GetFunction("formulafull")) ((TF1*)hist->GetFunction("formulafull"))->Draw("same");
c->Update();
}[/code]