void FitTest() { TList* l = new TList; for (Int_t i = 0; i < 10; i++) { TH1D* h = new TH1D(Form("h%02d", i), Form("Histogram %02d", i), 20, -5., 5.); h->FillRandom("gaus"); l->Add(h); } TCanvas* c = new TCanvas; TListIter nextHist(l); TH1D* h; while ((h = (TH1D*) nextHist())) { c->cd(); h->Draw(); c->Update(); cout << "Do you want to fit this histogram [y/n]? " << flush; TString input; cin >> input; input.ToLower(); if (!input.BeginsWith("y")) continue; TF1* f1 = new TF1("user", "gaus", -5., 5.); h->FitPanel(); TList *lc = (TList*)gROOT->GetListOfCanvases(); TFitPanel *fitPanel = (TFitPanel*) lc->FindObject("R__fitpanel"); gClient->WaitFor((TGWindow*) fitPanel->GetCanvasImp()); // After this I would typically store the fitted function. } }