Hi there,
Is there a way to somehow clear a TGraph ?
Here’s my problem.
I have this piece of code that works great, but when I run it twice, the output is different and I don’t know why.
The vectors are cleared properly so it doesn’t come from there.
Thank you very much,
TGraph *gr_kaon = new TGraph(vec_xx_kaon.size(),&vec_xx_kaon[0],&vec_yy_kaon[0]);
gr_kaon->SetMarkerStyle(21);
gr_kaon->SetMarkerColor(kBlue-6);
gr_kaon->SetMarkerSize(0.8);
gr_kaon->GetXaxis()->SetLimits(-50.,50.);
gr_kaon->GetYaxis()->SetRangeUser(-50.,50.);
TF1 *gr_kaon_fit;
double a_fit_kaon = 0.;
double b_fit_kaon = 0.;
if(vec_xx_kaon.size()>0){
gr_kaon->Fit("pol1","QCM");
gr_kaon_fit = gr_kaon->GetFunction("pol1");
gr_kaon_fit->SetLineWidth(2);
gr_kaon_fit->SetLineColor(4);
a_fit_kaon = gr_kaon_fit->GetParameter(1);
b_fit_kaon = gr_kaon_fit->GetParameter(0);
endl;
}
cout << "OUTPUT: " << a_fit_kaon << " " << b_fit_kaon << endl;