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


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

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


在下文中一共展示了TGeoManager::CloseGeometry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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");
}
开发者ID:alisw,项目名称:geant4_vmc,代码行数:55,代码来源:OpNoviceGeom.C

示例2: endDocument

void LCDDImp::endDocument() {
  TGeoManager* mgr = m_manager;
  if (!mgr->IsClosed()) {
#if 0
    Region trackingRegion("TrackingRegion");
    trackingRegion.setThreshold(1);
    trackingRegion.setStoreSecondaries(true);
    add(trackingRegion);
    m_trackingVol.setRegion(trackingRegion);
    // Set the tracking volume to invisible.
    VisAttr trackingVis("TrackingVis");
    trackingVis.setVisible(false);
    m_trackingVol.setVisAttributes(trackingVis);
    add(trackingVis);
#endif
    /// Since we allow now for anonymous shapes,
    /// we will rename them to use the name of the volume they are assigned to
    mgr->CloseGeometry();
    ShapePatcher patcher(m_volManager, m_world);
    patcher.patchShapes();
    mapDetectorTypes();
  }
}
开发者ID:vvolkl,项目名称:DD4hep,代码行数:23,代码来源:LCDDImp.cpp

示例3: 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;
}
开发者ID:andrewadare,项目名称:svxgeo,代码行数:37,代码来源:AddLadder.C

示例4: 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();
}
开发者ID:star-bnl,项目名称:star-emc,代码行数:95,代码来源:show.C

示例5: 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");

}
开发者ID:ThomasRuf,项目名称:FairShip,代码行数:101,代码来源:snoopy.C

示例6: assembly

void assembly()
{
//--- Definition of a simple geometry
    gSystem->Load("libGeom");
    TGeoManager *geom = new TGeoManager("Assemblies",
                                        "Geometry using assemblies");
    Int_t i;
    //--- 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("Aluminium",2, matAl);

    //--- make the top container volume
    TGeoVolume *top = geom->MakeBox("TOP", Vacuum, 1000., 1000., 100.);
    geom->SetTopVolume(top);

    // Make the elementary assembly of the whole structure
    TGeoVolume *tplate = new TGeoVolumeAssembly("TOOTHPLATE");

    Int_t ntooth = 5;
    Double_t xplate = 25;
    Double_t yplate = 50;
    Double_t xtooth = 10;
    Double_t ytooth = 0.5*yplate/ntooth;
    Double_t dshift = 2.*xplate + xtooth;
    Double_t xt,yt;

    TGeoVolume *plate = geom->MakeBox("PLATE", Al, xplate,yplate,1);
    plate->SetLineColor(kBlue);
    TGeoVolume *tooth = geom->MakeBox("TOOTH", Al, xtooth,ytooth,1);
    tooth->SetLineColor(kBlue);
    tplate->AddNode(plate,1);
    for (i=0; i<ntooth; i++) {
        xt = xplate+xtooth;
        yt = -yplate + (4*i+1)*ytooth;
        tplate->AddNode(tooth, i+1, new TGeoTranslation(xt,yt,0));
        xt = -xplate-xtooth;
        yt = -yplate + (4*i+3)*ytooth;
        tplate->AddNode(tooth, ntooth+i+1, new TGeoTranslation(xt,yt,0));
    }

    TGeoRotation *rot1 = new TGeoRotation();
    rot1->RotateX(90);
    TGeoRotation *rot;
    // Make a hexagone cell out of 6 tooth plates. These can zip together
    // without generating overlaps (they are self-contained)
    TGeoVolume *cell = new TGeoVolumeAssembly("CELL");
    for (i=0; i<6; i++) {
        Double_t phi =  60.*i;
        Double_t phirad = phi*TMath::DegToRad();
        Double_t xp = dshift*TMath::Sin(phirad);
        Double_t yp = -dshift*TMath::Cos(phirad);
        rot = new TGeoRotation(*rot1);
        rot->RotateZ(phi);
        cell->AddNode(tplate,i+1,new TGeoCombiTrans(xp,yp,0,rot));
    }

    // Make a row as an assembly of cells, then combine rows in a honeycomb
    // structure. This again works without any need to define rows as
    // "overlapping"
    TGeoVolume *row = new TGeoVolumeAssembly("ROW");
    Int_t ncells = 5;
    for (i=0; i<ncells; i++) {
        Double_t ycell = (2*i+1)*(dshift+10);
        row->AddNode(cell, ncells+i+1, new TGeoTranslation(0,ycell,0));
        row->AddNode(cell,ncells-i,new TGeoTranslation(0,-ycell,0));
    }

    Double_t dxrow = 3.*(dshift+10.)*TMath::Tan(30.*TMath::DegToRad());
    Double_t dyrow = dshift+10.;
    Int_t nrows = 5;
    for (i=0; i<nrows; i++) {
        Double_t xrow = 0.5*(2*i+1)*dxrow;
        Double_t yrow = 0.5*dyrow;
        if ((i%2)==0) yrow = -yrow;
        top->AddNode(row, nrows+i+1, new TGeoTranslation(xrow,yrow,0));
        top->AddNode(row, nrows-i, new TGeoTranslation(-xrow,-yrow,0));
    }

    //--- close the geometry
    geom->CloseGeometry();

    geom->SetVisLevel(4);
    geom->SetVisOption(0);
    top->Draw();
}
开发者ID:Y--,项目名称:root,代码行数:88,代码来源:assembly.C

