本文整理汇总了C++中TGeoManager::MakeTubs方法的典型用法代码示例。如果您正苦于以下问题:C++ TGeoManager::MakeTubs方法的具体用法?C++ TGeoManager::MakeTubs怎么用?C++ TGeoManager::MakeTubs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TGeoManager
的用法示例。
在下文中一共展示了TGeoManager::MakeTubs方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rootgeom
void rootgeom()
{
//Definition of a simple geometry (the 4 ROOT characters)
//Author: Andrei Gheata
// gStyle->SetCanvasPreferGL(true);
gSystem->Load("libGeom");
TGeoManager *geom = new TGeoManager("simple1", "Simple geometry");
//--- define some materials
TGeoMaterial *matVacuum = new TGeoMaterial("Vacuum", 0,0,0);
TGeoMaterial *matAl = new TGeoMaterial("Al", 26.98,13,2.7);
// //--- define some media
TGeoMedium *Vacuum = new TGeoMedium("Vacuum",1, matVacuum);
TGeoMedium *Al = new TGeoMedium("Root Material",2, matAl);
//--- define the transformations
TGeoTranslation *tr1 = new TGeoTranslation(20., 0, 0.);
TGeoTranslation *tr2 = new TGeoTranslation(10., 0., 0.);
TGeoTranslation *tr3 = new TGeoTranslation(10., 20., 0.);
TGeoTranslation *tr4 = new TGeoTranslation(5., 10., 0.);
TGeoTranslation *tr5 = new TGeoTranslation(20., 0., 0.);
TGeoTranslation *tr6 = new TGeoTranslation(-5., 0., 0.);
TGeoTranslation *tr7 = new TGeoTranslation(7.5, 7.5, 0.);
TGeoRotation *rot1 = new TGeoRotation("rot1", 90., 0., 90., 270., 0., 0.);
TGeoCombiTrans *combi1 = new TGeoCombiTrans(7.5, -7.5, 0., rot1);
TGeoTranslation *tr8 = new TGeoTranslation(7.5, -5., 0.);
TGeoTranslation *tr9 = new TGeoTranslation(7.5, 20., 0.);
TGeoTranslation *tr10 = new TGeoTranslation(85., 0., 0.);
TGeoTranslation *tr11 = new TGeoTranslation(35., 0., 0.);
TGeoTranslation *tr12 = new TGeoTranslation(-15., 0., 0.);
TGeoTranslation *tr13 = new TGeoTranslation(-65., 0., 0.);
TGeoTranslation *tr14 = new TGeoTranslation(0,0,-100);
TGeoCombiTrans *combi2 = new TGeoCombiTrans(0,0,100,
new TGeoRotation("rot2",90,180,90,90,180,0));
TGeoCombiTrans *combi3 = new TGeoCombiTrans(100,0,0,
new TGeoRotation("rot3",90,270,0,0,90,180));
TGeoCombiTrans *combi4 = new TGeoCombiTrans(-100,0,0,
new TGeoRotation("rot4",90,90,0,0,90,0));
TGeoCombiTrans *combi5 = new TGeoCombiTrans(0,100,0,
new TGeoRotation("rot5",0,0,90,180,90,270));
TGeoCombiTrans *combi6 = new TGeoCombiTrans(0,-100,0,
new TGeoRotation("rot6",180,0,90,180,90,90));
//--- make the top container volume
Double_t worldx = 110.;
Double_t worldy = 50.;
Double_t worldz = 5.;
TGeoVolume *top = geom->MakeBox("TOP", Vacuum, 270., 270., 120.);
geom->SetTopVolume(top);
TGeoVolume *replica = geom->MakeBox("REPLICA", Vacuum,120,120,120);
replica->SetVisibility(kFALSE);
TGeoVolume *rootbox = geom->MakeBox("ROOT", Vacuum, 110., 50., 5.);
rootbox->SetVisibility(kFALSE);
//--- make letter 'R'
TGeoVolume *R = geom->MakeBox("R", Vacuum, 25., 25., 5.);
R->SetVisibility(kFALSE);
TGeoVolume *bar1 = geom->MakeBox("bar1", Al, 5., 25, 5.);
bar1->SetLineColor(kRed);
R->AddNode(bar1, 1, tr1);
TGeoVolume *bar2 = geom->MakeBox("bar2", Al, 5., 5., 5.);
bar2->SetLineColor(kRed);
R->AddNode(bar2, 1, tr2);
R->AddNode(bar2, 2, tr3);
TGeoVolume *tub1 = geom->MakeTubs("tub1", Al, 5., 15., 5., 90., 270.);
tub1->SetLineColor(kRed);
R->AddNode(tub1, 1, tr4);
TGeoVolume *bar3 = geom->MakeArb8("bar3", Al, 5.);
bar3->SetLineColor(kRed);
TGeoArb8 *arb = (TGeoArb8*)bar3->GetShape();
arb->SetVertex(0, 15., -5.);
arb->SetVertex(1, 0., -25.);
arb->SetVertex(2, -10., -25.);
arb->SetVertex(3, 5., -5.);
arb->SetVertex(4, 15., -5.);
arb->SetVertex(5, 0., -25.);
arb->SetVertex(6, -10., -25.);
arb->SetVertex(7, 5., -5.);
R->AddNode(bar3, 1, gGeoIdentity);
//--- make letter 'O'
TGeoVolume *O = geom->MakeBox("O", Vacuum, 25., 25., 5.);
O->SetVisibility(kFALSE);
TGeoVolume *bar4 = geom->MakeBox("bar4", Al, 5., 7.5, 5.);
bar4->SetLineColor(kYellow);
O->AddNode(bar4, 1, tr5);
O->AddNode(bar4, 2, tr6);
TGeoVolume *tub2 = geom->MakeTubs("tub1", Al, 7.5, 17.5, 5., 0., 180.);
tub2->SetLineColor(kYellow);
O->AddNode(tub2, 1, tr7);
O->AddNode(tub2, 2, combi1);
//--- make letter 'T'
TGeoVolume *T = geom->MakeBox("T", Vacuum, 25., 25., 5.);
T->SetVisibility(kFALSE);
TGeoVolume *bar5 = geom->MakeBox("bar5", Al, 5., 20., 5.);
bar5->SetLineColor(kBlue);
T->AddNode(bar5, 1, tr8);
//.........这里部分代码省略.........
示例2: 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)));
//.........这里部分代码省略.........
示例3: 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;
}
示例4: 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: {
//.........这里部分代码省略.........
示例5: main
//.........这里部分代码省略.........
// {
// for(auto j=0;j<np;++j)
// {
// Vector3D localp, localdir;
// sm->MasterToLocal(conventionalpoints[j], localp);
// sm->MasterToLocalVec(conventionaldirs[j], localdir);
// distances2[j]=unplaceddaughter->DistanceToIn( localp, localdir, steps[j]);
// }
// }
// timer.Stop();
// double t5 = timer.getDeltaSecs();
//
// // now unplaced version but inlined matrices
// timer.Start();
// for(int reps=0;reps<NREPS;reps++)
// {
// for(auto j=0;j<np;++j)
// {
// Vector3D localp, localdir;
// // this inlines I think
// tm->MasterToLocal<-1,-1>(conventionalpoints[j], localp);
// tm->MasterToLocalVec<-1>(conventionaldirs[j], localdir);
// distances2[j]=unplaceddaughter->DistanceToIn( localp, localdir, 1E30);
// }
// }
// timer.Stop();
// double t6 = timer.getDeltaSecs();
//
// std::cerr << "SCALAR " << tm->isTranslation() << " " << tm->isRotation() << "("<<tm->getNumberOfZeroEntries()<<")" << " " << t3 << " " << t4 << " " << t5 << " " << t6 << std::endl;
//
TGeoMatrix * rootmatrix= new TGeoCombiTrans(TransCases[t][0], TransCases[t][1], TransCases[t][2],
new TGeoRotation("rot1",EulerAngles[r][0], EulerAngles[r][1], EulerAngles[r][2]));
TGeoManager *geom = new TGeoManager("","");
TGeoVolume * vol = geom->MakeTubs("atube",0, tp->GetRmin(), tp->GetRmax(), tp->GetDZ(),tp->GetSPhi() *360/(2.*M_PI), tp->GetSPhi()+360*tp->GetDPhi()/(2.*M_PI));
TGeoShape * roottube=vol->GetShape();
// now the scalar version from ROOTGeantV
// timer.Start();
// for(int reps=0;reps<NREPS;reps++)
// {
// for(auto j=0;j<np;++j)
// {
// Vector3D localp, localdir;
// rootmatrix->MasterToLocal( &conventionalpoints[j].x, &localp.x );
// rootmatrix->MasterToLocalVect( &conventionaldirs[j].x, &localdir.x );
// distancesROOTSCALAR[j]=roottube->DistFromOutside( &localp.x, &localdir.x, 3, Utils::kInfinity, 0);
// }
// }
// timer.Stop();
// double t7 = timer.getDeltaSecs();
// now the scalar version from ROOTGeantV
timer.Start();
for(int reps=0;reps<NREPS;reps++)
{
for(auto j=0;j<np;++j)
{
Vector3D localp, localdir;
rootmatrix->MasterToLocal( &conventionalpoints[j].x, &localp.x );
rootmatrix->MasterToLocalVect( &conventionaldirs[j].x, &localdir.x );
distancesROOTSCALAR[j]=roottube->DistFromInside( &conventionalpoints[j].x, &conventionaldirs[j].x, 3, Utils::kInfinity, 0);
}
}
timer.Stop();
double t7 = timer.getDeltaSecs();