Logo ROOT   6.18/05
Reference Guide
geodemo.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_geom
3/// Web-based GUI to draw the geometry shapes.
4///
5/// \macro_code
6///
7/// \author Andrei Gheata and Sergey Linev
8
9#include "TMath.h"
10#include "TControlBar.h"
11#include "TROOT.h"
12#include "TRandom.h"
13#include "TApplication.h"
14#include "TSystem.h"
15#include "TCanvas.h"
16#include "TGeoManager.h"
17#include "TGeoNode.h"
18#include "TPaveText.h"
19#include "TGeoBBox.h"
20#include "TGeoPara.h"
21#include "TGeoTube.h"
22#include "TGeoCone.h"
23#include "TGeoEltu.h"
24#include "TGeoSphere.h"
25#include "TGeoTorus.h"
26#include "TGeoTrd1.h"
27#include "TGeoTrd2.h"
28#include "TGeoParaboloid.h"
29#include "TGeoHype.h"
30#include "TGeoPcon.h"
31#include "TGeoPgon.h"
32#include "TGeoArb8.h"
33#include "TGeoXtru.h"
34#include "TGeoCompositeShape.h"
35#include "TGeoPhysicalNode.h"
36
37#include <ROOT/REveGeomViewer.hxx>
38
39
40
41Bool_t comments = kTRUE;
42Bool_t raytracing = kFALSE;
43Bool_t grotate = kFALSE;
44Bool_t show_axis = kTRUE;
45Int_t nsegments = 80;
46
47std::shared_ptr<ROOT::Experimental::REveGeomViewer> viewer;
48TGeoManager *oldGeoManager = nullptr;
49
50
51void DeleteGeometry()
52{
53 oldGeoManager = gGeoManager;
54 gGeoManager = nullptr;
55}
56
57//______________________________________________________________________________
58
59void ShowGeometry()
60{
61 if (!viewer)
62 viewer = std::make_shared<ROOT::Experimental::REveGeomViewer>();
63
64 viewer->SetGeometry(gGeoManager);
65
66 if (oldGeoManager) {
67 delete oldGeoManager;
68 oldGeoManager = nullptr;
69 }
70
71 std::string opt = "z";
72 if (show_axis) opt+=",axis";
73 if (grotate) opt+=",rotate";
74 viewer->SetDrawOptions(opt);
75
76 // show geometry viewer in web window (or refresh existing)
77 viewer->Show("?nobrowser");
78}
79
80//______________________________________________________________________________
81void MakePicture()
82{
83// TView *view = gPad->GetView();
84// if (view) {
85// if (axis) view->ShowAxis();
86// }
87// Bool_t is_raytracing = gGeoManager->GetGeomPainter()->IsRaytracing();
88// if (is_raytracing != raytracing) {
89// gGeoManager->GetGeomPainter()->SetRaytracing(raytracing);
90// gPad->Modified();
91// gPad->Update();
92// }
93}
94
95//______________________________________________________________________________
96void AddText(TPaveText *pave, const char *datamember, Double_t value, const char *comment)
97{
98 char line[128];
99 for (Int_t i=0; i<128; i++) line[i] = ' ';
100 memcpy(&line[0], datamember, strlen(datamember));
101 line[10] = '=';
102 char number[20];
103 sprintf(number, "%5.2f", value);
104 memcpy(&line[12], number, strlen(number));
105 line[26] = '=';
106 line[27] = '>';
107 sprintf(&line[30], "%s",comment);
108 TText *text = pave->AddText(line);
109// text->SetTextColor(4);
110 text->SetTextAlign(12);//12
111}
112
113//______________________________________________________________________________
114void AddText(TPaveText *pave, const char *datamember, Int_t value, const char *comment)
115{
116 char line[128];
117 for (Int_t i=0; i<128; i++) line[i] = ' ';
118 memcpy(&line[0], datamember, strlen(datamember));
119 line[10] = '=';
120 char number[20];
121 sprintf(number, "%5i", value);
122 memcpy(&line[12], number, strlen(number));
123 line[26] = '=';
124 line[27] = '>';
125 sprintf(&line[30], "%s",comment);
126 TText *text = pave->AddText(line);
127// text->SetTextColor(4);
128 text->SetTextAlign(12);
129}
130
131//______________________________________________________________________________
132void AddText(TPaveText *pave, TObject *pf, Int_t iaxis)
133{
134 char line[128];
136 if (!pave || !pf) return;
137 for (Int_t i=0; i<128; i++) line[i] = ' ';
138 TGeoVolume *volume = finder->GetVolume();
139 TGeoShape *sh = volume->GetShape();
140 sprintf(line, "Division of %s on axis %d (%s)", volume->GetName(), iaxis,sh->GetAxisName(iaxis));
141 TText *text = pave->AddText(line);
142 text->SetTextColor(3);
143 text->SetTextAlign(12);
144 AddText(pave, "fNdiv",finder->GetNdiv(),"number of divisions");
145 AddText(pave, "fStart",finder->GetStart(),"start divisioning position");
146 AddText(pave, "fStep",finder->GetStep(),"division step");
147}
148
149//______________________________________________________________________________
150void SavePicture(const char *name, TObject *objcanvas, TObject *objvol, Int_t iaxis, Double_t step)
151{
152}
153
154//______________________________________________________________________________
155Int_t randomColor()
156{
157 Double_t color = 7.*gRandom->Rndm();
158 return (1+Int_t(color));
159}
160
161//______________________________________________________________________________
162void raytrace() {
163 raytracing = !raytracing;
164 printf("Toggle raytracing\n");
165}
166
167//______________________________________________________________________________
168void help() {
169 //
170
171 new TCanvas("chelp","Help to run demos",200,10,700,600);
172
173 TPaveText *welcome = new TPaveText(.1,.8,.9,.97);
174 welcome->AddText("Welcome to the new geometry package");
175 welcome->SetTextFont(32);
176 welcome->SetTextColor(4);
177 welcome->SetFillColor(24);
178 welcome->Draw();
179
180 TPaveText *hdemo = new TPaveText(.05,.05,.95,.7);
181 hdemo->SetTextAlign(12);
182 hdemo->SetTextFont(52);
183 hdemo->AddText("- Demo for building TGeo basic shapes and simple geometry. Shape parameters are");
184 hdemo->AddText(" displayed in the right pad");
185 hdemo->AddText("- Click left mouse button to execute one demo");
186 hdemo->AddText("- While pointing the mouse to the pad containing the geometry, do:");
187 hdemo->AddText("- .... click-and-move to rotate");
188 hdemo->AddText("- .... press j/k to zoom/unzoom");
189 hdemo->AddText("- .... press l/h/u/i to move the view center around");
190 hdemo->AddText("- Click Ray-trace ON/OFF to toggle ray-tracing");
191 hdemo->AddText("- Use <View with x3d> from the <View> menu to get an x3d view");
192 hdemo->AddText("- .... same methods to rotate/zoom/move the view");
193 hdemo->AddText("- Execute box(1,8) to divide a box in 8 equal slices along X");
194 hdemo->AddText("- Most shapes can be divided on X,Y,Z,Rxy or Phi :");
195 hdemo->AddText("- .... root[0] <shape>(IAXIS, NDIV, START, STEP);");
196 hdemo->AddText(" .... IAXIS = 1,2,3 meaning (X,Y,Z) or (Rxy, Phi, Z)");
197 hdemo->AddText(" .... NDIV = number of slices");
198 hdemo->AddText(" .... START = start slicing position");
199 hdemo->AddText(" .... STEP = division step");
200 hdemo->AddText("- Click Comments ON/OFF to toggle comments");
201 hdemo->AddText("- Click Ideal/Align geometry to see how alignment works");
202 hdemo->AddText(" ");
203 hdemo->SetAllWith("....","color",2);
204 hdemo->SetAllWith("....","font",72);
205 hdemo->SetAllWith("....","size",0.03);
206
207 hdemo->Draw();
208}
209
210//______________________________________________________________________________
211void autorotate()
212{
213 grotate = !grotate;
214
215 printf("Toggle rotate\n");
216}
217
218//______________________________________________________________________________
219void axes()
220{
221 show_axis = !show_axis;
222
223 printf("Toggle axes\n");
224}
225
226//______________________________________________________________________________
227void box(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
228{
229 if (iaxis<0 || iaxis>3) {
230 printf("Wrong division axis. Range is 1-3.\n");
231 return;
232 }
233
234 DeleteGeometry();
235
236 new TGeoManager("box", "poza1");
237 TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
238 TGeoMedium *med = new TGeoMedium("MED",1,mat);
239 TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
241 TGeoVolume *vol = gGeoManager->MakeBox("BOX",med, 20,30,40);
242 vol->SetLineColor(randomColor());
243 vol->SetLineWidth(2);
244 top->AddNode(vol,1);
245 if (iaxis) {
246 TGeoVolume *slice = vol->Divide("SLICE",iaxis,ndiv,start,step);
247 if (!slice) return;
248 slice->SetLineColor(randomColor());
249 }
251 gGeoManager->SetNsegments(nsegments);
252
253 ShowGeometry();
254/*
255
256 top->Draw();
257 MakePicture();
258 if (!comments) return;
259 c->cd(2);
260 TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
261 pt->SetLineColor(1);
262 TGeoBBox *box = (TGeoBBox*)(vol->GetShape());
263 TText *text = pt->AddText("TGeoBBox - box class");
264 text->SetTextColor(2);
265 AddText(pt,"fDX",box->GetDX(),"half length in X");
266 AddText(pt,"fDY",box->GetDY(),"half length in Y");
267 AddText(pt,"fDZ",box->GetDZ(),"half length in Z");
268 AddText(pt,"fOrigin[0]",(box->GetOrigin())[0],"box origin on X");
269 AddText(pt,"fOrigin[1]",(box->GetOrigin())[1],"box origin on Y");
270 AddText(pt,"fOrigin[2]",(box->GetOrigin())[2],"box origin on Z");
271 if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
272 pt->AddText("Execute: box(iaxis, ndiv, start, step) to divide this.");
273 pt->AddText("----- IAXIS can be 1, 2 or 3 (X, Y, Z)");
274 pt->AddText("----- NDIV must be a positive integer");
275 pt->AddText("----- START must be a valid axis offset within shape range on divided axis");
276 pt->AddText("----- STEP is the division step. START+NDIV*STEP must be in range also");
277 pt->AddText("----- If START and STEP are omitted, all range of the axis will be divided");
278 pt->AddText(" ");
279 pt->SetTextSize(0.044);
280 pt->SetAllWith("-----","color",2);
281 pt->SetAllWith("-----","font",72);
282 pt->SetAllWith("-----","size",0.04);
283 pt->SetAllWith("Execute","color",4);
284 pt->SetTextAlign(12);
285 pt->Draw();
286// SavePicture("box",c,vol,iaxis,step);
287 c->cd(1);
288 gROOT->SetInterrupt(kTRUE);
289 */
290}
291
292//______________________________________________________________________________
293void para(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
294{
295 DeleteGeometry();
296
297 new TGeoManager("para", "poza1");
298 TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
299 TGeoMedium *med = new TGeoMedium("MED",1,mat);
300 TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
302 TGeoVolume *vol = gGeoManager->MakePara("PARA",med, 20,30,40,30,15,30);
303 vol->SetLineColor(randomColor());
304 vol->SetLineWidth(2);
305 top->AddNode(vol,1);
306 if (iaxis) {
307 TGeoVolume *slice = vol->Divide("SLICE",iaxis,ndiv,start,step);
308 if (!slice) return;
309 slice->SetLineColor(randomColor());
310 }
312 gGeoManager->SetNsegments(nsegments);
313
314 ShowGeometry();
315
316/*
317 MakePicture();
318 if (!comments) return;
319 c->cd(2);
320 TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
321 pt->SetLineColor(1);
322 TGeoPara *para = (TGeoPara*)(vol->GetShape());
323 TText *text = pt->AddText("TGeoPara - parallelepiped class");
324 text->SetTextColor(2);
325 AddText(pt,"fX",para->GetX(),"half length in X");
326 AddText(pt,"fY",para->GetY(),"half length in Y");
327 AddText(pt,"fZ",para->GetZ(),"half length in Z");
328 AddText(pt,"fAlpha",para->GetAlpha(),"angle about Y of the Z bases");
329 AddText(pt,"fTheta",para->GetTheta(),"inclination of para axis about Z");
330 AddText(pt,"fPhi",para->GetPhi(),"phi angle of para axis");
331 if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
332 pt->AddText("Execute: para(iaxis, ndiv, start, step) to divide this.");
333 pt->AddText("----- IAXIS can be 1, 2 or 3 (X, Y, Z)");
334 pt->AddText("----- NDIV must be a positive integer");
335 pt->AddText("----- START must be a valid axis offset within shape range on divided axis");
336 pt->AddText("----- STEP is the division step. START+NDIV*STEP must be in range also");
337 pt->AddText("----- If START and STEP are omitted, all range of the axis will be divided");
338 pt->AddText(" ");
339 pt->SetTextSize(0.044);
340 pt->SetAllWith("-----","color",2);
341 pt->SetAllWith("-----","font",72);
342 pt->SetAllWith("-----","size",0.04);
343 pt->SetAllWith("Execute","color",4);
344 pt->SetTextAlign(12);
345 pt->Draw();
346 c->cd(1);
347// SavePicture("para",c,vol,iaxis,step);
348 */
349}
350
351//______________________________________________________________________________
352void tube(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
353{
354 if (iaxis<0 || iaxis>3) {
355 printf("Wrong division axis. Range is 1-3.\n");
356 return;
357 }
358
359 DeleteGeometry();
360
361 new TGeoManager("tube", "poza2");
362 TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
363 TGeoMedium *med = new TGeoMedium("MED",1,mat);
364 TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
366 TGeoVolume *vol = gGeoManager->MakeTube("TUBE",med, 20,30,40);
367 vol->SetLineColor(randomColor());
368 vol->SetLineWidth(2);
369 top->AddNode(vol,1);
370 if (iaxis) {
371 TGeoVolume *slice = vol->Divide("SLICE",iaxis,ndiv,start,step);
372 if (!slice) return;
373 slice->SetLineColor(randomColor());
374 }
376 gGeoManager->SetNsegments(nsegments);
377
378 ShowGeometry();
379
380 /*
381 MakePicture();
382 if (!comments) return;
383 c->cd(2);
384 TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
385 pt->SetLineColor(1);
386 TGeoTube *tube = (TGeoTube*)(vol->GetShape());
387 TText *text = pt->AddText("TGeoTube - tube class");
388 text->SetTextColor(2);
389 AddText(pt,"fRmin",tube->GetRmin(),"minimum radius");
390 AddText(pt,"fRmax",tube->GetRmax(),"maximum radius");
391 AddText(pt,"fDZ", tube->GetDZ(), "half length in Z");
392 if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
393 pt->AddText("Execute: tube(iaxis, ndiv, start, step) to divide this.");
394 pt->AddText("----- IAXIS can be 1, 2 or 3 (Rxy, Phi, Z)");
395 pt->AddText("----- NDIV must be a positive integer");
396 pt->AddText("----- START must be a valid axis offset within shape range on divided axis");
397 pt->AddText("----- STEP is the division step. START+NDIV*STEP must be in range also");
398 pt->AddText("----- If START and STEP are omitted, all range of the axis will be divided");
399 pt->AddText(" ");
400 pt->SetAllWith("-----","color",2);
401 pt->SetAllWith("-----","font",72);
402 pt->SetAllWith("-----","size",0.04);
403 pt->SetAllWith("Execute","color",4);
404 pt->SetTextAlign(12);
405 pt->SetTextSize(0.044);
406 pt->Draw();
407 c->cd(1);
408// SavePicture("tube",c,vol,iaxis,step);
409 *
410 */
411}
412
413//______________________________________________________________________________
414void tubeseg(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
415{
416 if (iaxis<0 || iaxis>3) {
417 printf("Wrong division axis. Range is 1-3.\n");
418 return;
419 }
420
421 DeleteGeometry();
422
423 new TGeoManager("tubeseg", "poza3");
424 TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
425 TGeoMedium *med = new TGeoMedium("MED",1,mat);
426 TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
428 TGeoVolume *vol = gGeoManager->MakeTubs("TUBESEG",med, 20,30,40,-30,270);
429 vol->SetLineColor(randomColor());
430 if (iaxis) {
431 TGeoVolume *slice = vol->Divide("SLICE",iaxis,ndiv,start,step);
432 if (!slice) return;
433 slice->SetLineColor(randomColor());
434 }
435 vol->SetLineWidth(2);
436 top->AddNode(vol,1);
438 gGeoManager->SetNsegments(nsegments);
439
440 ShowGeometry();
441
442 /*
443 MakePicture();
444 if (!comments) return;
445 c->cd(2);
446 TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
447 pt->SetLineColor(1);
448 TGeoTubeSeg *tubeseg = (TGeoTubeSeg*)(vol->GetShape());
449 TText *text = pt->AddText("TGeoTubeSeg - tube segment class");
450 text->SetTextColor(2);
451 AddText(pt,"fRmin",tubeseg->GetRmin(),"minimum radius");
452 AddText(pt,"fRmax",tubeseg->GetRmax(),"maximum radius");
453 AddText(pt,"fDZ", tubeseg->GetDZ(), "half length in Z");
454 AddText(pt,"fPhi1",tubeseg->GetPhi1(),"first phi limit");
455 AddText(pt,"fPhi2",tubeseg->GetPhi2(),"second phi limit");
456 if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
457 pt->AddText("Execute: tubeseg(iaxis, ndiv, start, step) to divide this.");
458 pt->AddText("----- IAXIS can be 1, 2 or 3 (Rxy, Phi, Z)");
459 pt->AddText("----- NDIV must be a positive integer");
460 pt->AddText("----- START must be a valid axis offset within shape range on divided axis");
461 pt->AddText("----- STEP is the division step. START+NDIV*STEP must be in range also");
462 pt->AddText("----- If START and STEP are omitted, all range of the axis will be divided");
463 pt->AddText(" ");
464 pt->SetAllWith("-----","color",2);
465 pt->SetAllWith("-----","font",72);
466 pt->SetAllWith("-----","size",0.04);
467 pt->SetAllWith("Execute","color",4);
468 pt->SetTextAlign(12);
469 pt->SetTextSize(0.044);
470 pt->Draw();
471 c->cd(1);
472// SavePicture("tubeseg",c,vol,iaxis,step);
473 *
474 */
475}
476
477//______________________________________________________________________________
478void ctub(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
479{
480 if (iaxis<0 || iaxis>2) {
481 printf("Wrong division axis. Range is 1-2.\n");
482 return;
483 }
484
485 DeleteGeometry();
486
487 new TGeoManager("ctub", "poza3");
488 TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
489 TGeoMedium *med = new TGeoMedium("MED",1,mat);
490 TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
492 Double_t theta = 160.*TMath::Pi()/180.;
493 Double_t phi = 30.*TMath::Pi()/180.;
494 Double_t nlow[3];
495 nlow[0] = TMath::Sin(theta)*TMath::Cos(phi);
496 nlow[1] = TMath::Sin(theta)*TMath::Sin(phi);
497 nlow[2] = TMath::Cos(theta);
498 theta = 20.*TMath::Pi()/180.;
499 phi = 60.*TMath::Pi()/180.;
500 Double_t nhi[3];
501 nhi[0] = TMath::Sin(theta)*TMath::Cos(phi);
502 nhi[1] = TMath::Sin(theta)*TMath::Sin(phi);
503 nhi[2] = TMath::Cos(theta);
504 TGeoVolume *vol = gGeoManager->MakeCtub("CTUB",med, 20,30,40,-30,250, nlow[0], nlow[1], nlow[2], nhi[0],nhi[1],nhi[2]);
505 vol->SetLineColor(randomColor());
506 if (iaxis) {
507 TGeoVolume *slice = vol->Divide("SLICE",iaxis,ndiv,start,step);
508 if (!slice) return;
509 slice->SetLineColor(randomColor());
510 }
511 vol->SetLineWidth(2);
512 top->AddNode(vol,1);
514 gGeoManager->SetNsegments(nsegments);
515
516 ShowGeometry();
517
518 /*
519 MakePicture();
520 if (!comments) return;
521 c->cd(2);
522 TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
523 pt->SetLineColor(1);
524 TGeoTubeSeg *tubeseg = (TGeoTubeSeg*)(vol->GetShape());
525 TText *text = pt->AddText("TGeoTubeSeg - tube segment class");
526 text->SetTextColor(2);
527 AddText(pt,"fRmin",tubeseg->GetRmin(),"minimum radius");
528 AddText(pt,"fRmax",tubeseg->GetRmax(),"maximum radius");
529 AddText(pt,"fDZ", tubeseg->GetDZ(), "half length in Z");
530 AddText(pt,"fPhi1",tubeseg->GetPhi1(),"first phi limit");
531 AddText(pt,"fPhi2",tubeseg->GetPhi2(),"second phi limit");
532 if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
533 pt->AddText(" ");
534 pt->SetTextAlign(12);
535 pt->SetTextSize(0.044);
536 pt->Draw();
537 c->cd(1);
538// SavePicture("tubeseg",c,vol,iaxis,step);
539 *
540 */
541}
542
543//______________________________________________________________________________
544void cone(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
545{
546 if (iaxis<0 || iaxis>3) {
547 printf("Wrong division axis. Range is 1-3.\n");
548 return;
549 }
550 if (iaxis==1) {
551 printf("cannot divide cone on Rxy\n");
552 return;
553 }
554
555 DeleteGeometry();
556
557 new TGeoManager("cone", "poza4");
558 TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
559 TGeoMedium *med = new TGeoMedium("MED",1,mat);
560 TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
562 TGeoVolume *vol = gGeoManager->MakeCone("CONE",med, 40,10,20,35,45);
563 vol->SetLineColor(randomColor());
564 vol->SetLineWidth(2);
565 if (iaxis) {
566 TGeoVolume *slice = vol->Divide("SLICE",iaxis,ndiv,start,step);
567 if (!slice) return;
568 slice->SetLineColor(randomColor());
569 }
570 top->AddNode(vol,1);
572 gGeoManager->SetNsegments(nsegments);
573
574 ShowGeometry();
575
576 /*
577
578 if (!comments) return;
579 c->cd(2);
580 TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
581 pt->SetLineColor(1);
582 TGeoCone *cone = (TGeoCone*)(vol->GetShape());
583 TText *text = pt->AddText("TGeoCone - cone class");
584 text->SetTextColor(2);
585 AddText(pt,"fDZ", cone->GetDZ(), "half length in Z");
586 AddText(pt,"fRmin1",cone->GetRmin1(),"inner radius at -dz");
587 AddText(pt,"fRmax1",cone->GetRmax1(),"outer radius at -dz");
588 AddText(pt,"fRmin2",cone->GetRmin2(),"inner radius at +dz");
589 AddText(pt,"fRmax2",cone->GetRmax2(),"outer radius at +dz");
590 if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
591 pt->AddText("Execute: cone(iaxis, ndiv, start, step) to divide this.");
592 pt->AddText("----- IAXIS can be 2 or 3 (Phi, Z)");
593 pt->AddText("----- NDIV must be a positive integer");
594 pt->AddText("----- START must be a valid axis offset within shape range on divided axis");
595 pt->AddText("----- STEP is the division step. START+NDIV*STEP must be in range also");
596 pt->AddText("----- If START and STEP are omitted, all range of the axis will be divided");
597 pt->AddText(" ");
598 pt->SetAllWith("-----","color",2);
599 pt->SetAllWith("-----","font",72);
600 pt->SetAllWith("-----","size",0.04);
601 pt->SetAllWith("Execute","color",4);
602 pt->SetTextAlign(12);
603 pt->SetTextSize(0.044);
604 pt->Draw();
605 c->cd(1);
606 */
607// SavePicture("cone",c,vol,iaxis,step);
608}
609
610//______________________________________________________________________________
611void coneseg(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
612{
613 if (iaxis<0 || iaxis>3) {
614 printf("Wrong division axis. Range is 1-3.\n");
615 return;
616 }
617
618 DeleteGeometry();
619
620 new TGeoManager("coneseg", "poza5");
621 TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
622 TGeoMedium *med = new TGeoMedium("MED",1,mat);
623 TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
625 TGeoVolume *vol = gGeoManager->MakeCons("CONESEG",med, 40,30,40,10,20,-30,250);
626 vol->SetLineColor(randomColor());
627// vol->SetLineWidth(2);
628 top->AddNode(vol,1);
629 if (iaxis) {
630 TGeoVolume *slice = vol->Divide("SLICE",iaxis,ndiv,start,step);
631 if (!slice) return;
632 slice->SetLineColor(randomColor());
633 }
635 gGeoManager->SetNsegments(nsegments);
636
637 ShowGeometry();
638
639/* MakePicture();
640 if (!comments) return;
641 c->cd(2);
642 TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
643 pt->SetLineColor(1);
644 TGeoConeSeg *coneseg = (TGeoConeSeg*)(vol->GetShape());
645 TText *text = pt->AddText("TGeoConeSeg - coneseg class");
646 text->SetTextColor(2);
647 AddText(pt,"fDZ", coneseg->GetDZ(), "half length in Z");
648 AddText(pt,"fRmin1",coneseg->GetRmin1(),"inner radius at -dz");
649 AddText(pt,"fRmax1",coneseg->GetRmax1(),"outer radius at -dz");
650 AddText(pt,"fRmin2",coneseg->GetRmin1(),"inner radius at +dz");
651 AddText(pt,"fRmax2",coneseg->GetRmax1(),"outer radius at +dz");
652 AddText(pt,"fPhi1",coneseg->GetPhi1(),"first phi limit");
653 AddText(pt,"fPhi2",coneseg->GetPhi2(),"second phi limit");
654 if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
655 pt->AddText("Execute: coneseg(iaxis, ndiv, start, step) to divide this.");
656 pt->AddText("----- IAXIS can be 2 or 3 (Phi, Z)");
657 pt->AddText("----- NDIV must be a positive integer");
658 pt->AddText("----- START must be a valid axis offset within shape range on divided axis");
659 pt->AddText("----- STEP is the division step. START+NDIV*STEP must be in range also");
660 pt->AddText("----- If START and STEP are omitted, all range of the axis will be divided");
661 pt->AddText(" ");
662 pt->SetAllWith("-----","color",2);
663 pt->SetAllWith("-----","font",72);
664 pt->SetAllWith("-----","size",0.04);
665 pt->SetAllWith("Execute","color",4);
666 pt->SetTextAlign(12);
667 pt->SetTextSize(0.044);
668 pt->Draw();
669 c->cd(1);
670// SavePicture("coneseg",c,vol,iaxis,step);
671 *
672 */
673}
674
675//______________________________________________________________________________
676void eltu(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
677{
678 DeleteGeometry();
679
680 new TGeoManager("eltu", "poza6");
681 TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
682 TGeoMedium *med = new TGeoMedium("MED",1,mat);
683 TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
685 TGeoVolume *vol = gGeoManager->MakeEltu("ELTU",med, 30,10,40);
686 vol->SetLineColor(randomColor());
687// vol->SetLineWidth(2);
688 top->AddNode(vol,1);
689 if (iaxis) {
690 TGeoVolume *slice = vol->Divide("SLICE",iaxis,ndiv,start,step);
691 if (!slice) return;
692 slice->SetLineColor(randomColor());
693 }
695 gGeoManager->SetNsegments(nsegments);
696
697 ShowGeometry();
698 /*
699
700 MakePicture();
701 if (!comments) return;
702 c->cd(2);
703 TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
704 pt->SetLineColor(1);
705 TGeoEltu *eltu = (TGeoEltu*)(vol->GetShape());
706 TText *text = pt->AddText("TGeoEltu - eltu class");
707 text->SetTextColor(2);
708 AddText(pt,"fA",eltu->GetA(), "semi-axis along x");
709 AddText(pt,"fB",eltu->GetB(), "semi-axis along y");
710 AddText(pt,"fDZ", eltu->GetDZ(), "half length in Z");
711 if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
712 pt->AddText("Execute: eltu(iaxis, ndiv, start, step) to divide this.");
713 pt->AddText("----- IAXIS can be 2 or 3 (Phi, Z)");
714 pt->AddText("----- NDIV must be a positive integer");
715 pt->AddText("----- START must be a valid axis offset within shape range on divided axis");
716 pt->AddText("----- STEP is the division step. START+NDIV*STEP must be in range also");
717 pt->AddText("----- If START and STEP are omitted, all range of the axis will be divided");
718 pt->AddText(" ");
719 pt->SetAllWith("-----","color",2);
720 pt->SetAllWith("-----","font",72);
721 pt->SetAllWith("-----","size",0.04);
722 pt->SetAllWith("Execute","color",4);
723 pt->SetTextAlign(12);
724 pt->SetTextSize(0.044);
725 pt->Draw();
726 c->cd(1);
727// SavePicture("eltu",c,vol,iaxis,step);
728 *
729 */
730}
731
732//______________________________________________________________________________
733void sphere(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
734{
735 DeleteGeometry();
736
737 if (iaxis!=0) {
738 printf("Cannot divide spheres\n");
739 return;
740 }
741
742 new TGeoManager("sphere", "poza7");
743 TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
744 TGeoMedium *med = new TGeoMedium("MED",1,mat);
745 TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
747 TGeoVolume *vol = gGeoManager->MakeSphere("SPHERE",med, 30,40,60,120,30,240);
748 vol->SetLineColor(randomColor());
749 vol->SetLineWidth(2);
750 top->AddNode(vol,1);
751 if (iaxis) {
752 TGeoVolume *slice = vol->Divide("SLICE",iaxis,ndiv,start,step);
753 if (!slice) return;
754 slice->SetLineColor(randomColor());
755 }
757 gGeoManager->SetNsegments(nsegments);
758
759 ShowGeometry();
760
761/* top->Draw();
762 MakePicture();
763 if (!comments) return;
764 c->cd(2);
765 TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
766 pt->SetLineColor(1);
767 TGeoSphere *sphere = (TGeoSphere*)(vol->GetShape());
768 TText *text = pt->AddText("TGeoSphere- sphere class");
769 text->SetTextColor(2);
770 AddText(pt,"fRmin",sphere->GetRmin(),"inner radius");
771 AddText(pt,"fRmax",sphere->GetRmax(),"outer radius");
772 AddText(pt,"fTheta1",sphere->GetTheta1(),"lower theta limit");
773 AddText(pt,"fTheta2",sphere->GetTheta2(),"higher theta limit");
774 AddText(pt,"fPhi1",sphere->GetPhi1(),"lower phi limit");
775 AddText(pt,"fPhi2",sphere->GetPhi2(),"higher phi limit");
776 if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
777 pt->AddText(" ");
778 pt->SetTextSize(0.044);
779 pt->Draw();
780 c->cd(1);
781// SavePicture("sphere",c,vol,iaxis,step);
782 *
783 */
784}
785
786//______________________________________________________________________________
787void torus(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
788{
789 if (iaxis!=0) {
790 printf("Cannot divide a torus\n");
791 return;
792 }
793
794 DeleteGeometry();
795
796 new TGeoManager("torus", "poza2");
797 TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
798 TGeoMedium *med = new TGeoMedium("MED",1,mat);
799 TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
801 TGeoVolume *vol = gGeoManager->MakeTorus("TORUS",med, 40,20,25,0,270);
802 vol->SetLineColor(randomColor());
803 top->AddNode(vol,1);
804 if (iaxis) {
805 TGeoVolume *slice = vol->Divide("SLICE",iaxis,ndiv,start,step);
806 if (!slice) return;
807 slice->SetLineColor(2);
808 }
810 gGeoManager->SetNsegments(nsegments);
811
812 ShowGeometry();
813
814 /*
815 top->Draw();
816 MakePicture();
817 if (!comments) return;
818 c->cd(2);
819 TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
820 pt->SetLineColor(1);
821 TGeoTorus *tor = (TGeoTorus*)(vol->GetShape());
822 TText *text = pt->AddText("TGeoTorus - torus class");
823 text->SetTextColor(2);
824 AddText(pt,"fR",tor->GetR(),"radius of the ring");
825 AddText(pt,"fRmin",tor->GetRmin(),"minimum radius");
826 AddText(pt,"fRmax",tor->GetRmax(),"maximum radius");
827 AddText(pt,"fPhi1", tor->GetPhi1(), "starting phi angle");
828 AddText(pt,"fDphi", tor->GetDphi(), "phi range");
829 if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
830 pt->AddText(" ");
831 pt->SetTextSize(0.044);
832 pt->Draw();
833 c->cd(1);
834 */
835}
836
837//______________________________________________________________________________
838void trd1(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
839{
840 if (iaxis<0 || iaxis>3) {
841 printf("Wrong division axis. Range is 1-3.\n");
842 return;
843 }
844 if (iaxis==1) {
845 printf("Cannot divide trd1 on X axis\n");
846 return;
847 }
848
849 DeleteGeometry();
850
851 new TGeoManager("trd1", "poza8");
852 TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
853 TGeoMedium *med = new TGeoMedium("MED",1,mat);
854 TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
856 TGeoVolume *vol = gGeoManager->MakeTrd1("Trd1",med, 10,20,30,40);
857 vol->SetLineColor(randomColor());
858 vol->SetLineWidth(2);
859 top->AddNode(vol,1);
860 if (iaxis) {
861 TGeoVolume *slice = vol->Divide("SLICE",iaxis,ndiv,start,step);
862 if (!slice) return;
863 slice->SetLineColor(randomColor());
864 }
866 gGeoManager->SetNsegments(nsegments);
867
868 ShowGeometry();
869
870/* top->Draw();
871 MakePicture();
872 if (!comments) return;
873 c->cd(2);
874 TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
875 pt->SetLineColor(1);
876 TGeoTrd1 *trd1 = (TGeoTrd1*)(vol->GetShape());
877 TText *text = pt->AddText("TGeoTrd1 - Trd1 class");
878 text->SetTextColor(2);
879 AddText(pt,"fDx1",trd1->GetDx1(),"half length in X at lower Z surface(-dz)");
880 AddText(pt,"fDx2",trd1->GetDx2(),"half length in X at higher Z surface(+dz)");
881 AddText(pt,"fDy",trd1->GetDy(),"half length in Y");
882 AddText(pt,"fDz",trd1->GetDz(),"half length in Z");
883 if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
884 pt->AddText("Execute: trd1(iaxis, ndiv, start, step) to divide this.");
885 pt->AddText("----- IAXIS can be 2 or 3 (Y, Z)");
886 pt->AddText("----- NDIV must be a positive integer");
887 pt->AddText("----- START must be a valid axis offset within shape range on divided axis");
888 pt->AddText("----- STEP is the division step. START+NDIV*STEP must be in range also");
889 pt->AddText("----- If START and STEP are omitted, all range of the axis will be divided");
890 pt->AddText(" ");
891 pt->SetAllWith("-----","color",2);
892 pt->SetAllWith("-----","font",72);
893 pt->SetAllWith("-----","size",0.04);
894 pt->SetAllWith("Execute","color",4);
895 pt->SetTextAlign(12);
896 pt->SetTextSize(0.044);
897 pt->Draw();
898 c->cd(1);
899// SavePicture("trd1",c,vol,iaxis,step);
900 *
901 */
902}
903
904//______________________________________________________________________________
905void parab()
906{
907 DeleteGeometry();
908
909 new TGeoManager("parab", "paraboloid");
910 TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
911 TGeoMedium *med = new TGeoMedium("MED",1,mat);
912 TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
914 TGeoVolume *vol = gGeoManager->MakeParaboloid("PARAB",med,0, 40, 50);
915 TGeoParaboloid *par = (TGeoParaboloid*)vol->GetShape();
916 vol->SetLineColor(randomColor());
917 vol->SetLineWidth(2);
918 top->AddNode(vol,1);
920 gGeoManager->SetNsegments(nsegments);
921
922 ShowGeometry();
923
924/* top->Draw();
925 MakePicture();
926 if (!comments) return;
927 c->cd(2);
928 TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
929 pt->SetLineColor(1);
930 TText *text = pt->AddText("TGeoParaboloid - Paraboloid class");
931 text->SetTextColor(2);
932 AddText(pt,"fRlo",par->GetRlo(),"radius at Z=-dz");
933 AddText(pt,"fRhi",par->GetRhi(),"radius at Z=+dz");
934 AddText(pt,"fDz",par->GetDz(),"half-length on Z axis");
935 pt->AddText("----- A paraboloid is described by the equation:");
936 pt->AddText("----- z = a*r*r + b; where: r = x*x + y*y");
937 pt->AddText("----- Create with: TGeoParaboloid *parab = new TGeoParaboloid(rlo, rhi, dz);");
938 pt->AddText("----- dz: half-length in Z (range from -dz to +dz");
939 pt->AddText("----- rlo: radius at z=-dz given by: -dz = a*rlo*rlo + b");
940 pt->AddText("----- rhi: radius at z=+dz given by: dz = a*rhi*rhi + b");
941 pt->AddText("----- rlo != rhi; both >= 0");
942 pt->AddText(" ");
943 pt->SetAllWith("-----","color",2);
944 pt->SetAllWith("-----","font",72);
945 pt->SetAllWith("-----","size",0.04);
946 pt->SetTextAlign(12);
947 pt->SetTextSize(0.044);
948 pt->Draw();
949 c->cd(1);
950*/
951}
952
953//______________________________________________________________________________
954void hype()
955{
956 DeleteGeometry();
957
958 new TGeoManager("hype", "hyperboloid");
959 TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
960 TGeoMedium *med = new TGeoMedium("MED",1,mat);
961 TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
963 TGeoVolume *vol = gGeoManager->MakeHype("HYPE",med,10, 45 ,20,45,40);
964 TGeoHype *hype = (TGeoHype*)vol->GetShape();
965 vol->SetLineColor(randomColor());
966 vol->SetLineWidth(2);
967 top->AddNode(vol,1);
969 gGeoManager->SetNsegments(nsegments);
970
971 ShowGeometry();
972/*
973 top->Draw();
974 MakePicture();
975 if (!comments) return;
976 c->cd(2);
977 TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
978 pt->SetLineColor(1);
979 TText *text = pt->AddText("TGeoHype - Hyperboloid class");
980 text->SetTextColor(2);
981 AddText(pt,"fRmin",hype->GetRmin(),"minimum inner radius");
982 AddText(pt,"fStIn",hype->GetStIn(),"inner surface stereo angle [deg]");
983 AddText(pt,"fRmax",hype->GetRmax(),"minimum outer radius");
984 AddText(pt,"fStOut",hype->GetStOut(),"outer surface stereo angle [deg]");
985 AddText(pt,"fDz",hype->GetDz(),"half-length on Z axis");
986 pt->AddText("----- A hyperboloid is described by the equation:");
987 pt->AddText("----- r^2 - (tan(stereo)*z)^2 = rmin^2; where: r = x*x + y*y");
988 pt->AddText("----- Create with: TGeoHype *hype = new TGeoHype(rin, stin, rout, stout, dz);");
989 pt->AddText("----- rin < rout; rout > 0");
990 pt->AddText("----- rin = 0; stin > 0 => inner surface conical");
991 pt->AddText("----- stin/stout = 0 => corresponding surface cylindrical");
992 pt->AddText(" ");
993 pt->SetAllWith("-----","color",2);
994 pt->SetAllWith("-----","font",72);
995 pt->SetAllWith("-----","size",0.04);
996 pt->SetTextAlign(12);
997 pt->SetTextSize(0.044);
998 pt->Draw();
999 c->cd(1);
1000 */
1001}
1002//______________________________________________________________________________
1003void pcon(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
1004{
1005 if (iaxis<0 || iaxis>3) {
1006 printf("Wrong division axis. Range is 1-3.\n");
1007 return;
1008 }
1009 if (iaxis==1) {
1010 printf("Cannot divide pcon on Rxy\n");
1011 return;
1012 }
1013
1014 DeleteGeometry();
1015
1016 new TGeoManager("pcon", "poza10");
1017 TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
1018 TGeoMedium *med = new TGeoMedium("MED",1,mat);
1019 TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
1021 TGeoVolume *vol = gGeoManager->MakePcon("PCON",med, -30.0,300,4);
1022 TGeoPcon *pcon = (TGeoPcon*)(vol->GetShape());
1023 pcon->DefineSection(0,0,15,20);
1024 pcon->DefineSection(1,20,15,20);
1025 pcon->DefineSection(2,20,15,25);
1026 pcon->DefineSection(3,50,15,20);
1027 vol->SetLineColor(randomColor());
1028 vol->SetLineWidth(2);
1029 top->AddNode(vol,1);
1030 if (iaxis) {
1031 TGeoVolume *slice = vol->Divide("SLICE",iaxis,ndiv,start,step);
1032 if (!slice) return;
1033 slice->SetLineColor(randomColor());
1034 }
1036 gGeoManager->SetNsegments(nsegments);
1037
1038 ShowGeometry();
1039
1040 /*
1041 top->Draw();
1042 MakePicture();
1043 if (!comments) return;
1044 c->cd(2);
1045 TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
1046 pt->SetLineColor(1);
1047 TText *text = pt->AddText("TGeoPcon - pcon class");
1048 text->SetTextColor(2);
1049 AddText(pt,"fPhi1",pcon->GetPhi1(),"lower phi limit");
1050 AddText(pt,"fDphi",pcon->GetDphi(),"phi range");
1051 AddText(pt,"fNz",pcon->GetNz(),"number of z planes");
1052 for (Int_t j=0; j<pcon->GetNz(); j++) {
1053 char line[128];
1054 sprintf(line, "fZ[%i]=%5.2f fRmin[%i]=%5.2f fRmax[%i]=%5.2f",
1055 j,pcon->GetZ()[j],j,pcon->GetRmin()[j],j,pcon->GetRmax()[j]);
1056 text = pt->AddText(line);
1057 text->SetTextColor(4);
1058 text->SetTextAlign(12);
1059 }
1060 if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
1061 pt->AddText("Execute: pcon(iaxis, ndiv, start, step) to divide this.");
1062 pt->AddText("----- IAXIS can be 2 or 3 (Phi, Z)");
1063 pt->AddText("----- NDIV must be a positive integer");
1064 pt->AddText("----- START must be a valid axis offset within shape range on divided axis");
1065 pt->AddText("----- STEP is the division step. START+NDIV*STEP must be in range also");
1066 pt->AddText("----- If START and STEP are omitted, all range of the axis will be divided");
1067 pt->AddText(" ");
1068 pt->SetAllWith("-----","color",2);
1069 pt->SetAllWith("-----","font",72);
1070 pt->SetAllWith("-----","size",0.04);
1071 pt->SetAllWith("Execute","color",4);
1072 pt->SetTextAlign(12);
1073 pt->SetTextSize(0.044);
1074 pt->Draw();
1075 c->cd(1);
1076// SavePicture("pcon",c,vol,iaxis,step);
1077 *
1078 */
1079}
1080
1081//______________________________________________________________________________
1082void pgon(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
1083{
1084 if (iaxis<0 || iaxis>3) {
1085 printf("Wrong division axis. Range is 1-3.\n");
1086 return;
1087 }
1088 if (iaxis==1) {
1089 printf("Cannot divide pgon on Rxy\n");
1090 return;
1091 }
1092
1093 DeleteGeometry();
1094
1095 new TGeoManager("pgon", "poza11");
1096 TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
1097 TGeoMedium *med = new TGeoMedium("MED",1,mat);
1098 TGeoVolume *top = gGeoManager->MakeBox("TOP",med,150,150,100);
1100 TGeoVolume *vol = gGeoManager->MakePgon("PGON",med, -45.0,270.0,4,4);
1101 TGeoPgon *pgon = (TGeoPgon*)(vol->GetShape());
1102 pgon->DefineSection(0,-70,45,50);
1103 pgon->DefineSection(1,0,35,40);
1104 pgon->DefineSection(2,0,30,35);
1105 pgon->DefineSection(3,70,90,100);
1106 vol->SetLineColor(randomColor());
1107 vol->SetLineWidth(2);
1108 top->AddNode(vol,1);
1109 if (iaxis) {
1110 TGeoVolume *slice = vol->Divide("SLICE",iaxis,ndiv,start,step);
1111 if (!slice) return;
1112 slice->SetLineColor(randomColor());
1113 }
1115 gGeoManager->SetNsegments(nsegments);
1116
1117 ShowGeometry();
1118
1119/*
1120 top->Draw();
1121 MakePicture();
1122 if (!comments) return;
1123 c->cd(2);
1124 TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
1125 pt->SetLineColor(1);
1126 TText *text = pt->AddText("TGeoPgon - pgon class");
1127 text->SetTextColor(2);
1128 AddText(pt,"fPhi1",pgon->GetPhi1(),"lower phi limit");
1129 AddText(pt,"fDphi",pgon->GetDphi(),"phi range");
1130 AddText(pt,"fNedges",pgon->GetNedges(),"number of edges");
1131 AddText(pt,"fNz",pgon->GetNz(),"number of z planes");
1132 for (Int_t j=0; j<pgon->GetNz(); j++) {
1133 char line[128];
1134 sprintf(line, "fZ[%i]=%5.2f fRmin[%i]=%5.2f fRmax[%i]=%5.2f",
1135 j,pgon->GetZ()[j],j,pgon->GetRmin()[j],j,pgon->GetRmax()[j]);
1136 text = pt->AddText(line);
1137 text->SetTextColor(4);
1138 text->SetTextAlign(12);
1139 }
1140 if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
1141 pt->AddText("Execute: pgon(iaxis, ndiv, start, step) to divide this.");
1142 pt->AddText("----- IAXIS can be 2 or 3 (Phi, Z)");
1143 pt->AddText("----- NDIV must be a positive integer");
1144 pt->AddText("----- START must be a valid axis offset within shape range on divided axis");
1145 pt->AddText("----- STEP is the division step. START+NDIV*STEP must be in range also");
1146 pt->AddText("----- If START and STEP are omitted, all range of the axis will be divided");
1147 pt->AddText(" ");
1148 pt->SetAllWith("-----","color",2);
1149 pt->SetAllWith("-----","font",72);
1150 pt->SetAllWith("-----","size",0.04);
1151 pt->SetAllWith("Execute","color",4);
1152 pt->SetTextAlign(12);
1153 pt->SetTextSize(0.044);
1154 pt->SetTextSize(0.044);
1155 pt->Draw();
1156 c->cd(1);
1157// SavePicture("pgon",c,vol,iaxis,step);
1158 *
1159 */
1160}
1161
1162//______________________________________________________________________________
1163void arb8(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
1164{
1165 if (iaxis!=0) {
1166 printf("Cannot divide arb8\n");
1167 return;
1168 }
1169
1170 DeleteGeometry();
1171
1172 new TGeoManager("arb8", "poza12");
1173 TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
1174 TGeoMedium *med = new TGeoMedium("MED",1,mat);
1175 TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
1177 TGeoArb8 *arb = new TGeoArb8(20);
1178 arb->SetVertex(0,-30,-25);
1179 arb->SetVertex(1,-25,25);
1180 arb->SetVertex(2,5,25);
1181 arb->SetVertex(3,25,-25);
1182 arb->SetVertex(4,-28,-23);
1183 arb->SetVertex(5,-23,27);
1184 arb->SetVertex(6,-23,27);
1185 arb->SetVertex(7,13,-27);
1186 TGeoVolume *vol = new TGeoVolume("ARB8",arb,med);
1187 vol->SetLineColor(randomColor());
1188 vol->SetLineWidth(2);
1189 top->AddNode(vol,1);
1190 if (iaxis) {
1191 TGeoVolume *slice = vol->Divide("SLICE",iaxis,ndiv,start,step);
1192 if (!slice) return;
1193 slice->SetLineColor(randomColor());
1194 }
1196 gGeoManager->SetNsegments(nsegments);
1197
1198 ShowGeometry();
1199
1200/* top->Draw();
1201 MakePicture();
1202 if (!comments) return;
1203 c->cd(2);
1204 TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
1205 pt->SetLineColor(1);
1206 TText *text = pt->AddText("TGeoArb8 - arb8 class");
1207 text->SetTextColor(2);
1208 AddText(pt,"fDz",arb->GetDz(),"Z half length");
1209 char line[128];
1210 Double_t *vert = arb->GetVertices();
1211 text = pt->AddText("Vertices on lower Z plane:");
1212 text->SetTextColor(3);
1213 Int_t i;
1214 for (i=0; i<4; i++) {
1215 sprintf(line," fXY[%d] = (%5.2f, %5.2f)", i, vert[2*i], vert[2*i+1]);
1216 text = pt->AddText(line);
1217 text->SetTextSize(0.043);
1218 text->SetTextColor(4);
1219 }
1220 text = pt->AddText("Vertices on higher Z plane:");
1221 text->SetTextColor(3);
1222 for (i=4; i<8; i++) {
1223 sprintf(line," fXY[%d] = (%5.2f, %5.2f)", i, vert[2*i], vert[2*i+1]);
1224 text = pt->AddText(line);
1225 text->SetTextSize(0.043);
1226 text->SetTextColor(4);
1227 }
1228
1229 if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
1230 pt->AddText(" ");
1231 pt->SetTextSize(0.043);
1232 pt->Draw();
1233 c->cd(1);
1234// SavePicture("arb8",c,vol,iaxis,step);
1235 */
1236}
1237
1238//______________________________________________________________________________
1239void trd2(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
1240{
1241 if (iaxis && iaxis!=3) {
1242 printf("Wrong division axis. Can divide only in Z (3)\n");
1243 return;
1244 }
1245
1246 DeleteGeometry();
1247
1248 new TGeoManager("trd2", "poza9");
1249 TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
1250 TGeoMedium *med = new TGeoMedium("MED",1,mat);
1251 TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
1253 TGeoVolume *vol = gGeoManager->MakeTrd2("Trd2",med, 10,20,30,10,40);
1254 vol->SetLineColor(randomColor());
1255 vol->SetLineWidth(2);
1256 top->AddNode(vol,1);
1257 if (iaxis) {
1258 TGeoVolume *slice = vol->Divide("SLICE",iaxis,ndiv,start,step);
1259 if (!slice) return;
1260 slice->SetLineColor(randomColor());
1261 }
1263 gGeoManager->SetNsegments(nsegments);
1264
1265 ShowGeometry();
1266/* top->Draw();
1267 MakePicture();
1268 if (!comments) return;
1269 c->cd(2);
1270 TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
1271 pt->SetLineColor(1);
1272 TGeoTrd2 *trd2 = (TGeoTrd2*)(vol->GetShape());
1273 TText *text = pt->AddText("TGeoTrd2 - Trd2 class");
1274 text->SetTextColor(2);
1275 AddText(pt,"fDx1",trd2->GetDx1(),"half length in X at lower Z surface(-dz)");
1276 AddText(pt,"fDx2",trd2->GetDx2(),"half length in X at higher Z surface(+dz)");
1277 AddText(pt,"fDy1",trd2->GetDy1(),"half length in Y at lower Z surface(-dz)");
1278 AddText(pt,"fDy2",trd2->GetDy2(),"half length in Y at higher Z surface(-dz)");
1279 AddText(pt,"fDz",trd2->GetDz(),"half length in Z");
1280 if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
1281 pt->AddText("Execute: trd2(iaxis, ndiv, start, step) to divide this.");
1282 pt->AddText("----- IAXIS can be only 3 (Z)");
1283 pt->AddText("----- NDIV must be a positive integer");
1284 pt->AddText("----- START must be a valid axis offset within shape range on divided axis");
1285 pt->AddText("----- STEP is the division step. START+NDIV*STEP must be in range also");
1286 pt->AddText("----- If START and STEP are omitted, all range of the axis will be divided");
1287 pt->AddText(" ");
1288 pt->SetAllWith("-----","color",2);
1289 pt->SetAllWith("-----","font",72);
1290 pt->SetAllWith("-----","size",0.04);
1291 pt->SetAllWith("Execute","color",4);
1292 pt->SetTextAlign(12);
1293 pt->SetTextSize(0.044);
1294 pt->Draw();
1295 c->cd(1);
1296// SavePicture("trd2",c,vol,iaxis,step);
1297 *
1298 */
1299}
1300
1301//______________________________________________________________________________
1302void trap(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
1303{
1304 if (iaxis && iaxis!=3) {
1305 printf("Wrong division axis. Can divide only in Z (3)\n");
1306 return;
1307 }
1308
1309 DeleteGeometry();
1310
1311 new TGeoManager("trap", "poza10");
1312 TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
1313 TGeoMedium *med = new TGeoMedium("MED",1,mat);
1314 TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
1316 TGeoVolume *vol = gGeoManager->MakeTrap("Trap",med, 30,15,30,20,10,15,0,20,10,15,0);
1317 vol->SetLineColor(randomColor());
1318 vol->SetLineWidth(2);
1319 top->AddNode(vol,1);
1320 if (iaxis) {
1321 TGeoVolume *slice = vol->Divide("SLICE",iaxis,ndiv,start,step);
1322 if (!slice) return;
1323 slice->SetLineColor(randomColor());
1324 }
1326 gGeoManager->SetNsegments(nsegments);
1327
1328 ShowGeometry();
1329
1330/*
1331 top->Draw();
1332 MakePicture();
1333 if (!comments) return;
1334 c->cd(2);
1335 TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
1336 pt->SetLineColor(1);
1337 TGeoTrap *trap = (TGeoTrap*)(vol->GetShape());
1338 TText *text = pt->AddText("TGeoTrap - Trapezoid class");
1339 text->SetTextColor(2);
1340 AddText(pt,"fDz",trap->GetDz(),"half length in Z");
1341 AddText(pt,"fTheta",trap->GetTheta(),"theta angle of trapezoid axis");
1342 AddText(pt,"fPhi",trap->GetPhi(),"phi angle of trapezoid axis");
1343 AddText(pt,"fH1",trap->GetH1(),"half length in y at -fDz");
1344 AddText(pt,"fAlpha1",trap->GetAlpha1(),"angle between centers of x edges and y axis at -fDz");
1345 AddText(pt,"fBl1",trap->GetBl1(),"half length in x at -dZ and y=-fH1");
1346 AddText(pt,"fTl1",trap->GetTl1(),"half length in x at -dZ and y=+fH1");
1347 AddText(pt,"fH2",trap->GetH2(),"half length in y at +fDz");
1348 AddText(pt,"fBl2",trap->GetBl2(),"half length in x at +dZ and y=-fH1");
1349 AddText(pt,"fTl2",trap->GetTl2(),"half length in x at +dZ and y=+fH1");
1350 AddText(pt,"fAlpha2",trap->GetAlpha2(),"angle between centers of x edges and y axis at +fDz");
1351 if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
1352 pt->AddText("Execute: trap(iaxis, ndiv, start, step) to divide this.");
1353 pt->AddText("----- IAXIS can be only 3 (Z)");
1354 pt->AddText("----- NDIV must be a positive integer");
1355 pt->AddText("----- START must be a valid axis offset within shape range on divided axis");
1356 pt->AddText("----- STEP is the division step. START+NDIV*STEP must be in range also");
1357 pt->AddText("----- If START and STEP are omitted, all range of the axis will be divided");
1358 pt->AddText(" ");
1359 pt->SetAllWith("-----","color",2);
1360 pt->SetAllWith("-----","font",72);
1361 pt->SetAllWith("-----","size",0.04);
1362 pt->SetAllWith("Execute","color",4);
1363 pt->SetTextAlign(12);
1364 pt->SetTextSize(0.044);
1365 pt->Draw();
1366 c->cd(1);
1367// SavePicture("trap",c,vol,iaxis,step);
1368 *
1369 */
1370}
1371
1372//______________________________________________________________________________
1373void gtra(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
1374{
1375 if (iaxis && iaxis!=3) {
1376 printf("Wrong division axis. Can divide only in Z (3)\n");
1377 return;
1378 }
1379
1380 DeleteGeometry();
1381
1382 new TGeoManager("gtra", "poza11");
1383 TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
1384 TGeoMedium *med = new TGeoMedium("MED",1,mat);
1385 TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
1387 TGeoVolume *vol = gGeoManager->MakeGtra("Gtra",med, 30,15,30,30,20,10,15,0,20,10,15,0);
1388 vol->SetLineColor(randomColor());
1389 vol->SetLineWidth(2);
1390 top->AddNode(vol,1);
1391 if (iaxis) {
1392 TGeoVolume *slice = vol->Divide("SLICE",iaxis,ndiv,start,step);
1393 if (!slice) return;
1394 slice->SetLineColor(randomColor());
1395 }
1397 gGeoManager->SetNsegments(nsegments);
1398
1399 ShowGeometry();
1400
1401/*
1402 top->Draw();
1403 MakePicture();
1404 if (!comments) return;
1405 c->cd(2);
1406 TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
1407 pt->SetLineColor(1);
1408 TGeoGtra *trap = (TGeoGtra*)(vol->GetShape());
1409 TText *text = pt->AddText("TGeoGtra - Twisted trapezoid class");
1410 text->SetTextColor(2);
1411 AddText(pt,"fDz",trap->GetDz(),"half length in Z");
1412 AddText(pt,"fTheta",trap->GetTheta(),"theta angle of trapezoid axis");
1413 AddText(pt,"fPhi",trap->GetPhi(),"phi angle of trapezoid axis");
1414 AddText(pt,"fTwist",trap->GetTwistAngle(), "twist angle");
1415 AddText(pt,"fH1",trap->GetH1(),"half length in y at -fDz");
1416 AddText(pt,"fAlpha1",trap->GetAlpha1(),"angle between centers of x edges and y axis at -fDz");
1417 AddText(pt,"fBl1",trap->GetBl1(),"half length in x at -dZ and y=-fH1");
1418 AddText(pt,"fTl1",trap->GetTl1(),"half length in x at -dZ and y=+fH1");
1419 AddText(pt,"fH2",trap->GetH2(),"half length in y at +fDz");
1420 AddText(pt,"fBl2",trap->GetBl2(),"half length in x at +dZ and y=-fH1");
1421 AddText(pt,"fTl2",trap->GetTl2(),"half length in x at +dZ and y=+fH1");
1422 AddText(pt,"fAlpha2",trap->GetAlpha2(),"angle between centers of x edges and y axis at +fDz");
1423 if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
1424 pt->AddText("Execute: gtra(iaxis, ndiv, start, step) to divide this.");
1425 pt->AddText("----- IAXIS can be only 3 (Z)");
1426 pt->AddText("----- NDIV must be a positive integer");
1427 pt->AddText("----- START must be a valid axis offset within shape range on divided axis");
1428 pt->AddText("----- STEP is the division step. START+NDIV*STEP must be in range also");
1429 pt->AddText("----- If START and STEP are omitted, all range of the axis will be divided");
1430 pt->AddText(" ");
1431 pt->SetAllWith("-----","color",2);
1432 pt->SetAllWith("-----","font",72);
1433 pt->SetAllWith("-----","size",0.04);
1434 pt->SetAllWith("Execute","color",4);
1435 pt->SetTextAlign(12);
1436 pt->SetTextSize(0.044);
1437 pt->Draw();
1438 c->cd(1);
1439// SavePicture("gtra",c,vol,iaxis,step);
1440 *
1441 */
1442}
1443
1444//______________________________________________________________________________
1445void xtru()
1446{
1447 DeleteGeometry();
1448
1449 new TGeoManager("xtru", "poza12");
1450 TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
1451 TGeoMedium *med = new TGeoMedium("MED",1,mat);
1452 TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
1454 TGeoVolume *vol = gGeoManager->MakeXtru("XTRU",med,4);
1455 TGeoXtru *xtru = (TGeoXtru*)vol->GetShape();
1456 Double_t x[8] = {-30,-30,30,30,15,15,-15,-15};
1457 Double_t y[8] = {-30,30,30,-30,-30,15,15,-30};
1458 xtru->DefinePolygon(8,x,y);
1459 xtru->DefineSection(0,-40, -20., 10., 1.5);
1460 xtru->DefineSection(1, 10, 0., 0., 0.5);
1461 xtru->DefineSection(2, 10, 0., 0., 0.7);
1462 xtru->DefineSection(3, 40, 10., 20., 0.9);
1463 vol->SetLineColor(randomColor());
1464 vol->SetLineWidth(2);
1465 top->AddNode(vol,1);
1467 gGeoManager->SetNsegments(nsegments);
1468
1469 ShowGeometry();
1470
1471/* top->Draw();
1472 MakePicture();
1473 if (!comments) return;
1474 c->cd(2);
1475 TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
1476 pt->SetLineColor(1);
1477 TText *text = pt->AddText("TGeoXtru - Polygonal extrusion class");
1478 text->SetTextColor(2);
1479 AddText(pt,"fNvert",xtru->GetNvert(),"number of polygone vertices");
1480 AddText(pt,"fNz",xtru->GetNz(),"number of Z sections");
1481 pt->AddText("----- Any Z section is an arbitrary polygone");
1482 pt->AddText("----- The shape can have an arbitrary number of Z sections, as for pcon/pgon");
1483 pt->AddText("----- Create with: TGeoXtru *xtru = new TGeoXtru(nz);");
1484 pt->AddText("----- Define the blueprint polygon :");
1485 pt->AddText("----- Double_t x[8] = {-30,-30,30,30,15,15,-15,-15};");
1486 pt->AddText("----- Double_t y[8] = {-30,30,30,-30,-30,15,15,-30};");
1487 pt->AddText("----- xtru->DefinePolygon(8,x,y);");
1488 pt->AddText("----- Define translations/scales of the blueprint for Z sections :");
1489 pt->AddText("----- xtru->DefineSection(i, Zsection, x0, y0, scale);");
1490 pt->AddText("----- Sections have to be defined in increasing Z order");
1491 pt->AddText("----- 2 sections can be defined at same Z (not for first/last sections)");
1492 pt->AddText(" ");
1493 pt->SetAllWith("-----","color",2);
1494 pt->SetAllWith("-----","font",72);
1495 pt->SetAllWith("-----","size",0.04);
1496 pt->SetTextAlign(12);
1497 pt->SetTextSize(0.044);
1498 pt->Draw();
1499 c->cd(1);
1500 */
1501}
1502
1503//______________________________________________________________________________
1504void composite()
1505{
1506 DeleteGeometry();
1507
1508 new TGeoManager("xtru", "poza12");
1509 TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
1510 TGeoMedium *med = new TGeoMedium("MED",1,mat);
1511 TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
1513
1514 // define shape components with names
1515 TGeoPgon *pgon = new TGeoPgon("pg",0.,360.,6,2);
1516 pgon->DefineSection(0,0,0,20);
1517 pgon->DefineSection(1, 30,0,20);
1518
1519 new TGeoSphere("sph", 40., 45.);
1520 // define named geometrical transformations with names
1521 TGeoTranslation *tr = new TGeoTranslation(0., 0., 45.);
1522 tr->SetName("tr");
1523 // register all used transformations
1524 tr->RegisterYourself();
1525 // create the composite shape based on a Boolean expression
1526 TGeoCompositeShape *cs = new TGeoCompositeShape("mir", "sph:tr*pg");
1527
1528 TGeoVolume *vol = new TGeoVolume("COMP",cs);
1529 vol->SetLineColor(randomColor());
1530 top->AddNode(vol,1);
1532 gGeoManager->SetNsegments(nsegments);
1533
1534 ShowGeometry();
1535
1536/* top->Draw();
1537 MakePicture();
1538 if (!comments) return;
1539 c->cd(2);
1540 TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
1541 pt->SetLineColor(1);
1542 TText *text = pt->AddText("TGeoCompositeShape - composite shape class");
1543 text->SetTextColor(2);
1544 pt->AddText("----- Define the shape components and don't forget to name them");
1545 pt->AddText("----- Define geometrical transformations that apply to shape components");
1546 pt->AddText("----- Name all transformations and register them");
1547 pt->AddText("----- Define the composite shape based on a Boolean expression");
1548 pt->AddText(" TGeoCompositeShape(\"someName\", \"expression\")");
1549 pt->AddText("----- Expression is made of <shapeName:transfName> components related by Boolean operators");
1550 pt->AddText("----- Boolean operators can be: (+) union, (-) subtraction and (*) intersection");
1551 pt->AddText("----- Use parenthesis in the expression to force precedence");
1552 pt->AddText(" ");
1553 pt->SetAllWith("-----","color",4);
1554 pt->SetAllWith("-----","font",72);
1555 pt->SetAllWith("-----","size",0.04);
1556 pt->SetTextAlign(12);
1557 pt->SetTextSize(0.044);
1558 pt->Draw();
1559 c->cd(1);
1560 */
1561}
1562
1563//______________________________________________________________________________
1564void ideal()
1565{
1566// This is an ideal geometry. In real life, some geometry pieces are moved/rotated
1567// with respect to their ideal positions. This is called alignment. Alignment
1568// operations can be handled by TGeo starting from a CLOSED geometry (applied a posteriori)
1569// Alignment is handled by PHYSICAL NODES, representing an unique object in geometry.
1570//
1571// Creating physical nodes:
1572// 1. TGeoPhysicalNode *node = gGeoManager->MakePhysicalNode(const char *path)
1573// - creates a physical node represented by path
1574// - path can be : TOP_1/A_2/B_3
1575// - B_3 is the 'final node' e.g. the logical node represented by this physical node
1576// 2. TGeoPhysicalNode *node = gGeoManager->MakePhysicalNode()
1577// - creates a physical node representing the current modeller state
1578
1579// Setting visualisation options for TGeoPhysicalNode *node:
1580// 1. node->SetVisibility(Bool_t flag); // set node visible(*) or invisible
1581// 2. node->SetIsVolAtt(Bool_t flag); // set line attributes to match the ones of the volumes in the branch
1582// - default - TRUE
1583// - when called with FALSE - the attributes defined for the physical node will be taken
1584// node->SetLineColor(color);
1585// node->SetLineWidth(width);
1586// node->SetLineStyle(style);
1587// 3. node->SetVisibleFull(Bool_t flag); // not only last node in the branch is visible (default)
1588//
1589// Activating/deactivating physical nodes drawing - not needed in case of alignment
1590
1591// Aligning physical nodes
1592//==========================
1593// node->Align(TGeoMatrix *newmat, TGeoShape *newshape, Bool_t check=kFALSE);
1594// newmat = new matrix to replace final node LOCAL matrix
1595// newshape = new shape to replace final node shape
1596// check = optional check if the new aligned node is overlapping
1597// gGeoManager->SetDrawExtraPaths(Bool_t flag)
1598
1599
1600 DeleteGeometry();
1601
1602 new TGeoManager("alignment", "Ideal geometry");
1603 TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
1604 TGeoMedium *med = new TGeoMedium("MED",1,mat);
1605 TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,10);
1607 TGeoVolume *slicex = top->Divide("SX",1,10,-100,10);
1608 TGeoVolume *slicey = slicex->Divide("SY",2,10,-100,10);
1609 TGeoVolume *vol = gGeoManager->MakePgon("CELL",med,0.,360.,6,2);
1610 TGeoPgon *pgon = (TGeoPgon*)(vol->GetShape());
1611 pgon->DefineSection(0,-5,0.,2.);
1612 pgon->DefineSection(1,5,0.,2.);
1613 vol->SetLineColor(randomColor());
1614 slicey->AddNode(vol,1);
1616 gGeoManager->SetNsegments(nsegments);
1617
1618
1619 ShowGeometry();
1620
1621/*
1622 top->Draw();
1623 MakePicture();
1624 if (!comments) return;
1625 c->cd(2);
1626 TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
1627 pt->SetLineColor(1);
1628 TText *text = pt->AddText("Ideal / Aligned geometry");
1629 text->SetTextColor(2);
1630 pt->AddText("-- Create physical nodes for the objects you want to align");
1631 pt->AddText("-- You must start from a valid CLOSED geometry");
1632 pt->AddText(" TGeoPhysicalNode *node = gGeoManager->MakePhysicalNode(const char *path)");
1633 pt->AddText(" + creates a physical node represented by path, e.g. TOP_1/A_2/B_3");
1634 pt->AddText(" node->Align(TGeoMatrix *newmat, TGeoShape *newshape, Bool_t check=kFALSE)");
1635 pt->AddText(" + newmat = new matrix to replace final node LOCAL matrix");
1636 pt->AddText(" + newshape = new shape to replace final node shape");
1637 pt->AddText(" + check = optional check if the new aligned node is overlapping");
1638 pt->AddText(" ");
1639 pt->SetAllWith("--","color",4);
1640 pt->SetAllWith("--","font",72);
1641 pt->SetAllWith("--","size",0.04);
1642 pt->SetAllWith("+","color",2);
1643 pt->SetAllWith("+","font",72);
1644 pt->SetAllWith("+","size",0.04);
1645 pt->SetTextAlign(12);
1646 pt->SetTextSize(0.044);
1647 pt->Draw();
1648 c->cd(1);
1649*/
1650}
1651
1652//______________________________________________________________________________
1653void align()
1654{
1655 if (!gGeoManager) return;
1656 if (strcmp(gGeoManager->GetName(),"alignment")) {
1657 printf("Click: <Ideal geometry> first %s\n", gGeoManager->GetName());
1658 return;
1659 }
1660 char name[30];
1662 TGeoPhysicalNode *node;
1663 TGeoTranslation *tr;
1664 for (Int_t i=1; i<=10; i++) {
1665 for (Int_t j=1; j<=10; j++) {
1666 node = 0;
1667 sprintf(name, "TOP_1/SX_%d/SY_%d/CELL_1",i,j);
1668 if (list) node = (TGeoPhysicalNode*)list->At(10*(i-1)+j-1);
1669 if (!node) node = gGeoManager->MakePhysicalNode(name);
1670 if (node->IsAligned()) {
1671 tr = (TGeoTranslation*)node->GetNode()->GetMatrix();
1672 tr->SetTranslation(2.*gRandom->Rndm(), 2.*gRandom->Rndm(),0.);
1673 } else {
1674 tr = new TGeoTranslation(2.*gRandom->Rndm(), 2.*gRandom->Rndm(),0.);
1675 }
1676 node->Align(tr);
1677 }
1678 }
1679
1680 ShowGeometry();
1681}
1682
1683void quit_root()
1684{
1685 printf("Terminate\n");
1687}
1688
1689//______________________________________________________________________________
1690void geodemo()
1691{
1692// root[0] .x geodemo.C
1693// root[1] box(); //draw a TGeoBBox with description
1694//
1695// The box can be divided on one axis.
1696//
1697// root[2] box(iaxis, ndiv, start, step);
1698//
1699// where: iaxis = 1,2 or 3, meaning (X,Y,Z) or (Rxy, phi, Z) depending on shape type
1700// ndiv = number of slices
1701// start = starting position (must be in shape range)
1702// step = division step
1703// If step=0, all range of a given axis will be divided
1704//
1705// The same can procedure can be performed for visualizing other shapes.
1706// When drawing one shape after another, the old geometry/canvas will be deleted.
1707 TControlBar *bar = new TControlBar("vertical", "TGeo shapes",10,10);
1708 bar->AddButton("How to run ","help()","Instructions for running this macro");
1709 bar->AddButton("Arb8 ","arb8()","An arbitrary polyhedron defined by vertices (max 8) sitting on 2 parallel planes");
1710 bar->AddButton("Box ","box()","A box shape.");
1711 bar->AddButton("Composite ","composite()","A composite shape");
1712 bar->AddButton("Cone ","cone()","A conical tube");
1713 bar->AddButton("Cone segment","coneseg()","A conical segment");
1714 bar->AddButton("Cut tube ","ctub()","A cut tube segment");
1715 bar->AddButton("Elliptical tube","eltu()","An elliptical tube");
1716 bar->AddButton("Extruded poly","xtru()","A general polygone extrusion");
1717 bar->AddButton("Hyperboloid ","hype()","A hyperboloid");
1718 bar->AddButton("Paraboloid ","parab()","A paraboloid");
1719 bar->AddButton("Polycone ","pcon()","A polycone shape");
1720 bar->AddButton("Polygone ","pgon()","A polygone");
1721 bar->AddButton("Parallelepiped","para()","A parallelepiped shape");
1722 bar->AddButton("Sphere ","sphere()","A spherical sector");
1723 bar->AddButton("Trd1 ","trd1()","A trapezoid with dX varying with Z");
1724 bar->AddButton("Trd2 ","trd2()","A trapezoid with both dX and dY varying with Z");
1725 bar->AddButton("Trapezoid ","trap()","A general trapezoid");
1726 bar->AddButton("Torus ","torus()","A toroidal segment");
1727 bar->AddButton("Tube ","tube()","A tube with inner and outer radius");
1728 bar->AddButton("Tube segment","tubeseg()","A tube segment");
1729 bar->AddButton("Twisted trap","gtra()","A twisted trapezoid");
1730 bar->AddButton("Aligned (ideal)","ideal()","An ideal (un-aligned) geometry");
1731 bar->AddButton("Un-aligned","align()","Some alignment operation");
1732 bar->AddButton("RAY-TRACE ON/OFF","raytrace()","Toggle ray-tracing mode");
1733 bar->AddButton("COMMENTS ON/OFF","comments = !comments;","Toggle explanations pad ON/OFF");
1734 bar->AddButton("AXES ON/OFF","axes()","Toggle axes ON/OFF");
1735 bar->AddButton("AUTOROTATE ON/OFF","autorotate()","Toggle autorotation ON/OFF");
1736 bar->AddButton("Quit","quit_root()","Exit from ROOT session");
1737 bar->Show();
1738 gROOT->SaveContext();
1739
1740// cone();
1741}
int Int_t
Definition: RtypesCore.h:41
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
const Bool_t kTRUE
Definition: RtypesCore.h:87
R__EXTERN TApplication * gApplication
Definition: TApplication.h:165
char name[80]
Definition: TGX11.cxx:109
R__EXTERN TGeoManager * gGeoManager
Definition: TGeoManager.h:601
#define gROOT
Definition: TROOT.h:414
R__EXTERN TRandom * gRandom
Definition: TRandom.h:62
virtual void Terminate(Int_t status=0)
Terminate the application by call TSystem::Exit() unless application has been told to return from Run...
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition: TAttFill.h:37
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
Definition: TAttText.h:41
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
Definition: TAttText.h:43
virtual void SetTextFont(Font_t tfont=62)
Set the text font.
Definition: TAttText.h:45
The Canvas class.
Definition: TCanvas.h:31
A Control Bar is a fully user configurable tool which provides fast access to frequently used operati...
Definition: TControlBar.h:22
An arbitrary trapezoid with less than 8 vertices standing on two parallel planes perpendicular to Z a...
Definition: TGeoArb8.h:18
virtual void SetVertex(Int_t vnum, Double_t x, Double_t y)
Set values for a given vertex.
Definition: TGeoArb8.cxx:1248
Class handling Boolean composition of shapes.
Hyperboloid class defined by 5 parameters.
Definition: TGeoHype.h:18
The manager class for any TGeo geometry.
Definition: TGeoManager.h:43
TGeoVolume * MakeCone(const char *name, TGeoMedium *medium, Double_t dz, Double_t rmin1, Double_t rmax1, Double_t rmin2, Double_t rmax2)
Make in one step a volume pointing to a cone shape with given medium.
TGeoVolume * MakeXtru(const char *name, TGeoMedium *medium, Int_t nz)
Make a TGeoXtru-shaped volume with nz planes.
TGeoVolume * MakePcon(const char *name, TGeoMedium *medium, Double_t phi, Double_t dphi, Int_t nz)
Make in one step a volume pointing to a polycone shape with given medium.
TGeoVolume * MakeTube(const char *name, TGeoMedium *medium, Double_t rmin, Double_t rmax, Double_t dz)
Make in one step a volume pointing to a tube shape with given medium.
TGeoVolume * MakeCons(const char *name, TGeoMedium *medium, Double_t dz, Double_t rmin1, Double_t rmax1, Double_t rmin2, Double_t rmax2, Double_t phi1, Double_t phi2)
Make in one step a volume pointing to a cone segment shape with given medium.
TGeoVolume * MakePara(const char *name, TGeoMedium *medium, Double_t dx, Double_t dy, Double_t dz, Double_t alpha, Double_t theta, Double_t phi)
Make in one step a volume pointing to a parallelepiped shape with given medium.
TGeoVolume * MakeTorus(const char *name, TGeoMedium *medium, Double_t r, Double_t rmin, Double_t rmax, Double_t phi1=0, Double_t dphi=360)
Make in one step a volume pointing to a torus shape with given medium.
void CloseGeometry(Option_t *option="d")
Closing geometry implies checking the geometry validity, fixing shapes with negative parameters (run-...
TGeoVolume * MakeTrd2(const char *name, TGeoMedium *medium, Double_t dx1, Double_t dx2, Double_t dy1, Double_t dy2, Double_t dz)
Make in one step a volume pointing to a TGeoTrd2 shape with given medium.
TGeoVolume * MakeGtra(const char *name, TGeoMedium *medium, Double_t dz, Double_t theta, Double_t phi, Double_t twist, Double_t h1, Double_t bl1, Double_t tl1, Double_t alpha1, Double_t h2, Double_t bl2, Double_t tl2, Double_t alpha2)
Make in one step a volume pointing to a twisted trapezoid shape with given medium.
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.
TGeoVolume * MakeTrd1(const char *name, TGeoMedium *medium, Double_t dx1, Double_t dx2, Double_t dy, Double_t dz)
Make in one step a volume pointing to a TGeoTrd1 shape with given medium.
TGeoVolume * MakeSphere(const char *name, TGeoMedium *medium, Double_t rmin, Double_t rmax, Double_t themin=0, Double_t themax=180, Double_t phimin=0, Double_t phimax=360)
Make in one step a volume pointing to a sphere shape with given medium.
void SetTopVolume(TGeoVolume *vol)
Set the top volume and corresponding node as starting point of the geometry.
TGeoVolume * MakeCtub(const char *name, TGeoMedium *medium, Double_t rmin, Double_t rmax, Double_t dz, Double_t phi1, Double_t phi2, Double_t lx, Double_t ly, Double_t lz, Double_t tx, Double_t ty, Double_t tz)
Make in one step a volume pointing to a tube segment shape with given medium.
TGeoVolume * MakePgon(const char *name, TGeoMedium *medium, Double_t phi, Double_t dphi, Int_t nedges, Int_t nz)
Make in one step a volume pointing to a polygone shape with given medium.
TGeoVolume * MakeTrap(const char *name, TGeoMedium *medium, Double_t dz, Double_t theta, Double_t phi, Double_t h1, Double_t bl1, Double_t tl1, Double_t alpha1, Double_t h2, Double_t bl2, Double_t tl2, Double_t alpha2)
Make in one step a volume pointing to a trapezoid shape with given medium.
void SetNsegments(Int_t nseg)
Set number of segments for approximating circles in drawing.
TGeoPhysicalNode * MakePhysicalNode(const char *path=0)
Makes a physical node corresponding to a path.
TObjArray * GetListOfPhysicalNodes()
Definition: TGeoManager.h:487
TGeoVolume * MakeHype(const char *name, TGeoMedium *medium, Double_t rin, Double_t stin, Double_t rout, Double_t stout, Double_t dz)
Make in one step a volume pointing to a tube shape with given medium.
TGeoVolume * MakeParaboloid(const char *name, TGeoMedium *medium, Double_t rlo, Double_t rhi, Double_t dz)
Make in one step a volume pointing to a tube shape with given medium.
TGeoVolume * MakeTubs(const char *name, TGeoMedium *medium, Double_t rmin, Double_t rmax, Double_t dz, Double_t phi1, Double_t phi2)
Make in one step a volume pointing to a tube segment shape with given medium.
TGeoVolume * MakeEltu(const char *name, TGeoMedium *medium, Double_t a, Double_t b, Double_t dz)
Make in one step a volume pointing to a tube shape with given medium.
Base class describing materials.
Definition: TGeoMaterial.h:31
virtual void RegisterYourself()
Register the matrix in the current manager, which will become the owner.
Definition: TGeoMatrix.cxx:526
Media are used to store properties related to tracking and which are useful only when using geometry ...
Definition: TGeoMedium.h:24
virtual TGeoMatrix * GetMatrix() const =0
Paraboloid class.
Base finder class for patterns.
Int_t GetNdiv() const
TGeoVolume * GetVolume() const
Double_t GetStep() const
Double_t GetStart() const
A polycone.
Definition: TGeoPcon.h:18
virtual void DefineSection(Int_t snum, Double_t z, Double_t rmin, Double_t rmax)
Defines z position of a section plane, rmin and rmax at this z.
Definition: TGeoPcon.cxx:618
A polygone.
Definition: TGeoPgon.h:20
Physical nodes are the actual 'touchable' objects in the geometry, representing a path of positioned ...
Bool_t IsAligned() const
TGeoNode * GetNode(Int_t level=-1) const
Return node in branch at LEVEL. If not specified, return last leaf.
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.
Base abstract class for all shapes.
Definition: TGeoShape.h:26
virtual const char * GetAxisName(Int_t iaxis) const =0
Spherical shell class.
Definition: TGeoSphere.h:18
Class describing translations.
Definition: TGeoMatrix.h:122
void SetTranslation(Double_t dx, Double_t dy, Double_t dz)
Set translation components.
Definition: TGeoMatrix.cxx:750
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition: TGeoVolume.h:53
TGeoShape * GetShape() const
Definition: TGeoVolume.h:191
virtual TGeoVolume * Divide(const char *divname, Int_t iaxis, Int_t ndiv, Double_t start, Double_t step, Int_t numed=0, Option_t *option="")
Division a la G3.
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
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:984
An extrusion with fixed outline shape in x-y and a sequence of z extents (segments).
Definition: TGeoXtru.h:22
Bool_t DefinePolygon(Int_t nvert, const Double_t *xv, const Double_t *yv)
Creates the polygon representing the blueprint of any Xtru section.
Definition: TGeoXtru.cxx:698
virtual void DefineSection(Int_t snum, Double_t z, Double_t x0=0., Double_t y0=0., Double_t scale=1.)
defines z position of a section plane, rmin and rmax at this z.
Definition: TGeoXtru.cxx:731
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition: TNamed.cxx:140
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
An array of TObjects.
Definition: TObjArray.h:37
TObject * At(Int_t idx) const
Definition: TObjArray.h:166
Mother of all ROOT objects.
Definition: TObject.h:37
A Pave (see TPave) with text, lines or/and boxes inside.
Definition: TPaveText.h:21
virtual TText * AddText(Double_t x1, Double_t y1, const char *label)
Add a new Text line to this pavetext at given coordinates.
Definition: TPaveText.cxx:182
virtual void Draw(Option_t *option="")
Draw this pavetext with its current attributes.
Definition: TPaveText.cxx:233
virtual void SetAllWith(const char *text, Option_t *option, Double_t value)
Set attribute option for all lines containing string text.
Definition: TPaveText.cxx:879
virtual Double_t Rndm()
Machine independent random number generator.
Definition: TRandom.cxx:541
Base class for several text objects.
Definition: TText.h:23
TText * text
TLine * line
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Definition: fillpatterns.C:1
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
static constexpr double bar
Double_t Cos(Double_t)
Definition: TMath.h:629
constexpr Double_t Pi()
Definition: TMath.h:38
Double_t Sin(Double_t)
Definition: TMath.h:625