示例7: event3D

void event3D()
{
  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);

     //--- make the top container volume
   Double_t worldx = 110.;
   Double_t worldy = 50.;
   Double_t worldz = 5.;

   TGeoVolume *top = geom->MakeBox("TOP", Vacuum, 100., 100., 100.);
   geom->SetTopVolume(top);

   gGeoManager->GetVolume("TOP")->InvisibleAll();

   //Measurements (in cm)
   
   Double_t target_rad = 0.3;
   Double_t target_len = 48.58;

   Double_t RTPC_len = 41.;
   
   Double_t foil1_R1 = 2.;
   Double_t foil1_R2 = 2.0000018;

   Double_t foil2_R1 = 3.;
   Double_t foil2_R2 = 3.0000018;

   Double_t GEM1_R1 = 7.;
   Double_t GEM1_R2 = 7.0005;

   Double_t GEM2_R1 = 7.3;
   Double_t GEM2_R2 = 7.3005;

   Double_t GEM3_R1 = 7.6;
   Double_t GEM3_R2 = 7.6005;

   Double_t Z_offset = 0;

   Int_t trans_lvl = 70;
   
   TGeoTube *target = new TGeoTube("target_tube",0, target_rad, target_len/2);
   
   TGeoVolume *target_vol = new TGeoVolume("target_vol",target, Al); //(*)

   top->AddNode(target_vol,1,new TGeoTranslation(0,0, Z_offset));
   gGeoManager->GetVolume("target_vol")->SetTransparency(0);   

   TGeoTube *foil1 = new TGeoTube("foil1_tube", foil1_R1, foil1_R2, RTPC_len/2);
   
   TGeoVolume *foil1_vol = new TGeoVolume("foil1_vol", foil1, Al); //(*)

   top->AddNode(foil1_vol,1,new TGeoTranslation(0,0, Z_offset));


   TGeoTube *foil2 = new TGeoTube("foil2_tube", foil2_R1, foil2_R2, RTPC_len/2);
   
   TGeoVolume *foil2_vol = new TGeoVolume("foil2_vol", foil2, Al); //(*)

   top->AddNode(foil2_vol,1,new TGeoTranslation(0,0, Z_offset));


   TGeoTube *gem1 = new TGeoTube("gem1_tube", GEM1_R1, GEM1_R2, RTPC_len/2);
   TGeoVolume *gem1_vol = new TGeoVolume("gem1_vol", gem1, Al); //(*)
   gem1_vol->SetLineColor(kOrange);
   top->AddNode(gem1_vol,1,new TGeoTranslation(0,0, Z_offset));

   TGeoTube *gem2 = new TGeoTube("gem2_tube", GEM2_R1, GEM2_R2, RTPC_len/2);
   TGeoVolume *gem2_vol = new TGeoVolume("gem2_vol", gem2, Al); //(*)
   gem2_vol->SetLineColor(kGreen);
   top->AddNode(gem2_vol,1,new TGeoTranslation(0,0, Z_offset));

   TGeoTube *gem3 = new TGeoTube("gem3_tube", GEM3_R1, GEM3_R2, RTPC_len/2);
   TGeoVolume *gem3_vol = new TGeoVolume("gem3_vol", gem3, Al); //(*)
   top->AddNode(gem3_vol,1,new TGeoTranslation(0,0, Z_offset));
   gem3_vol->SetLineColor(kRed);
   gGeoManager->GetVolume("gem3_vol")->SetTransparency(trans_lvl);   

   
   //--- draw the ROOT box.
   // by default the picture will appear in the standard ROOT TPad.
   //if you have activated the following line in system.rootrc,
   //it will appear in the GL viewer
   //#Viewer3D.DefaultDrawOption:   ogl
   
   geom->CloseGeometry();
   
   geom->SetVisLevel(4);
  
   //   top->SetVisibility(kFALSE);
   top->Draw("ogl");
   gWorld = top;
}
开发者ID:jixie,项目名称:AnaRTPC,代码行数:100,代码来源:event_macro.C

