Le KumaC++ de l’exercice 2
hprof->Fit("pol2"); // on fitte l'histogramme "hprof" avec un polynome de
// on recupere la fonction de fit
TF1 *pol2=(TF1 *)hprof->GetListOfFunctions()->FindObject("pol2");
// on aurait aussi pu taper:
// TF1 *pol2=hprof->GetFunction("pol2");
pol2->SetLineColor(kRed);
hprof->SetMarkerColor(kGreen); // on met la couleur de hprof a vert
hprof->SetMarkerStyle(21); // on met ses symboles (marqueurs) a carre plein
hprof->Draw("P"); // on dessine hprof avec des marqueurs
// la fonction de fit est automatiquement dessinee
// On cree une legende X1 Y1 X2 Y2 titre
TLegend *leg=new TLegend(0.3,0.6,0.7,0.7,"Legende");
leg->AddEntry(hprof,"histogramme"); // on ajoute la ligne liee a hprof
leg->AddEntry(pol2,"fit polynome degre 2"); // on ajoute la ligne liee a pol2
leg->Draw(); // on la dessine
cp /home/mra1/Jour2/exo_2_legende.C ./