本文整理汇总了C++中TGeoVolume::Draw方法的典型用法代码示例。如果您正苦于以下问题:C++ TGeoVolume::Draw方法的具体用法?C++ TGeoVolume::Draw怎么用?C++ TGeoVolume::Draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TGeoVolume
的用法示例。
在下文中一共展示了TGeoVolume::Draw方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Show
void Visualizer::Show(){
std::cout<<"=============================================="<<std::endl;
std::cout<<"========= Inside Expected SHOW() ============="<<std::endl;
std::cout<<"=============================================="<<std::endl;
TGeoVolume *top = gGeoManager->MakeBox("Top", NULL, kInfinity, kInfinity, kInfinity);
gGeoManager->SetTopVolume(top);
for(int i = 0 ; i < fVolumes.size() ; i++){
top->AddNode(std::get<0>(fVolumes[i]), 1 , std::get<1>(fVolumes[i]));
}
top->SetLineColor(kGreen);
gGeoManager->CloseGeometry();
#ifndef USE_OGL
top->Draw();
#else
top->Draw("ogl"); //to display the geometry using openGL
#endif
//
//TPad::x3d("OPENGL");
gGeoManager->Export("plane.root");
//top->Export("planeTop.root");
//fApp->Run();
}
示例2: s_intersection
void s_intersection()
{
gROOT->GetListOfCanvases()->Delete();
TCanvas *c = new TCanvas("composite shape", "Intersection boolean operation", 700, 1000);
c->Divide(1,2,0,0);
c->cd(2);
gPad->SetPad(0,0,1,0.4);
c->cd(1);
gPad->SetPad(0,0.4,1,1);
if (gGeoManager) delete gGeoManager;
new TGeoManager("xtru", "poza12");
TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
TGeoMedium *med = new TGeoMedium("MED",1,mat);
TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
gGeoManager->SetTopVolume(top);
// define shape components with names
TGeoBBox *box = new TGeoBBox("bx", 40., 40., 40.);
TGeoSphere *sph = new TGeoSphere("sph", 40., 45.);
// define named geometrical transformations with names
TGeoTranslation *tr = new TGeoTranslation(0., 0., 45.);
tr->SetName("tr");
// register all used transformations
tr->RegisterYourself();
// create the composite shape based on a Boolean expression
TGeoCompositeShape *cs = new TGeoCompositeShape("mir", "sph:tr * bx");
TGeoVolume *vol = new TGeoVolume("COMP2",cs);
top->AddNode(vol,1);
gGeoManager->CloseGeometry();
gGeoManager->SetNsegments(100);
top->Draw();
MakePicture();
c->cd(2);
TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
pt->SetLineColor(1);
TText *text = pt->AddText("TGeoCompositeShape - composite shape class");
text->SetTextColor(2);
pt->AddText("----- Here is an example of boolean intersection operation : A * B");
pt->AddText("----- A == sphere (with inner radius non-zero), B == box");
pt->AddText(" ");
pt->SetAllWith("-----","color",4);
pt->SetAllWith("-----","font",72);
pt->SetAllWith("-----","size",0.04);
pt->SetTextAlign(12);
pt->SetTextSize(0.044);
pt->Draw();
c->cd(1);
}
示例3: s_difference
void s_difference()
{
gROOT->GetListOfCanvases()->Delete();
TCanvas *c = new TCanvas("composite shape", "Difference boolean operation", 700, 1000);
c->Divide(1,2,0,0);
c->cd(2);
gPad->SetPad(0,0,1,0.4);
c->cd(1);
gPad->SetPad(0,0.4,1,1);
if (gGeoManager) delete gGeoManager;
new TGeoManager("xtru", "poza12");
TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
TGeoMedium *med = new TGeoMedium("MED",1,mat);
TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
gGeoManager->SetTopVolume(top);
// define shape components with names
TGeoTorus *tor = new TGeoTorus("tor", 45., 15., 20., 45., 145.);
TGeoSphere *sph = new TGeoSphere("sph", 20., 45., 0., 180., 0., 270.);
// create the composite shape based on a Boolean expression
TGeoCompositeShape *cs = new TGeoCompositeShape("mir", "sph - tor");
TGeoVolume *vol = new TGeoVolume("COMP3",cs);
top->AddNode(vol,1);
gGeoManager->CloseGeometry();
gGeoManager->SetNsegments(60);
top->Draw();
MakePicture();
c->cd(2);
TPaveText *pt = new TPaveText(.01, .01, .99, .99);
pt->SetLineColor(1);
TText *text = pt->AddText("TGeoCompositeShape - composite shape class");
text->SetTextColor(2);
pt->AddText("----- It's an example of boolean difference: A - B");
pt->AddText("----- A == part of sphere (0-180, 0-270), B == partial torus (45-145)");
pt->AddText(" ");
pt->SetAllWith("-----","color",4);
pt->SetAllWith("-----","font",72);
pt->SetAllWith("-----","size",0.04);
pt->SetTextAlign(12);
pt->SetTextSize(0.044);
pt->Draw();
c->cd(1);
}
示例4: ATTPC_d2He
void ATTPC_d2He() {
// Load the necessary FairRoot libraries
//gROOT->LoadMacro("$VMCWORKDIR/gconfig/basiclibs.C");
//basiclibs();
//gSystem->Load("libGeoBase");
//gSystem->Load("libParBase");
//gSystem->Load("libBase");
// Load needed material definition from media.geo file
create_materials_from_media_file();
// Get the GeoManager for later usage
gGeoMan = (TGeoManager*) gROOT->FindObject("FAIRGeom");
gGeoMan->SetVisLevel(7);
// Create the top volume
TGeoVolume* top = new TGeoVolumeAssembly("TOP");
gGeoMan->SetTopVolume(top);
TGeoMedium* gas = gGeoMan->GetMedium(MediumVacuum);
TGeoVolume* tpcvac = new TGeoVolumeAssembly(geoVersion);
tpcvac -> SetMedium(gas);
top->AddNode(tpcvac, 1);
gModules = create_detector();
//position_detector();
cout<<"Voxelizing."<<endl;
top->Voxelize("");
gGeoMan->CloseGeometry();
//add_alignable_volumes();
gGeoMan->CheckOverlaps(0.001);
gGeoMan->PrintOverlaps();
gGeoMan->Test();
TFile* outfile = new TFile(FileName,"RECREATE");
top->Write();
outfile->Close();
TFile* outfile1 = new TFile(FileName1,"RECREATE");
gGeoMan->Write();
outfile1->Close();
top->Draw("ogl");
//top->Raytrace();
}
示例5: display
static long display(LCDD& lcdd, int argc, char** argv) {
TGeoManager& mgr = lcdd.manager();
const char* opt = "ogl";
if (argc > 0) {
opt = argv[0];
}
mgr.SetVisLevel(4);
mgr.SetVisOption(1);
TGeoVolume* vol = mgr.GetTopVolume();
if (vol) {
vol->Draw(opt);
return 1;
}
return 0;
}
示例6: AddLadder
void AddLadder()
{
SvxTGeo *geo = new SvxTGeo;
geo->ReadParFile("parfiles/svxPISA.par");
// Make an empty 100x100x100 cm^3 space in the experiment hall.
geo->MakeTopVolume(200/2, 200/2, 200/2);
// Place VTX sensors in the volume.
geo->AddSensors();
// Get handles for further manipulation
TGeoManager *mgr = geo->GeoManager();
TGeoVolume *top = mgr->GetTopVolume();
// Add a ladder with new index 20 and the same geometry as B1L9.
double xyz[3] = {0};
geo->GetSensorXYZ(1, 9, 0, xyz);
geo->AddLadder(1, 20, xyz[0], xyz[1], 0., geo->GetLadderPhiTilt(1,9));
// Now rotate B1L20 by angular difference between B1L9 and B1L8.
double dphi = geo->SensorPhiRad(1,9,0) - geo->SensorPhiRad(1,8,0);
geo->RotateLadder(1, 20, 0., 0., dphi);
// Done building model.
// Close geometry to check for problems (overlapping boundaries)
mgr->CloseGeometry();
// Press j,k to zoom; u,i to look up/down; h,l to look left, right.
TCanvas *c = new TCanvas("c", "svx model", 1400, 1000);
c->SetFillColor(kBlack);
top->Draw();
geo->WriteParFile("parfiles/svxPISA.newladders.par");
return;
}
示例7: Draw3D
void Draw3D(AliITSOnlineCalibrationSPDhandler *h){
TGeoHMatrix m2t[240];
for(Int_t imod=0; imod<240; imod++){
int vid = AliITSAlignMille2Module::GetVolumeIDFromIndex(imod);
AliITSAlignMille2Module::SensVolMatrix(vid,&m2t[imod]);
}
delete gGeoManager;
new TGeoManager("SPD","active");
TGeoMaterial *vacuum = new TGeoMaterial("vacuum",0,0,0);
TGeoMedium *none = new TGeoMedium("Vacuum",0,vacuum);
TGeoVolume *top = gGeoManager->MakeBox("TOP",none,500,500,500);
gGeoManager->SetTopVolume(top);
TGeoVolume *ladder = gGeoManager->MakeBox("ladder",none,0.6375,0.001/2,3.48);
Int_t nActive[2]={0,0};
for(Int_t imod=0; imod<240; imod++){
TGeoRotation *rot = new TGeoRotation();
rot->SetMatrix(m2t[imod].GetRotationMatrix());
TGeoCombiTrans *matrix = new TGeoCombiTrans(m2t[imod].GetTranslation()[0],m2t[imod].GetTranslation()[1],m2t[imod].GetTranslation()[2],rot);
if((40960-h->GetNrBad(imod))>0) {
top->AddNode(ladder,imod,matrix);
if(imod<80) nActive[0]++;
else nActive[1]++;
}
}
printf(" \n\n Number of Active SPD modules (->Total) : inner %i (80) outer %i (160) \n\n\n",nActive[0],nActive[1]);
gGeoManager->CloseGeometry();
top->Draw("ogl");
gPad->GetView()->ShowAxis();
}
示例8: StEEmcDbMaker
void
show
(
char* inpDir = "", // MuDST directory
char* inpFile = "show.lis", // MuDST file(s);
char* outFile = "show.root",// output tree file
Int_t nFiles = 50, // # of MuDST file(s)
Int_t nEvents = 100 // # of events
)
// remeber to adjust dbase timestamp below !!!!
// what a ... design
{
//gErrorIgnoreLevel=1999;
// load root/root4star libraries
gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
loadSharedLibraries();
// load more libraries :)
gSystem->Load("libmysqlclient");
gSystem->Load("libGeom");
gSystem->Load("StDbLib");
gSystem->Load("StDbBroker");
gSystem->Load("St_db_Maker");
// load even more libraries (EEMC stuff)
gSystem->Load("StEEmcUtil");
gSystem->Load("StEEmcDbMaker");
gSystem->Load("StEEmcPoolTTM");
// create the chain
chain = new StChain("StChain");
//
now = new TDatime;
// for display
TCanvas *c1 = new TCanvas("eemc","eemc",10,10,1000,1000);
TPaveLabel *tlab = new TPaveLabel(-0.99,+0.99,+0.99,+0.90,
"EEMC TOWERS & TPC TRACKS Piotr A Zolnierczuk (IU)");
eventInfo = new TPaveText (-0.99,-0.99,+0.0 ,-0.75);
dateInfo = new TPaveLabel(+0.60,-0.99,+0.99,-0.95,now->AsString());
TGeoManager *gm = new TGeoManager("eemc", "eemc tower display");
TGeoVolume *top = gm->MakeBox("star",0, 200., 200., 350.);
TGeoVolume *smbox = gm->MakeBox("smbox1",0, 2., 2., 2.);
smbox->SetLineColor(kRed);
// eemc
eemc = new EEmcTTDisplay();
eemc->SetMagneticField(0.5); // in Tesla
eemc->SetShowExtrapolatedTracks(true);
TGeoTranslation *etra = new TGeoTranslation(0.0,0.0,0.5*(eemc->getZ1()+eemc->getZ2()));
top->AddNode(smbox, 1,NULL);
top->AddNode(eemc(),1,etra);
gm->SetTopVolume(top);
gm->CloseGeometry();
gm->SetVisLevel(4);
gm->SetVisOption(0);
c1->SetTheta(90);
c1->SetPhi(0);
top->Draw();
tlab->Draw();
gPad->Update();
// now we add Makers to the chain... some of that is black magic :)
muDstMk = new StMuDstMaker(0,0,inpDir,inpFile,"",nFiles); // muDST main chain
StMuDbReader *db = StMuDbReader::instance(); // need the database
St_db_Maker *dbMk = new St_db_Maker("StarDb", "MySQL:StarDb"); // need another db(?)
new StEEmcDbMaker("eemcDb"); // need EEMC database
// now comment in/out/change the below if you want it your way
dbMk->setTimeStampDay(20040331); // format: yyyymmdd
// finally after so many lines we arrive at the good stuff
ttm = new EEmcTTMMaker ("TTM",muDstMk,eemcDbMk);
ttm->Summary(cout); //
StMuDebug::setLevel(0);
chain->Init();
StEEmcDb *eemcDb = (StEEmcDb*)chain->GetDataSet("StEEmcDb");
eemcDb->setSectors(1,12); // request EEMC DB for sectors you need (dafault:1-12)
eemcDb->setPreferedFlavor("onlped","eemcPMTped"); // request alternative flavor
chain->ls(3);
//---------------------------------------------------
next();
}
示例9: complex_1
void complex_1()
{
gROOT->GetListOfCanvases()->Delete();
TCanvas *c = new TCanvas("composite shape", "A * B - C", 700, 1000);
c->Divide(1,2,0,0);
c->cd(2);
gPad->SetPad(0,0,1,0.4);
c->cd(1);
gPad->SetPad(0,0.4,1,1);
if (gGeoManager) delete gGeoManager;
new TGeoManager("xtru", "poza12");
TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
TGeoMedium *med = new TGeoMedium("MED",1,mat);
TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
gGeoManager->SetTopVolume(top);
// define shape components with names
TGeoBBox *box = new TGeoBBox("box", 20., 20., 20.);
TGeoBBox *box1 = new TGeoBBox("box1", 5., 5., 5.);
TGeoSphere *sph = new TGeoSphere("sph", 5., 25.);
TGeoSphere *sph1 = new TGeoSphere("sph1", 1., 15.);
// create the composite shape based on a Boolean expression
TGeoTranslation *tr = new TGeoTranslation(0., 30., 0.);
TGeoTranslation *tr1 = new TGeoTranslation(0., 40., 0.);
TGeoTranslation *tr2 = new TGeoTranslation(0., 30., 0.);
TGeoTranslation *tr3 = new TGeoTranslation(0., 30., 0.);
tr->SetName("tr");
tr1->SetName("tr1");
tr2->SetName("tr2");
tr3->SetName("tr3");
// register all used transformations
tr->RegisterYourself();
tr1->RegisterYourself();
tr2->RegisterYourself();
tr3->RegisterYourself();
TGeoCompositeShape *cs = new TGeoCompositeShape("mir", "(sph * box) + (sph1:tr - box1:tr1)");
TGeoVolume *vol = new TGeoVolume("COMP4",cs);
// vol->SetLineColor(randomColor());
top->AddNode(vol,1);
gGeoManager->CloseGeometry();
gGeoManager->SetNsegments(80);
top->Draw();
MakePicture();
c->cd(2);
TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
pt->SetLineColor(1);
TText *text = pt->AddText("TGeoCompositeShape - composite shape class");
text->SetTextColor(2);
pt->AddText("----- (sphere * box) + (sphere - box) ");
pt->AddText(" ");
pt->SetAllWith("-----","color",4);
pt->SetAllWith("-----","font",72);
pt->SetAllWith("-----","size",0.04);
pt->SetTextAlign(12);
pt->SetTextSize(0.044);
pt->Draw();
c->cd(1);
}
示例10: rotSensor
//.........这里部分代码省略.........
pointsSmall[6] = -0.5529/2; pointsSmall[7] = -5.3358/2;
pointsSmall[8] = -1.9579/2; pointsSmall[9] = 5.3358/2;
pointsSmall[10] = 1.9579/2; pointsSmall[11] = 5.3358/2;
pointsSmall[12] = 0.5529/2; pointsSmall[13] = -5.3358/2;
pointsSmall[14] = -0.5529/2; pointsSmall[15] = -5.3358/2;
// TGeoShape* smallSensorShape = new TGeoTrd1("StripSensorActiveSmallShape", 1.9579/2, 0.5529/2, 0.03/2, 5.3358/2);
TGeoShape* smallSensorShape = new TGeoArb8("StripSensorActiveSmallShape", 0.03/2, pointsSmall);
TGeoVolume* smallSensorVolume = new TGeoVolume("StripSensorActiveSmallTrap", smallSensorShape, gGeoMan->GetMedium("HYPdiamond"));
TGeoTranslation transSmallSensor(0,5.3358/2+2.1,0);
TGeoCombiTrans combined2(transSmallSensor, rotSensor);
for (int i = 0; i < 12; i++){
TString rotName("rotSmallSens");
rotName.Append(i+1);
TGeoRotation rotSens(rotName.Data(), 0,0, i*2 * 360/24);
TGeoHMatrix sens = rotSens * combined2;
smallRing->AddNode(smallSensorVolume, i+12, new TGeoHMatrix(sens));
}
lambdaDisk->AddNode(largeRing, 0, new TGeoTranslation(0,0,-0.5));
lambdaDisk->AddNode(largeRing, 1, new TGeoRotation("largeRingRot",0,0,360/24));
TGeoCombiTrans combiSmallRing2(TGeoTranslation(0,0,-1.5), TGeoRotation("smallRingRot",0,0,360/24));
lambdaDisk->AddNode(smallRing, 0, new TGeoTranslation(0,0,-1.0));
lambdaDisk->AddNode(smallRing, 1, new TGeoHMatrix(combiSmallRing2));
TGeoVolumeAssembly* supportDisk = new TGeoVolumeAssembly("SupportDisk");
TGeoVolumeAssembly* supportLarge = new TGeoVolumeAssembly("SupportLarge");
TGeoShape* carbonFoamShape = new TGeoBBox(3.4/2, 0.2/2, 3.5/2);
TGeoVolume* carbonFoam = new TGeoVolume("CarbonFoam", carbonFoamShape, gGeoMan->GetMedium("carbonfoam"));
TGeoShape* carbonFiberShape = new TGeoBBox(3.4/2, 0.02/2, 3.5/2);
TGeoVolume* carbonFiber = new TGeoVolume("CarbonFiber", carbonFiberShape, gGeoMan->GetMedium("carbon"));
TGeoShape* HYPdiamondReadoutShape = new TGeoBBox(3.4/2, 0.02/2, 3.5/2);
TGeoVolume* HYPdiamondReadout = new TGeoVolume("HYPdiamondReadout", HYPdiamondReadoutShape, gGeoMan->GetMedium("HYPdiamond"));
TGeoShape* aluCablesShape = new TGeoBBox(3.4/2, 0.4/2, 3.5/2);
TGeoVolume* aluCables = new TGeoVolume("AluCables", aluCablesShape, gGeoMan->GetMedium("aluminium"));
supportLarge->AddNode(carbonFoam, 1);
supportLarge->AddNode(carbonFiber, 1, new TGeoTranslation(0,(0.2 + 0.02)/2, 0));
supportLarge->AddNode(carbonFiber, 2, new TGeoTranslation(0,-(0.2 + 0.02)/2, 0));
supportLarge->AddNode(HYPdiamondReadout, 1, new TGeoTranslation(0,(0.2 + 0.02 + 0.02)/2, 0));
supportLarge->AddNode(HYPdiamondReadout, 2, new TGeoTranslation(0,-(0.2 + 0.02 + 0.02)/2, 0));
supportLarge->AddNode(aluCables, 1, new TGeoTranslation(0,(0.2 + 0.02 + 0.02 + 0.4)/2, 0));
supportLarge->AddNode(aluCables, 2, new TGeoTranslation(0,-(0.2 + 0.02 + 0.02 + 0.4)/2, 0));
TGeoTranslation transSupportLarge(0,(14.8669)/2 + 5.5665 + 1,0);
for (int i = 0; i < 24; i++){
TString rotName("rotSupportLarge");
rotName.Append(i+1);
TGeoRotation rotSens(rotName.Data(), 0,0, i * 360/24);
TGeoHMatrix sens = rotSens * transSupportLarge;
supportDisk->AddNode(supportLarge, i+1, new TGeoHMatrix(sens));
}
TGeoVolumeAssembly* supportSmall = new TGeoVolumeAssembly("SupportSmall");
TGeoShape* carbonFoamShapeSmall = new TGeoBBox(1.8/2, 0.2/2, 3.5/2);
TGeoVolume* carbonFoamSmall = new TGeoVolume("CarbonFoamSmall", carbonFoamShapeSmall, gGeoMan->GetMedium("carbonfoam"));
TGeoShape* carbonFiberShapeSmall = new TGeoBBox(1.8/2, 0.02/2, 3.5/2);
TGeoVolume* carbonFiberSmall = new TGeoVolume("CarbonFiberSmall", carbonFiberShapeSmall, gGeoMan->GetMedium("carbon"));
TGeoShape* HYPdiamondReadoutShapeSmall = new TGeoBBox(1.8/2, 0.02/2, 3.5/2);
TGeoVolume* HYPdiamondReadoutSmall = new TGeoVolume("HYPdiamondReadoutSmall", HYPdiamondReadoutShapeSmall, gGeoMan->GetMedium("HYPdiamond"));
TGeoShape* aluCablesShapeSmall = new TGeoBBox(1.8/2, 0.4/2, 3.5/2);
TGeoVolume* aluCablesSmall = new TGeoVolume("AluCablesSmall", aluCablesShapeSmall, gGeoMan->GetMedium("aluminium"));
supportSmall->AddNode(carbonFoamSmall, 1);
supportSmall->AddNode(carbonFiberSmall, 1, new TGeoTranslation(0,(0.2 + 0.02)/2, 0));
supportSmall->AddNode(carbonFiberSmall, 2, new TGeoTranslation(0,-(0.2 + 0.02)/2, 0));
supportSmall->AddNode(HYPdiamondReadoutSmall, 1, new TGeoTranslation(0,(0.2 + 0.02 + 0.02)/2, 0));
supportSmall->AddNode(HYPdiamondReadoutSmall, 2, new TGeoTranslation(0,-(0.2 + 0.02 + 0.02)/2, 0));
supportSmall->AddNode(aluCablesSmall, 1, new TGeoTranslation(0,(0.2 + 0.02 + 0.02 + 0.4)/2, 0));
supportSmall->AddNode(aluCablesSmall, 2, new TGeoTranslation(0,-(0.2 + 0.02 + 0.02 + 0.4)/2, 0));
TGeoTranslation transSupportSmall(0,2.1 + 5.3358 + 0.5,0);
for (int i = 0; i < 24; i++){
TString rotName("rotSupportSmall");
rotName.Append(i+1);
TGeoRotation rotSens(rotName.Data(), 0,0, i * 360/24);
TGeoHMatrix sens = rotSens * transSupportSmall;
supportDisk->AddNode(supportSmall, i+1, new TGeoHMatrix(sens));
}
combinedLambdaDisks->AddNode(lambdaDisk,1,new TGeoTranslation(0,0,positionOfDisk1inZ));
//combinedLambdaDisks->AddNode(lambdaDisk,2,new TGeoTranslation(0,0,positionOfDisk2inZ));
//combinedLambdaDisks->AddNode(supportDisk,1, new TGeoTranslation(0,0,(positionOfDisk1inZ + positionOfDisk2inZ)/2));
top->AddNode(combinedLambdaDisks,0);
gGeoMan->CloseGeometry();
top->Write();
fi->Close();
// gGeoManager->Export(outfile);
gGeoManager->SetVisLevel(30);
top->Draw("ogl");
}
示例11: glViewerLOD
//.........这里部分代码省略.........
}
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: {
assert(kFALSE);
}
}
volumes[i]->SetLineColor(color);
}
printf("\nCreated %d volumes\n\n", volumeCount);
// Scatter reqSpheres placed sphere randomly in space
Double_t x, y, z;
for (i = 0; i < reqNodes; i++) {
// Pick random volume
UInt_t useVolume = gRandom->Integer(volumeCount);
TGeoTranslation * trans;
TGeoRotation * rot;
if (randomDist) {
// Random translation
gRandom->Rannor(x, y);
gRandom->Rannor(z,dummy);
trans = new TGeoTranslation(x*worldRadius, y*worldRadius, z*worldRadius);
// Random rotation
gRandom->Rannor(x, y);
gRandom->Rannor(z,dummy);
rot = new TGeoRotation("rot", x*360.0, y*360.0, z*360.0);
} else {
UInt_t perSide = pow(reqNodes,1.0/3.0)+0.5;
Double_t distance = sizeBase*5.0;
UInt_t xi, yi, zi;
zi = i / (perSide*perSide);
yi = (i / perSide) % perSide;
xi = i % perSide;
trans = new TGeoTranslation(xi*distance,yi*distance,zi*distance);
rot = new TGeoRotation("rot",0.0, 0.0, 0.0);
}
top->AddNode(volumes[useVolume], i, new TGeoCombiTrans(*trans, *rot));
//printf("Added node %d (Volume %d)\n", i, useVolume);
}
geom->CloseGeometry();
top->Draw("ogl");
}
示例12: 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");
}
示例13: create_bpipe_geometry_v13e
//.........这里部分代码省略.........
pipe->AddNode(pipe3, 0);
TGeoVolume* pipevac2 = MakeVacuum(2, nSects02, z02, rin02, rout02, vacuum, &infoFile);
pipevac2->SetLineColor(kCyan);
pipe->AddNode(pipevac2, 0);
//*/
// define some rotation & translation for pipe4-pipe7 & pipevac3-pipevac5
// Initial phi (Euler rotation angle about Z)
// Initial theta (Euler rotation angle about new X)
// Initial psi (Euler rotation angle about new Z)
cout<<endl<<"Rotation angle (@[0;0;1800]mm)="<< rotangle <<"deg";
TGeoRotation *r1 = new TGeoRotation("r1", 90., rotangle, 0.); // deg - Euler angles
r1->RegisterYourself();
Double_t shift = rotangle/10.+0.1; // cm - volume boolean operation correction - TODO
Double_t dx=0., dy=0., dz=1800.-10.*shift; // mm
TGeoCombiTrans *c1 = new TGeoCombiTrans("c1", dx/10., dy/10., dz/10., r1); // mm->cm
c1->RegisterYourself();
TGeoTranslation *t1 = new TGeoTranslation("t1", 0., 0., 180.-shift); // cm
t1->RegisterYourself();
Double_t phi, theta, psi;
c1->GetRotation()->GetAngles(phi, theta, psi);
infoFile << endl << "Beam pipe section: " << pipe4name << endl;
infoFile << "Traslation(dx,dy,dz): "<< dx <<" "<< dy <<" "<< dz <<" mm" << endl;
infoFile << "Rotation(phi,theta,psi): " << phi <<" "<< theta <<" "<< psi <<" deg"<< endl;
infoFile << setw(2) << "i" << setw(10) << "Z,mm" << setw(10) << "Rin,mm" << setw(10) << "Rout,mm" << setw(10) << "h,mm" << endl;
// create shape components for pipe4
TGeoPcon* p4 = MakeShape(nSects4, "p4", z4, rin4, rout4, &infoFile);
TGeoBBox* b = new TGeoBBox("b", 7., 7., shift); // cm 0.13
// create a composite for pipe4
//*
TGeoCompositeShape *cs1 = new TGeoCompositeShape("cs1", "p4:r1-b");
TGeoVolume *pipe4 = new TGeoVolume("pipe4",cs1, pipeMedium);
pipe4->SetLineColor(kGreen+2);
pipe->AddNode(pipe4, 0, t1);
//*/
// create shape components for pipevac3
TGeoPcon* p03 = MakeShape(nSects03, "p03", z03, rin03, rout03, &infoFileEmpty);
// create a composite for pipevac3
TGeoCompositeShape *cs2 = new TGeoCompositeShape("cs2", "p03:r1-b");
TGeoVolume *pipevac3 = new TGeoVolume("pipevac3",cs2, vacuum);
pipevac3->SetLineColor(kCyan);
pipe->AddNode(pipevac3, 0, t1);
//*
infoFile << endl << "Beam pipe section: " << pipe5name << endl;
infoFile << "Traslation(dx,dy,dz): "<< dx <<" "<< dy <<" "<< dz <<" mm" << endl;
infoFile << "Rotation(phi,theta,psi): " << phi <<" "<< theta <<" "<< psi <<" deg"<< endl;
infoFile << setw(2) << "i" << setw(10) << "Z,mm" << setw(10) << "Rin,mm" << setw(10) << "Rout,mm" << setw(10) << "h,mm" << endl;
TGeoVolume* pipe5 = MakePipe (5, nSects5, z5, rin5, rout5, pipeMedium, &infoFile);
pipe5->SetLineColor(kGreen);
pipe->AddNode(pipe5, 0, c1);
TGeoVolume* pipevac4 = MakeVacuum(4, nSects04, z04, rin04, rout04, vacuum, &infoFile);
pipevac4->SetLineColor(kCyan);
pipe->AddNode(pipevac4, 0, c1);
infoFile << endl << "Beam pipe section: " << pipe6name << endl;
infoFile << "Traslation(dx,dy,dz): "<< dx <<" "<< dy <<" "<< dz <<" mm" << endl;
infoFile << "Rotation(phi,theta,psi): " << phi <<" "<< theta <<" "<< psi <<" deg"<< endl;
infoFile << setw(2) << "i" << setw(10) << "Z,mm" << setw(10) << "Rin,mm" << setw(10) << "Rout,mm" << setw(10) << "h,mm" << endl;
TGeoVolume* pipe6 = MakePipe (6, nSects6, z6, rin6, rout6, pipeMedium, &infoFile);
pipe6->SetLineColor(kBlue);
pipe->AddNode(pipe6, 0, c1);
infoFile << endl << "Beam pipe section: " << pipe7name << endl;
infoFile << "Traslation(dx,dy,dz): "<< dx <<" "<< dy <<" "<< dz <<" mm" << endl;
infoFile << "Rotation(phi,theta,psi): " << phi <<" "<< theta <<" "<< psi <<" deg"<< endl;
infoFile << setw(2) << "i" << setw(10) << "Z,mm" << setw(10) << "Rin,mm" << setw(10) << "Rout,mm" << setw(10) << "h,mm" << endl;
TGeoVolume* pipe7 = MakePipe (7, nSects7, z7, rin7, rout7, pipeMedium, &infoFile);
pipe7->SetLineColor(kGreen);
pipe->AddNode(pipe7, 0, c1);
TGeoVolume* pipevac5 = MakeVacuum(5, nSects05, z05, rin05, rout05, vacuum, &infoFile);
pipevac5->SetLineColor(kCyan);
pipe->AddNode(pipevac5, 0, c1);
//*/
// ----- End --------------------------------------------------
// --------------- Finish -----------------------------------------------
top->AddNode(pipe, 1);
cout << endl << endl;
gGeoMan->CloseGeometry();
gGeoMan->CheckOverlaps(0.001);
gGeoMan->PrintOverlaps();
gGeoMan->Test();
// visualize it with ray tracing, OGL/X3D viewer
//top->Raytrace();
top->Draw("ogl");
//top->Draw("x3d");
TFile* rootFile = new TFile(rootFileName, "RECREATE");
top->Write();
cout << endl;
cout << "Geometry " << top->GetName() << " written to "
<< rootFileName << endl;
rootFile->Close();
infoFile.close();
}
示例14: south_gate
//.........这里部分代码省略.........
top->AddNodeOverlap(mBlock,1,new TGeoCombiTrans(0,110,550, new TGeoRotation("r1",0,45,0)));
sprintf(nBlocks,"ab%d",N++);
mBlock = geom->MakeBox(nBlocks, Iron, 110,10,2);
mBlock->SetLineColor(42);
top->AddNodeOverlap(mBlock,1,new TGeoCombiTrans(335,0,550, new TGeoRotation("r1",90,-45,0)));
sprintf(nBlocks,"ab%d",N++);
mBlock = geom->MakeBox(nBlocks, Iron, 110,10,2);
mBlock->SetLineColor(42);
top->AddNodeOverlap(mBlock,1,new TGeoCombiTrans(-335,0,550, new TGeoRotation("r1",90,45,0)));
////////////////////////////////add box
k=0; i=0;
while (i<5){
while(k<6){
sprintf(nBlocks,"ab%d",N++);
mBlock = geom->MakeBox(nBlocks,Iron,18,10,2);
mBlock->SetLineColor(8);
{
top->AddNodeOverlap(mBlock,1,new TGeoCombiTrans(-270+(k*100),-111,550, new TGeoRotation("r1",0,-45,0)));
}
k++;
}
i++; k=0;
}
k=0; i=0;
while (i<5){
while(k<6){
sprintf(nBlocks,"ab%d",N++);
mBlock = geom->MakeBox(nBlocks,Iron,18,10,2);
mBlock->SetLineColor(8);
{
top->AddNodeOverlap(mBlock,1,new TGeoCombiTrans(-270+(k*100),111,550, new TGeoRotation("r1",0,45,0)));
}
k++;
}
i++; k=0;
}
sprintf(nBlocks,"ab%d",N++);
mBlock = geom->MakeBox(nBlocks, Iron, 18,10,2);
mBlock->SetLineColor(8);
top->AddNodeOverlap(mBlock,1,new TGeoCombiTrans(336,0,550, new TGeoRotation("r1",90,-45,0)));
sprintf(nBlocks,"ab%d",N++);
mBlock = geom->MakeBox(nBlocks, Iron, 18,10,2);
mBlock->SetLineColor(8);
top->AddNodeOverlap(mBlock,1,new TGeoCombiTrans(-336,0,550, new TGeoRotation("r1",90,45,0)));
// | | | | |
sprintf(nBlocks,"ab%d",N++);
mBlock = geom->MakeBox(nBlocks, Iron, 300,75,40);
mBlock->SetLineColor(45);
top->AddNodeOverlap(mBlock,1,new TGeoCombiTrans(0,0,450, new TGeoRotation("r1",0,0,0)));
//kiwa
sprintf(nBlocks,"ab%d",N++);
mBlock = geom->MakeBox(nBlocks, Iron, 305,80,2.5);
mBlock->SetLineColor(10);
top->AddNodeOverlap(mBlock,1,new TGeoTranslation(0,0,430));
top->SetVisibility(0);
geom->CloseGeometry();
top->Draw("ogl");
}
示例15: robot
//.........这里部分代码省略.........
Bbul->SetLineColor(17);
Bbul->SetFillColor(17);
// drawing arms
top->AddNodeOverlap(S, 1, new TGeoCombiTrans(3, 73, 30, new TGeoRotation("R2", 0, -30, 0)));
top->AddNodeOverlap(S, 1, new TGeoCombiTrans(3, -73, 30, new TGeoRotation("R2", 0, 210, 0)));
top->AddNodeOverlap(S_1, 1, new TGeoCombiTrans(3, -73, 27, new TGeoRotation("R2", 0, 0, 0)));
top->AddNodeOverlap(S_1, 1, new TGeoCombiTrans(3, 73, 27, new TGeoRotation("R2", 0, 0, 0)));
top->AddNodeOverlap(Pal, 1, new TGeoCombiTrans(3, -73, -5, new TGeoRotation("R2", 0, 0, 0)));
top->AddNodeOverlap(Pal, 1, new TGeoCombiTrans(3, 73, -5, new TGeoRotation("R2", 0, 0, 0)));
top->AddNodeOverlap(Fal, 1, new TGeoCombiTrans(3, -73, -60, new TGeoRotation("R2", 0, 0, 0)));
top->AddNodeOverlap(Fal, 1, new TGeoCombiTrans(3, 73, -60, new TGeoRotation("R2", 0, 0, 0)));
top->AddNodeOverlap(Bbul, 1, new TGeoCombiTrans(3, -97, -72, new TGeoRotation("R2", 0, -90, 0)));
top->AddNodeOverlap(Bbul, 1, new TGeoCombiTrans(3, -97, -48, new TGeoRotation("R2", 0, -90, 0)));
top->AddNodeOverlap(Bbul, 1, new TGeoCombiTrans(3, 97, -72, new TGeoRotation("R2", 0, 90, 0)));
top->AddNodeOverlap(Bbul, 1, new TGeoCombiTrans(3, 97, -48, new TGeoRotation("R2", 0, 90, 0)));
// hands
TGeoVolume *Son_d = Robot->MakeBox("Son_d", Iron, 15, 15, 7);
Son_d->SetLineColor(4);
Son_d->SetFillColor(4);
TGeoVolume *Son_g = Robot->MakeBox("Son_g", Iron, 4, 10, 4);
Son_g->SetLineColor(4);
Son_g->SetFillColor(4);
TGeoVolume *Son_g1 = Robot->MakeBox("Son_g1", Iron, 6, 6, 6);
Son_g1->SetLineColor(4);
Son_g1->SetFillColor(4);
TGeoVolume *Son_g2 = Robot->MakeBox("Son_g2", Iron, 8, 3, 3);
Son_g2->SetLineColor(4);
Son_g2->SetFillColor(4);
TGeoVolume *Last_b = Robot->MakeCone("Last_b", Iron, 10, 0, 0, 0, 4);
Last_b->SetLineColor(17);
Last_b->SetFillColor(17);
TGeoVolume *Last = Robot->MakeSphere("Last", Iron, 0, 3, 0, 180, 0, 360);
Last->SetLineColor(2);
Last->SetFillColor(2);
// drawing hands
top->AddNodeOverlap(Son_d, 1, new TGeoCombiTrans(3, -80, -105, new TGeoRotation("R2", 0, 90, 0)));
for (int i = 0; i < 4; i++) {
top->AddNodeOverlap(Son_g, 1, new TGeoCombiTrans(-6 + 6 * i, -72, -118, new TGeoRotation("R2", 0, -10, 0)));
}
for (int i = 0; i < 4; i++) {
top->AddNodeOverlap(Son_g, 1, new TGeoCombiTrans(-6 + 6 * i, -67, -113, new TGeoRotation("R2", 0, 110, 0)));
}
top->AddNodeOverlap(Son_g1, 1, new TGeoCombiTrans(-5, -70, -98, new TGeoRotation("R2", 0, 0, 0)));
top->AddNodeOverlap(Son_g2, 1, new TGeoCombiTrans(-5, -65, -102, new TGeoRotation("R2", 0, 60, 0)));
top->AddNodeOverlap(Son_d, 1, new TGeoCombiTrans(3, 80, -105, new TGeoRotation("R2", 0, 90, 0)));
for (int i = 0; i < 4; i++) {
top->AddNodeOverlap(Son_g, 1, new TGeoCombiTrans(-6 + 6 * i, 72, -118, new TGeoRotation("R2", 0, 10, 0)));
}
for (int i = 0; i < 4; i++) {
top->AddNodeOverlap(Son_g, 1, new TGeoCombiTrans(-6 + 6 * i, 67, -113, new TGeoRotation("R2", 0, 70, 0)));
}
top->AddNodeOverlap(Son_g1, 1, new TGeoCombiTrans(-5, 70, -98, new TGeoRotation("R2", 0, 0, 0)));
top->AddNodeOverlap(Son_g2, 1, new TGeoCombiTrans(-5, 65, -102, new TGeoRotation("R2", 0, 60, 0)));
top->AddNodeOverlap(Last_b, 1, new TGeoCombiTrans(3, -88, -103, new TGeoRotation("R2", 0, 180, 0)));
top->AddNodeOverlap(Last_b, 1, new TGeoCombiTrans(12, -88, -103, new TGeoRotation("R2", 0, 180, 0)));
top->AddNodeOverlap(Last_b, 1, new TGeoCombiTrans(-7, -88, -103, new TGeoRotation("R2", 0, 180, 0)));
top->AddNodeOverlap(Last_b, 1, new TGeoCombiTrans(3, 88, -103, new TGeoRotation("R2", 0, 180, 0)));
top->AddNodeOverlap(Last_b, 1, new TGeoCombiTrans(12, 88, -103, new TGeoRotation("R2", 0, 180, 0)));
top->AddNodeOverlap(Last_b, 1, new TGeoCombiTrans(-7, 88, -103, new TGeoRotation("R2", 0, 180, 0)));
top->AddNodeOverlap(Last, 1, new TGeoCombiTrans(3, -88, -112, new TGeoRotation("R2", 0, 180, 0)));
top->AddNodeOverlap(Last, 1, new TGeoCombiTrans(12, -88, -112, new TGeoRotation("R2", 0, 180, 0)));
top->AddNodeOverlap(Last, 1, new TGeoCombiTrans(-7, -88, -112, new TGeoRotation("R2", 0, 180, 0)));
top->AddNodeOverlap(Last, 1, new TGeoCombiTrans(3, 88, -112, new TGeoRotation("R2", 0, 180, 0)));
top->AddNodeOverlap(Last, 1, new TGeoCombiTrans(12, 88, -112, new TGeoRotation("R2", 0, 180, 0)));
top->AddNodeOverlap(Last, 1, new TGeoCombiTrans(-7, 88, -112, new TGeoRotation("R2", 0, 180, 0)));
for (int i = 1; i < 20; i += 1) {
if (i < 7) {
TGeoVolume *Effect =
Robot->MakeCons("Effect", Iron, 3, 20 / sin(i), 21 / sin(i), 20 / sin(i), 21 / sin(i), 0, 70);
Effect->SetLineColor(9);
Effect->SetFillColor(9);
top->AddNodeOverlap(Effect, 1, new TGeoTranslation(3, 0, -280));
}
if (6 < i && i < 10) {
TGeoVolume *Effect =
Robot->MakeCons("Effect", Iron, 5, 20 / sin(i), 21 / sin(i), 20 / sin(i), 21 / sin(i), 50, 120);
Effect->SetLineColor(38);
Effect->SetFillColor(38);
top->AddNodeOverlap(Effect, 1, new TGeoTranslation(3, 0, -280));
}
if (9 < i && i < 20) {
TGeoVolume *Effect =
Robot->MakeCons("Effect", Iron, 4, 20 / sin(i), 21 / sin(i), 20 / sin(i), 21 / sin(i), 200, 330);
Effect->SetLineColor(33);
Effect->SetFillColor(33);
top->AddNodeOverlap(Effect, 1, new TGeoTranslation(3, 0, -280));
}
}
// close geometry
top->SetVisibility(0);
Robot->CloseGeometry();
// in GL viewer
top->Draw("ogl");
}