本文整理汇总了C++中TGeoManager::Export方法的典型用法代码示例。如果您正苦于以下问题:C++ TGeoManager::Export方法的具体用法?C++ TGeoManager::Export怎么用?C++ TGeoManager::Export使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TGeoManager
的用法示例。
在下文中一共展示了TGeoManager::Export方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: snoopy
//.........这里部分代码省略.........
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));
TGeoRotation m3;
m3.SetAngles(180, 0, 0);
TGeoTranslation m4(0, 0, 1940);
TGeoCombiTrans m5(m4, m3);
TGeoHMatrix *m6 = new TGeoHMatrix(m5);
top->AddNode(magnet1, 2, m6);
// tracking station 3
top->AddNode(det1, 6, new TGeoTranslation(0, 0, 2150));
TGeoRotation r3;
r3.SetAngles(15,0,0);
TGeoTranslation t3(0, 0, 2170);
TGeoCombiTrans c3(t3, r3);
TGeoHMatrix *h3 = new TGeoHMatrix(c3);
top->AddNode(det1, 7, h3);
// fifth part of vacuum chamber up to fourth tracking station
TGeoVolume *tub5 = geom->MakeTube("tub5", Al, 245, 250, 90);
tub5->SetLineColor(18);
top->AddNode(tub5, 1, new TGeoTranslation(0, 0, 2270));
// tracking station 4
top->AddNode(det1, 8, new TGeoTranslation(0, 0, 2370));
TGeoRotation r4;
r4.SetAngles(15,0,0);
TGeoTranslation t4(0, 0, 2390);
TGeoCombiTrans c4(t4, r4);
TGeoHMatrix *h4 = new TGeoHMatrix(c4);
top->AddNode(det1, 9, h4);
// ecal
TGeoVolume *ecal = geom->MakeBox("ecal", Al, 250, 250, 40);
ecal->SetLineColor(6); // purple
top->AddNode(ecal, 1, new TGeoTranslation(0, 0, 2440));
// muon filter
TGeoVolume *muonfilter = geom->MakeBox("muonfilter", Al, 250, 250, 20);
muonfilter->SetLineColor(kGreen);
top->AddNode(muonfilter, 1, new TGeoTranslation(0, 0, 2500));
// sixth part of vacuum chamber up to muon detector
TGeoVolume *tub6 = geom->MakeTube("tub6", Al, 245, 250, 20);
tub6->SetLineColor(18);
top->AddNode(tub6, 1, new TGeoTranslation(0, 0, 2540));
// muon detector
top->AddNode(det1, 10, new TGeoTranslation(0, 0, 2570));
TGeoRotation r5;
r5.SetAngles(15,0,0);
TGeoTranslation t5(0, 0, 2590);
TGeoCombiTrans c5(t5, r5);
TGeoHMatrix *h5 = new TGeoHMatrix(c5);
top->AddNode(det1, 12, h5);
geom->CloseGeometry();
top->Draw("ogl");
geom->Export("snoopy.gdml");
}
示例3: geom_Al
//.........这里部分代码省略.........
TGeoVolume* infinite_plate =
geom->MakeTube( "Infinite_Plate", med_1, 0.0, plate_radius, plate_half_length );
infinite_plate->SetUniqueID( 3 );
infinite_plate->SetLineColor( 4 );
//--------------------------------------------------------
// Create the vacuum (R = "infinite" cm, h = "infinite")
//--------------------------------------------------------
// Set a radius of 7 cm ( 167 x the CSDA range = 0.4814;
double vacuum_radius = 7.0;
// Set a vacuum length large enough to cover the whole geometry
double vacuum_half_length = 2.0*plate_half_length + 5.0 + calorimeter_thickness + 0.5;
// Add region
TGeoVolume* void_region =
geom->MakeTube( "Void", void_med, 0.0, vacuum_radius, vacuum_half_length );
void_region->SetUniqueID( 4 );
void_region->SetLineColor( 6 );
void_region->SetVisibility( true );
//--------------------------------------------------------
// Create the graveyard (encompasses the entire geometry)
//--------------------------------------------------------
// Add region
TGeoVolume* graveyard_region =
geom->MakeTube( "Graveyard", graveyard_med, 0.0, vacuum_radius + 0.5, vacuum_half_length + 0.5 );
graveyard_region->SetUniqueID( 5 );
graveyard_region->SetLineColor( 7 );
graveyard_region->SetVisContainers( true );
//---------------------------------------------------------------------------//
// Heirarchy (Volume) Definitions
//---------------------------------------------------------------------------//
// Set graveyard as the top volume
geom->SetTopVolume(graveyard_region);
//------------------------
// Add vacuum to graveyard
//------------------------
// Get z position of the vacuum
double vacuum_z = vacuum_half_length;
// Add region
graveyard_region->AddNode(void_region, 0 );
//-----------------------------------
// Add the calorimeter foil to vacuum
//-----------------------------------
// Set the front of the calorimeter at a z of 5 cm
double calorimeter_z = 5.0 + half_cal_thickness;
// Add the front calorimeter foil to vacuum
void_region->AddNode( calorimeter_foil, 1, new TGeoTranslation(0,0,calorimeter_z) );
//-----------------------------------
// Add the front foil to vacuum
//-----------------------------------
if( front_thickness > 0.0 )
{
// Set the front foil 0.1 cm in front of the calorimeter
double front_z = 4.9 - front_thickness/2.0;
// Add the region
void_region->AddNode( front_foil, 2, new TGeoTranslation(0,0,front_z) );
}
//-----------------------------------
// Add the infinite plate to vacuum
//-----------------------------------
// Set the infinite plate 0.1 cm behind the calorimeter
double plate_z = 5.1 + calorimeter_thickness + plate_half_length;
// Add region
void_region->AddNode( infinite_plate, 3, new TGeoTranslation(0,0,plate_z) );
//---------------------------------------------------------------------------//
// Export and Drawing Capabilities
//---------------------------------------------------------------------------//
// Close the geometry
geom->CloseGeometry();
// // Draw the geometry
// geom->SetTopVisible();
// graveyard_region->Draw();
// TView *view = gPad->GetView();
// view->ShowAxis();
// Export the geometry
geom->Export( "geom_Al.root" );
// Finished
exit(0);
}