示例8: 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"); 
}
开发者ID:Simple-Shyam,项目名称:Phd-work,代码行数:101,代码来源:startdetector1.C

示例9: 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;
}
开发者ID:amadio,项目名称:geant,代码行数:92,代码来源:runGPU0.C

示例10: 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");
}
开发者ID:alcap-org,项目名称:AlcapDAQ,代码行数:65,代码来源:nucleus.C

示例11: 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();


}
开发者ID:NicolasWinckler,项目名称:CbmRoot,代码行数:101,代码来源:create_bpipe_geometry_v14c.C

示例12: main

int main(int argc, char * argv[])
{

   // generate benchmark cases
   TransformationMatrix const * identity = new TransformationMatrix(0,0,0,0,0,0);

   double L = 10.;
   double Lz = 10.;
   const double Sqrt2 = sqrt(2.);

   TGeoManager * geom = new TGeoManager("simple1", "ToyDetector");
   TGeoMaterial * matVacuum = new TGeoMaterial("Vacuum",0,0,0);

   TGeoMedium * vac = new TGeoMedium("Vacuum",1,matVacuum);
   TGeoVolume * world = geom->MakeBox("world", vac, L, L, Lz  );

   geom->SetTopVolume( world );

   TGeoVolume * boxlevel2 = geom->MakeBox( "boxlevel2", vac, Sqrt2*L/2./2., Sqrt2*L/2./2.,Lz);
   TGeoVolume * boxlevel3 = geom->MakeBox( "boxlevel3", vac, L/2./2.,L/2./2.,Lz);
   TGeoVolume * boxlevel1 = geom->MakeBox( "boxlevel1", vac, L/2.,L/2., Lz);

   boxlevel2->AddNode( boxlevel3, 1, new TGeoRotation("mat1",0,0,-45));
   boxlevel1->AddNode( boxlevel2, 1, new TGeoRotation("mat2",0,0,45));
   world->AddNode( boxlevel1, 1, new TGeoTranslation("trans1",-L/2., 0,0 ) );
   world->AddNode( boxlevel1, 2, new TGeoTranslation("trans2",L/2., 0,0 ) );
   geom->CloseGeometry();
   delete world->GetVoxels();
   world->SetVoxelFinder(0);

    // perform basic tests
   TGeoNavigator * nav = geom->GetCurrentNavigator(); // new TGeoNavigator(geom);
   StopWatch timer;

   timer.Start();
   int stepsdone=0;
   for(int n=0;n<1000;n++)
     {
   for(int i=0;i<100000;i++)
   // testing the NavigationAndStepInterface
   {
      int localstepsdone=0;
      double distancetravelled=0.;
      Vector3D p;
      PhysicalVolume::samplePoint( p, L, L, Lz, 1. );

      //std::cerr << p << std::endl;
      //setup point in world
      Vector3D d(1,0,0);

      TGeoNode const * vol;
      nav->SetCurrentPoint( p.x, p.y, p.z );
      nav->SetCurrentDirection( d.x, d.y, d.z);
      vol=nav->FindNode(p.x,p.y,p.z);

      while( vol!=NULL )
      {
         localstepsdone++;

         // do one step ( this will internally adjust the current point and so on )
         vol = nav->FindNextBoundaryAndStep(Utils::kInfinity);

         distancetravelled+=nav->GetStep();
         //double const * p = nav->GetCurrentPoint();
         //double const * pl = nav->GetLastPoint();
         //double const * cd = nav->GetCurrentDirection();

         //std::cerr << " proposed step: " << nav->GetStep();
         //std::cerr << " current point " << p[0] << " " << p[1] << " " << p[2] << std::endl;
         //std::cerr << " last point " << pl[0] << " " << pl[1] << " " << pl[2] << std::endl;
         //std::cerr << " current dir " << cd[0] << " " << cd[1] << " " << cd[2] << std::endl;
      }
   //   std::cerr << localstepsdone << " " << distancetravelled << std::endl;
      stepsdone+=localstepsdone;
   }
     }
   timer.Stop();
   std::cout << " time for 100000 particles " << timer.getDeltaSecs( ) << std::endl;
   std::cout << " average steps done " << stepsdone / 100000. << std::endl;
   std::cout << " time per step " << timer.getDeltaSecs()/stepsdone << std::endl;
}
开发者ID:sawenzel,项目名称:VecGeom,代码行数:81,代码来源:NavigationInBoxDetector_Benchmark_ROOT.cpp

示例13: 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);
}
开发者ID:lkersting,项目名称:frensie-tests,代码行数:101,代码来源:geom_Al.c

示例14: 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");
}
开发者ID:amadio,项目名称:geant,代码行数:101,代码来源:robot.C

示例15: 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");
}
开发者ID:My-Source,项目名称:root,代码行数:101,代码来源:glViewerLOD.C


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