#include #include "TRandom3.h" #include "TCanvas.h" #include "TStyle.h" #include "TTree.h" int isotropic_3d(){ TRandom3 *ran = new TRandom3(); const double pi = 4*atan(1.0); TTree *t = new TTree("t","tree for isotropic 3d"); Double_t theta, phi, x, y, z; t->Branch("theta",&theta,"theta/D"); t->Branch("phi",&phi,"phi/D"); t->Branch("x",&x,"x/D"); t->Branch("y",&y,"y/D"); t->Branch("z",&z,"z/D"); for (int i=0; i<50000; i++){ theta = acos(-ran->Uniform(-1.0,1.0)); phi = ran->Uniform(0.0,2*pi); x = sin(theta)*cos(phi); y = sin(theta)*sin(phi); z = cos(theta); t->Fill(); } TCanvas *c1 = new TCanvas("c1", "c1"); gStyle->SetPadTopMargin(0.15); gStyle->SetLabelSize(0.05,"XYZ"); gStyle->SetTitleSize(0.10,""); gStyle->SetTitleXSize(0.05); gStyle->SetTitleXSize(0.05); gStyle->SetTitleYSize(0.05); c1->Divide(3,3); c1->cd(1); t->Draw("z:y:x","(x>0)&&(y>0)&&(z>0)"); c1->cd(2); t->Draw("theta"); c1->cd(3); t->Draw("phi"); c1->cd(4); t->Draw("x"); c1->cd(5); t->Draw("y"); c1->cd(6); t->Draw("z"); c1->cd(7); t->Draw("y:x"); c1->cd(8); t->Draw("z:x"); c1->cd(9); t->Draw("z:y"); return 0; }