After clicking the “Fit” button in the “Fit Panel”, try (warning: the address of the function created by the “Fit Panel” will change each time one clicks the “Fit” button): {
Double_t xmin = hspec->GetXaxis()->GetXmin();
Double_t xmax = hspec->GetXaxis()->GetXmax();
std::cout << "xmin = " << xmin << " , xmax = " << xmax << std::endl;
// a "temporary function" (pointer changes when the "Fit" button is clicked)
TF1 *f = hspec->GetFunction("PrevFitTMP"); // function created by Fit Panel
if (f) {
xmin = f->GetXmin(); // f->GetXmin(); ... or ... f->GetXaxis()->GetXmin();
xmax = f->GetXmax(); // f->GetXmax(); ... or ... f->GetXaxis()->GetXmax();
std::cout << "xmin = " << xmin << " , xmax = " << xmax << std::endl;
} else std::cout << "Fit function not found." << std::endl;
}