{ // // Get random numbers and show the correlations // gROOT->Reset(); #include "myrand.h" int number_of_points=20000; int a=11679,c=32431,m=129029; // create canvas c1 = new TCanvas("c1","Distribution of Random Numbers",200,10,700,780); c1->SetGrid(); c1->SetFillColor(42); // pad for plot pad1 = new TPad("pad1","Pad for 1d rand numbers",0.02,0.62,0.98,0.98,21); pad2 = new TPad("pad2","Pad for 2d rand numbers",0.02,0.1,0.48,0.6,21); pad3 = new TPad("pad3","Pad for 3d rand numbers",0.50,0.1,0.98,0.6,21); pad4 = new TPad("pad4","Pad for Value output",0.02,0.02,0.98,0.08,21); pad1->Draw(); pad2->Draw(); pad3->Draw(); pad4->Draw(); prand=new CMyRand(); prand->setseed(10); prand->setpara(a,c,m); pad4->cd(); char text[80]; sprintf(text,"a = %d c = %d m = %d",a,c,m); rndtxt = new TText(0.1,0.1,text); rndtxt->SetTextSize(0.8); rndtxt->Draw(); pad1->cd(); pad1->SetGridx(); pad1->SetGridy(); // create 1d-Histo h1f = new TH1F("h1f","Random Numbers",20,0.0,1.0); h1f->SetMarkerStyle(21); h1f->SetMarkerSize(0.7); h1f->SetFillColor(2); h1f->Draw(); for(int i=1;i<=number_of_points;++i) { h1f->Fill(prand->getrand()); if(i%1000 == 0) { h1f->Draw(); c1->Modified(); c1->Update(); } } // check correlation between 2 random numbers pad2->cd(); pad2->SetGridx(); pad2->SetGridy(); nt2d = new TNtuple("nt2d","2D Random numbers","r1:r2:i"); for(int i=1;i<=number_of_points;++i) { float x,y; x=prand->getrand(); y=prand->getrand(); nt2d->Fill(x,y,i); } // now draw the Ntuple entries nt2d->SetMarkerStyle(20); nt2d->SetMarkerSize(0.3); nt2d->SetMarkerColor(5); nt2d->Draw("r1:r2"); c1->Modified(); c1->Update(); // check correlation between 3 random numbers // create NTuple with random numbers pad3->cd(); nt3d = new TNtuple("nt3d","3D Random numbers","r1:r2:r3:i"); for(int i=1;i<=number_of_points;++i) { float x,y,z; x=prand->getrand(); y=prand->getrand(); z=prand->getrand(); nt3d->Fill(x,y,z,i); } // now draw the Ntuple entries nt3d->SetMarkerStyle(20); nt3d->SetMarkerSize(0.3); nt3d->SetMarkerColor(2); nt3d->Draw("r1:r2:r3"); nt3d->Draw("r1:r2:r3","r3<1.0 && r3>=0.6","same"); nt3d->SetMarkerColor(4); nt3d->Draw("r1:r2:r3","r3<0.3","same"); nt3d->SetMarkerColor(3); nt3d->Draw("r1:r2:r3","r3<0.6 && r3>=0.3","same"); c1->Modified(); c1->Update(); };