void EffiFitTest() { TEfficiency* pEff = new TEfficiency("eff","my efficiency;x;#epsilon",20,0,10); TRandom3 rand3; bool bPassed; double x; for(int i=0; i<10000; ++i) { //simulate events with variable under investigation x = rand3.Uniform(10); //check selection: bPassed = DoesEventPassSelection(x) bPassed = rand3.Rndm() < TMath::Gaus(x,5,4); pEff->Fill(bPassed,x); } //create a function for fitting and do the fit TF1* f1 = new TF1("f1","gaus",0,10); f1->SetParameters(1,5,2); TFitResultPtr res = pEff->Fit(f1, "V S"); //!!!!!!! show that the returned fit result pointer is nullptr !!!!!!!! cout << res.Get() << endl; //!!!!!!! cause a crash !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (res.Get())->Print(); //create a threshold function TF1* f2 = new TF1("thres","0.8",0,10); f2->SetLineColor(kRed); //add it to the list of functions //use add first because the parameters of the last function will be displayed pEff->GetListOfFunctions()->AddFirst(f2); pEff->Draw("AP"); }