Here is an example //file iland.C Double_t fitlan(Double_t *x,Double_t *par) { Double_t result = par[0] * TMath::Landau(x[0],par[1], par[2]); return result; } void iland() { //generate N Landau signals, fit each one and evaluate the integral Int_t Nbins = 1000; TH1F *h = new TH1F("h","all signals",Nbins,0,Nbins); Int_t N = 10; Int_t i,j; Double_t MostProb, spread; for (i=0;i<N;i++) { MostProb = 100 + i*Nbins/Double_t(N); spread = 8+4*gRandom->Rndm(); Int_t NR = 100 + 5000*gRandom->Rndm(); for (j=0;j<NR;j++) { h->Fill(gRandom->Landau(MostProb,spread)); } } TF1 *signal = new TF1("signal",fitlan,0,1,3); for (i=0;i<N;i++) { MostProb = 100 + i*Nbins/Double_t(N); spread = 10; signal->SetParameters(10,MostProb,spread); Double_t from = MostProb-3*spread; Double_t to = MostProb+7*spread; signal->SetRange(from, to); h->Fit(signal,"+r"); Double_t integral = signal->Integral(from,to); printf("i=%d, integral=%g\n",i,integral); } h->Draw(); } in a root session, do root > .x iland.C Rene Brun On Tue, 12 Nov 2002, Praveen Boinee wrote: > Dear ROOTers > > I want to know how to make landau fit for the histograms using userdefined routines > > My task: i try to checking energy loss of positron due to ionisation using geant4 simulation......... >
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:17 MET