本文整理汇总了C++中TGeoManager::SetTopVisible方法的典型用法代码示例。如果您正苦于以下问题:C++ TGeoManager::SetTopVisible方法的具体用法?C++ TGeoManager::SetTopVisible怎么用?C++ TGeoManager::SetTopVisible使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TGeoManager
的用法示例。
在下文中一共展示了TGeoManager::SetTopVisible方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OpNoviceGeom
void OpNoviceGeom()
{
// Create root geometry corresponding to OpNovice example
double fExpHall_x, fExpHall_y, fExpHall_z;
double fTank_x, fTank_y, fTank_z;
double fBubble_x, fBubble_y, fBubble_z;
double a, z, density;
int nelements;
fExpHall_x = fExpHall_y = fExpHall_z = 10000.0;
fTank_x = fTank_y = fTank_z = 5000.0;
fBubble_x = fBubble_y = fBubble_z = 500.0;
TGeoManager *geom = new TGeoManager("OpNoviceGeom", "GEANT4 OpNovice example");
// Air
//
TGeoElement *N = new TGeoElement("Nitrogen", "N", z=7 , a=14.01);
TGeoElement *O = new TGeoElement("Oxygen" , "O", z=8 , a=16.00);
TGeoMixture *air = new TGeoMixture("Air", 2, density=1.29E-3);
air->AddElement(N, 0.7);
air->AddElement(O, 0.3);
TGeoMedium *medair = new TGeoMedium("Air", 1, air);
// Water
//
TGeoElement *H = new TGeoElement("Hydrogen", "H", z=1 , a=1.01);
TGeoMixture *water = new TGeoMixture("Water", 2, density=1.0);
water->AddElement(H,2);
water->AddElement(O,1);
TGeoMedium *medwater = new TGeoMedium("Water", 2, water);
// The experimental Hall
//
TGeoBBox *expHall_box = new TGeoBBox("World",fExpHall_x,fExpHall_y,fExpHall_z);
TGeoVolume *expHall_log = new TGeoVolume("World", expHall_box, medair);
expHall_log->SetLineColor(1);
expHall_log->SetVisContainers();
geom->SetTopVolume(expHall_log);
// The Water Tank
//
TGeoBBox *waterTank_box = new TGeoBBox("Tank",fTank_x,fTank_y,fTank_z);
TGeoVolume *waterTank_log = new TGeoVolume("Tank", waterTank_box, medwater);
waterTank_log->SetLineColor(kBlue);
waterTank_log->SetTransparency(70);
waterTank_log->SetVisContainers();
expHall_log->AddNode(waterTank_log, 0);
// The Air Bubble
//
TGeoBBox *bubbleAir_box = new TGeoBBox("Bubble",fBubble_x,fBubble_y,fBubble_z);
TGeoVolume *bubbleAir_log = new TGeoVolume("Bubble", bubbleAir_box, medair);
bubbleAir_log->SetLineColor(kCyan);
bubbleAir_log->SetTransparency(70);
waterTank_log->AddNode(bubbleAir_log, 0, new TGeoTranslation(0,2500,0));
geom->CloseGeometry();
geom->SetTopVisible(true);
geom->Export("OpNoviceGeom.root");
}
示例2: 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);
//.........这里部分代码省略.........
示例3: snoopy
void snoopy()
{
TGeoManager *geom = new TGeoManager("snoopy", "Snoopy Detector");
// define some materials
TGeoMaterial *matVacuum = new TGeoMaterial("Vacuum", 0, 0, 0);
TGeoMaterial *matAl = new TGeoMaterial("Al", 26.98, 13, 2.7);
TGeoMaterial *matFe = new TGeoMaterial("Fe", 55.84, 26, 7.9);
// define some media
TGeoMedium *Vacuum = new TGeoMedium("Vacuum", 1, matVacuum);
TGeoMedium *Al = new TGeoMedium("Al", 2, matAl);
TGeoMedium *Fe = new TGeoMedium("Fe", 3, matFe);
// create top volume
TGeoVolume *top = geom->MakeBox("top", Vacuum, 600, 600, 2500);
geom->SetTopVolume(top);
geom->SetTopVisible(0);
// first part of vacuum chamber up to veto station
TGeoVolume *tub1 = geom->MakeTube("tub1", Al, 245, 250, 50);
tub1->SetLineColor(18); // silver/gray
top->AddNode(tub1, 1, new TGeoTranslation(0, 0, -2450));
// veto station
TGeoBBox *detbox1 = new TGeoBBox("detbox1", 250, 250, 10);
TGeoBBox *detbox2 = new TGeoBBox("detbox2", 245, 245, 10);
TGeoCompositeShape *detcomp1 = new TGeoCompositeShape("detcomp1", "detbox1-detbox2");
TGeoVolume *det1 = new TGeoVolume("det1", detcomp1,Vacuum);
det1->SetLineColor(kRed);
top->AddNode(det1, 1, new TGeoTranslation(0, 0, -2390));
TGeoRotation r0;
r0.SetAngles(15,0,0);
TGeoTranslation t0(0, 0, -2370);
TGeoCombiTrans c0(t0, r0);
TGeoHMatrix *h0 = new TGeoHMatrix(c0);
top->AddNode(det1, 11, h0);
// second part of vacuum chamber up to first tracking station
TGeoVolume *tub2 = geom->MakeTube("tub2", Al, 245, 250, 3880/2); // 1890
tub2->SetLineColor(18);
top->AddNode(tub2, 1, new TGeoTranslation(0, 0, -440));
// tracking station 1
top->AddNode(det1, 2, new TGeoTranslation(0, 0, 1510));
TGeoRotation r1;
r1.SetAngles(15,0,0);
TGeoTranslation t1(0, 0, 1530);
TGeoCombiTrans c1(t1, r1);
TGeoHMatrix *h1 = new TGeoHMatrix(c1);
top->AddNode(det1, 3, h1);
// third part of vacuum chamber up to second tracking station
TGeoVolume *tub3 = geom->MakeTube("tub3", Al, 245, 250, 80);
tub3->SetLineColor(18);
top->AddNode(tub3, 1, new TGeoTranslation(0, 0, 1620));
// tracking station 2
top->AddNode(det1, 4, new TGeoTranslation(0, 0, 1710));
TGeoRotation r2;
r2.SetAngles(15,0,0);
TGeoTranslation t2(0, 0, 1730);
TGeoCombiTrans c2(t2, r2);
TGeoHMatrix *h2 = new TGeoHMatrix(c2);
top->AddNode(det1, 5, h2);
// fourth part of vacuum chamber up to third tracking station and being covered by magnet
TGeoVolume *tub4 = geom->MakeTube("tub4", Al, 245, 250, 200);
tub4->SetLineColor(18);
top->AddNode(tub4, 1, new TGeoTranslation(0, 0, 1940));
// magnet yoke
TGeoBBox *magyoke1 = new TGeoBBox("magyoke1", 350, 350, 125);
TGeoBBox *magyoke2 = new TGeoBBox("magyoke2", 250, 250, 126);
TGeoCompositeShape *magyokec = new TGeoCompositeShape("magyokec", "magyoke1-magyoke2");
TGeoVolume *magyoke = new TGeoVolume("magyoke", magyokec, Fe);
magyoke->SetLineColor(kBlue);
//magyoke->SetTransparency(50);
top->AddNode(magyoke, 1, new TGeoTranslation(0, 0, 1940));
// magnet
TGeoTubeSeg *magnet1a = new TGeoTubeSeg("magnet1a", 250, 300, 35, 45, 135);
TGeoTubeSeg *magnet1b = new TGeoTubeSeg("magnet1b", 250, 300, 35, 45, 135);
TGeoTubeSeg *magnet1c = new TGeoTubeSeg("magnet1c", 250, 270, 125, 45, 60);
TGeoTubeSeg *magnet1d = new TGeoTubeSeg("magnet1d", 250, 270, 125, 120, 135);
// magnet composite shape matrices
TGeoTranslation *m1 = new TGeoTranslation(0, 0, 160);
m1->SetName("m1");
m1->RegisterYourself();
TGeoTranslation *m2 = new TGeoTranslation(0, 0, -160);
m2->SetName("m2");
m2->RegisterYourself();
TGeoCompositeShape *magcomp1 = new TGeoCompositeShape("magcomp1", "magnet1a:m1+magnet1b:m2+magnet1c+magnet1d");
TGeoVolume *magnet1 = new TGeoVolume("magnet1", magcomp1, Fe);
magnet1->SetLineColor(kYellow);
top->AddNode(magnet1, 1, new TGeoTranslation(0, 0, 1940));
//.........这里部分代码省略.........
示例4: 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)));
//.........这里部分代码省略.........
示例5: TGeoManager
TGeoVolume *VP_SimpleECal(int nphi = 4, int nz = 3, double density = 8.28)
{
const double world_x = 9000.;
const double world_y = 9000.;
const double world_z = 16000;
TGeoManager *geom = new TGeoManager("SimpleECal", "Simplification of the CMS ECal");
TGeoMaterial *world_mat = new TGeoMaterial("world", 1, 2, 0);
TGeoMedium *world_med = new TGeoMedium("world_medium", 0, world_mat);
TGeoVolume *world = geom->MakeBox("top", world_med, world_x, world_y, world_z);
geom->SetTopVolume(world);
geom->SetTopVisible(1);
int crystal_nphi = nphi;
int crystal_nz = nz;
double ecal_density = density;
const int crystal_n = crystal_nphi * crystal_nz;
const double ecal_zmin = -3000.;
const double ecal_zmax = 3000.;
const double ecal_rmin = 10.;
const double ecal_rmax = 5000.;
const double ecal_dz = 0.5 * (ecal_zmax - ecal_zmin) / crystal_nz;
const double ecal_sphi = 0.;
// const G4double ecal_dphi = 2.0*M_PI/crystal_nphi;
// G4 seems to be in radian while TGeo seems to be in degree.
// const double ecal_dphi = 2.0*TMath::Pi()/crystal_nphi;
const double ecal_dphi = 2.0 * 180 / crystal_nphi;
int iptr = 0;
TGeoElementTable *table = gGeoManager->GetElementTable();
// TGeoElement* elPb = new TGeoElement( "Lead", "Pb", 82., 207.19*g/mole );
// TGeoElement* elW = new TGeoElement( "Tungstenm", "W",74., 183.85*g/mole);
// TGeoElement* elO = new TGeoElement( "Oxygen", "O2", 8., 16.*g/mole );
TGeoElement *elPb = table->GetElement(82);
TGeoElement *elW = table->GetElement(74);
TGeoElement *elO = table->GetElement(8);
// TGeoMaterial *ecal_mat = new TGeoMaterial("ecal",90,120,density);
TGeoMixture *ecal_mat = new TGeoMixture("ecal_mat", 3, density);
ecal_mat->AddElement(elPb, 1);
ecal_mat->AddElement(elW, 1);
ecal_mat->AddElement(elO, 4);
TGeoMedium *ecal_med = new TGeoMedium("ecal_med", 0, ecal_mat);
for (int j = 0; j < crystal_nz; ++j) {
for (int i = 0; i < crystal_nphi; ++i) {
iptr = i + j * crystal_nphi;
TGeoVolume *ecal = geom->MakeTubs(TString::Format("ecal-%d-%d", j, i), ecal_med, ecal_rmin, ecal_rmax, ecal_dz,
ecal_sphi + i * ecal_dphi, ecal_sphi + (i + 1) * ecal_dphi);
ecal->SetLineColor(iptr);
// top->AddNode(ecal,1,new TGeoCombiTrans(0,0,0,new TGeoRotation("ecal",0,0,0)));
// GPThreeVector ecal_trans = GPThreeVector_create(0,0,ecal_zmin+(2.0*j+1.0)*ecal_dz);
double dx = 0.0;
double dy = 0.0;
double dz = ecal_zmin + (2.0 * j + 1.0) * ecal_dz;
TGeoTranslation *ecal_trans = new TGeoTranslation("", dx, dy, dz);
// GPLogicalVolume_Constructor(ecal_log+iptr, (GPVSolid*)ecal, ecal_mat);
// GPVPhysicalVolume_Constructor(ecal_phy+iptr, idRot, ecal_trans, ecal_log+iptr);
world->AddNode(ecal, iptr, ecal_trans);
// Set mother
// GPVPhysicalVolume_SetMotherLogical(ecal_phy+iptr, world_log);
// addLogicalVolumePointers( ecal_log+iptr);
// addPhysicalVolumePointers( ecal_phy+iptr);
}
}
// add daughter volume
// for ( int j=0; j < crystal_nz ; ++j ) {
// for ( int i=0; i < crystal_nphi ; ++i ) {
// iptr = i+j*crystal_nphi;
// addLogicalVolumeDaughter( world_log, ecal_phy+iptr);
// }
// }
// Register world volume pointers for relocation
// addLogicalVolumePointers( world_log );
// addPhysicalVolumePointers( world_phy );
geom->CloseGeometry();
return world;
}