ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
parallel_world.C
Go to the documentation of this file.
1 void align();
2 
3 //______________________________________________________________________________
4 void parallel_world(Bool_t usepw=kTRUE, Bool_t useovlp=kTRUE)
5 {
6 // Misaligning geometry generate in many cases overlaps, due to the idealization
7 // of the design and the fact that in real life movements of the geometry volumes
8 // have constraints and are correlated. This typically generates inconsistent
9 // response of the navigation methods, leading to inefficiencies during tracking,
10 // errors in the material budget calculations, and so on. Among those, there are
11 // dangerous cases when the hidden volumes are sensitive.
12 // This macro demonstrates how to use the "parallel world" feature to assign
13 // highest navigation priority to some physical paths in geometry.
14 //
15 
16  TGeoManager *geom = new TGeoManager("parallel_world", "Showcase for prioritized physical paths");
17  TGeoMaterial *matV = new TGeoMaterial("Vac", 0,0,0);
18  TGeoMedium *medV = new TGeoMedium("MEDVAC",1,matV);
19  TGeoMaterial *matAl = new TGeoMaterial("Al", 26.98,13,2.7);
20  TGeoMedium *medAl = new TGeoMedium("MEDAL",2,matAl);
21  TGeoMaterial *matSi = new TGeoMaterial("Si", 28.085,14,2.329);
22  TGeoMedium *medSi = new TGeoMedium("MEDSI",3,matSi);
23  TGeoVolume *top = gGeoManager->MakeBox("TOP",medV,100,400,1000);
25 
26  // Shape for the support block
27  TGeoBBox *sblock = new TGeoBBox("sblock", 20,10,2);
28  // The volume for the support
29  TGeoVolume *support = new TGeoVolume("block",sblock, medAl);
30  support->SetLineColor(kGreen);
31 
32  // Shape for the sensor to be prioritized in case of overlap
33  TGeoBBox *ssensor = new TGeoBBox("sensor", 19,9,0.2);
34  // The volume for the sensor
35  TGeoVolume *sensor = new TGeoVolume("sensor",ssensor, medSi);
36  sensor->SetLineColor(kRed);
37 
38  // Chip assembly of support+sensor
39  TGeoVolumeAssembly *chip = new TGeoVolumeAssembly("chip");
40  chip->AddNode(support, 1);
41  chip->AddNode(sensor,1, new TGeoTranslation(0,0,-2.1));
42 
43  // A ladder that normally sags
44  TGeoBBox *sladder = new TGeoBBox("sladder", 20,300,5);
45  // The volume for the ladder
46  TGeoVolume *ladder = new TGeoVolume("ladder",sladder, medAl);
47  ladder->SetLineColor(kBlue);
48 
49  // Add nodes
50  top->AddNode(ladder,1);
51  for (Int_t i=0; i<10; i++)
52  top->AddNode(chip, i+1, new TGeoTranslation(0, -225.+50.*i, 10));
53 
55  TGeoParallelWorld *pw = 0;
56  if (usepw) pw = gGeoManager->CreateParallelWorld("priority_sensors");
57 // Align chips
58  align();
59  if (usepw) {
60  if (useovlp) pw->AddOverlap(ladder);
61  pw->CloseGeometry();
63  }
64  TString cname;
65  cname = usepw ? "cpw" : "cnopw";
66  TCanvas *c = (TCanvas*)gROOT->GetListOfCanvases()->FindObject(cname);
67  if (c) c->cd();
68  else c = new TCanvas(cname, "",800,600);
69  top->Draw();
70 // top->RandomRays(0,0,0,0,sensor->GetName());
71  // Track random "particles" coming from the block side and draw only the tracklets
72  // actually crossing one of the sensors. Note that some of the tracks coming
73  // from the outer side may see the full sensor, while the others only part of it.
75  timer.Start();
76  top->RandomRays(100000,0,0,-30,sensor->GetName());
77  timer.Stop();
78  timer.Print();
79  TView3D *view = (TView3D*)gPad->GetView();
80  view->SetParallel();
81  view->Side();
82  if (usepw) pw->PrintDetectedOverlaps();
83 }
84 
85 //______________________________________________________________________________
86 void align()
87 {
88 // Aligning 2 sensors so they will overlap with the support. One sensor is positioned
89 // normally while the other using the shared matrix
90  TGeoPhysicalNode *node;
92  Double_t sag;
93  for (Int_t i=0; i<10; i++) {
94  node = gGeoManager->MakePhysicalNode(TString::Format("/TOP_1/chip_%d",i+1));
95  sag = 8.-0.494*(i-4.5)*(i-4.5);
96  TGeoTranslation *tr = new TGeoTranslation(0., -225.+50.*i, 10-sag);
97  node->Align(tr);
98  if (pw) pw->AddNode(TString::Format("/TOP_1/chip_%d",i+1));
99  }
100 }
void align()
void Print(Option_t *option="") const
Print the real and cpu time passed between the start and stop events.
Definition: TStopwatch.cxx:217
TGeoPhysicalNode * MakePhysicalNode(const char *path=0)
Makes a physical node corresponding to a path.
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
Definition: TStopwatch.cxx:56
return c
Definition: Rtypes.h:61
void AddNode(const char *path)
Add a node normally to this world. Overlapping nodes not allowed.
TVirtualPad * cd(Int_t subpadnumber=0)
Set current canvas & pad.
Definition: TCanvas.cxx:659
virtual void Draw(Option_t *option="")
draw top volume according to option
#define gROOT
Definition: TROOT.h:344
void SetTopVolume(TGeoVolume *vol)
Set the top volume and corresponding node as starting point of the geometry.
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Definition: Rtypes.h:61
virtual void SetParallel()
Set the parallel option (default).
Definition: TView3D.cxx:1360
TGeoParallelWorld * GetParallelWorld() const
Definition: TGeoManager.h:549
TStopwatch timer
Definition: pirndm.C:37
void Stop()
Stop the stopwatch.
Definition: TStopwatch.cxx:75
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
Definition: TString.cxx:2321
TGeoVolume * MakeBox(const char *name, TGeoMedium *medium, Double_t dx, Double_t dy, Double_t dz)
Make in one step a volume pointing to a box shape with given medium.
void AddOverlap(TGeoVolume *vol, Bool_t activate=kTRUE)
To use this optimization, the user should declare the full list of volumes which may overlap with any...
virtual void AddNode(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=0, Option_t *option="")
Add a TGeoNode to the list of nodes.
Definition: TGeoVolume.cxx:948
The 3D view class.
Definition: TView3D.h:31
void RandomRays(Int_t nrays=10000, Double_t startx=0, Double_t starty=0, Double_t startz=0, const char *target_vol=0, Bool_t check_norm=kFALSE)
Random raytracing method.
Int_t PrintDetectedOverlaps() const
Print the overlaps which were detected during real tracking.
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
void CloseGeometry(Option_t *option="d")
Closing geometry implies checking the geometry validity, fixing shapes with negative parameters (run-...
virtual void Side()
Definition: TView3D.cxx:1982
void SetUseParallelWorldNav(Bool_t flag)
Activate/deactivate usage of parallel world navigation.
virtual void AddNode(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=0, Option_t *option="")
Add a component to the assembly.
The Canvas class.
Definition: TCanvas.h:48
R__EXTERN TGeoManager * gGeoManager
Definition: TGeoManager.h:556
double Double_t
Definition: RtypesCore.h:55
Bool_t CloseGeometry()
The main geometry must be closed.
tuple view
Definition: tornado.py:20
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Bool_t Align(TGeoMatrix *newmat=0, TGeoShape *newshape=0, Bool_t check=kFALSE, Double_t ovlp=0.001)
Align a physical node with a new relative matrix/shape.
#define gPad
Definition: TVirtualPad.h:288
Definition: Rtypes.h:61
TGeoParallelWorld * CreateParallelWorld(const char *name)
Create a parallel world for prioritized navigation.
const Bool_t kTRUE
Definition: Rtypes.h:91
void parallel_world(Bool_t usepw=kTRUE, Bool_t useovlp=kTRUE)
Definition: parallel_world.C:4
Stopwatch class.
Definition: TStopwatch.h:30