Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGeoPara.cxx
Go to the documentation of this file.
1// @(#)root/geom:$Id$
2// Author: Andrei Gheata 31/01/02
3// TGeoPara::Contains() implemented by Mihaela Gheata
4
5/*************************************************************************
6 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
7 * All rights reserved. *
8 * *
9 * For the licensing terms see $ROOTSYS/LICENSE. *
10 * For the list of contributors see $ROOTSYS/README/CREDITS. *
11 *************************************************************************/
12
13/** \class TGeoPara
14\ingroup Shapes_classes
15\brief Parallelepiped class.
16
17A parallelepiped is a shape having 3 pairs of parallel faces out of
18which one is parallel with the XY plane (Z faces). All faces are
19parallelograms in the general case. The Z faces have 2 edges parallel
20with the X-axis.
21
22The shape has the center in the origin and it is defined by:
23
24 - `dX, dY, dZ:` half-lengths of the projections of the edges on X, Y
25 and Z. The lower Z face is positioned at `-dZ`, while the upper at `+dZ`.
26 - `alpha:` angle between the segment defined by the centers of the
27 X-parallel edges and Y axis `[-90,90]` in degrees
28 - `theta:` theta angle of the segment defined by the centers of the Z faces;
29 - `phi:` phi angle of the same segment
30
31~~~ {.cpp}
32TGeoPara(dX,dY,dZ,alpha,theta,phi);
33~~~
34
35A box is a particular parallelepiped having the parameters:
36`(dX,dY,dZ,0.,0.,0.)`.
37
38Begin_Macro
39{
40 TCanvas *c = new TCanvas("c", "c",0,0,600,600);
41 new TGeoManager("para", "poza1");
42 TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
43 TGeoMedium *med = new TGeoMedium("MED",1,mat);
44 TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
45 gGeoManager->SetTopVolume(top);
46 TGeoVolume *vol = gGeoManager->MakePara("PARA",med, 20,30,40,30,15,30);
47 vol->SetLineWidth(2);
48 top->AddNode(vol,1);
49 gGeoManager->CloseGeometry();
50 gGeoManager->SetNsegments(80);
51 top->Draw();
52 TView *view = gPad->GetView();
53 if (view) view->ShowAxis();
54}
55End_Macro
56
57*/
58
59#include <iostream>
60
61#include "TGeoManager.h"
62#include "TGeoMatrix.h"
63#include "TGeoVolume.h"
64#include "TGeoPara.h"
65#include "TMath.h"
66
67
68////////////////////////////////////////////////////////////////////////////////
69/// Default constructor
70
72{
74 fX = fY = fZ = 0;
75 fAlpha = 0;
76 fTheta = 0;
77 fPhi = 0;
78 fTxy = 0;
79 fTxz = 0;
80 fTyz = 0;
81}
82
83////////////////////////////////////////////////////////////////////////////////
84/// Default constructor specifying minimum and maximum radius
85
87 : TGeoBBox(0, 0, 0)
88{
90 fX = dx;
91 fY = dy;
92 fZ = dz;
93 fAlpha = alpha;
94 fTheta = theta;
95 fPhi = phi;
96 fTxy = TMath::Tan(alpha * TMath::DegToRad());
98 Double_t ph = phi * TMath::DegToRad();
99 fTxz = tth * TMath::Cos(ph);
100 fTyz = tth * TMath::Sin(ph);
101 if ((fX < 0) || (fY < 0) || (fZ < 0)) {
102 // printf("para : %f %f %f\n", fX, fY, fZ);
104 } else
105 ComputeBBox();
106}
107
108////////////////////////////////////////////////////////////////////////////////
109/// Default constructor specifying minimum and maximum radius
110
112 Double_t phi)
113 : TGeoBBox(name, 0, 0, 0)
114{
116 fX = dx;
117 fY = dy;
118 fZ = dz;
119 fAlpha = alpha;
120 fTheta = theta;
121 fPhi = phi;
122 fTxy = TMath::Tan(alpha * TMath::DegToRad());
124 Double_t ph = phi * TMath::DegToRad();
125 fTxz = tth * TMath::Cos(ph);
126 fTyz = tth * TMath::Sin(ph);
127 if ((fX < 0) || (fY < 0) || (fZ < 0)) {
128 // printf("para : %f %f %f\n", fX, fY, fZ);
130 } else
131 ComputeBBox();
132}
133
134////////////////////////////////////////////////////////////////////////////////
135/// Default constructor
136/// - param[0] = dx
137/// - param[1] = dy
138/// - param[2] = dz
139/// - param[3] = alpha
140/// - param[4] = theta
141/// - param[5] = phi
142
144{
146 SetDimensions(param);
147 if ((fX < 0) || (fY < 0) || (fZ < 0))
149 else
150 ComputeBBox();
151}
152
153////////////////////////////////////////////////////////////////////////////////
154/// destructor
155
157
158////////////////////////////////////////////////////////////////////////////////
159/// Computes capacity of the shape in [length^3]
160
162{
163 Double_t capacity = 8. * fX * fY * fZ;
164 return capacity;
165}
166
167////////////////////////////////////////////////////////////////////////////////
168/// compute bounding box
169
171{
174 Double_t dz = fZ;
176 memset(fOrigin, 0, 3 * sizeof(Double_t));
177}
178
179////////////////////////////////////////////////////////////////////////////////
180/// Compute normal to closest surface from POINT.
181
182void TGeoPara::ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm) const
183{
184 Double_t saf[3];
185 // distance from point to higher Z face
186 saf[0] = TMath::Abs(fZ - TMath::Abs(point[2])); // Z
187
188 Double_t yt = point[1] - fTyz * point[2];
189 saf[1] = TMath::Abs(fY - TMath::Abs(yt)); // Y
190 // cos of angle YZ
191 Double_t cty = 1.0 / TMath::Sqrt(1.0 + fTyz * fTyz);
192
193 Double_t xt = point[0] - fTxz * point[2] - fTxy * yt;
194 saf[2] = TMath::Abs(fX - TMath::Abs(xt)); // X
195 // cos of angle XZ
196 Double_t ctx = 1.0 / TMath::Sqrt(1.0 + fTxy * fTxy + fTxz * fTxz);
197 saf[2] *= ctx;
198 saf[1] *= cty;
199 Int_t i = TMath::LocMin(3, saf);
200 switch (i) {
201 case 0:
202 norm[0] = norm[1] = 0;
203 norm[2] = TMath::Sign(1., dir[2]);
204 return;
205 case 1:
206 norm[0] = 0;
207 norm[1] = cty;
208 norm[2] = -fTyz * cty;
209 break;
210 case 2:
214 }
215 if (norm[0] * dir[0] + norm[1] * dir[1] + norm[2] * dir[2] < 0) {
216 norm[0] = -norm[0];
217 norm[1] = -norm[1];
218 norm[2] = -norm[2];
219 }
220}
221
222////////////////////////////////////////////////////////////////////////////////
223/// test if point is inside this sphere
224/// test Z range
225
227{
228 if (TMath::Abs(point[2]) > fZ)
229 return kFALSE;
230 // check X and Y
231 Double_t yt = point[1] - fTyz * point[2];
232 if (TMath::Abs(yt) > fY)
233 return kFALSE;
234 Double_t xt = point[0] - fTxz * point[2] - fTxy * yt;
235 if (TMath::Abs(xt) > fX)
236 return kFALSE;
237 return kTRUE;
238}
239
240////////////////////////////////////////////////////////////////////////////////
241/// compute distance from inside point to surface of the para
242/// Boundary safe algorithm.
243
246{
247 if (iact < 3 && safe) {
248 // compute safety
249 *safe = Safety(point, kTRUE);
250 if (iact == 0)
251 return TGeoShape::Big();
252 if (iact == 1 && step < *safe)
253 return TGeoShape::Big();
254 }
255 Double_t saf[2];
257 Double_t s;
258 saf[0] = fZ + point[2];
259 saf[1] = fZ - point[2];
260 if (!TGeoShape::IsSameWithinTolerance(dir[2], 0)) {
261 s = (dir[2] > 0) ? (saf[1] / dir[2]) : (-saf[0] / dir[2]);
262 if (s < 0)
263 return 0.0;
264 if (s < snxt)
265 snxt = s;
266 }
267 // distance from point to center axis on Y
268 Double_t yt = point[1] - fTyz * point[2];
269 saf[0] = fY + yt;
270 saf[1] = fY - yt;
271 Double_t dy = dir[1] - fTyz * dir[2];
273 s = (dy > 0) ? (saf[1] / dy) : (-saf[0] / dy);
274 if (s < 0)
275 return 0.0;
276 if (s < snxt)
277 snxt = s;
278 }
279 // distance from point to center axis on X
280 Double_t xt = point[0] - fTxz * point[2] - fTxy * yt;
281 saf[0] = fX + xt;
282 saf[1] = fX - xt;
283 Double_t dx = dir[0] - fTxz * dir[2] - fTxy * dy;
285 s = (dx > 0) ? (saf[1] / dx) : (-saf[0] / dx);
286 if (s < 0)
287 return 0.0;
288 if (s < snxt)
289 snxt = s;
290 }
291 return snxt;
292}
293
294////////////////////////////////////////////////////////////////////////////////
295/// compute distance from inside point to surface of the para
296
299{
300 if (iact < 3 && safe) {
301 // compute safe distance
302 *safe = Safety(point, kFALSE);
303 if (iact == 0)
304 return TGeoShape::Big();
305 if (iact == 1 && step < *safe)
306 return TGeoShape::Big();
307 }
308 Bool_t in = kTRUE;
310 safz = TMath::Abs(point[2]) - fZ;
311 if (safz > 0) {
312 // outside Z
313 if (point[2] * dir[2] >= 0)
314 return TGeoShape::Big();
315 in = kFALSE;
316 }
317 Double_t yt = point[1] - fTyz * point[2];
319 Double_t dy = dir[1] - fTyz * dir[2];
320 if (safy > 0) {
321 if (yt * dy >= 0)
322 return TGeoShape::Big();
323 in = kFALSE;
324 }
325 Double_t xt = point[0] - fTxy * yt - fTxz * point[2];
327 Double_t dx = dir[0] - fTxy * dy - fTxz * dir[2];
328 if (safx > 0) {
329 if (xt * dx >= 0)
330 return TGeoShape::Big();
331 in = kFALSE;
332 }
333 // protection in case point is actually inside
334 if (in) {
335 if (safz > safx && safz > safy) {
336 if (point[2] * dir[2] > 0)
337 return TGeoShape::Big();
338 return 0.0;
339 }
340 if (safx > safy) {
341 if (xt * dx > 0)
342 return TGeoShape::Big();
343 return 0.0;
344 }
345 if (yt * dy > 0)
346 return TGeoShape::Big();
347 return 0.0;
348 }
350 if (safz > 0) {
351 Double_t snxt = safz / TMath::Abs(dir[2]);
352 xnew = point[0] + snxt * dir[0];
353 ynew = point[1] + snxt * dir[1];
354 znew = (point[2] > 0) ? fZ : (-fZ);
355 Double_t ytn = ynew - fTyz * znew;
356 if (TMath::Abs(ytn) <= fY) {
357 Double_t xtn = xnew - fTxy * ytn - fTxz * znew;
358 if (TMath::Abs(xtn) <= fX)
359 return snxt;
360 }
361 }
362 if (safy > 0) {
364 znew = point[2] + snxt * dir[2];
365 if (TMath::Abs(znew) <= fZ) {
366 Double_t ytn = (yt > 0) ? fY : (-fY);
367 xnew = point[0] + snxt * dir[0];
368 Double_t xtn = xnew - fTxy * ytn - fTxz * znew;
369 if (TMath::Abs(xtn) <= fX)
370 return snxt;
371 }
372 }
373 if (safx > 0) {
375 znew = point[2] + snxt * dir[2];
376 if (TMath::Abs(znew) <= fZ) {
377 ynew = point[1] + snxt * dir[1];
378 Double_t ytn = ynew - fTyz * znew;
379 if (TMath::Abs(ytn) <= fY)
380 return snxt;
381 }
382 }
383 return TGeoShape::Big();
384}
385
386////////////////////////////////////////////////////////////////////////////////
387/// Divide this parallelepiped shape belonging to volume "voldiv" into ndiv equal volumes
388/// called divname, from start position with the given step. Returns pointer
389/// to created division cell volume. In case a wrong division axis is supplied,
390/// returns pointer to volume to be divided.
391
394{
395 TGeoShape *shape; //--- shape to be created
396 TGeoVolume *vol; //--- division volume to be created
397 TGeoVolumeMulti *vmulti; //--- generic divided volume
398 TGeoPatternFinder *finder; //--- finder to be attached
399 TString opt = ""; //--- option to be attached
400 Double_t end = start + ndiv * step;
401 switch (iaxis) {
402 case 1: //--- divide on X
403 shape = new TGeoPara(step / 2, fY, fZ, fAlpha, fTheta, fPhi);
404 finder = new TGeoPatternParaX(voldiv, ndiv, start, end);
405 opt = "X";
406 break;
407 case 2: //--- divide on Y
408 shape = new TGeoPara(fX, step / 2, fZ, fAlpha, fTheta, fPhi);
409 finder = new TGeoPatternParaY(voldiv, ndiv, start, end);
410 opt = "Y";
411 break;
412 case 3: //--- divide on Z
413 shape = new TGeoPara(fX, fY, step / 2, fAlpha, fTheta, fPhi);
414 finder = new TGeoPatternParaZ(voldiv, ndiv, start, end);
415 opt = "Z";
416 break;
417 default: Error("Divide", "Wrong axis type for division"); return nullptr;
418 }
419 vol = new TGeoVolume(divname, shape, voldiv->GetMedium());
421 vmulti->AddVolume(vol);
422 voldiv->SetFinder(finder);
423 finder->SetDivIndex(voldiv->GetNdaughters());
424 for (Int_t ic = 0; ic < ndiv; ic++) {
425 voldiv->AddNodeOffset(vol, ic, start + step / 2. + ic * step, opt.Data());
426 ((TGeoNodeOffset *)voldiv->GetNodes()->At(voldiv->GetNdaughters() - 1))->SetFinder(finder);
427 }
428 return vmulti;
429}
430
431////////////////////////////////////////////////////////////////////////////////
432/// Get range of shape for a given axis.
433
435{
436 xlo = 0;
437 xhi = 0;
438 Double_t dx = 0;
439 switch (iaxis) {
440 case 1:
441 xlo = -fX;
442 xhi = fX;
443 dx = xhi - xlo;
444 return dx;
445 case 2:
446 xlo = -fY;
447 xhi = fY;
448 dx = xhi - xlo;
449 return dx;
450 case 3:
451 xlo = -fZ;
452 xhi = fZ;
453 dx = xhi - xlo;
454 return dx;
455 }
456 return dx;
457}
458
459////////////////////////////////////////////////////////////////////////////////
460/// Fill vector param[4] with the bounding cylinder parameters. The order
461/// is the following : Rmin, Rmax, Phi1, Phi2
462
467
468////////////////////////////////////////////////////////////////////////////////
469/// Fills real parameters of a positioned box inside this. Returns 0 if successful.
470
472{
473 dx = dy = dz = 0;
474 if (mat->IsRotation()) {
475 Error("GetFittingBox", "cannot handle parametrized rotated volumes");
476 return 1; // ### rotation not accepted ###
477 }
478 //--> translate the origin of the parametrized box to the frame of this box.
479 Double_t origin[3];
480 mat->LocalToMaster(parambox->GetOrigin(), origin);
481 if (!Contains(origin)) {
482 Error("GetFittingBox", "wrong matrix - parametrized box is outside this");
483 return 1; // ### wrong matrix ###
484 }
485 //--> now we have to get the valid range for all parametrized axis
486 Double_t dd[3];
487 dd[0] = parambox->GetDX();
488 dd[1] = parambox->GetDY();
489 dd[2] = parambox->GetDZ();
490 //-> check if Z range is fixed
491 if (dd[2] < 0) {
492 dd[2] = TMath::Min(origin[2] + fZ, fZ - origin[2]);
493 if (dd[2] < 0) {
494 Error("GetFittingBox", "wrong matrix");
495 return 1;
496 }
497 }
498 if (dd[0] >= 0 && dd[1] >= 0) {
499 dx = dd[0];
500 dy = dd[1];
501 dz = dd[2];
502 return 0;
503 }
504 //-> check now range at Z = origin[2] +/- dd[2]
505 Double_t upper[8];
506 Double_t lower[8];
507 Double_t z = origin[2] - dd[2];
508 lower[0] = z * fTxz - fTxy * fY - fX;
509 lower[1] = -fY + z * fTyz;
510 lower[2] = z * fTxz + fTxy * fY - fX;
511 lower[3] = fY + z * fTyz;
512 lower[4] = z * fTxz + fTxy * fY + fX;
513 lower[5] = fY + z * fTyz;
514 lower[6] = z * fTxz - fTxy * fY + fX;
515 lower[7] = -fY + z * fTyz;
516 z = origin[2] + dd[2];
517 upper[0] = z * fTxz - fTxy * fY - fX;
518 upper[1] = -fY + z * fTyz;
519 upper[2] = z * fTxz + fTxy * fY - fX;
520 upper[3] = fY + z * fTyz;
521 upper[4] = z * fTxz + fTxy * fY + fX;
522 upper[5] = fY + z * fTyz;
523 upper[6] = z * fTxz - fTxy * fY + fX;
524 upper[7] = -fY + z * fTyz;
525
526 for (Int_t iaxis = 0; iaxis < 2; iaxis++) {
527 if (dd[iaxis] >= 0)
528 continue;
530 for (Int_t ivert = 0; ivert < 4; ivert++) {
533 }
534 dd[iaxis] = ddmin;
535 }
536 dx = dd[0];
537 dy = dd[1];
538 dz = dd[2];
539 return 0;
540}
541
542////////////////////////////////////////////////////////////////////////////////
543/// in case shape has some negative parameters, these has to be computed
544/// in order to fit the mother
545
547{
549 return nullptr;
550 if (!mother->TestShapeBit(kGeoPara)) {
551 Error("GetMakeRuntimeShape", "invalid mother");
552 return nullptr;
553 }
554 Double_t dx, dy, dz;
555 if (fX < 0)
556 dx = ((TGeoPara *)mother)->GetX();
557 else
558 dx = fX;
559 if (fY < 0)
560 dy = ((TGeoPara *)mother)->GetY();
561 else
562 dy = fY;
563 if (fZ < 0)
564 dz = ((TGeoPara *)mother)->GetZ();
565 else
566 dz = fZ;
567 return (new TGeoPara(dx, dy, dz, fAlpha, fTheta, fPhi));
568}
569
570////////////////////////////////////////////////////////////////////////////////
571/// print shape parameters
572
574{
575 printf("*** Shape %s: TGeoPara ***\n", GetName());
576 printf(" dX = %11.5f\n", fX);
577 printf(" dY = %11.5f\n", fY);
578 printf(" dZ = %11.5f\n", fZ);
579 printf(" alpha = %11.5f\n", fAlpha);
580 printf(" theta = %11.5f\n", fTheta);
581 printf(" phi = %11.5f\n", fPhi);
582 printf(" Bounding box:\n");
584}
585
586////////////////////////////////////////////////////////////////////////////////
587/// computes the closest distance from given point to this shape, according
588/// to option. The matching point on the shape is stored in spoint.
589
591{
592 Double_t saf[3];
593 // distance from point to higher Z face
594 saf[0] = fZ - TMath::Abs(point[2]); // Z
595
596 Double_t yt = point[1] - fTyz * point[2];
597 saf[1] = fY - TMath::Abs(yt); // Y
598 // cos of angle YZ
599 Double_t cty = 1.0 / TMath::Sqrt(1.0 + fTyz * fTyz);
600
601 Double_t xt = point[0] - fTxz * point[2] - fTxy * yt;
602 saf[2] = fX - TMath::Abs(xt); // X
603 // cos of angle XZ
604 Double_t ctx = 1.0 / TMath::Sqrt(1.0 + fTxy * fTxy + fTxz * fTxz);
605 saf[2] *= ctx;
606 saf[1] *= cty;
607 if (in)
608 return saf[TMath::LocMin(3, saf)];
609 for (Int_t i = 0; i < 3; i++)
610 saf[i] = -saf[i];
611 return saf[TMath::LocMax(3, saf)];
612}
613
614////////////////////////////////////////////////////////////////////////////////
615/// Save a primitive as a C++ statement(s) on output stream "out".
616
617void TGeoPara::SavePrimitive(std::ostream &out, Option_t * /*option*/ /*= ""*/)
618{
620 return;
621 out << " // Shape: " << GetName() << " type: " << ClassName() << std::endl;
622 out << " dx = " << fX << ";" << std::endl;
623 out << " dy = " << fY << ";" << std::endl;
624 out << " dz = " << fZ << ";" << std::endl;
625 out << " alpha = " << fAlpha << ";" << std::endl;
626 out << " theta = " << fTheta << ";" << std::endl;
627 out << " phi = " << fPhi << ";" << std::endl;
628 out << " TGeoShape *" << GetPointerName() << " = new TGeoPara(\"" << GetName() << "\",dx,dy,dz,alpha,theta,phi);"
629 << std::endl;
631}
632
633////////////////////////////////////////////////////////////////////////////////
634/// Set dimensions starting from an array.
635
637{
638 fX = param[0];
639 fY = param[1];
640 fZ = param[2];
641 fAlpha = param[3];
642 fTheta = param[4];
643 fPhi = param[5];
644 fTxy = TMath::Tan(param[3] * TMath::DegToRad());
645 Double_t tth = TMath::Tan(param[4] * TMath::DegToRad());
646 Double_t ph = param[5] * TMath::DegToRad();
647 fTxz = tth * TMath::Cos(ph);
648 fTyz = tth * TMath::Sin(ph);
649}
650
651////////////////////////////////////////////////////////////////////////////////
652/// Create PARA mesh points
653
655{
656 if (!points)
657 return;
658 Double_t txy = fTxy;
659 Double_t txz = fTxz;
660 Double_t tyz = fTyz;
661 *points++ = -fZ * txz - txy * fY - fX;
662 *points++ = -fY - fZ * tyz;
663 *points++ = -fZ;
664 *points++ = -fZ * txz + txy * fY - fX;
665 *points++ = +fY - fZ * tyz;
666 *points++ = -fZ;
667 *points++ = -fZ * txz + txy * fY + fX;
668 *points++ = +fY - fZ * tyz;
669 *points++ = -fZ;
670 *points++ = -fZ * txz - txy * fY + fX;
671 *points++ = -fY - fZ * tyz;
672 *points++ = -fZ;
673 *points++ = +fZ * txz - txy * fY - fX;
674 *points++ = -fY + fZ * tyz;
675 *points++ = +fZ;
676 *points++ = +fZ * txz + txy * fY - fX;
677 *points++ = +fY + fZ * tyz;
678 *points++ = +fZ;
679 *points++ = +fZ * txz + txy * fY + fX;
680 *points++ = +fY + fZ * tyz;
681 *points++ = +fZ;
682 *points++ = +fZ * txz - txy * fY + fX;
683 *points++ = -fY + fZ * tyz;
684 *points++ = +fZ;
685}
686
687////////////////////////////////////////////////////////////////////////////////
688/// create sphere mesh points
689
691{
692 if (!points)
693 return;
694 Double_t txy = fTxy;
695 Double_t txz = fTxz;
696 Double_t tyz = fTyz;
697 *points++ = -fZ * txz - txy * fY - fX;
698 *points++ = -fY - fZ * tyz;
699 *points++ = -fZ;
700 *points++ = -fZ * txz + txy * fY - fX;
701 *points++ = +fY - fZ * tyz;
702 *points++ = -fZ;
703 *points++ = -fZ * txz + txy * fY + fX;
704 *points++ = +fY - fZ * tyz;
705 *points++ = -fZ;
706 *points++ = -fZ * txz - txy * fY + fX;
707 *points++ = -fY - fZ * tyz;
708 *points++ = -fZ;
709 *points++ = +fZ * txz - txy * fY - fX;
710 *points++ = -fY + fZ * tyz;
711 *points++ = +fZ;
712 *points++ = +fZ * txz + txy * fY - fX;
713 *points++ = +fY + fZ * tyz;
714 *points++ = +fZ;
715 *points++ = +fZ * txz + txy * fY + fX;
716 *points++ = +fY + fZ * tyz;
717 *points++ = +fZ;
718 *points++ = +fZ * txz - txy * fY + fX;
719 *points++ = -fY + fZ * tyz;
720 *points++ = +fZ;
721}
722
723////////////////////////////////////////////////////////////////////////////////
724/// fill size of this 3-D object
725
727{
729}
730
731////////////////////////////////////////////////////////////////////////////////
732/// Check the inside status for each of the points in the array.
733/// Input: Array of point coordinates + vector size
734/// Output: Array of Booleans for the inside of each point
735
737{
738 for (Int_t i = 0; i < vecsize; i++)
739 inside[i] = Contains(&points[3 * i]);
740}
741
742////////////////////////////////////////////////////////////////////////////////
743/// Compute the normal for an array o points so that norm.dot.dir is positive
744/// Input: Arrays of point coordinates and directions + vector size
745/// Output: Array of normal directions
746
748{
749 for (Int_t i = 0; i < vecsize; i++)
750 ComputeNormal(&points[3 * i], &dirs[3 * i], &norms[3 * i]);
751}
752
753////////////////////////////////////////////////////////////////////////////////
754/// Compute distance from array of input points having directions specified by dirs. Store output in dists
755
757 Double_t *step) const
758{
759 for (Int_t i = 0; i < vecsize; i++)
760 dists[i] = DistFromInside(&points[3 * i], &dirs[3 * i], 3, step[i]);
761}
762
763////////////////////////////////////////////////////////////////////////////////
764/// Compute distance from array of input points having directions specified by dirs. Store output in dists
765
767 Double_t *step) const
768{
769 for (Int_t i = 0; i < vecsize; i++)
770 dists[i] = DistFromOutside(&points[3 * i], &dirs[3 * i], 3, step[i]);
771}
772
773////////////////////////////////////////////////////////////////////////////////
774/// Compute safe distance from each of the points in the input array.
775/// Input: Array of point coordinates, array of statuses for these points, size of the arrays
776/// Output: Safety values
777
778void TGeoPara::Safety_v(const Double_t *points, const Bool_t *inside, Double_t *safe, Int_t vecsize) const
779{
780 for (Int_t i = 0; i < vecsize; i++)
781 safe[i] = Safety(&points[3 * i], inside[i]);
782}
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:71
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
double Double_t
Double 8 bytes.
Definition RtypesCore.h:73
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
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 points
char name[80]
Definition TGX11.cxx:110
R__EXTERN TGeoManager * gGeoManager
Box class.
Definition TGeoBBox.h:17
void GetBoundingCylinder(Double_t *param) const override
Fill vector param[4] with the bounding cylinder parameters.
Definition TGeoBBox.cxx:600
void SetBoxDimensions(Double_t dx, Double_t dy, Double_t dz, Double_t *origin=nullptr)
Set parameters of the box.
Definition TGeoBBox.cxx:969
Double_t fOrigin[3]
Definition TGeoBBox.h:23
void InspectShape() const override
Prints shape parameters.
Definition TGeoBBox.cxx:810
void Sizeof3D() const override
TGeoVolumeMulti * MakeVolumeMulti(const char *name, TGeoMedium *medium)
Make a TGeoVolumeMulti handling a list of volumes.
Geometrical transformation package.
Definition TGeoMatrix.h:38
Node containing an offset.
Definition TGeoNode.h:184
Parallelepiped class.
Definition TGeoPara.h:17
void SetDimensions(Double_t *param) override
Set dimensions starting from an array.
Definition TGeoPara.cxx:636
Double_t fTxy
Definition TGeoPara.h:26
Double_t fTyz
Definition TGeoPara.h:28
void ComputeNormal_v(const Double_t *points, const Double_t *dirs, Double_t *norms, Int_t vecsize) override
Compute the normal for an array o points so that norm.dot.dir is positive Input: Arrays of point coor...
Definition TGeoPara.cxx:747
Double_t fX
Definition TGeoPara.h:20
Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const override
computes the closest distance from given point to this shape, according to option.
Definition TGeoPara.cxx:590
void Sizeof3D() const override
fill size of this 3-D object
Definition TGeoPara.cxx:726
TGeoShape * GetMakeRuntimeShape(TGeoShape *mother, TGeoMatrix *mat) const override
in case shape has some negative parameters, these has to be computed in order to fit the mother
Definition TGeoPara.cxx:546
void GetBoundingCylinder(Double_t *param) const override
Fill vector param[4] with the bounding cylinder parameters.
Definition TGeoPara.cxx:463
Double_t Capacity() const override
Computes capacity of the shape in [length^3].
Definition TGeoPara.cxx:161
TGeoVolume * Divide(TGeoVolume *voldiv, const char *divname, Int_t iaxis, Int_t ndiv, Double_t start, Double_t step) override
Divide this parallelepiped shape belonging to volume "voldiv" into ndiv equal volumes called divname,...
Definition TGeoPara.cxx:393
Double_t GetAxisRange(Int_t iaxis, Double_t &xlo, Double_t &xhi) const override
Get range of shape for a given axis.
Definition TGeoPara.cxx:434
TGeoPara()
Default constructor.
Definition TGeoPara.cxx:71
void InspectShape() const override
print shape parameters
Definition TGeoPara.cxx:573
void Safety_v(const Double_t *points, const Bool_t *inside, Double_t *safe, Int_t vecsize) const override
Compute safe distance from each of the points in the input array.
Definition TGeoPara.cxx:778
Double_t fTheta
Definition TGeoPara.h:24
void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm) const override
Compute normal to closest surface from POINT.
Definition TGeoPara.cxx:182
Int_t GetFittingBox(const TGeoBBox *parambox, TGeoMatrix *mat, Double_t &dx, Double_t &dy, Double_t &dz) const override
Fills real parameters of a positioned box inside this. Returns 0 if successful.
Definition TGeoPara.cxx:471
Double_t fTxz
Definition TGeoPara.h:27
void DistFromInside_v(const Double_t *points, const Double_t *dirs, Double_t *dists, Int_t vecsize, Double_t *step) const override
Compute distance from array of input points having directions specified by dirs. Store output in dist...
Definition TGeoPara.cxx:756
void SetPoints(Double_t *points) const override
Create PARA mesh points.
Definition TGeoPara.cxx:654
Double_t fAlpha
Definition TGeoPara.h:23
void Contains_v(const Double_t *points, Bool_t *inside, Int_t vecsize) const override
Check the inside status for each of the points in the array.
Definition TGeoPara.cxx:736
Double_t fZ
Definition TGeoPara.h:22
~TGeoPara() override
destructor
Definition TGeoPara.cxx:156
Double_t fY
Definition TGeoPara.h:21
Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=TGeoShape::Big(), Double_t *safe=nullptr) const override
compute distance from inside point to surface of the para
Definition TGeoPara.cxx:298
Double_t fPhi
Definition TGeoPara.h:25
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a primitive as a C++ statement(s) on output stream "out".
Definition TGeoPara.cxx:617
void DistFromOutside_v(const Double_t *points, const Double_t *dirs, Double_t *dists, Int_t vecsize, Double_t *step) const override
Compute distance from array of input points having directions specified by dirs. Store output in dist...
Definition TGeoPara.cxx:766
Bool_t Contains(const Double_t *point) const override
test if point is inside this sphere test Z range
Definition TGeoPara.cxx:226
Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=TGeoShape::Big(), Double_t *safe=nullptr) const override
compute distance from inside point to surface of the para Boundary safe algorithm.
Definition TGeoPara.cxx:245
void ComputeBBox() override
compute bounding box
Definition TGeoPara.cxx:170
base finder class for patterns. A pattern is specifying a division type
a X axis divison pattern for PARA shapes
a Y axis divison pattern for PARA shapes
a Z axis divison pattern for PARA shapes
Base abstract class for all shapes.
Definition TGeoShape.h:25
static Double_t Big()
Definition TGeoShape.h:94
void SetShapeBit(UInt_t f, Bool_t set)
Equivalent of TObject::SetBit.
static Bool_t IsSameWithinTolerance(Double_t a, Double_t b)
Check if two numbers differ with less than a tolerance.
const char * GetPointerName() const
Provide a pointer name containing uid.
const char * GetName() const override
Get the shape name.
@ kGeoSavePrimitive
Definition TGeoShape.h:64
@ kGeoRunTimeShape
Definition TGeoShape.h:40
Bool_t TestShapeBit(UInt_t f) const
Definition TGeoShape.h:175
Volume families.
Definition TGeoVolume.h:266
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition TGeoVolume.h:43
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:202
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition TObject.cxx:226
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:864
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1071
Basic string class.
Definition TString.h:138
const char * Data() const
Definition TString.h:384
Long64_t LocMin(Long64_t n, const T *a)
Returns index of array with the minimum element.
Definition TMath.h:993
T1 Sign(T1 a, T2 b)
Returns a value with the magnitude of a and the sign of b.
Definition TMathBase.h:176
Long64_t LocMax(Long64_t n, const T *a)
Returns index of array with the maximum element.
Definition TMath.h:1099
constexpr Double_t DegToRad()
Conversion from degree to radian: .
Definition TMath.h:82
Double_t Sqrt(Double_t x)
Returns the square root of x.
Definition TMath.h:673
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Definition TMathBase.h:199
Double_t Cos(Double_t)
Returns the cosine of an angle of x radians.
Definition TMath.h:605
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Definition TMath.h:599
Double_t Tan(Double_t)
Returns the tangent of an angle of x radians.
Definition TMath.h:611
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:124