9 void nucleus(Int_t nProtons = 40,Int_t nNeutrons = 60)
11 Double_t NeutronRadius = 60,
15 Double_t vol = nProtons + nNeutrons;
16 vol = 3 * vol / (4 * TMath::Pi());
18 NucleusRadius = distance * TMath::Power(vol, 1./3.);
21 TGeoManager * geom =
new TGeoManager(
"nucleus",
"Model of a nucleus");
22 geom->SetNsegments(40);
23 TGeoMaterial *matEmptySpace =
new TGeoMaterial(
"EmptySpace", 0, 0, 0);
24 TGeoMaterial *matProton =
new TGeoMaterial(
"Proton" , .938, 1., 10000.);
25 TGeoMaterial *matNeutron =
new TGeoMaterial(
"Neutron" , .935, 0., 10000.);
27 TGeoMedium *EmptySpace =
new TGeoMedium(
"Empty", 1, matEmptySpace);
28 TGeoMedium *Proton =
new TGeoMedium(
"Proton", 1, matProton);
29 TGeoMedium *Neutron =
new TGeoMedium(
"Neutron",1, matNeutron);
33 Double_t worldx = 200.;
34 Double_t worldy = 200.;
35 Double_t worldz = 200.;
37 TGeoVolume *top = geom->MakeBox(
"WORLD", EmptySpace, worldx, worldy, worldz);
38 geom->SetTopVolume(top);
40 TGeoVolume * proton = geom->MakeSphere(
"proton", Proton, 0., ProtonRadius);
41 TGeoVolume * neutron = geom->MakeSphere(
"neutron", Neutron, 0., NeutronRadius);
42 proton->SetLineColor(kRed);
43 neutron->SetLineColor(kBlue);
45 Double_t x, y, z, dummy;
47 while ( i< nProtons) {
48 gRandom->Rannor(x, y);
49 gRandom->Rannor(z,dummy);
50 if ( TMath::Sqrt(x*x + y*y + z*z) < 1) {
51 x = (2 * x - 1) * NucleusRadius;
52 y = (2 * y - 1) * NucleusRadius;
53 z = (2 * z - 1) * NucleusRadius;
54 top->AddNode(proton, i,
new TGeoTranslation(x, y, z));
59 while ( i < nNeutrons) {
60 gRandom->Rannor(x, y);
61 gRandom->Rannor(z,dummy);
62 if ( TMath::Sqrt(x*x + y*y + z*z) < 1) {
63 x = (2 * x - 1) * NucleusRadius;
64 y = (2 * y - 1) * NucleusRadius;
65 z = (2 * z - 1) * NucleusRadius;
66 top->AddNode(neutron, i + nProtons,
new TGeoTranslation(x, y, z));
70 geom->CloseGeometry();