mathGammaNormal.C

Go to the documentation of this file.
00001 // tutorial illustrating the use of TMath::GammaDist and TMath::LogNormal
00002 //Author: Anna Kreshuk
00003 void mathGammaNormal(){
00004   TCanvas *myc = new TCanvas("c1","gamma and lognormal",10,10,600,800);
00005   myc->Divide(1,2);
00006   TPad *pad1 = myc->cd(1);
00007   pad1->SetLogy();
00008   pad1->SetGrid();
00009 
00010   //TMath::GammaDist
00011   TF1 *fgamma = new TF1("fgamma", "TMath::GammaDist(x, [0], [1], [2])", 0, 10);
00012   fgamma->SetParameters(0.5, 0, 1);
00013   TF1 *f1 = fgamma->DrawCopy();
00014   f1->SetMinimum(1e-5);
00015   f1->SetLineColor(kRed);
00016   fgamma->SetParameters(1, 0, 1);
00017   TF1 *f2 = fgamma->DrawCopy("same");
00018   f2->SetLineColor(kGreen);
00019   fgamma->SetParameters(2, 0, 1);
00020   TF1 *f3 = fgamma->DrawCopy("same");
00021   f3->SetLineColor(kBlue);
00022   fgamma->SetParameters(5, 0, 1);
00023   TF1 *f4 = fgamma->DrawCopy("same");
00024   f4->SetLineColor(kMagenta);
00025   TLegend *legend1 = new TLegend(.2,.15,.5,.4);
00026   legend1->AddEntry(f1,"gamma = 0.5 mu = 0  beta = 1","l");
00027   legend1->AddEntry(f2,"gamma = 1   mu = 0  beta = 1","l");
00028   legend1->AddEntry(f3,"gamma = 2   mu = 0  beta = 1","l");
00029   legend1->AddEntry(f4,"gamma = 5   mu = 0  beta = 1","l");
00030   legend1->Draw();
00031 
00032   //TMath::LogNormal
00033   TPad *pad2 = myc->cd(2);
00034   pad2->SetLogy();
00035   pad2->SetGrid();
00036   TF1 *flog = new TF1("flog", "TMath::LogNormal(x, [0], [1], [2])", 0, 5);
00037   flog->SetParameters(0.5, 0, 1);
00038   TF1 *g1 = flog->DrawCopy();
00039   g1->SetLineColor(kRed);
00040   flog->SetParameters(1, 0, 1);
00041   TF1 *g2 = flog->DrawCopy("same");
00042   g2->SetLineColor(kGreen);
00043   flog->SetParameters(2, 0, 1);
00044   TF1 *g3 = flog->DrawCopy("same");
00045   g3->SetLineColor(kBlue);
00046   flog->SetParameters(5, 0, 1);
00047   TF1 *g4 = flog->DrawCopy("same");
00048   g4->SetLineColor(kMagenta);
00049   TLegend *legend2 = new TLegend(.2,.15,.5,.4);
00050   legend2->AddEntry(g1,"sigma = 0.5 theta = 0  m = 1","l");
00051   legend2->AddEntry(g2,"sigma = 1   theta = 0  m = 1","l");
00052   legend2->AddEntry(g3,"sigma = 2   theta = 0  m = 1","l");
00053   legend2->AddEntry(g4,"sigma = 5   theta = 0  m = 1","l");
00054   legend2->Draw();
00055 }
00056 

Generated on Tue Jul 5 15:44:50 2011 for ROOT_528-00b_version by  doxygen 1.5.1