Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
parallel_world.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_geom
3/// Misaligning geometry generate in many cases overlaps, due to the idealization
4/// of the design and the fact that in real life movements of the geometry volumes
5/// have constraints and are correlated.
6///
7/// This typically generates inconsistent
8/// response of the navigation methods, leading to inefficiencies during tracking,
9/// errors in the material budget calculations, and so on. Among those, there are
10/// dangerous cases when the hidden volumes are sensitive.
11/// This macro demonstrates how to use the "parallel world" feature to assign
12/// highest navigation priority to some physical paths in geometry.
13///
14/// \macro_image
15/// \macro_code
16///
17/// \author Andrei Gheata
18
19void align();
20
21//______________________________________________________________________________
23{
24 // web geometry display does not support "parallel world" feature
25 gROOT->SetWebDisplay("off");
26
27 TGeoManager *geom = new TGeoManager("parallel_world", "Showcase for prioritized physical paths");
28 TGeoMaterial *matV = new TGeoMaterial("Vac", 0, 0, 0);
29 TGeoMedium *medV = new TGeoMedium("MEDVAC", 1, matV);
30 TGeoMaterial *matAl = new TGeoMaterial("Al", 26.98, 13, 2.7);
31 TGeoMedium *medAl = new TGeoMedium("MEDAL", 2, matAl);
32 TGeoMaterial *matSi = new TGeoMaterial("Si", 28.085, 14, 2.329);
33 TGeoMedium *medSi = new TGeoMedium("MEDSI", 3, matSi);
34 TGeoVolume *top = gGeoManager->MakeBox("TOP", medV, 100, 400, 1000);
36
37 // Shape for the support block
38 TGeoBBox *sblock = new TGeoBBox("sblock", 20, 10, 2);
39 // The volume for the support
40 TGeoVolume *support = new TGeoVolume("block", sblock, medAl);
41 support->SetLineColor(kGreen);
42
43 // Shape for the sensor to be prioritized in case of overlap
44 TGeoBBox *ssensor = new TGeoBBox("sensor", 19, 9, 0.2);
45 // The volume for the sensor
46 TGeoVolume *sensor = new TGeoVolume("sensor", ssensor, medSi);
47 sensor->SetLineColor(kRed);
48
49 // Chip assembly of support+sensor
51 chip->AddNode(support, 1);
52 chip->AddNode(sensor, 1, new TGeoTranslation(0, 0, -2.1));
53
54 // A ladder that normally sags
55 TGeoBBox *sladder = new TGeoBBox("sladder", 20, 300, 5);
56 // The volume for the ladder
57 TGeoVolume *ladder = new TGeoVolume("ladder", sladder, medAl);
58 ladder->SetLineColor(kBlue);
59
60 // Add nodes
61 top->AddNode(ladder, 1);
62 for (Int_t i = 0; i < 10; i++)
63 top->AddNode(chip, i + 1, new TGeoTranslation(0, -225. + 50. * i, 10));
64
66 TGeoParallelWorld *pw = nullptr;
67 if (usepw)
68 pw = gGeoManager->CreateParallelWorld("priority_sensors");
69 // Align chips
70 align();
71 if (usepw) {
72 if (useovlp)
73 pw->AddOverlap(ladder);
74 pw->CloseGeometry();
76 }
78 cname = usepw ? "cpw" : "cnopw";
79 TCanvas *c = (TCanvas *)gROOT->GetListOfCanvases()->FindObject(cname);
80 if (c)
81 c->cd();
82 else
83 c = new TCanvas(cname, "", 800, 600);
84 top->Draw();
85 // top->RandomRays(0,0,0,0,sensor->GetName());
86 // Track random "particles" coming from the block side and draw only the tracklets
87 // actually crossing one of the sensors. Note that some of the tracks coming
88 // from the outer side may see the full sensor, while the others only part of it.
90 timer.Start();
91 top->RandomRays(100000, 0, 0, -30, sensor->GetName());
92 timer.Stop();
93 timer.Print();
94 TView3D *view = (TView3D *)gPad->GetView();
95 if (view) {
96 view->SetParallel();
97 view->Side();
98 }
99 if (usepw)
100 pw->PrintDetectedOverlaps();
101}
102
103//______________________________________________________________________________
104void align()
105{
106 // Aligning 2 sensors so they will overlap with the support. One sensor is positioned
107 // normally while the other using the shared matrix
108 TGeoPhysicalNode *node;
111 for (Int_t i = 0; i < 10; i++) {
112 node = gGeoManager->MakePhysicalNode(TString::Format("/TOP_1/chip_%d", i + 1));
113 sag = 8. - 0.494 * (i - 4.5) * (i - 4.5);
114 TGeoTranslation *tr = new TGeoTranslation(0., -225. + 50. * i, 10 - sag);
115 node->Align(tr);
116 if (pw)
117 pw->AddNode(TString::Format("/TOP_1/chip_%d", i + 1));
118 }
119}
#define c(i)
Definition RSha256.hxx:101
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
double Double_t
Definition RtypesCore.h:59
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
@ kRed
Definition Rtypes.h:66
@ kGreen
Definition Rtypes.h:66
@ kBlue
Definition Rtypes.h:66
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char cname
R__EXTERN TGeoManager * gGeoManager
#define gROOT
Definition TROOT.h:406
#define gPad
The Canvas class.
Definition TCanvas.h:23
Box class.
Definition TGeoBBox.h:17
The manager class for any TGeo geometry.
Definition TGeoManager.h:44
TGeoParallelWorld * GetParallelWorld() const
TGeoPhysicalNode * MakePhysicalNode(const char *path=nullptr)
Makes a physical node corresponding to a path.
void CloseGeometry(Option_t *option="d")
Closing geometry implies checking the geometry validity, fixing shapes with negative parameters (run-...
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 SetTopVolume(TGeoVolume *vol)
Set the top volume and corresponding node as starting point of the geometry.
void SetUseParallelWorldNav(Bool_t flag)
Activate/deactivate usage of parallel world navigation.
TGeoParallelWorld * CreateParallelWorld(const char *name)
Create a parallel world for prioritised navigation.
Base class describing materials.
Media are used to store properties related to tracking and which are useful only when using geometry ...
Definition TGeoMedium.h:23
Base class for a flat parallel geometry.
Physical nodes are the actual 'touchable' objects in the geometry, representing a path of positioned ...
Bool_t Align(TGeoMatrix *newmat=nullptr, TGeoShape *newshape=nullptr, Bool_t check=kFALSE, Double_t ovlp=0.001)
Align a physical node with a new relative matrix/shape.
Class describing translations.
Definition TGeoMatrix.h:116
Volume assemblies.
Definition TGeoVolume.h:316
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition TGeoVolume.h:43
void RandomRays(Int_t nrays=10000, Double_t startx=0, Double_t starty=0, Double_t startz=0, const char *target_vol=nullptr, Bool_t check_norm=kFALSE)
Random raytracing method.
virtual TGeoNode * AddNode(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=nullptr, Option_t *option="")
Add a TGeoNode to the list of nodes.
void Draw(Option_t *option="") override
draw top volume according to option
TObject * FindObject(const char *name) const override
Search if object named name is inside this pad or in pads inside this pad.
Definition TPad.cxx:2700
Stopwatch class.
Definition TStopwatch.h:28
Basic string class.
Definition TString.h:139
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:2378
The 3D view class.
Definition TView3D.h:29
void SetParallel() override
Set the parallel option (default).
Definition TView3D.cxx:1304
void Side() override
Definition TView3D.cxx:1933