70 fIntBuffer(0), fDblBuffer(0)
96 std::vector<ThreadData_t*>::iterator i =
fThreadData.begin();
116 for (
Int_t tid=0; tid<nthreads; tid++) {
195 Double_t rmin1, rmax1, rmin2, rmax2, dphi, dz;
199 for (ipl=0; ipl<
fNz-1; ipl++) {
200 dz =
fZ[ipl+1]-
fZ[ipl];
204 rmin2 =
fRmin[ipl+1];
205 rmax2 =
fRmax[ipl+1];
206 capacity +=
fNedges*(tphi2/3.)*dz*(rmax1*rmax1+rmax1*rmax2+rmax2*rmax2 -
207 rmin1*rmin1-rmin1*rmin2-rmin2*rmin2);
218 for (
Int_t isec=0; isec<
fNz-1; isec++) {
219 if (
fZ[isec]>
fZ[isec+1]) {
221 Fatal(
"ComputeBBox",
"Wrong section order");
228 Fatal(
"ComputeBBox",
"Shape %s at index %d: Not allowed first two or last two sections at same Z",
260 if (ddp<0) ddp+= 360;
261 if (ddp<=fDphi) xmax = rmax;
263 if (ddp<0) ddp+= 360;
264 if (ddp<=fDphi) ymax = rmax;
266 if (ddp<0) ddp+= 360;
267 if (ddp<=fDphi) xmin = -rmax;
269 if (ddp<0) ddp+= 360;
270 if (ddp<=fDphi) ymin = -rmax;
276 fDZ = 0.5*(zmax-zmin);
291 if (phi1<0) phi1+=360;
306 if (ipl==(
fNz-1) || ipl<0) {
311 Int_t iplclose = ipl;
312 if ((
fZ[ipl+1]-point[2])<(point[2]-
fZ[ipl])) iplclose++;
317 while (phi<
fPhi1) phi+=360.;
325 if (iplclose==0 || iplclose==(
fNz-1)) {
344 dz =
fZ[ipl+1]-
fZ[ipl];
346 rmin2 =
fRmin[ipl+1];
350 ta = (rmin2-rmin1)/dz;
352 rpgon = rmin1 + (point[2]-fZ[ipl])*ta;
360 rpgon =
fRmax[ipl] + (point[2]-fZ[ipl])*ta;
366 if (norm[0]*dir[0]+norm[1]*dir[1]+norm[2]*dir[2]<0) {
384 while (phi <
fPhi1) phi += 360.0;
405 if (r<rmin)
return kFALSE;
406 if (r>rmax)
return kFALSE;
410 Double_t dzrat = (point[2]-fZ[iz])/dz;
413 if (r < rmin)
return kFALSE;
415 if (r > rmax)
return kFALSE;
426 if (iact<3 && safe) {
435 if (dir[2]>=0)
return 0.;
440 if (dir[2]<=0)
return 0.;
454 if ((point[0]*dir[1]-point[1]*dir[0])>0) {
492 Double_t rproj = point[0]*cphi+point[1]*sphi;
495 if (rproj>
fRmin[ipln] && rproj<
fRmin[ipln+1])
return 0.0;
496 if (rproj<
fRmax[ipln] && rproj>
fRmax[ipln+1])
return 0.0;
499 if (rproj<
fRmin[ipln] && rproj>
fRmin[ipln+1])
return 0.0;
500 if (rproj>
fRmax[ipln] && rproj<
fRmax[ipln+1])
return 0.0;
523 while (phi<
fPhi1) phi+=360.;
525 if (ipsec>
fNedges-1) ipsec = -1;
544 Double_t rdotn = point[0]*dir[0]+point[1]*dir[1];
546 sphi[icrossed] = stepmax;
547 iphi[icrossed++] = istart;
550 sphi[icrossed] =
TMath::Sqrt((point[0]*point[0]+point[1]*point[1])/(1.-dir[2]*dir[2]));
551 iphi[icrossed++] = istart;
552 if (sphi[icrossed-1]>stepmax) {
553 sphi[icrossed-1] = stepmax;
557 while (phi<
fPhi1) phi+=360.;
559 if (istart>
fNedges-1) istart=-1;
560 iphi[icrossed] = istart;
561 sphi[icrossed] = stepmax;
567 if (istart<0) ist=(incsec>0)?0:
fNedges;
568 else ist=(incsec>0)?(istart+1):istart;
574 if (istart<0) gapdone =
kTRUE;
575 phi = phi1+ist*divphi;
579 if (!crossing) sphi[icrossed] = stepmax;
580 iphi[icrossed++] = istart;
582 if (sphi[icrossed-1]>stepmax) {
583 sphi[icrossed-1] = stepmax;
587 istart = (incsec>0)?0:(
fNedges-1);
594 if (gapdone)
return icrossed;
597 ist=(incsec>0)?(istart+1):istart;
615 if (iphi[0]<0 && nphi==1)
return kFALSE;
631 rmin =
Rpg(point[2], ipl,
kTRUE, apg,bpg);
632 rmax =
Rpg(point[2], ipl,
kFALSE, apg,bpg);
642 memcpy(pt,point,3*
sizeof(
Double_t));
643 for (iphcrt=0; iphcrt<nphi; iphcrt++) {
648 if (iphi[iphcrt]<0) {
653 snextphi = stepphi[iphcrt];
654 phi = phi1+(iphi[iphcrt]+0.5)*divphi;
657 rproj = pt[0]*cosph+pt[1]*sinph;
659 ndot = dir[0]*cosph+dir[1]*sinph;
661 dist = (ndot>0)?((rmax-rproj)/ndot):((rmin-rproj)/ndot);
664 if (dist < (snextphi-step)) {
666 if (snext<stepmax)
return kTRUE;
670 for (i=0; i<3; i++) pt[i] = point[i]+step*dir[i];
686 if (iphi[0]<0 && nphi==1)
return kFALSE;
702 rmin =
Rpg(point[2], ipl,
kTRUE, apg,bpg);
703 rmax =
Rpg(point[2], ipl,
kFALSE, apg,bpg);
713 memcpy(pt,point,3*
sizeof(
Double_t));
714 for (iphcrt=0; iphcrt<nphi; iphcrt++) {
715 if (step>stepmax)
return kFALSE;
716 snextphi = stepphi[iphcrt];
717 if (iphi[iphcrt]<0) {
718 if (iphcrt==nphi-1)
return kFALSE;
719 if (snextphi>stepmax)
return kFALSE;
720 for (i=0; i<3; i++) pt[i] = point[i]+snextphi*dir[i];
721 phi = phi1+(iphi[iphcrt+1]+0.5)*divphi;
724 rproj = pt[0]*cosph+pt[1]*sinph;
725 if (rproj<rmin || rproj>rmax) {
733 phi = phi1+(iphi[iphcrt]+0.5)*divphi;
736 rproj = pt[0]*cosph+pt[1]*sinph;
738 ndot = dir[0]*cosph+dir[1]*sinph;
746 if (snext<stepmax)
return kTRUE;
749 for (i=0; i<3; i++) pt[i] = point[i]+step*dir[i];
777 Int_t incseg = (dir[2]>0)?1:-1;
779 Int_t iplstart = ipl;
783 Double_t rpgin=0,rpgout=0,apgin=0,apgout=0,bpgin=0,bpgout=0;
788 Double_t distz=0, distr=0, din=0, dout=0;
790 memcpy(pt,point,3*
sizeof(
Double_t));
791 for (iphcrt=iphstart; iphcrt<nphi; iphcrt++) {
797 if (iphi[iphcrt]<0) {
801 snextphi = stepphi[iphcrt];
802 phi = phi1+(iphi[iphcrt]+0.5)*divphi;
805 Double_t rproj =
Rproj(pt[2], pt, dir, cosph, sinph, apr, bpr);
807 while (ipl>=0 && ipl<
fNz-1) {
810 distz = (
fZ[ipl+((1+incseg)>>1)]-pt[2])*invdir;
812 dz =
fZ[ipl+1] -
fZ[ipl];
814 rnew = apr+bpr*fZ[ipl];
816 if (rpg<=0) din=distz;
818 if (rpg<=0) dout=distz;
821 rpgin =
Rpg(pt[2], ipl,
kTRUE, apgin, bpgin);
824 znew = (apr-apgin)/db;
825 din = (znew-pt[2])*invdir;
827 rpgout =
Rpg(pt[2], ipl,
kFALSE, apgout, bpgout);
830 znew = (apr-apgout)/db;
831 dout = (znew-pt[2])*invdir;
837 if (iphcrt==iphstart && ipl==iplstart) {
838 if (rproj<rpgin+1.
E-8) {
841 snext = (din<0)?step:(step+din);
849 }
else if (rproj>rpgout-1.
E-8) {
852 snext = (dout<0)?step:(step+dout);
864 if (snextphi < step+
TMath::Min(distz,distr)) {
865 for (i=0; i<3; i++) pt[i] = point[i] + snextphi*dir[i];
877 if ((ipl+incseg<0) || (ipl+incseg>
fNz-2)) {
899 if (iphi[0]<0 && nphi==1)
return kFALSE;
904 Int_t incseg = (dir[2]>0)?1:-1;
908 if (incseg<0)
return kFALSE;
912 if (incseg>0)
return kFALSE;
916 if ((ipl+incseg)<0 || (ipl+incseg)>
fNz-1)
return kFALSE;
935 memcpy(pt,point,3*
sizeof(
Double_t));
936 for (iphcrt=0; iphcrt<nphi; iphcrt++) {
938 if (step>stepmax)
return kFALSE;
940 snextphi = stepphi[iphcrt];
941 if (iphi[iphcrt]<0) {
942 if (iphcrt==nphi-1)
return kFALSE;
943 if (snextphi>stepmax)
return kFALSE;
944 for (i=0; i<3; i++) pt[i] = point[i]+snextphi*dir[i];
948 while (pt[2]>
fZ[ipl+1]) {
953 while (pt[2]<
fZ[ipl]) {
959 rpgin =
Rpg(pt[2],ipl,
kTRUE,apg,bpg);
961 phi = phi1+(iphi[iphcrt+1]+0.5)*divphi;
965 rproj = pt[0]*cosph+pt[1]*sinph;
966 if (rproj<rpgin || rproj>rpgout) {
986 if (sstart>stepmax)
return kFALSE;
988 memcpy(pt, point, 3*
sizeof(
Double_t));
989 if (sstart>0)
for (
Int_t i=0; i<3; i++) pt[i] += sstart*dir[i];
992 Int_t incseg = (dir[2]>0)?1:-1;
1000 Rproj(pt[2], point, dir, cphi, sphi, apr, bpr);
1003 Int_t icrtseg = ipl;
1004 Int_t isegstart = ipl;
1005 Int_t iseglast = (incseg>0)?(
fNz-1):-1;
1006 Double_t din,dout,rdot,rnew,rpg,apg,bpg,db,znew;
1008 for (ipl=isegstart; ipl!=iseglast; ipl+=incseg) {
1009 step = (
fZ[ipl+1-((1+incseg)>>1)]-pt[2])*invdir;
1018 dz =
fZ[ipl+1]-
fZ[ipl];
1022 else rdot = dir[0]*cphi+dir[1]*sphi+dir[2]*(
fRmin[ipl]-
fRmin[ipl+1])/dz;
1027 rnew = apr+bpr*fZ[ipl];
1029 if (rpg<=0) din=(fZ[ipl]-pt[2])*invdir;
1031 rpg =
Rpg(pt[2], ipl,
kTRUE, apg, bpg);
1034 znew = (apr-apg)/db;
1035 if (znew>fZ[ipl] && znew<fZ[ipl+1]) {
1036 din=(znew-pt[2])*invdir;
1045 else rdot = dir[0]*cphi+dir[1]*sphi+dir[2]*(
fRmax[ipl]-
fRmax[ipl+1])/dz;
1050 rnew = apr+bpr*fZ[ipl];
1052 if (rpg<=0) dout=(fZ[ipl]-pt[2])*invdir;
1054 rpg =
Rpg(pt[2], ipl,
kFALSE, apg, bpg);
1057 znew = (apr-apg)/db;
1058 if (znew>fZ[ipl] && znew<fZ[ipl+1]) dout=(znew-pt[2])*invdir;
1071 snext = sstart+step;
1084 if (iact<3 && safe) {
1097 memcpy(pt,point,3*
sizeof(
Double_t));
1112 if (r2>(radmax*radmax) || pt[2]<
fZ[0] || pt[2]>
fZ[
fNz-1]) {
1113 pt[2] -= 0.5*(
fZ[0]+
fZ[
fNz-1]);
1119 for (i=0; i<3; i++) pt[i] += snext*dir[i];
1132 while (phi <
fPhi1) phi += 360.0;
1135 ipsec =
Int_t(ddp/divphi);
1138 if (rpr>=rmin && rpr<=rmax)
return snext;
1152 if (
SliceCrossingZ(pt, dir, icrossed, iph, sph, snewcross, stepmax))
return (snext+snewcross);
1159 while (ph<
fPhi1) ph+=360.;
1161 if (ipsec>
fNedges-1) ipsec = -1;
1169 if (ipl==
fNz-1) ipl--;
1180 Double_t rproj = pt[0]*cphi+pt[1]*sphi;
1182 if (rproj<
fRmin[ipl] && rproj>
fRmin[ipl+1] && dir[2]>0)
return 0.0;
1183 if (rproj>
fRmin[ipl] && rproj<
fRmin[ipl+1] && dir[2]<0)
return 0.0;
1184 if (rproj>
fRmax[ipl] && rproj<
fRmax[ipl+1] && dir[2]>0)
return 0.0;
1185 if (rproj<
fRmax[ipl] && rproj>
fRmax[ipl+1] && dir[2]<0)
return 0.0;
1191 if (rproj<rpgout+1.
E-8) {
1194 if (rproj>rpgin-1.
E-8) {
1205 if (safrmin<safz && safrmin<safrmax && safrmin<safphi) {
1209 if (ndotd>0)
return snext;
1212 if (!done && safrmax<safz && safrmax<safphi) {
1215 if (ndotd<0)
return snext;
1218 if (!done && safz<safphi) {
1222 if (iplc==0 || iplc==
fNz-1) {
1223 if (pt[2]*dir[2]<0)
return snext;
1255 if (!icrossed)
return snext;
1257 if (iph[0]>=0 && sph[0]>1.
E-8)
return snext;
1260 if (
SliceCrossing(pt, dir, icrossed, iph, sph, snewcross, stepmax)) {
1302 Error(
"Divide",
"makes no sense dividing a pgon on radius");
1306 Error(
"Divide",
"ndiv should divide number of pgon edges");
1317 for (is=0; is<
fNz; is++)
1320 for (
id=0;
id<ndiv;
id++) {
1327 for (ipl=0; ipl<fNz-1; ipl++) {
1328 if (start<
fZ[ipl])
continue;
1330 if ((start+ndiv*step)>
fZ[ipl+1])
continue;
1338 Error(
"Divide",
"cannot divide pcon on Z if divided region is not between 2 consecutive planes");
1341 finder =
new TGeoPatternZ(voldiv, ndiv, start, start+ndiv*step);
1346 for (
id=0;
id<ndiv;
id++) {
1354 ((
TGeoPgon*)shape)->DefineSection(0, -step/2, rmin1, rmax1);
1355 ((
TGeoPgon*)shape)->DefineSection(1, step/2, rmin2, rmax2);
1363 Error(
"Divide",
"Wrong axis type for division");
1374 param[0] =
fRmin[0];
1375 param[1] =
fRmax[0];
1377 if (
fRmin[i] < param[0]) param[0] =
fRmin[i];
1378 if (
fRmax[i] > param[1]) param[1] =
fRmax[i];
1382 param[0] *= param[0];
1383 param[1] *= param[1];
1390 param[3] = param[2]+
fDphi;
1398 printf(
"*** Shape %s: TGeoPgon ***\n",
GetName());
1399 printf(
" Nedges = %i\n",
fNedges);
1411 if (nz < 2)
return 0;
1413 if (nbPnts <= 0)
return 0;
1417 Int_t nbSegs = 4*(nz*n-1+(specialCase ==
kTRUE));
1418 Int_t nbPols = 2*(nz*n-1+(specialCase ==
kTRUE));
1421 nbPnts, 3*nbPnts, nbSegs, 3*nbSegs, nbPols, 6*nbPols);
1441 if (nbPnts <= 0)
return;
1447 Int_t indx, indx2, k;
1452 for (i = 0; i < nz*2; i++) {
1454 for (j = 1; j <
n; j++) {
1456 buff.
fSegs[indx++] = indx2+j-1;
1457 buff.
fSegs[indx++] = indx2+j;
1461 buff.
fSegs[indx++] = indx2+j-1;
1462 buff.
fSegs[indx++] = indx2;
1467 for (i = 0; i < 2; i++) {
1468 indx2 = i*(nz-1)*2*n;
1469 for (j = 0; j <
n; j++) {
1471 buff.
fSegs[indx++] = indx2+j;
1472 buff.
fSegs[indx++] = indx2+n+j;
1477 for (i = 0; i < (nz-1); i++) {
1480 for (j = 0; j <
n; j++) {
1481 buff.
fSegs[indx++] = c+2;
1482 buff.
fSegs[indx++] = indx2+j;
1483 buff.
fSegs[indx++] = indx2+n*2+j;
1487 for (j = 0; j <
n; j++) {
1488 buff.
fSegs[indx++] = c+3;
1489 buff.
fSegs[indx++] = indx2+j;
1490 buff.
fSegs[indx++] = indx2+n*2+j;
1497 for (i = 1; i < (nz-1); i++) {
1498 for (j = 0; j < 2; j++) {
1500 buff.
fSegs[indx++] = 2*i * n + j*(n-1);
1501 buff.
fSegs[indx++] = (2*i+1) * n + j*(n-1);
1512 for (j = 0; j < n-1; j++) {
1513 buff.
fPols[indx++] = c+3;
1514 buff.
fPols[indx++] = 4;
1515 buff.
fPols[indx++] = 2*nz*m+i*n+j;
1516 buff.
fPols[indx++] = i*(nz*2-2)*m+m+j;
1517 buff.
fPols[indx++] = 2*nz*m+i*n+j+1;
1518 buff.
fPols[indx++] = i*(nz*2-2)*m+j;
1521 buff.
fPols[indx++] = c+3;
1522 buff.
fPols[indx++] = 4;
1523 buff.
fPols[indx++] = 2*nz*m+i*n+j;
1524 buff.
fPols[indx++] = i*(nz*2-2)*m+m+j;
1525 buff.
fPols[indx++] = 2*nz*m+i*
n;
1526 buff.
fPols[indx++] = i*(nz*2-2)*m+j;
1529 for (j = 0; j < n-1; j++) {
1530 buff.
fPols[indx++] = c+3;
1531 buff.
fPols[indx++] = 4;
1532 buff.
fPols[indx++] = i*(nz*2-2)*m+j;
1533 buff.
fPols[indx++] = 2*nz*m+i*n+j+1;
1534 buff.
fPols[indx++] = i*(nz*2-2)*m+m+j;
1535 buff.
fPols[indx++] = 2*nz*m+i*n+j;
1538 buff.
fPols[indx++] = c+3;
1539 buff.
fPols[indx++] = 4;
1540 buff.
fPols[indx++] = i*(nz*2-2)*m+j;
1541 buff.
fPols[indx++] = 2*nz*m+i*
n;
1542 buff.
fPols[indx++] = i*(nz*2-2)*m+m+j;
1543 buff.
fPols[indx++] = 2*nz*m+i*n+j;
1547 for (k = 0; k < (nz-1); k++) {
1549 for (j = 0; j < n-1; j++) {
1550 buff.
fPols[indx++] = c+i;
1551 buff.
fPols[indx++] = 4;
1552 buff.
fPols[indx++] = nz*2*m+(2*k+i*1+2)*n+j+1;
1553 buff.
fPols[indx++] = (2*k+i*1+2)*m+j;
1554 buff.
fPols[indx++] = nz*2*m+(2*k+i*1+2)*n+j;
1555 buff.
fPols[indx++] = (2*k+i*1)*m+j;
1558 buff.
fPols[indx++] = c+i;
1559 buff.
fPols[indx++] = 4;
1560 buff.
fPols[indx++] = nz*2*m+(2*k+i*1+2)*n;
1561 buff.
fPols[indx++] = (2*k+i*1+2)*m+j;
1562 buff.
fPols[indx++] = nz*2*m+(2*k+i*1+2)*n+j;
1563 buff.
fPols[indx++] = (2*k+i*1)*m+j;
1566 for (j = 0; j < n-1; j++) {
1567 buff.
fPols[indx++] = c+i;
1568 buff.
fPols[indx++] = 4;
1569 buff.
fPols[indx++] = (2*k+i*1)*m+j;
1570 buff.
fPols[indx++] = nz*2*m+(2*k+i*1+2)*n+j;
1571 buff.
fPols[indx++] = (2*k+i*1+2)*m+j;
1572 buff.
fPols[indx++] = nz*2*m+(2*k+i*1+2)*n+j+1;
1575 buff.
fPols[indx++] = c+i;
1576 buff.
fPols[indx++] = 4;
1577 buff.
fPols[indx++] = (2*k+i*1)*m+j;
1578 buff.
fPols[indx++] = nz*2*m+(2*k+i*1+2)*n+j;
1579 buff.
fPols[indx++] = (2*k+i*1+2)*m+j;
1580 buff.
fPols[indx++] = nz*2*m+(2*k+i*1+2)*n;
1588 for (k = 0; k < (nz-1); k++) {
1589 buff.
fPols[indx++] = c+2;
1590 buff.
fPols[indx++] = 4;
1591 buff.
fPols[indx++] = k==0 ? indx2 : indx2+2*nz*n+2*(k-1);
1592 buff.
fPols[indx++] = indx2+2*(k+1)*n;
1593 buff.
fPols[indx++] = indx2+2*nz*n+2*k;
1594 buff.
fPols[indx++] = indx2+(2*k+3)*n;
1596 buff.
fPols[indx++] = c+2;
1597 buff.
fPols[indx++] = 4;
1598 buff.
fPols[indx++] = k==0 ? indx2+n-1 : indx2+2*nz*n+2*(k-1)+1;
1599 buff.
fPols[indx++] = indx2+(2*k+3)*n+n-1;
1600 buff.
fPols[indx++] = indx2+2*nz*n+2*k+1;
1601 buff.
fPols[indx++] = indx2+2*(k+1)*n+n-1;
1603 buff.
fPols[indx-8] = indx2+
n;
1604 buff.
fPols[indx-2] = indx2+2*n-1;
1618 if (ipl<0 || ipl>
fNz-2) {
1619 Fatal(
"Rpg",
"Plane index parameter ipl=%i out of range\n", ipl);
1639 a = (r1*fZ[ipl+1]-
r2*fZ[ipl])*dzinv;
1656 a = ((point[0]*dir[2]-point[2]*dir[0])*cphi+(point[1]*dir[2]-point[2]*dir[1])*sphi)*invdirz;
1657 b = (dir[0]*cphi+dir[1]*sphi)*invdirz;
1670 if (ipl<0 || ipl>
fNz-2)
return (safmin+1.);
1673 if (dz<1
E-9)
return 1E9;
1674 Double_t znew = point[2] - 0.5*(fZ[ipl]+fZ[ipl+1]);
1686 r =
TMath::Sqrt(point[0]*point[0]+point[1]*point[1]);
1696 saf[2] = (rout-
r)*cr2;
1697 for (i=0; i<3; i++) saf[i]=-saf[i];
1700 if (safe<0) safe = 0;
1705 if (rmin1+rmin2>1
E-10) {
1706 ta = (rmin2-rmin1)/dz;
1708 rpgon = rmin1 + (point[2]-fZ[ipl])*ta;
1709 saf[1] = (r-rpgon)*calf;
1713 ta = (rmax2-rmax1)/dz;
1715 rpgon = rmax1 + (point[2]-fZ[ipl])*ta;
1716 saf[2] = (rpgon-
r)*calf;
1721 for (i=0; i<3; i++) saf[i]=-saf[i];
1737 Int_t ipl, iplane, iphi;
1743 if (ipl==(
fNz-1))
return 0;
1744 if (ipl<0)
return 0;
1745 dz = 0.5*(
fZ[ipl+1]-
fZ[ipl]);
1746 if (dz<1
E-8)
return 0;
1757 while ((iplane<
fNz-1) && saftmp<1E10) {
1759 if (saftmp<safmin) safmin=saftmp;
1765 while ((iplane>=0) && saftmp<1E10) {
1767 if (saftmp<safmin) safmin=saftmp;
1775 else if (ipl==
fNz-1) ipl=
fNz-2;
1776 dz = 0.5*(
fZ[ipl+1]-
fZ[ipl]);
1779 if (ipl>
fNz-2)
return 0.;
1780 dz = 0.5*(
fZ[ipl+1]-
fZ[ipl]);
1789 while ((iplane<
fNz-1) && saftmp<1E10) {
1791 if (saftmp<safmin) safmin=saftmp;
1797 while ((iplane>=0) && saftmp<1E10) {
1799 if (saftmp<safmin) safmin=saftmp;
1811 out <<
" // Shape: " <<
GetName() <<
" type: " <<
ClassName() << std::endl;
1812 out <<
" phi1 = " <<
fPhi1 <<
";" << std::endl;
1813 out <<
" dphi = " <<
fDphi <<
";" << std::endl;
1814 out <<
" nedges = " <<
fNedges <<
";" << std::endl;
1815 out <<
" nz = " <<
fNz <<
";" << std::endl;
1816 out <<
" TGeoPgon *pgon = new TGeoPgon(\"" <<
GetName() <<
"\",phi1,dphi,nedges,nz);" << std::endl;
1818 out <<
" z = " <<
fZ[i] <<
";" << std::endl;
1819 out <<
" rmin = " <<
fRmin[i] <<
";" << std::endl;
1820 out <<
" rmax = " <<
fRmax[i] <<
";" << std::endl;
1821 out <<
" pgon->DefineSection(" << i <<
", z,rmin,rmax);" << std::endl;
1823 out <<
" TGeoShape *" <<
GetPointerName() <<
" = pgon;" << std::endl;
1837 Error(
"SetDimensions",
"Pgon %s: Number of Z sections must be > 2",
GetName());
1842 if (
fZ)
delete []
fZ;
1866 for (i = 0; i <
fNz; i++) {
1867 for (j = 0; j <
n; j++) {
1871 points[indx++] =
fZ[i];
1873 for (j = 0; j <
n; j++) {
1877 points[indx++] =
fZ[i];
1896 for (i = 0; i <
fNz; i++) {
1897 for (j = 0; j <
n; j++) {
1901 points[indx++] =
fZ[i];
1903 for (j = 0; j <
n; j++) {
1907 points[indx++] =
fZ[i];
1922 nsegs = 4*(nz*n-1+(specialCase ==
kTRUE));
1923 npols = 2*(nz*n-1+(specialCase ==
kTRUE));
1956 if (nz >= 2 && nbPnts > 0) {
1958 Int_t nbSegs = 4*(nz*n-1+(specialCase ==
kTRUE));
1959 Int_t nbPols = 2*(nz*n-1+(specialCase ==
kTRUE));
1960 if (buffer.
SetRawSizes(nbPnts, 3*nbPnts, nbSegs, 3*nbSegs, nbPols, 6*nbPols)) {
1987 for (
Int_t i=0; i<vecsize; i++) inside[i] =
Contains(&points[3*i]);
1997 for (
Int_t i=0; i<vecsize; i++)
ComputeNormal(&points[3*i], &dirs[3*i], &norms[3*i]);
2005 for (
Int_t i=0; i<vecsize; i++) dists[i] =
DistFromInside(&points[3*i], &dirs[3*i], 3, step[i]);
2013 for (
Int_t i=0; i<vecsize; i++) dists[i] =
DistFromOutside(&points[3*i], &dirs[3*i], 3, step[i]);
2023 for (
Int_t i=0; i<vecsize; i++) safe[i] =
Safety(&points[3*i], inside[i]);
TGeoVolumeMulti * MakeVolumeMulti(const char *name, TGeoMedium *medium)
Make a TGeoVolumeMulti handling a list of volumes.
Bool_t SliceCrossing(const Double_t *point, const Double_t *dir, Int_t nphi, Int_t *iphi, Double_t *sphi, Double_t &snext, Double_t stepmax) const
Check boundary crossing inside phi slices.
virtual void SetPoints(Double_t *points) const
create polygone mesh points
virtual void GetMeshNumbers(Int_t &nvert, Int_t &nsegs, Int_t &npols) const
Returns numbers of vertices, segments and polygons composing the shape mesh.
double dist(Rotation3D const &r1, Rotation3D const &r2)
#define snext(osub1, osub2)
Long64_t LocMax(Long64_t n, const T *a)
void SetFinder(TGeoPatternFinder *finder)
virtual void ComputeNormal_v(const Double_t *points, const Double_t *dirs, Double_t *norms, Int_t vecsize)
Compute the normal for an array o points so that norm.dot.dir is positive Input: Arrays of point coor...
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
virtual void Sizeof3D() const
fill size of this 3-D object
void AddNodeOffset(TGeoVolume *vol, Int_t copy_no, Double_t offset=0, Option_t *option="")
Add a division node to the list of nodes.
void ClearThreadData() const
virtual Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=TGeoShape::Big(), Double_t *safe=0) const
compute distance from inside point to surface of the polygone first find out in which Z section the p...
virtual ~TGeoPgon()
destructor
virtual void GetBoundingCylinder(Double_t *param) const
Fill vector param[4] with the bounding cylinder parameters.
Bool_t TestBit(UInt_t f) const
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Double_t * fDblBuffer
[fNedges+4] temporary int buffer array
virtual void InspectShape() const
Inspect the PGON parameters.
Short_t Min(Short_t a, Short_t b)
virtual void Contains_v(const Double_t *points, Bool_t *inside, Int_t vecsize) const
Check the inside status for each of the points in the array.
virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const
computes the closest distance from given point to this shape, according to option.
static Double_t SafetyPhi(const Double_t *point, Bool_t in, Double_t phi1, Double_t phi2)
Static method to compute safety w.r.t a phi corner defined by cosines/sines of the angles phi1...
virtual Int_t GetNsegments() const
Returns number of segments on each mesh circle segment.
void LocatePhi(const Double_t *point, Int_t &ipsec) const
Locates index IPSEC of the phi sector containing POINT.
TObject * At(Int_t idx) const
Int_t fThreadSize
Navigation data per thread.
Double_t SafetyToSegment(const Double_t *point, Int_t ipl, Int_t iphi, Bool_t in, Double_t safphi, Double_t safmin=TGeoShape::Big()) const
Compute safety from POINT to segment between planes ipl, ipl+1 within safmin.
Bool_t SliceCrossingInZ(const Double_t *point, const Double_t *dir, Int_t nphi, Int_t *iphi, Double_t *sphi, Double_t &snext, Double_t stepmax) const
Performs ray propagation between Z segments.
~ThreadData_t()
Destructor.
virtual Bool_t Contains(const Double_t *point) const
test if point is inside this shape check total z range
static Bool_t IsSameWithinTolerance(Double_t a, Double_t b)
Check if two numbers differ with less than a tolerance.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual void DistFromOutside_v(const Double_t *points, const Double_t *dirs, Double_t *dists, Int_t vecsize, Double_t *step) const
Compute distance from array of input points having directions specified by dirs. Store output in dist...
static Double_t Tolerance()
Int_t GetNdaughters() const
std::vector< ThreadData_t * > fThreadData
virtual const char * ClassName() const
Returns name of class to which the object belongs.
virtual void DistFromInside_v(const Double_t *points, const Double_t *dirs, Double_t *dists, Int_t vecsize, Double_t *step) const
Compute distance from array of input points having directions specified by dirs. Store output in dist...
void AddVolume(TGeoVolume *vol)
Add a volume with valid shape to the list of volumes.
virtual TGeoVolume * Divide(TGeoVolume *voldiv, const char *divname, Int_t iaxis, Int_t ndiv, Double_t start, Double_t step)
Divide this polygone shape belonging to volume "voldiv" into ndiv volumes called divname, from start position with the given step.
static Bool_t IsCrossingSemiplane(const Double_t *point, const Double_t *dir, Double_t cphi, Double_t sphi, Double_t &snext, Double_t &rxy)
Compute distance from POINT to semiplane defined by PHI angle along DIR.
virtual const TBuffer3D & GetBuffer3D(Int_t reqSections, Bool_t localFrame) const
Fills a static 3D buffer and returns a reference.
TGeoMedium * GetMedium() const
Int_t GetPhiCrossList(const Double_t *point, const Double_t *dir, Int_t istart, Double_t *sphi, Int_t *iphi, Double_t stepmax=TGeoShape::Big()) const
Size for the navigation data array.
virtual void ComputeBBox()
compute bounding box for a polygone Check if the sections are in increasing Z order ...
Double_t ATan2(Double_t, Double_t)
Bool_t SliceCrossingIn(const Double_t *point, const Double_t *dir, Int_t ipl, Int_t nphi, Int_t *iphi, Double_t *sphi, Double_t &snext, Double_t stepmax) const
Check boundary crossing inside phi slices.
virtual void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm)
Compute normal to closest surface from POINT.
void SetSectionsValid(UInt_t mask)
const char * GetPointerName() const
Provide a pointer name containing uid.
virtual void InspectShape() const
print shape parameters
Base finder class for patterns.
virtual const char * GetName() const
Get the shape name.
virtual Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=TGeoShape::Big(), Double_t *safe=0) const
Compute distance from outside point to surface of the polygone.
Int_t ShapeDistancetoPrimitive(Int_t numpoints, Int_t px, Int_t py) const
Returns distance to shape primitive mesh.
Bool_t SectionsValid(UInt_t mask) const
Base abstract class for all shapes.
unsigned int r1[N_CITIES]
TObjArray * GetListOfShapes() const
Bool_t IsCrossingSlice(const Double_t *point, const Double_t *dir, Int_t iphi, Double_t sstart, Int_t &ipl, Double_t &snext, Double_t stepmax) const
Check crossing of a given pgon slice, from a starting point inside the slice.
void TransformPoints(Double_t *points, UInt_t NbPoints) const
Tranform a set of points (LocalToMaster)
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Bool_t SetRawSizes(UInt_t reqPnts, UInt_t reqPntsCapacity, UInt_t reqSegs, UInt_t reqSegsCapacity, UInt_t reqPols, UInt_t reqPolsCapacity)
Set kRaw tessellation section of buffer with supplied sizes.
Generic 3D primitive description class.
static Int_t Lock()
Static method to lock the main thread mutex.
void CreateThreadData(Int_t nthreads)
Create thread data for n threads max.
void SetDivIndex(Int_t index)
ThreadData_t()
[fNedges+4] temporary double buffer array
static Int_t UnLock()
Static method to unlock the main thread mutex.
virtual void Safety_v(const Double_t *points, const Bool_t *inside, Double_t *safe, Int_t vecsize) const
Compute safe distance from each of the points in the input array.
static Bool_t IsCloseToPhi(Double_t epsil, const Double_t *point, Double_t c1, Double_t s1, Double_t c2, Double_t s2)
True if point is closer than epsil to one of the phi planes defined by c1,s1 or c2,s2.
Bool_t SliceCrossingZ(const Double_t *point, const Double_t *dir, Int_t nphi, Int_t *iphi, Double_t *sphi, Double_t &snext, Double_t stepmax) const
Performs ray propagation between Z segments.
R__EXTERN TGeoManager * gGeoManager
virtual Double_t Capacity() const
Computes capacity of the shape in [length^3].
virtual Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=TGeoShape::Big(), Double_t *safe=0) const
Compute distance from outside point to surface of the box.
ThreadData_t & GetThreadData() const
Int_t IndexOf(const TObject *obj) const
Node containing an offset.
void SetShapeBit(UInt_t f, Bool_t set)
Equivalent of TObject::SetBit.
you should not use this method at all Int_t Int_t z
virtual void FillBuffer3D(TBuffer3D &buffer, Int_t reqSections, Bool_t localFrame) const
Fills the supplied buffer, with sections in desired frame See TBuffer3D.h for explanation of sections...
virtual void SetDimensions(Double_t *param)
Set PGON dimensions starting from an array.
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
compute closest distance from point px,py to each corner
static Int_t ThreadId()
Translates the current thread id to an ordinal number.
virtual void SetSegsAndPols(TBuffer3D &buff) const
Fill TBuffer3D structure for segments and polygons.
Short_t Max(Short_t a, Short_t b)
static Double_t DistFromOutsideS(const Double_t *point, const Double_t *dir, Double_t rmin, Double_t rmax, Double_t dz)
Static method to compute distance from outside point to a tube with given parameters Boundary safe al...
virtual Int_t GetNmeshVertices() const
Return number of vertices of the mesh representation.
virtual TBuffer3D * MakeBuffer3D() const
Creates a TBuffer3D describing this shape.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
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.
static void NormalPhi(const Double_t *point, const Double_t *dir, Double_t *norm, Double_t c1, Double_t s1, Double_t c2, Double_t s2)
Static method to compute normal to phi planes.
Double_t Rproj(Double_t z, const Double_t *point, const Double_t *dir, Double_t cphi, Double_t sphi, Double_t &a, Double_t &b) const
Computes projected distance at a given Z for a given ray inside a given sector and fills coefficients...
Double_t Sqrt(Double_t x)
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
Long64_t LocMin(Long64_t n, const T *a)
double norm(double *x, double *p)
Int_t GetBasicColor() const
Get the basic color (0-7).
Long64_t BinarySearch(Long64_t n, const T *array, T value)
unsigned int r2[N_CITIES]
Double_t Rpg(Double_t z, Int_t ipl, Bool_t inner, Double_t &a, Double_t &b) const
Computes projected pgon radius (inner or outer) corresponding to a given Z value. ...
const char * Data() const