From $ROOTSYS/tutorials/geom/parallel_world.C

//______________________________________________________________________________
void parallel_world(Bool_t usepw=kTRUE, Bool_t useovlp=kTRUE)
{
// Misaligning geometry generate in many cases overlaps, due to the idealization
// of the design and the fact that in real life movements of the geometry volumes
// have constraints and are correlated. This typically generates inconsistent
// response of the navigation methods, leading to inefficiencies during tracking,
// errors in the material budget calculations, and so on. Among those, there are
// dangerous cases when the hidden volumes are sensitive.
// This macro demonstrates how to use the "parallel world" feature to assign
// highest navigation priority to some physical paths in geometry.
//

   TGeoManager *geom = new TGeoManager("parallel_world", "Showcase for prioritized physical paths");
   TGeoMaterial *matV = new TGeoMaterial("Vac", 0,0,0);
   TGeoMedium *medV = new TGeoMedium("MEDVAC",1,matV);
   TGeoMaterial *matAl = new TGeoMaterial("Al", 26.98,13,2.7);
   TGeoMedium *medAl = new TGeoMedium("MEDAL",2,matAl);
   TGeoMaterial *matSi = new TGeoMaterial("Si", 28.085,14,2.329);
   TGeoMedium *medSi = new TGeoMedium("MEDSI",3,matSi);
   TGeoVolume *top = gGeoManager->MakeBox("TOP",medV,100,400,1000);
   gGeoManager->SetTopVolume(top);

   // Shape for the support block
   TGeoBBox *sblock = new TGeoBBox("sblock", 20,10,2);
   // The volume for the support
   TGeoVolume *support = new TGeoVolume("block",sblock, medAl);
   support->SetLineColor(kGreen);

   // Shape for the sensor to be prioritized in case of overlap
   TGeoBBox *ssensor = new TGeoBBox("sensor", 19,9,0.2);
   // The volume for the sensor
   TGeoVolume *sensor = new TGeoVolume("sensor",ssensor, medSi);
   sensor->SetLineColor(kRed);

   // Chip assembly of support+sensor
   TGeoVolumeAssembly *chip = new TGeoVolumeAssembly("chip");
   chip->AddNode(support, 1);
   chip->AddNode(sensor,1, new TGeoTranslation(0,0,-2.1));

   // A ladder that normally sags
   TGeoBBox *sladder = new TGeoBBox("sladder", 20,300,5);
   // The volume for the ladder
   TGeoVolume *ladder = new TGeoVolume("ladder",sladder, medAl);
   ladder->SetLineColor(kBlue);

   // Add nodes
   top->AddNode(ladder,1);
   for (Int_t i=0; i<10; i++)
      top->AddNode(chip, i+1, new TGeoTranslation(0, -225.+50.*i, 10));

   gGeoManager->CloseGeometry();
   TGeoParallelWorld *pw = 0;
   if (usepw) pw = gGeoManager->CreateParallelWorld("priority_sensors");
// Align chips
   align();
   if (usepw) {
      if (useovlp) pw->AddOverlap(ladder);
      pw->CloseGeometry();
      gGeoManager->SetUseParallelWorldNav(kTRUE);
   }
   TString cname;
   cname = usepw ? "cpw" : "cnopw";
   TCanvas *c = (TCanvas*)gROOT->GetListOfCanvases()->FindObject(cname);
   if (c) c->cd();
   else   c = new TCanvas(cname, "",800,600);
   top->Draw();
//   top->RandomRays(0,0,0,0,sensor->GetName());
   // Track random "particles" coming from the block side and draw only the tracklets
   // actually crossing one of the sensors. Note that some of the tracks coming
   // from the outer side may see the full sensor, while the others only part of it.
   TStopwatch timer;
   timer.Start();
   top->RandomRays(100000,0,0,-30,sensor->GetName());
   timer.Stop();
   timer.Print();
   TView3D *view = (TView3D*)gPad->GetView();
   view->SetParallel();
   view->Side();
   if (usepw) pw->PrintDetectedOverlaps();
}

//______________________________________________________________________________
void align()
{
// Aligning 2 sensors so they will overlap with the support. One sensor is positioned
// normally while the other using the shared matrix
   TGeoPhysicalNode *node;
   TGeoParallelWorld *pw = gGeoManager->GetParallelWorld();
   Double_t sag;
   for (Int_t i=0; i<10; i++) {
      node = gGeoManager->MakePhysicalNode(TString::Format("/TOP_1/chip_%d",i+1));
      sag = 8.-0.494*(i-4.5)*(i-4.5);
      TGeoTranslation *tr = new TGeoTranslation(0., -225.+50.*i, 10-sag);
      node->Align(tr);
      if (pw) pw->AddNode(TString::Format("/TOP_1/chip_%d",i+1));
   }   
}
 parallel_world.C:1
 parallel_world.C:2
 parallel_world.C:3
 parallel_world.C:4
 parallel_world.C:5
 parallel_world.C:6
 parallel_world.C:7
 parallel_world.C:8
 parallel_world.C:9
 parallel_world.C:10
 parallel_world.C:11
 parallel_world.C:12
 parallel_world.C:13
 parallel_world.C:14
 parallel_world.C:15
 parallel_world.C:16
 parallel_world.C:17
 parallel_world.C:18
 parallel_world.C:19
 parallel_world.C:20
 parallel_world.C:21
 parallel_world.C:22
 parallel_world.C:23
 parallel_world.C:24
 parallel_world.C:25
 parallel_world.C:26
 parallel_world.C:27
 parallel_world.C:28
 parallel_world.C:29
 parallel_world.C:30
 parallel_world.C:31
 parallel_world.C:32
 parallel_world.C:33
 parallel_world.C:34
 parallel_world.C:35
 parallel_world.C:36
 parallel_world.C:37
 parallel_world.C:38
 parallel_world.C:39
 parallel_world.C:40
 parallel_world.C:41
 parallel_world.C:42
 parallel_world.C:43
 parallel_world.C:44
 parallel_world.C:45
 parallel_world.C:46
 parallel_world.C:47
 parallel_world.C:48
 parallel_world.C:49
 parallel_world.C:50
 parallel_world.C:51
 parallel_world.C:52
 parallel_world.C:53
 parallel_world.C:54
 parallel_world.C:55
 parallel_world.C:56
 parallel_world.C:57
 parallel_world.C:58
 parallel_world.C:59
 parallel_world.C:60
 parallel_world.C:61
 parallel_world.C:62
 parallel_world.C:63
 parallel_world.C:64
 parallel_world.C:65
 parallel_world.C:66
 parallel_world.C:67
 parallel_world.C:68
 parallel_world.C:69
 parallel_world.C:70
 parallel_world.C:71
 parallel_world.C:72
 parallel_world.C:73
 parallel_world.C:74
 parallel_world.C:75
 parallel_world.C:76
 parallel_world.C:77
 parallel_world.C:78
 parallel_world.C:79
 parallel_world.C:80
 parallel_world.C:81
 parallel_world.C:82
 parallel_world.C:83
 parallel_world.C:84
 parallel_world.C:85
 parallel_world.C:86
 parallel_world.C:87
 parallel_world.C:88
 parallel_world.C:89
 parallel_world.C:90
 parallel_world.C:91
 parallel_world.C:92
 parallel_world.C:93
 parallel_world.C:94
 parallel_world.C:95
 parallel_world.C:96
 parallel_world.C:97
 parallel_world.C:98
 parallel_world.C:99