本文整理汇总了C++中TGeoManager::MakeSphere方法的典型用法代码示例。如果您正苦于以下问题:C++ TGeoManager::MakeSphere方法的具体用法?C++ TGeoManager::MakeSphere怎么用?C++ TGeoManager::MakeSphere使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TGeoManager
的用法示例。
在下文中一共展示了TGeoManager::MakeSphere方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: robot
void robot()
{
// Drawing a famous Korean robot, TaekwonV, using ROOT geometry class.
// Name: robot.C
// Author: Jin Hui Hwang, Dept. of Physics, Univ. of Seoul
// Reviewed by Sunman Kim ([email protected])
// Supervisor: Prof. Inkyu Park ([email protected])
//
// How to run: .x robot.C in ROOT terminal, then use OpenGL
//
// This macro was created for the evaluation of Computational Physics course in 2006.
// We thank to Prof. Inkyu Park for his special lecture on ROOT and to all of ROOT team
//
TGeoManager *Robot = new TGeoManager("Robot", "This is Taegwon V");
TGeoMaterial *vacuum = new TGeoMaterial("vacuum", 0, 0, 0);
TGeoMaterial *Fe = new TGeoMaterial("Fe", 55.845, 26, 7.87);
TGeoMedium *Air = new TGeoMedium("Vacuum", 0, vacuum);
TGeoMedium *Iron = new TGeoMedium("Iron", 1, Fe);
// create volume
TGeoVolume *top = Robot->MakeBox("top", Air, 1000, 1000, 1000);
Robot->SetTopVolume(top);
Robot->SetTopVisible(0);
// If you want to see the boundary, please input the number, 1 instead of 0.
// Like this, geom->SetTopVisible(1);
// head
TGeoVolume *Band = Robot->MakeEltu("Band", Iron, 20, 20, 2.5);
Band->SetLineColor(12);
Band->SetFillColor(12);
TGeoVolume *Band_b = Robot->MakeSphere("Band_b", Iron, 0, 2, 0, 180, 180, 360);
Band_b->SetLineColor(2);
Band_b->SetFillColor(2);
TGeoVolume *Head = Robot->MakeSphere("Head", Iron, 0, 19, 0, 180, 180, 360);
Head->SetLineColor(17);
Head->SetFillColor(17);
TGeoVolume *Horn = Robot->MakeSphere("Horn", Iron, 0, 10, 60, 180, 240, 300);
// drawing head
top->AddNodeOverlap(Band, 1, new TGeoTranslation(0, 0, 90));
float Phi = 3.14;
int N = 10;
for (int i = 0; i <= N; i++) {
top->AddNodeOverlap(Band_b, 1, new TGeoCombiTrans(sin(2 * Phi / N * i) * 19, -cos(2 * Phi / N * i) * 19, 90,
new TGeoRotation("R1", -90 + (360 / N * i), -90, 90)));
}
top->AddNodeOverlap(Head, 1, new TGeoCombiTrans(0, 0, 87.5, new TGeoRotation("R2", 0, -90, 0)));
char name[50];
float pcs = 30;
for (int i = 1; i < pcs; i++) {
sprintf(name, "Horn%d", i);
Horn = Robot->MakeSphere(name, Iron, 10 - 10 / pcs * i, 10, 180 - (120 / pcs) * i, 180 - ((120 / pcs) * (i - 1)),
240, 300);
Horn->SetLineColor(2);
Horn->SetFillColor(2);
top->AddNodeOverlap(Horn, 1, new TGeoCombiTrans(0, 8, 102, new TGeoRotation("R2", 0, 140, 0)));
top->AddNodeOverlap(Horn, 1, new TGeoCombiTrans(0, -8, 102, new TGeoRotation("R2", 180, 140, 0)));
}
// face
TGeoVolume *Migan = Robot->MakeGtra("Migan", Iron, 3, 0, 0, 0, 3, 2, 11, 0, 3, 3, 11, 0);
Migan->SetLineColor(17);
Migan->SetFillColor(17);
TGeoVolume *Ko = Robot->MakeGtra("Ko", Iron, 7, 0, 0, 0, 3, 1, 5, 0, 3, 2, 5, 0);
Ko->SetLineColor(17);
Ko->SetFillColor(17);
TGeoVolume *Ko_m = Robot->MakeBox("Ko_m", Iron, 2, 8, 4);
Ko_m->SetLineColor(17);
Ko_m->SetFillColor(17);
TGeoVolume *Bol_1 = Robot->MakeBox("Bol_1", Iron, 7, 5.5, 7);
Bol_1->SetLineColor(17);
Bol_1->SetFillColor(17);
TGeoVolume *Bol_2 = Robot->MakeGtra("Bol_2", Iron, 1, 0, 0, 0, 7, 0, 9, 0, 7, 0, 9, 0);
Bol_2->SetLineColor(17);
Bol_2->SetFillColor(17);
TGeoVolume *Noon = Robot->MakeBox("Noon", Iron, 1, 10, 5);
Noon->SetLineColor(12);
Noon->SetFillColor(12);
TGeoVolume *Tuck = Robot->MakeBox("Tuck", Iron, 2, 10, 5.5);
Tuck->SetLineColor(2);
Tuck->SetFillColor(2);
TGeoVolume *Tuck_1 = Robot->MakeBox("Tuck_1", Iron, 2, 9, 1);
Tuck_1->SetLineColor(2);
Tuck_1->SetFillColor(2);
TGeoVolume *Tuck_2 = Robot->MakeBox("Tuck_2", Iron, 3, 1, 14);
Tuck_2->SetLineColor(2);
Tuck_2->SetFillColor(2);
TGeoVolume *Tuck_j = Robot->MakeSphere("Tuck_j", Iron, 0, 3.5, 0, 180, 0, 360);
Tuck_j->SetLineColor(5);
Tuck_j->SetFillColor(5);
TGeoVolume *Ear = Robot->MakeCons("Ear", Iron, 1, 0, 3, 0, 3, 0, 360);
Ear->SetLineColor(5);
Ear->SetFillColor(5);
TGeoVolume *Ear_2 = Robot->MakeCone("Ear_2", Iron, 5, 0, 0, 0, 3);
//.........这里部分代码省略.........
示例2: glViewerLOD
void glViewerLOD(Int_t reqNodes = 1000, Bool_t randomDist = kTRUE,
Bool_t reqSpheres = kTRUE, Bool_t reqTubes = kTRUE)
{
TGeoManager * geom = new TGeoManager("LODTest", "GL viewer LOD test");
geom->SetNsegments(4); // Doesn't matter keep low
TGeoMaterial *matEmptySpace = new TGeoMaterial("EmptySpace", 0, 0, 0);
TGeoMaterial *matSolid = new TGeoMaterial("Solid" , .938, 1., 10000.);
TGeoMedium *medEmptySpace = new TGeoMedium("Empty", 1, matEmptySpace);
TGeoMedium *medSolid = new TGeoMedium("Solid", 1, matSolid);
Double_t sizeBase = 20.0;
Double_t worldRadius;
if (randomDist) {
worldRadius = pow(reqNodes,.5)*sizeBase;
} else {
worldRadius = pow(reqNodes,.3)*sizeBase;
}
TGeoVolume *top = geom->MakeBox
("WORLD", medEmptySpace, worldRadius, worldRadius, worldRadius);
geom->SetTopVolume(top);
gRandom->SetSeed();
// Create random number of unique sphere shapes - up to 25% of
// total placed sphere requested
UInt_t volumeCount = gRandom->Integer(reqNodes/4)+1;
TGeoVolume ** volumes = new TGeoVolume[volumeCount];
TGeoVolume * volume;
Double_t dummy;
for (UInt_t i = 0; i < volumeCount; i++) {
char name[128];
sprintf(name, "Volume_%d", i);
// Random volume shape
Int_t type = -1;
if (reqSpheres && reqTubes) {
type = gRandom->Integer(2);
if (type == 1)
type += gRandom->Integer(3);
}
else if(reqSpheres)
type = 0;
else if(reqTubes)
type = 1 + gRandom->Integer(3);
// Random dimensions
Double_t rMin = gRandom->Rndm() * sizeBase;
Double_t rMax = rMin + gRandom->Rndm() * sizeBase * 2.0;
Double_t dz = pow(gRandom->Rndm(),2.0) * sizeBase * 15.0;
Double_t phi1 = gRandom->Rndm() * 90.0;
Double_t phi2 = phi1 + gRandom->Rndm() * 270.0;
// Pick random color (not black)
Int_t color = gRandom->Integer(50);
if (color == kBlack) color += 1;
switch (type) {
case 0: {
// GL viewer only supports solid spheres (0. inner radius)
volumes[i] = geom->MakeSphere(name, medSolid, 0., rMax);
printf("Volume %d : Color %d, Sphere, Radius %f\n", i, color, rMax);
break;
}
case 1: {
volumes[i] = geom->MakeTube(name, medSolid, rMin, rMax, dz);
printf("Volume %d : Color %d, Tube, Inner Radius %f, "
"Outer Radius %f, Length %f\n",
i, color, rMin, rMax, dz);
break;
}
case 2: {
volumes[i] = geom->MakeTubs(name, medSolid, rMin, rMax, dz,
phi1, phi2);
printf("Volume %d : Color %d, Tube Seg, Inner Radius %f, "
"Outer Radius %f, Length %f, Phi1 %f, Phi2 %f\n",
i, color, rMin, rMax, dz, phi1, phi2);
break;
}
case 3: {
Double_t n1[3], n2[3];
n1[0] = gRandom->Rndm()*.5;
n1[1] = gRandom->Rndm()*.5; n1[2] = -1.0 + gRandom->Rndm()*.5;
n2[0] = gRandom->Rndm()*.5;
n2[1] = gRandom->Rndm()*.5; n2[2] = 1.0 - gRandom->Rndm()*.5;
volumes[i] = geom->MakeCtub(name, medSolid, rMin, rMax, dz,
phi1, phi2, n1[0], n1[1], n1[2],
n2[0], n2[1], n2[2]);
printf("Volume %d : Color %d, Cut Tube, Inner Radius %f, "
"Outer Radius %f, Length %f, Phi1 %f, Phi2 %f, "
"n1 (%f,%f,%f), n2 (%f,%f,%f)\n",
i, color, rMin, rMax, dz, phi1, phi2,
n1[0], n1[1], n1[2], n2[0], n2[1], n2[2]);
break;
}
default: {
//.........这里部分代码省略.........
示例3: lego
void lego()
{
// Drawing a figure, made of lego block, using ROOT geometry class.
// Name: lego.C
// Author: Soon Gi Kwon([email protected]), Dept. of Physics, Univ. of Seoul
// Reviewed by Sunman Kim ([email protected])
// Supervisor: Prof. Inkyu Park ([email protected])
//
// How to run: .x lego.C in ROOT terminal, then use OpenGL
//
// This macro was created for the evaluation of Computational Physics course in 2006.
// We thank to Prof. Inkyu Park for his special lecture on ROOT and to all of ROOT team
//
TGeoManager *geom = new TGeoManager("geom","My first 3D geometry");
TGeoMaterial *vacuum=new TGeoMaterial("vacuum",0,0,0);
TGeoMaterial *Fe=new TGeoMaterial("Fe",55.845,26,7.87);
TGeoMedium *Air=new TGeoMedium("Vacuum",0,vacuum);
TGeoMedium *Iron=new TGeoMedium("Iron",1,Fe);
// create volume
TGeoVolume *top=geom->MakeBox("top",Air,100,100,100);
geom->SetTopVolume(top);
geom->SetTopVisible(0);
// If you want to see the boundary, please input the number, 1 instead of 0.
// Like this, geom->SetTopVisible(1);
//----------------------------------------------------------------------
TGeoVolume *ha1=geom->MakeSphere("ha1",Iron,0,10,80,90,0,360);
ha1->SetLineColor(41);
top->AddNodeOverlap(ha1,1,new TGeoCombiTrans(0,0,4,new TGeoRotation("ha1",0,0,0)));
TGeoVolume *ha2=geom->MakeSphere("ha2",Iron,0,7,90,180,0,360);
ha2->SetLineColor(41);
top->AddNodeOverlap(ha2,1,new TGeoCombiTrans(0,0,4,new TGeoRotation("ha2",0,180,0)));
TGeoVolume *ha3=geom->MakeSphere("ha3",Iron,0,7.3,80,90,0,360);
ha3->SetLineColor(2);
top->AddNodeOverlap(ha3,1,new TGeoCombiTrans(0,0,4.8,new TGeoRotation("ha3",0,0,0)));
TGeoVolume *h1=geom->MakeTubs("h1",Iron,0,6,4.5,0,0);
h1->SetLineColor(5);
top->AddNodeOverlap(h1,1,new TGeoCombiTrans(0,0,0,new TGeoRotation("h1",0,0,0)));
TGeoVolume *h2=geom->MakeSphere("h2",Iron,0,7.5,0,52.5,0,360);
h2->SetLineColor(5);
top->AddNodeOverlap(h2,1,new TGeoCombiTrans(0,0,0,new TGeoRotation("h2",0,0,0)));
TGeoVolume *h3=geom->MakeSphere("h3",Iron,0,7.5,0,52.5,0,360);
h3->SetLineColor(5);
top->AddNodeOverlap(h3,1,new TGeoCombiTrans(0,0,0,new TGeoRotation("h3",180,180,0)));
TGeoVolume *h4=geom->MakeTubs("h4",Iron,2.5,3.5,1.5,0,0);
h4->SetLineColor(5);
top->AddNodeOverlap(h4,1,new TGeoCombiTrans(0,0,7.5,new TGeoRotation("h4",0,0,0)));
TGeoVolume *t1_1=geom->MakeTubs("t1_1",Iron,0,0.8,1,0,360);
t1_1->SetLineColor(12);
top->AddNodeOverlap(t1_1,1,new TGeoCombiTrans(-5,2,1.5,new TGeoRotation("t1_1",-90,90,0)));
TGeoVolume *t2_1=geom->MakeTubs("t2_1",Iron,0,0.8,1,0,360);
t2_1->SetLineColor(12);
top->AddNodeOverlap(t2_1,1,new TGeoCombiTrans(-5,-2,1.5,new TGeoRotation("t2_1",-90,90,0)));
TGeoVolume *fb1=geom->MakeTubs("fb1",Iron,2,2.3,1,100,260);
fb1->SetLineColor(12);
top->AddNodeOverlap(fb1,1,new TGeoCombiTrans(-5,0,-1,new TGeoRotation("fb1",90,90,90)));
TGeoVolume *m1=geom->MakeBox("m1",Iron,7,8,4);
m1->SetLineColor(2);
top->AddNodeOverlap(m1,1,new TGeoCombiTrans(0,0,-17,new TGeoRotation("m1",90,90,0)));
TGeoVolume *m2=geom->MakeTubs("m2",Iron,0,1,7,90,180);
m2->SetLineColor(2);
top->AddNodeOverlap(m2,1,new TGeoCombiTrans(-3,0,-9,new TGeoRotation("m2",0,90,0)));
TGeoVolume *m3=geom->MakeTubs("m3",Iron,0,1,7,0,90);
m3->SetLineColor(2);
top->AddNodeOverlap(m3,1,new TGeoCombiTrans(3,0,-9,new TGeoRotation("m3",0,90,0)));
TGeoVolume *m4=geom->MakeBox("m4",Iron,3,7,0.5);
m4->SetLineColor(2);
top->AddNodeOverlap(m4,1,new TGeoCombiTrans(0,0,-8.5,new TGeoRotation("m4",90,0,90)));
TGeoVolume *m5=geom->MakeTubs("m5",Iron,0,1.5,1.2,0,0);
m5->SetLineColor(5);
top->AddNodeOverlap(m5,1,new TGeoCombiTrans(0,0,-7.8,new TGeoRotation("m5",0,0,0)));
//.........这里部分代码省略.........
示例4: nucleus
void nucleus(Int_t nProtons = 40,Int_t nNeutrons = 60)
{
Double_t NeutronRadius = 60,
ProtonRadius = 60,
NucleusRadius,
distance = 60;
Double_t vol = nProtons + nNeutrons;
vol = 3 * vol / (4 * TMath::Pi());
NucleusRadius = distance * TMath::Power(vol, 1./3.);
// cout << "NucleusRadius: " << NucleusRadius << endl;
TGeoManager * geom = new TGeoManager("nucleus", "Model of a nucleus");
geom->SetNsegments(40);
TGeoMaterial *matEmptySpace = new TGeoMaterial("EmptySpace", 0, 0, 0);
TGeoMaterial *matProton = new TGeoMaterial("Proton" , .938, 1., 10000.);
TGeoMaterial *matNeutron = new TGeoMaterial("Neutron" , .935, 0., 10000.);
TGeoMedium *EmptySpace = new TGeoMedium("Empty", 1, matEmptySpace);
TGeoMedium *Proton = new TGeoMedium("Proton", 1, matProton);
TGeoMedium *Neutron = new TGeoMedium("Neutron",1, matNeutron);
// the space where the nucleus lives (top container volume)
Double_t worldx = 200.;
Double_t worldy = 200.;
Double_t worldz = 200.;
TGeoVolume *top = geom->MakeBox("WORLD", EmptySpace, worldx, worldy, worldz);
geom->SetTopVolume(top);
TGeoVolume * proton = geom->MakeSphere("proton", Proton, 0., ProtonRadius);
TGeoVolume * neutron = geom->MakeSphere("neutron", Neutron, 0., NeutronRadius);
proton->SetLineColor(kRed);
neutron->SetLineColor(kBlue);
Double_t x, y, z, dummy;
Int_t i = 0;
while ( i< nProtons) {
gRandom->Rannor(x, y);
gRandom->Rannor(z,dummy);
if ( TMath::Sqrt(x*x + y*y + z*z) < 1) {
x = (2 * x - 1) * NucleusRadius;
y = (2 * y - 1) * NucleusRadius;
z = (2 * z - 1) * NucleusRadius;
top->AddNode(proton, i, new TGeoTranslation(x, y, z));
i++;
}
}
i = 0;
while ( i < nNeutrons) {
gRandom->Rannor(x, y);
gRandom->Rannor(z,dummy);
if ( TMath::Sqrt(x*x + y*y + z*z) < 1) {
x = (2 * x - 1) * NucleusRadius;
y = (2 * y - 1) * NucleusRadius;
z = (2 * z - 1) * NucleusRadius;
top->AddNode(neutron, i + nProtons, new TGeoTranslation(x, y, z));
i++;
}
}
geom->CloseGeometry();
geom->SetVisLevel(4);
top->Draw("ogl");
}