当前位置: 首页>>代码示例>>C++>>正文


C++ TGeoManager::MakeTube方法代码示例

本文整理汇总了C++中TGeoManager::MakeTube方法的典型用法代码示例。如果您正苦于以下问题:C++ TGeoManager::MakeTube方法的具体用法?C++ TGeoManager::MakeTube怎么用?C++ TGeoManager::MakeTube使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TGeoManager的用法示例。


在下文中一共展示了TGeoManager::MakeTube方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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: {
//.........这里部分代码省略.........
开发者ID:My-Source,项目名称:root,代码行数:101,代码来源:glViewerLOD.C

示例2: 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));
//.........这里部分代码省略.........
开发者ID:ThomasRuf,项目名称:FairShip,代码行数:101,代码来源:snoopy.C

示例3: geom_Al


//.........这里部分代码省略.........

  // //----------------------
  // // Create the front foil
  // //----------------------

  // Calculate the range = 0.4814;
  double range_cm = range/density;

  // Calculate the thickness of the front foil
  double front_thickness = range_cm - half_cal_thickness;

  TGeoVolume* front_foil;
  if (front_thickness > 0.0 )
  {
    // Height (given - largest dimension)
    height = 8.89;
    // Half side length
    half_height = height/2.0;

    front_foil =
      geom->MakeBox( "Front_Foil", med_1, half_height, half_height, front_thickness/2.0 );

    front_foil->SetUniqueID( 2 );
    front_foil->SetLineColor( 3 );
  }

  //--------------------------------------------------------
  // Create the infinite plate (D = 7.62 cm, h = "infinite")
  //--------------------------------------------------------

  double plate_radius = 3.81;
  double plate_half_length = 0.5;
  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 );
开发者ID:lkersting,项目名称:frensie-tests,代码行数:66,代码来源:geom_Al.c


注:本文中的TGeoManager::MakeTube方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。