#include "TF1.h" #include "TH2F.h" #include "TPad.h" Double_t droite(Double_t *x, Double_t *par); void TestGetX(Int_t npx=100) { //Test inversion of linear function with TF1::GetX. //Use npx argument to change precision of inversion (calls SetNpx(npx)). TF1* func = (TF1*)gROOT->FindObject("my_func"); if(!func) func = new TF1("my_func", droite, 0, 5000, 2); func->SetNpx(npx); func->SetParameters(10.,10.); //histo pour la fonction inverse TH2F* h2 = (TH2F*)gROOT->FindObject("h2"); if(!h2) h2 = new TH2F("h2","x vs. y",1000,0,6000,500,0,500); else h2->Reset(); //remplit l'histo for(Double_t lite=0.;lite<=6000.;lite+=6.) h2->Fill(lite, func->GetX(lite)); if( gPad ) gPad->Modified(); else h2->Draw("box"); gPad->Update(); }