87 SetShapeBit(TGeoShape::kGeoCone);
98 TGeoCone::TGeoCone(Double_t dz, Double_t rmin1, Double_t rmax1,
99 Double_t rmin2, Double_t rmax2)
102 SetShapeBit(TGeoShape::kGeoCone);
103 SetConeDimensions(dz, rmin1, rmax1, rmin2, rmax2);
104 if ((dz<0) || (rmin1<0) || (rmax1<0) || (rmin2<0) || (rmax2<0)) {
105 SetShapeBit(kGeoRunTimeShape);
113 TGeoCone::TGeoCone(
const char *name, Double_t dz, Double_t rmin1, Double_t rmax1,
114 Double_t rmin2, Double_t rmax2)
115 :TGeoBBox(name, 0, 0, 0)
117 SetShapeBit(TGeoShape::kGeoCone);
118 SetConeDimensions(dz, rmin1, rmax1, rmin2, rmax2);
119 if ((dz<0) || (rmin1<0) || (rmax1<0) || (rmin2<0) || (rmax2<0)) {
120 SetShapeBit(kGeoRunTimeShape);
133 TGeoCone::TGeoCone(Double_t *param)
136 SetShapeBit(TGeoShape::kGeoCone);
137 SetDimensions(param);
138 if ((fDz<0) || (fRmin1<0) || (fRmax1<0) || (fRmin2<0) || (fRmax2<0))
139 SetShapeBit(kGeoRunTimeShape);
146 Double_t TGeoCone::Capacity()
const
148 return TGeoCone::Capacity(fDz, fRmin1, fRmax1, fRmin2, fRmax2);
154 Double_t TGeoCone::Capacity(Double_t dz, Double_t rmin1, Double_t rmax1, Double_t rmin2, Double_t rmax2)
156 Double_t capacity = (2.*dz*TMath::Pi()/3.)*(rmax1*rmax1+rmax2*rmax2+rmax1*rmax2-
157 rmin1*rmin1-rmin2*rmin2-rmin1*rmin2);
164 TGeoCone::~TGeoCone()
171 void TGeoCone::ComputeBBox()
173 TGeoBBox *box = (TGeoBBox*)
this;
174 box->SetBoxDimensions(TMath::Max(fRmax1, fRmax2), TMath::Max(fRmax1, fRmax2), fDz);
175 memset(fOrigin, 0, 3*
sizeof(Double_t));
181 void TGeoCone::ComputeNormal(
const Double_t *point,
const Double_t *dir, Double_t *norm)
183 Double_t safr,safe,phi;
184 memset(norm,0,3*
sizeof(Double_t));
185 phi = TMath::ATan2(point[1],point[0]);
186 Double_t cphi = TMath::Cos(phi);
187 Double_t sphi = TMath::Sin(phi);
188 Double_t ro1 = 0.5*(fRmin1+fRmin2);
189 Double_t tg1 = 0.5*(fRmin2-fRmin1)/fDz;
190 Double_t cr1 = 1./TMath::Sqrt(1.+tg1*tg1);
191 Double_t ro2 = 0.5*(fRmax1+fRmax2);
192 Double_t tg2 = 0.5*(fRmax2-fRmax1)/fDz;
193 Double_t cr2 = 1./TMath::Sqrt(1.+tg2*tg2);
195 Double_t r=TMath::Sqrt(point[0]*point[0]+point[1]*point[1]);
196 Double_t rin = tg1*point[2]+ro1;
197 Double_t rout = tg2*point[2]+ro2;
198 safe = TMath::Abs(fDz-TMath::Abs(point[2]));
201 safr = (ro1>0)?(TMath::Abs((r-rin)*cr1)):TGeoShape::Big();
208 safr = TMath::Abs((rout-r)*cr2);
214 if (norm[0]*dir[0]+norm[1]*dir[1]+norm[2]*dir[2]<0) {
224 void TGeoCone::ComputeNormalS(
const Double_t *point,
const Double_t *dir, Double_t *norm,
225 Double_t dz, Double_t rmin1, Double_t rmax1, Double_t rmin2, Double_t rmax2)
228 memset(norm,0,3*
sizeof(Double_t));
229 phi = TMath::ATan2(point[1],point[0]);
230 Double_t cphi = TMath::Cos(phi);
231 Double_t sphi = TMath::Sin(phi);
232 Double_t ro1 = 0.5*(rmin1+rmin2);
233 Double_t tg1 = 0.5*(rmin2-rmin1)/dz;
234 Double_t cr1 = 1./TMath::Sqrt(1.+tg1*tg1);
235 Double_t ro2 = 0.5*(rmax1+rmax2);
236 Double_t tg2 = 0.5*(rmax2-rmax1)/dz;
237 Double_t cr2 = 1./TMath::Sqrt(1.+tg2*tg2);
239 Double_t r=TMath::Sqrt(point[0]*point[0]+point[1]*point[1]);
240 Double_t rin = tg1*point[2]+ro1;
241 Double_t rout = tg2*point[2]+ro2;
242 safe = (ro1>0)?(TMath::Abs((r-rin)*cr1)):TGeoShape::Big();
246 if (TMath::Abs((rout-r)*cr2)<safe) {
251 if (norm[0]*dir[0]+norm[1]*dir[1]+norm[2]*dir[2]<0) {
261 Bool_t TGeoCone::Contains(
const Double_t *point)
const
263 if (TMath::Abs(point[2]) > fDz)
return kFALSE;
264 Double_t r2 = point[0]*point[0]+point[1]*point[1];
265 Double_t rl = 0.5*(fRmin2*(point[2]+fDz)+fRmin1*(fDz-point[2]))/fDz;
266 Double_t rh = 0.5*(fRmax2*(point[2]+fDz)+fRmax1*(fDz-point[2]))/fDz;
267 if ((r2<rl*rl) || (r2>rh*rh))
return kFALSE;
275 Double_t TGeoCone::DistFromInsideS(
const Double_t *point,
const Double_t *dir, Double_t dz,
276 Double_t rmin1, Double_t rmax1, Double_t rmin2, Double_t rmax2)
278 if (dz<=0)
return TGeoShape::Big();
281 Double_t sz = TGeoShape::Big();
283 sz = (TMath::Sign(dz, dir[2])-point[2])/dir[2];
284 if (sz<=0)
return 0.0;
286 Double_t rsq=point[0]*point[0]+point[1]*point[1];
287 Double_t zinv = 1./dz;
288 Double_t rin = 0.5*(rmin1+rmin2+(rmin2-rmin1)*point[2]*zinv);
290 Double_t sr = TGeoShape::Big();
294 if (rsq < rin*(rin+TGeoShape::Tolerance())) {
295 Double_t ddotn = point[0]*dir[0]+point[1]*dir[1]+0.5*(rmin1-rmin2)*dir[2]*zinv*TMath::Sqrt(rsq);
296 if (ddotn<=0)
return 0.0;
298 TGeoCone::DistToCone(point, dir, dz, rmin1, rmin2, b, delta);
302 zi = point[2]+sr*dir[2];
303 if (TMath::Abs(zi)<=dz)
return TMath::Min(sz,sr);
307 zi = point[2]+sr*dir[2];
308 if (TMath::Abs(zi)<=dz)
return TMath::Min(sz,sr);
314 Double_t rout = 0.5*(rmax1+rmax2+(rmax2-rmax1)*point[2]*zinv);
315 if (rsq > rout*(rout-TGeoShape::Tolerance())) {
316 Double_t ddotn = point[0]*dir[0]+point[1]*dir[1]+0.5*(rmax1-rmax2)*dir[2]*zinv*TMath::Sqrt(rsq);
317 if (ddotn>=0)
return 0.0;
318 TGeoCone::DistToCone(point, dir, dz, rmax1, rmax2, b, delta);
319 if (delta<0)
return 0.0;
322 if (TMath::Abs(-b-delta)>sr)
return sz;
323 zi = point[2]+sr*dir[2];
324 if (TMath::Abs(zi)<=dz)
return TMath::Min(sz,sr);
327 TGeoCone::DistToCone(point, dir, dz, rmax1, rmax2, b, delta);
331 zi = point[2]+sr*dir[2];
332 if (TMath::Abs(zi)<=dz)
return TMath::Min(sz,sr);
335 if (sr>TGeoShape::Tolerance()) {
336 zi = point[2]+sr*dir[2];
337 if (TMath::Abs(zi)<=dz)
return TMath::Min(sz,sr);
347 Double_t TGeoCone::DistFromInside(
const Double_t *point,
const Double_t *dir, Int_t iact, Double_t step, Double_t *safe)
const
349 if (iact<3 && safe) {
350 *safe = Safety(point, kTRUE);
351 if (iact==0)
return TGeoShape::Big();
352 if ((iact==1) && (*safe>step))
return TGeoShape::Big();
355 return TGeoCone::DistFromInsideS(point, dir, fDz, fRmin1, fRmax1, fRmin2, fRmax2);
362 Double_t TGeoCone::DistFromOutsideS(
const Double_t *point,
const Double_t *dir, Double_t dz,
363 Double_t rmin1, Double_t rmax1, Double_t rmin2, Double_t rmax2)
366 if (dz<=0)
return TGeoShape::Big();
372 if (dir[2]<=0)
return TGeoShape::Big();
373 snxt = (-dz-point[2])/dir[2];
374 xp = point[0]+snxt*dir[0];
375 yp = point[1]+snxt*dir[1];
376 Double_t r2 = xp*xp+yp*yp;
377 if ((r2>=rmin1*rmin1) && (r2<=rmax1*rmax1))
return snxt;
381 if (dir[2]>=0)
return TGeoShape::Big();
382 snxt = (dz-point[2])/dir[2];
383 xp = point[0]+snxt*dir[0];
384 yp = point[1]+snxt*dir[1];
385 Double_t r2 = xp*xp+yp*yp;
386 if ((r2>=rmin2*rmin2) && (r2<=rmax2*rmax2))
return snxt;
391 Double_t rsq = point[0]*point[0]+point[1]*point[1];
392 Double_t dzinv = 1./dz;
393 Double_t ro1=0.5*(rmin1+rmin2);
394 Bool_t hasrmin = (ro1>0)?kTRUE:kFALSE;
397 Bool_t inrmin = kTRUE;
399 tg1=0.5*(rmin2-rmin1)*dzinv;
400 rin=ro1+tg1*point[2];
401 if (rin>0 && rsq<rin*(rin-TGeoShape::Tolerance())) inrmin=kFALSE;
403 Double_t ro2=0.5*(rmax1+rmax2);
404 Double_t tg2=0.5*(rmax2-rmax1)*dzinv;
405 Double_t rout=tg2*point[2]+ro2;
406 Bool_t inrmax = kFALSE;
407 if (rout>0 && rsq<rout*(rout+TGeoShape::Tolerance())) inrmax=kTRUE;
408 Bool_t in = inz & inrmin & inrmax;
412 Double_t r=TMath::Sqrt(rsq);
413 Double_t safz = dz-TMath::Abs(point[2]);
414 Double_t safrmin = (hasrmin)?(r-rin):TGeoShape::Big();
415 Double_t safrmax = rout - r;
416 if (safz<=safrmin && safz<=safrmax) {
418 if (point[2]*dir[2]<0)
return 0.0;
419 return TGeoShape::Big();
421 if (safrmax<safrmin) {
423 Double_t ddotn = point[0]*dir[0]+point[1]*dir[1]-tg2*dir[2]*r;
424 if (ddotn<=0)
return 0.0;
425 return TGeoShape::Big();
428 Double_t ddotn = point[0]*dir[0]+point[1]*dir[1]-tg1*dir[2]*r;
429 if (ddotn>=0)
return 0.0;
431 TGeoCone::DistToCone(point, dir, dz, rmin1, rmin2, b, delta);
433 if (delta<0)
return 0.0;
435 if (snxt<0)
return TGeoShape::Big();
436 if (TMath::Abs(-b-delta)>snxt)
return TGeoShape::Big();
437 zp = point[2]+snxt*dir[2];
438 if (TMath::Abs(zp)<=dz)
return snxt;
439 return TGeoShape::Big();
443 snxt = TGeoShape::Big();
446 TGeoCone::DistToCone(point, dir, dz, rmin1, rmin2, b, delta);
447 if (delta<0)
return TGeoShape::Big();
450 zp = point[2]+snxt*dir[2];
451 if (TMath::Abs(zp)<=dz)
return snxt;
455 zp = point[2]+snxt*dir[2];
456 if (TMath::Abs(zp)<=dz)
return snxt;
458 snxt = TGeoShape::Big();
461 TGeoCone::DistToCone(point, dir, dz, rmin1, rmin2, b, delta);
463 Double_t din = -b+delta;
465 zp = point[2]+din*dir[2];
466 if (TMath::Abs(zp)<=dz) snxt = din;
472 if (inrmax)
return snxt;
475 TGeoCone::DistToCone(point, dir, dz, rmax1, rmax2, b, delta);
476 if (delta<0)
return snxt;
477 Double_t dout = -b-delta;
478 if (dout>0 && dout<snxt) {
479 zp = point[2]+dout*dir[2];
480 if (TMath::Abs(zp)<=dz)
return dout;
483 if (dout<=0 || dout>snxt)
return snxt;
484 zp = point[2]+dout*dir[2];
485 if (TMath::Abs(zp)<=dz)
return dout;
492 Double_t TGeoCone::DistFromOutside(
const Double_t *point,
const Double_t *dir, Int_t iact, Double_t step, Double_t *safe)
const
495 if (iact<3 && safe) {
496 *safe = Safety(point, kFALSE);
497 if (iact==0)
return TGeoShape::Big();
498 if ((iact==1) && (*safe>step))
return TGeoShape::Big();
501 Double_t sdist = TGeoBBox::DistFromOutside(point,dir, fDX, fDY, fDZ, fOrigin, step);
502 if (sdist>=step)
return TGeoShape::Big();
504 return TGeoCone::DistFromOutsideS(point, dir, fDz, fRmin1, fRmax1, fRmin2, fRmax2);
512 void TGeoCone::DistToCone(
const Double_t *point,
const Double_t *dir, Double_t dz, Double_t r1, Double_t r2,
513 Double_t &b, Double_t &delta)
517 Double_t ro0 = 0.5*(r1+r2);
518 Double_t tz = 0.5*(r2-r1)/dz;
519 Double_t rsq = point[0]*point[0] + point[1]*point[1];
520 Double_t rc = ro0 + point[2]*tz;
522 Double_t a = dir[0]*dir[0] + dir[1]*dir[1] - tz*tz*dir[2]*dir[2];
523 b = point[0]*dir[0] + point[1]*dir[1] - tz*rc*dir[2];
524 Double_t c = rsq - rc*rc;
526 if (TMath::Abs(a)<TGeoShape::Tolerance()) {
527 if (TMath::Abs(b)<TGeoShape::Tolerance())
return;
537 delta = TMath::Sqrt(delta);
546 Int_t TGeoCone::DistancetoPrimitive(Int_t px, Int_t py)
548 Int_t n = gGeoManager->GetNsegments();
549 const Int_t numPoints = 4*n;
550 return ShapeDistancetoPrimitive(numPoints, px, py);
561 TGeoVolume *TGeoCone::Divide(TGeoVolume *voldiv,
const char *divname, Int_t iaxis, Int_t ndiv,
562 Double_t start, Double_t step)
566 TGeoVolumeMulti *vmulti;
567 TGeoPatternFinder *finder;
570 Double_t end = start+ndiv*step;
573 Error(
"Divide",
"division of a cone on R not implemented");
576 finder =
new TGeoPatternCylPhi(voldiv, ndiv, start, end);
577 voldiv->SetFinder(finder);
578 finder->SetDivIndex(voldiv->GetNdaughters());
579 shape =
new TGeoConeSeg(fDz, fRmin1, fRmax1, fRmin2, fRmax2, -step/2, step/2);
580 vol =
new TGeoVolume(divname, shape, voldiv->GetMedium());
581 vmulti = gGeoManager->MakeVolumeMulti(divname, voldiv->GetMedium());
582 vmulti->AddVolume(vol);
584 for (
id=0;
id<ndiv;
id++) {
585 voldiv->AddNodeOffset(vol,
id, start+
id*step+step/2, opt.Data());
586 ((TGeoNodeOffset*)voldiv->GetNodes()->At(voldiv->GetNdaughters()-1))->SetFinder(finder);
590 vmulti = gGeoManager->MakeVolumeMulti(divname, voldiv->GetMedium());
591 finder =
new TGeoPatternZ(voldiv, ndiv, start, end);
592 voldiv->SetFinder(finder);
593 finder->SetDivIndex(voldiv->GetNdaughters());
594 for (
id=0;
id<ndiv;
id++) {
595 Double_t z1 = start+
id*step;
596 Double_t z2 = start+(
id+1)*step;
597 Double_t rmin1n = 0.5*(fRmin1*(fDz-z1)+fRmin2*(fDz+z1))/fDz;
598 Double_t rmax1n = 0.5*(fRmax1*(fDz-z1)+fRmax2*(fDz+z1))/fDz;
599 Double_t rmin2n = 0.5*(fRmin1*(fDz-z2)+fRmin2*(fDz+z2))/fDz;
600 Double_t rmax2n = 0.5*(fRmax1*(fDz-z2)+fRmax2*(fDz+z2))/fDz;
601 shape =
new TGeoCone(0.5*step,rmin1n, rmax1n, rmin2n, rmax2n);
602 vol =
new TGeoVolume(divname, shape, voldiv->GetMedium());
603 vmulti->AddVolume(vol);
605 voldiv->AddNodeOffset(vol,
id, start+
id*step+step/2, opt.Data());
606 ((TGeoNodeOffset*)voldiv->GetNodes()->At(voldiv->GetNdaughters()-1))->SetFinder(finder);
610 Error(
"Divide",
"Wrong axis type for division");
618 const char *TGeoCone::GetAxisName(Int_t iaxis)
const
635 Double_t TGeoCone::GetAxisRange(Int_t iaxis, Double_t &xlo, Double_t &xhi)
const
658 void TGeoCone::GetBoundingCylinder(Double_t *param)
const
660 param[0] = TMath::Min(fRmin1, fRmin2);
661 param[0] *= param[0];
662 param[1] = TMath::Max(fRmax1, fRmax2);
663 param[1] *= param[1];
672 TGeoShape *TGeoCone::GetMakeRuntimeShape(TGeoShape *mother, TGeoMatrix * )
const
674 if (!TestShapeBit(kGeoRunTimeShape))
return 0;
675 if (!mother->TestShapeBit(kGeoCone)) {
676 Error(
"GetMakeRuntimeShape",
"invalid mother");
679 Double_t rmin1, rmax1, rmin2, rmax2, dz;
685 if (fDz<0) dz=((TGeoCone*)mother)->GetDz();
687 rmin1 = ((TGeoCone*)mother)->GetRmin1();
689 rmax1 = ((TGeoCone*)mother)->GetRmax1();
691 rmin2 = ((TGeoCone*)mother)->GetRmin2();
693 rmax2 = ((TGeoCone*)mother)->GetRmax2();
695 return (
new TGeoCone(GetName(), dz, rmin1, rmax1, rmin2, rmax2));
703 Bool_t TGeoCone::GetPointsOnSegments(Int_t npoints, Double_t *array)
const
705 if (npoints > (npoints/2)*2) {
706 Error(
"GetPointsOnSegments",
"Npoints must be even number");
709 Bool_t hasrmin = (fRmin1>0 || fRmin2>0)?kTRUE:kFALSE;
711 if (hasrmin) nc = (Int_t)TMath::Sqrt(0.5*npoints);
712 else nc = (Int_t)TMath::Sqrt(1.*npoints);
713 Double_t dphi = TMath::TwoPi()/nc;
716 if (hasrmin) ntop = npoints/2 - nc*(nc-1);
717 else ntop = npoints - nc*(nc-1);
718 Double_t dz = 2*fDz/(nc-1);
725 for (Int_t i=0; i<nc; i++) {
726 if (i == (nc-1)) nphi = ntop;
728 if (hasrmin) rmin = 0.5*(fRmin1+fRmin2) + 0.5*(fRmin2-fRmin1)*z/fDz;
729 rmax = 0.5*(fRmax1+fRmax2) + 0.5*(fRmax2-fRmax1)*z/fDz;
731 for (Int_t j=0; j<nphi; j++) {
734 array[icrt++] = rmin * TMath::Cos(phi);
735 array[icrt++] = rmin * TMath::Sin(phi);
738 array[icrt++] = rmax * TMath::Cos(phi);
739 array[icrt++] = rmax * TMath::Sin(phi);
750 void TGeoCone::InspectShape()
const
752 printf(
"*** Shape %s TGeoCone ***\n", GetName());
753 printf(
" dz =: %11.5f\n", fDz);
754 printf(
" Rmin1 = %11.5f\n", fRmin1);
755 printf(
" Rmax1 = %11.5f\n", fRmax1);
756 printf(
" Rmin2 = %11.5f\n", fRmin2);
757 printf(
" Rmax2 = %11.5f\n", fRmax2);
758 printf(
" Bounding box:\n");
759 TGeoBBox::InspectShape();
766 TBuffer3D *TGeoCone::MakeBuffer3D()
const
768 Int_t n = gGeoManager->GetNsegments();
772 TBuffer3D* buff =
new TBuffer3D(TBuffer3DTypes::kGeneric,
779 SetPoints(buff->fPnts);
780 SetSegsAndPols(*buff);
788 void TGeoCone::SetSegsAndPols(TBuffer3D &buffer)
const
791 Int_t n = gGeoManager->GetNsegments();
792 Int_t c = GetBasicColor();
794 for (i = 0; i < 4; i++) {
795 for (j = 0; j < n; j++) {
796 buffer.fSegs[(i*n+j)*3 ] = c;
797 buffer.fSegs[(i*n+j)*3+1] = i*n+j;
798 buffer.fSegs[(i*n+j)*3+2] = i*n+j+1;
800 buffer.fSegs[(i*n+j-1)*3+2] = i*n;
802 for (i = 4; i < 6; i++) {
803 for (j = 0; j < n; j++) {
804 buffer.fSegs[(i*n+j)*3 ] = c+1;
805 buffer.fSegs[(i*n+j)*3+1] = (i-4)*n+j;
806 buffer.fSegs[(i*n+j)*3+2] = (i-2)*n+j;
809 for (i = 6; i < 8; i++) {
810 for (j = 0; j < n; j++) {
811 buffer.fSegs[(i*n+j)*3 ] = c;
812 buffer.fSegs[(i*n+j)*3+1] = 2*(i-6)*n+j;
813 buffer.fSegs[(i*n+j)*3+2] = (2*(i-6)+1)*n+j;
819 for (j = 0; j < n; j++) {
821 buffer.fPols[indx ] = c;
822 buffer.fPols[indx+1] = 4;
823 buffer.fPols[indx+5] = i*n+j;
824 buffer.fPols[indx+4] = (4+i)*n+j;
825 buffer.fPols[indx+3] = (2+i)*n+j;
826 buffer.fPols[indx+2] = (4+i)*n+j+1;
828 buffer.fPols[indx+2] = (4+i)*n;
830 for (j = 0; j < n; j++) {
832 buffer.fPols[indx ] = c;
833 buffer.fPols[indx+1] = 4;
834 buffer.fPols[indx+2] = i*n+j;
835 buffer.fPols[indx+3] = (4+i)*n+j;
836 buffer.fPols[indx+4] = (2+i)*n+j;
837 buffer.fPols[indx+5] = (4+i)*n+j+1;
839 buffer.fPols[indx+5] = (4+i)*n;
841 for (j = 0; j < n; j++) {
843 buffer.fPols[indx ] = c+i;
844 buffer.fPols[indx+1] = 4;
845 buffer.fPols[indx+2] = (i-2)*2*n+j;
846 buffer.fPols[indx+3] = (4+i)*n+j;
847 buffer.fPols[indx+4] = ((i-2)*2+1)*n+j;
848 buffer.fPols[indx+5] = (4+i)*n+j+1;
850 buffer.fPols[indx+5] = (4+i)*n;
852 for (j = 0; j < n; j++) {
854 buffer.fPols[indx ] = c+i;
855 buffer.fPols[indx+1] = 4;
856 buffer.fPols[indx+5] = (i-2)*2*n+j;
857 buffer.fPols[indx+4] = (4+i)*n+j;
858 buffer.fPols[indx+3] = ((i-2)*2+1)*n+j;
859 buffer.fPols[indx+2] = (4+i)*n+j+1;
861 buffer.fPols[indx+2] = (4+i)*n;
868 Double_t TGeoCone::Safety(
const Double_t *point, Bool_t in)
const
871 Double_t r=TMath::Sqrt(point[0]*point[0]+point[1]*point[1]);
872 saf[0] = TGeoShape::SafetySeg(r,point[2], fRmin1, -fDz, fRmax1, -fDz, !in);
873 saf[1] = TGeoShape::SafetySeg(r,point[2], fRmax2, fDz, fRmin2, fDz, !in);
874 saf[2] = TGeoShape::SafetySeg(r,point[2], fRmin2, fDz, fRmin1, -fDz, !in);
875 saf[3] = TGeoShape::SafetySeg(r,point[2], fRmax1, -fDz, fRmax2, fDz, !in);
876 Double_t safety = saf[TMath::LocMin(4,saf)];
877 if (safety>1.E20) safety = 0.;
885 Double_t TGeoCone::SafetyS(
const Double_t *point, Bool_t in, Double_t dz, Double_t rmin1, Double_t rmax1,
886 Double_t rmin2, Double_t rmax2, Int_t skipz)
889 Double_t r=TMath::Sqrt(point[0]*point[0]+point[1]*point[1]);
894 saf[0] = TGeoShape::Big();
895 saf[1] = TGeoShape::SafetySeg(r,point[2], rmax2, dz, rmin2, dz, !in);
898 saf[0] = TGeoShape::SafetySeg(r,point[2], rmin1, -dz, rmax1, -dz, !in);
899 saf[1] = TGeoShape::Big();
902 saf[0] = saf[1] = TGeoShape::Big();
905 saf[0] = TGeoShape::SafetySeg(r,point[2], rmin1, -dz, rmax1, -dz, !in);
906 saf[1] = TGeoShape::SafetySeg(r,point[2], rmax2, dz, rmin2, dz, !in);
909 if (rmin1>0 || rmin2>0)
910 saf[2] = TGeoShape::SafetySeg(r,point[2], rmin2, dz, rmin1, -dz, !in);
912 saf[2] = TGeoShape::Big();
913 saf[3] = TGeoShape::SafetySeg(r,point[2], rmax1, -dz, rmax2, dz, !in);
914 return saf[TMath::LocMin(4,saf)];
920 void TGeoCone::SavePrimitive(std::ostream &out, Option_t * )
922 if (TObject::TestBit(kGeoSavePrimitive))
return;
923 out <<
" // Shape: " << GetName() <<
" type: " << ClassName() << std::endl;
924 out <<
" dz = " << fDz <<
";" << std::endl;
925 out <<
" rmin1 = " << fRmin1 <<
";" << std::endl;
926 out <<
" rmax1 = " << fRmax1 <<
";" << std::endl;
927 out <<
" rmin2 = " << fRmin2 <<
";" << std::endl;
928 out <<
" rmax2 = " << fRmax2 <<
";" << std::endl;
929 out <<
" TGeoShape *" << GetPointerName() <<
" = new TGeoCone(\"" << GetName() <<
"\", dz,rmin1,rmax1,rmin2,rmax2);" << std::endl;
930 TObject::SetBit(TGeoShape::kGeoSavePrimitive);
936 void TGeoCone::SetConeDimensions(Double_t dz, Double_t rmin1, Double_t rmax1,
937 Double_t rmin2, Double_t rmax2)
948 Warning(
"SetConeDimensions",
"rmin1>rmax1 Switch rmin1<->rmax1");
949 SetShapeBit(TGeoShape::kGeoBad);
970 Warning(
"SetConeDimensions",
"rmin2>rmax2 Switch rmin2<->rmax2");
971 SetShapeBit(TGeoShape::kGeoBad);
990 void TGeoCone::SetDimensions(Double_t *param)
992 Double_t dz = param[0];
993 Double_t rmin1 = param[1];
994 Double_t rmax1 = param[2];
995 Double_t rmin2 = param[3];
996 Double_t rmax2 = param[4];
997 SetConeDimensions(dz, rmin1, rmax1, rmin2, rmax2);
1003 void TGeoCone::SetPoints(Double_t *points)
const
1005 Double_t dz, phi, dphi;
1008 n = gGeoManager->GetNsegments();
1014 for (j = 0; j < n; j++) {
1015 phi = j*dphi*TMath::DegToRad();
1016 points[indx++] = fRmin1 * TMath::Cos(phi);
1017 points[indx++] = fRmin1 * TMath::Sin(phi);
1018 points[indx++] = -dz;
1021 for (j = 0; j < n; j++) {
1022 phi = j*dphi*TMath::DegToRad();
1023 points[indx++] = fRmax1 * TMath::Cos(phi);
1024 points[indx++] = fRmax1 * TMath::Sin(phi);
1025 points[indx++] = -dz;
1028 for (j = 0; j < n; j++) {
1029 phi = j*dphi*TMath::DegToRad();
1030 points[indx++] = fRmin2 * TMath::Cos(phi);
1031 points[indx++] = fRmin2 * TMath::Sin(phi);
1032 points[indx++] = dz;
1035 for (j = 0; j < n; j++) {
1036 phi = j*dphi*TMath::DegToRad();
1037 points[indx++] = fRmax2 * TMath::Cos(phi);
1038 points[indx++] = fRmax2 * TMath::Sin(phi);
1039 points[indx++] = dz;
1047 void TGeoCone::SetPoints(Float_t *points)
const
1049 Double_t dz, phi, dphi;
1052 n = gGeoManager->GetNsegments();
1058 for (j = 0; j < n; j++) {
1059 phi = j*dphi*TMath::DegToRad();
1060 points[indx++] = fRmin1 * TMath::Cos(phi);
1061 points[indx++] = fRmin1 * TMath::Sin(phi);
1062 points[indx++] = -dz;
1065 for (j = 0; j < n; j++) {
1066 phi = j*dphi*TMath::DegToRad();
1067 points[indx++] = fRmax1 * TMath::Cos(phi);
1068 points[indx++] = fRmax1 * TMath::Sin(phi);
1069 points[indx++] = -dz;
1072 for (j = 0; j < n; j++) {
1073 phi = j*dphi*TMath::DegToRad();
1074 points[indx++] = fRmin2 * TMath::Cos(phi);
1075 points[indx++] = fRmin2 * TMath::Sin(phi);
1076 points[indx++] = dz;
1079 for (j = 0; j < n; j++) {
1080 phi = j*dphi*TMath::DegToRad();
1081 points[indx++] = fRmax2 * TMath::Cos(phi);
1082 points[indx++] = fRmax2 * TMath::Sin(phi);
1083 points[indx++] = dz;
1091 void TGeoCone::GetMeshNumbers(Int_t &nvert, Int_t &nsegs, Int_t &npols)
const
1093 Int_t n = gGeoManager->GetNsegments();
1102 Int_t TGeoCone::GetNmeshVertices()
const
1104 Int_t n = gGeoManager->GetNsegments();
1105 Int_t numPoints = n*4;
1112 void TGeoCone::Sizeof3D()
const
1119 const TBuffer3D & TGeoCone::GetBuffer3D(Int_t reqSections, Bool_t localFrame)
const
1121 static TBuffer3D buffer(TBuffer3DTypes::kGeneric);
1123 TGeoBBox::FillBuffer3D(buffer, reqSections, localFrame);
1125 if (reqSections & TBuffer3D::kRawSizes) {
1126 Int_t n = gGeoManager->GetNsegments();
1130 if (buffer.SetRawSizes(nbPnts, 3*nbPnts, nbSegs, 3*nbSegs, nbPols, 6*nbPols)) {
1131 buffer.SetSectionsValid(TBuffer3D::kRawSizes);
1136 if ((reqSections & TBuffer3D::kRaw) && buffer.SectionsValid(TBuffer3D::kRawSizes)) {
1137 SetPoints(buffer.fPnts);
1138 if (!buffer.fLocalFrame) {
1139 TransformPoints(buffer.fPnts, buffer.NbPnts());
1142 SetSegsAndPols(buffer);
1143 buffer.SetSectionsValid(TBuffer3D::kRaw);
1154 void TGeoCone::Contains_v(
const Double_t *points, Bool_t *inside, Int_t vecsize)
const
1156 for (Int_t i=0; i<vecsize; i++) inside[i] = Contains(&points[3*i]);
1164 void TGeoCone::ComputeNormal_v(
const Double_t *points,
const Double_t *dirs, Double_t *norms, Int_t vecsize)
1166 for (Int_t i=0; i<vecsize; i++) ComputeNormal(&points[3*i], &dirs[3*i], &norms[3*i]);
1172 void TGeoCone::DistFromInside_v(
const Double_t *points,
const Double_t *dirs, Double_t *dists, Int_t vecsize, Double_t* step)
const
1174 for (Int_t i=0; i<vecsize; i++) dists[i] = DistFromInside(&points[3*i], &dirs[3*i], 3, step[i]);
1180 void TGeoCone::DistFromOutside_v(
const Double_t *points,
const Double_t *dirs, Double_t *dists, Int_t vecsize, Double_t* step)
const
1182 for (Int_t i=0; i<vecsize; i++) dists[i] = DistFromOutside(&points[3*i], &dirs[3*i], 3, step[i]);
1190 void TGeoCone::Safety_v(
const Double_t *points,
const Bool_t *inside, Double_t *safe, Int_t vecsize)
const
1192 for (Int_t i=0; i<vecsize; i++) safe[i] = Safety(&points[3*i], inside[i]);
1195 ClassImp(TGeoConeSeg);
1200 TGeoConeSeg::TGeoConeSeg()
1202 fPhi1(0.), fPhi2(0.), fS1(0.), fC1(0.), fS2(0.), fC2(0.), fSm(0.), fCm(0.), fCdfi(0.)
1204 SetShapeBit(TGeoShape::kGeoConeSeg);
1205 fPhi1 = fPhi2 = 0.0;
1211 TGeoConeSeg::TGeoConeSeg(Double_t dz, Double_t rmin1, Double_t rmax1,
1212 Double_t rmin2, Double_t rmax2, Double_t phi1, Double_t phi2)
1213 :TGeoCone(dz, rmin1, rmax1, rmin2, rmax2),
1214 fPhi1(0.), fPhi2(0.), fS1(0.), fC1(0.), fS2(0.), fC2(0.), fSm(0.), fCm(0.), fCdfi(0.)
1217 SetShapeBit(TGeoShape::kGeoConeSeg);
1218 SetConsDimensions(dz, rmin1, rmax1, rmin2, rmax2, phi1, phi2);
1225 TGeoConeSeg::TGeoConeSeg(
const char *name, Double_t dz, Double_t rmin1, Double_t rmax1,
1226 Double_t rmin2, Double_t rmax2, Double_t phi1, Double_t phi2)
1227 :TGeoCone(name, dz, rmin1, rmax1, rmin2, rmax2),
1228 fPhi1(0.), fPhi2(0.), fS1(0.), fC1(0.), fS2(0.), fC2(0.), fSm(0.), fCm(0.), fCdfi(0.)
1230 SetShapeBit(TGeoShape::kGeoConeSeg);
1231 SetConsDimensions(dz, rmin1, rmax1, rmin2, rmax2, phi1, phi2);
1245 TGeoConeSeg::TGeoConeSeg(Double_t *param)
1246 :TGeoCone(0,0,0,0,0),
1247 fPhi1(0.), fPhi2(0.), fS1(0.), fC1(0.), fS2(0.), fC2(0.), fSm(0.), fCm(0.), fCdfi(0.)
1249 SetShapeBit(TGeoShape::kGeoConeSeg);
1250 SetDimensions(param);
1257 TGeoConeSeg::~TGeoConeSeg()
1264 void TGeoConeSeg::AfterStreamer()
1272 void TGeoConeSeg::InitTrigonometry()
1274 Double_t phi1 = fPhi1*TMath::DegToRad();
1275 Double_t phi2 = fPhi2*TMath::DegToRad();
1276 fC1 = TMath::Cos(phi1);
1277 fS1 = TMath::Sin(phi1);
1278 fC2 = TMath::Cos(phi2);
1279 fS2 = TMath::Sin(phi2);
1280 Double_t fio = 0.5*(phi1+phi2);
1281 fCm = TMath::Cos(fio);
1282 fSm = TMath::Sin(fio);
1283 Double_t dfi = 0.5*(phi2-phi1);
1284 fCdfi = TMath::Cos(dfi);
1290 Double_t TGeoConeSeg::Capacity()
const
1292 return TGeoConeSeg::Capacity(fDz, fRmin1, fRmax1, fRmin2, fRmax2, fPhi1, fPhi2);
1298 Double_t TGeoConeSeg::Capacity(Double_t dz, Double_t rmin1, Double_t rmax1, Double_t rmin2, Double_t rmax2, Double_t phi1, Double_t phi2)
1300 Double_t capacity = (TMath::Abs(phi2-phi1)*TMath::DegToRad()*dz/3.)*
1301 (rmax1*rmax1+rmax2*rmax2+rmax1*rmax2-
1302 rmin1*rmin1-rmin2*rmin2-rmin1*rmin2);
1309 void TGeoConeSeg::ComputeBBox()
1311 Double_t rmin, rmax;
1312 rmin = TMath::Min(fRmin1, fRmin2);
1313 rmax = TMath::Max(fRmax1, fRmax2);
1326 Double_t xmin = xc[TMath::LocMin(4, &xc[0])];
1327 Double_t xmax = xc[TMath::LocMax(4, &xc[0])];
1328 Double_t ymin = yc[TMath::LocMin(4, &yc[0])];
1329 Double_t ymax = yc[TMath::LocMax(4, &yc[0])];
1331 Double_t dp = fPhi2-fPhi1;
1332 Double_t ddp = -fPhi1;
1333 if (ddp<0) ddp+= 360;
1334 if (ddp<=dp) xmax = rmax;
1336 if (ddp<0) ddp+= 360;
1337 if (ddp<=dp) ymax = rmax;
1339 if (ddp<0) ddp+= 360;
1340 if (ddp<=dp) xmin = -rmax;
1342 if (ddp<0) ddp+= 360;
1343 if (ddp<=dp) ymin = -rmax;
1344 fOrigin[0] = (xmax+xmin)/2;
1345 fOrigin[1] = (ymax+ymin)/2;
1347 fDX = (xmax-xmin)/2;
1348 fDY = (ymax-ymin)/2;
1355 void TGeoConeSeg::ComputeNormal(
const Double_t *point,
const Double_t *dir, Double_t *norm)
1358 Double_t ro1 = 0.5*(fRmin1+fRmin2);
1359 Double_t tg1 = 0.5*(fRmin2-fRmin1)/fDz;
1360 Double_t cr1 = 1./TMath::Sqrt(1.+tg1*tg1);
1361 Double_t ro2 = 0.5*(fRmax1+fRmax2);
1362 Double_t tg2 = 0.5*(fRmax2-fRmax1)/fDz;
1363 Double_t cr2 = 1./TMath::Sqrt(1.+tg2*tg2);
1365 Double_t r=TMath::Sqrt(point[0]*point[0]+point[1]*point[1]);
1366 Double_t rin = tg1*point[2]+ro1;
1367 Double_t rout = tg2*point[2]+ro2;
1368 saf[0] = TMath::Abs(fDz-TMath::Abs(point[2]));
1369 saf[1] = (ro1>0)?(TMath::Abs((r-rin)*cr1)):TGeoShape::Big();
1370 saf[2] = TMath::Abs((rout-r)*cr2);
1371 Int_t i = TMath::LocMin(3,saf);
1372 if (((fPhi2-fPhi1)<360.) && TGeoShape::IsCloseToPhi(saf[i], point,fC1,fS1,fC2,fS2)) {
1373 TGeoShape::NormalPhi(point,dir,norm,fC1,fS1,fC2,fS2);
1377 norm[0] = norm[1] = 0.;
1378 norm[2] = TMath::Sign(1.,dir[2]);
1382 Double_t phi = TMath::ATan2(point[1],point[0]);
1383 Double_t cphi = TMath::Cos(phi);
1384 Double_t sphi = TMath::Sin(phi);
1396 if (norm[0]*dir[0]+norm[1]*dir[1]+norm[2]*dir[2]<0) {
1406 void TGeoConeSeg::ComputeNormalS(
const Double_t *point,
const Double_t *dir, Double_t *norm,
1407 Double_t dz, Double_t rmin1, Double_t rmax1, Double_t rmin2, Double_t rmax2,
1408 Double_t c1, Double_t s1, Double_t c2, Double_t s2)
1411 Double_t ro1 = 0.5*(rmin1+rmin2);
1412 Double_t tg1 = 0.5*(rmin2-rmin1)/dz;
1413 Double_t cr1 = 1./TMath::Sqrt(1.+tg1*tg1);
1414 Double_t ro2 = 0.5*(rmax1+rmax2);
1415 Double_t tg2 = 0.5*(rmax2-rmax1)/dz;
1416 Double_t cr2 = 1./TMath::Sqrt(1.+tg2*tg2);
1418 Double_t r=TMath::Sqrt(point[0]*point[0]+point[1]*point[1]);
1419 Double_t rin = tg1*point[2]+ro1;
1420 Double_t rout = tg2*point[2]+ro2;
1421 saf[0] = (ro1>0)?(TMath::Abs((r-rin)*cr1)):TGeoShape::Big();
1422 saf[1] = TMath::Abs((rout-r)*cr2);
1423 Int_t i = TMath::LocMin(2,saf);
1424 if (TGeoShape::IsCloseToPhi(saf[i], point,c1,s1,c2,s2)) {
1425 TGeoShape::NormalPhi(point,dir,norm,c1,s1,c2,s2);
1429 Double_t phi = TMath::ATan2(point[1],point[0]);
1430 Double_t cphi = TMath::Cos(phi);
1431 Double_t sphi = TMath::Sin(phi);
1443 if (norm[0]*dir[0]+norm[1]*dir[1]+norm[2]*dir[2]<0) {
1453 Bool_t TGeoConeSeg::Contains(
const Double_t *point)
const
1455 if (!TGeoCone::Contains(point))
return kFALSE;
1456 Double_t dphi = fPhi2 - fPhi1;
1457 if (dphi >= 360.)
return kTRUE;
1458 Double_t phi = TMath::ATan2(point[1], point[0]) * TMath::RadToDeg();
1459 if (phi < 0 ) phi+=360.;
1460 Double_t ddp = phi-fPhi1;
1461 if (ddp < 0) ddp+=360.;
1463 if (ddp > dphi)
return kFALSE;
1473 Double_t TGeoConeSeg::DistToCons(
const Double_t *point,
const Double_t *dir, Double_t r1, Double_t z1, Double_t r2, Double_t z2, Double_t phi1, Double_t phi2)
1475 Double_t dz = z2-z1;
1477 return TGeoShape::Big();
1480 Double_t dphi = phi2 - phi1;
1481 Bool_t hasphi = kTRUE;
1482 if (dphi >= 360.) hasphi=kFALSE;
1483 if (dphi < 0) dphi+=360.;
1486 Double_t ro0 = 0.5*(r1+r2);
1487 Double_t fz = (r2-r1)/dz;
1488 Double_t r0sq = point[0]*point[0] + point[1]*point[1];
1489 Double_t rc = ro0 + fz*(point[2]-0.5*(z1+z2));
1491 Double_t a = dir[0]*dir[0] + dir[1]*dir[1] - fz*fz*dir[2]*dir[2];
1492 Double_t b = point[0]*dir[0] + point[1]*dir[1] - fz*rc*dir[2];
1493 Double_t c = r0sq - rc*rc;
1495 if (a==0)
return TGeoShape::Big();
1499 Double_t delta = b*b - c;
1500 if (delta<0)
return TGeoShape::Big();
1501 delta = TMath::Sqrt(delta);
1503 Double_t snxt = -b-delta;
1508 ptnew[2] = point[2] + snxt*dir[2];
1509 if (((ptnew[2]-z1)*(ptnew[2]-z2)) < 0) {
1511 if (!hasphi)
return snxt;
1512 ptnew[0] = point[0] + snxt*dir[0];
1513 ptnew[1] = point[1] + snxt*dir[1];
1514 phi = TMath::ATan2(ptnew[1], ptnew[0]) * TMath::RadToDeg();
1515 if (phi < 0 ) phi+=360.;
1517 if (ddp < 0) ddp+=360.;
1519 if (ddp<=dphi)
return snxt;
1525 ptnew[2] = point[2] + snxt*dir[2];
1526 if (((ptnew[2]-z1)*(ptnew[2]-z2)) < 0) {
1528 if (!hasphi)
return snxt;
1529 ptnew[0] = point[0] + snxt*dir[0];
1530 ptnew[1] = point[1] + snxt*dir[1];
1531 phi = TMath::ATan2(ptnew[1], ptnew[0]) * TMath::RadToDeg();
1532 if (phi < 0 ) phi+=360.;
1534 if (ddp < 0) ddp+=360.;
1536 if (ddp<=dphi)
return snxt;
1539 return TGeoShape::Big();
1545 Double_t TGeoConeSeg::DistFromInsideS(
const Double_t *point,
const Double_t *dir, Double_t dz,
1546 Double_t rmin1, Double_t rmax1, Double_t rmin2, Double_t rmax2,
1547 Double_t c1, Double_t s1, Double_t c2, Double_t s2, Double_t cm, Double_t sm, Double_t cdfi)
1549 if (dz<=0)
return TGeoShape::Big();
1551 Double_t scone = TGeoCone::DistFromInsideS(point,dir,dz,rmin1,rmax1,rmin2,rmax2);
1552 if (scone<=0)
return 0.0;
1553 Double_t sfmin = TGeoShape::Big();
1554 Double_t rsq = point[0]*point[0]+point[1]*point[1];
1555 Double_t r = TMath::Sqrt(rsq);
1556 Double_t cpsi=point[0]*cm+point[1]*sm;
1557 if (cpsi>r*cdfi+TGeoShape::Tolerance()) {
1558 sfmin = TGeoShape::DistToPhiMin(point, dir, s1, c1, s2, c2, sm, cm);
1559 return TMath::Min(scone,sfmin);
1563 Double_t ddotn, xi, yi;
1564 if (TMath::Abs(point[1]-s1*r) < TMath::Abs(point[1]-s2*r)) {
1565 ddotn = s1*dir[0]-c1*dir[1];
1566 if (ddotn>=0)
return 0.0;
1567 ddotn = -s2*dir[0]+c2*dir[1];
1568 if (ddotn<=0)
return scone;
1569 sfmin = s2*point[0]-c2*point[1];
1570 if (sfmin<=0)
return scone;
1572 if (sfmin >= scone)
return scone;
1573 xi = point[0]+sfmin*dir[0];
1574 yi = point[1]+sfmin*dir[1];
1575 if (yi*cm-xi*sm<0)
return scone;
1578 ddotn = -s2*dir[0]+c2*dir[1];
1579 if (ddotn>=0)
return 0.0;
1580 ddotn = s1*dir[0]-c1*dir[1];
1581 if (ddotn<=0)
return scone;
1582 sfmin = -s1*point[0]+c1*point[1];
1583 if (sfmin<=0)
return scone;
1585 if (sfmin >= scone)
return scone;
1586 xi = point[0]+sfmin*dir[0];
1587 yi = point[1]+sfmin*dir[1];
1588 if (yi*cm-xi*sm>0)
return scone;
1595 Double_t TGeoConeSeg::DistFromInside(
const Double_t *point,
const Double_t *dir, Int_t iact, Double_t step, Double_t *safe)
const
1597 if (iact<3 && safe) {
1598 *safe = TGeoConeSeg::SafetyS(point, kTRUE, fDz,fRmin1,fRmax1,fRmin2,fRmax2,fPhi1,fPhi2);
1599 if (iact==0)
return TGeoShape::Big();
1600 if ((iact==1) && (*safe>step))
return TGeoShape::Big();
1602 if ((fPhi2-fPhi1)>=360.)
return TGeoCone::DistFromInsideS(point,dir,fDz,fRmin1,fRmax1,fRmin2,fRmax2);
1605 return TGeoConeSeg::DistFromInsideS(point,dir,fDz,fRmin1,fRmax1,fRmin2,fRmax2,fC1,fS1,fC2,fS2,fCm,fSm,fCdfi);
1611 Double_t TGeoConeSeg::DistFromOutsideS(
const Double_t *point,
const Double_t *dir, Double_t dz,
1612 Double_t rmin1, Double_t rmax1, Double_t rmin2, Double_t rmax2,
1613 Double_t c1, Double_t s1, Double_t c2, Double_t s2, Double_t cm, Double_t sm, Double_t cdfi)
1615 if (dz<=0)
return TGeoShape::Big();
1618 Double_t xi, yi, zi;
1620 zi = dz - TMath::Abs(point[2]);
1622 Double_t s = TGeoShape::Big();
1623 Double_t snxt=TGeoShape::Big();
1625 Bool_t inz = (zi<0)?kFALSE:kTRUE;
1627 if (point[2]*dir[2]>=0)
return TGeoShape::Big();
1628 s = -zi/TMath::Abs(dir[2]);
1629 xi = point[0]+s*dir[0];
1630 yi = point[1]+s*dir[1];
1639 if ((rin*rin<=r2) && (r2<=rout*rout)) {
1641 if (cpsi>=(cdfi*TMath::Sqrt(r2)))
return s;
1644 Double_t zinv = 1./dz;
1645 Double_t rsq = point[0]*point[0]+point[1]*point[1];
1646 Double_t r = TMath::Sqrt(rsq);
1647 Double_t ro1=0.5*(rmin1+rmin2);
1648 Bool_t hasrmin = (ro1>0)?kTRUE:kFALSE;
1650 Bool_t inrmin = kFALSE;
1653 tg1=0.5*(rmin2-rmin1)*zinv;
1654 rin = ro1+tg1*point[2];
1655 if (rsq > rin*(rin-TGeoShape::Tolerance())) inrmin=kTRUE;
1659 Double_t ro2=0.5*(rmax1+rmax2);
1660 Double_t tg2=0.5*(rmax2-rmax1)*zinv;
1661 rout = ro2+tg2*point[2];
1662 Bool_t inrmax = kFALSE;
1663 if (r < rout+TGeoShape::Tolerance()) inrmax = kTRUE;
1664 Bool_t inphi = kFALSE;
1665 cpsi=point[0]*cm+point[1]*sm;
1666 if (cpsi>r*cdfi-TGeoShape::Tolerance()) inphi = kTRUE;
1667 in = inz & inrmin & inrmax & inphi;
1670 Double_t safphi = (cpsi-r*cdfi)*TMath::Sqrt(1.-cdfi*cdfi);
1671 Double_t safrmin = (hasrmin)?TMath::Abs(r-rin):(TGeoShape::Big());
1672 Double_t safrmax = TMath::Abs(r-rout);
1674 if (zi<safrmax && zi<safrmin && zi<safphi) {
1675 if (point[2]*dir[2]<0)
return 0.0;
1676 return TGeoShape::Big();
1679 if (safrmax<safrmin && safrmax<safphi) {
1680 Double_t ddotn = point[0]*dir[0]+point[1]*dir[1]-tg2*dir[2]*r;
1681 if (ddotn<=0)
return 0.0;
1682 return TGeoShape::Big();
1685 if (safphi<safrmin) {
1689 if (point[0]*c1 + point[1]*s1 > point[0]*c2 + point[1]*s2) {
1690 un = dir[0]*s1-dir[1]*c1;
1691 if (un < 0)
return 0.0;
1692 if (cdfi>=0)
return TGeoShape::Big();
1693 un = -dir[0]*s2+dir[1]*c2;
1695 s = -point[0]*s2+point[1]*c2;
1698 zi = point[2]+s*dir[2];
1699 if (TMath::Abs(zi)<=dz) {
1700 xi = point[0]+s*dir[0];
1701 yi = point[1]+s*dir[1];
1702 if ((yi*cm-xi*sm)>0) {
1706 if ((rin*rin<=r2) && (rout*rout>=r2))
return s;
1712 un = -dir[0]*s2+dir[1]*c2;
1713 if (un < 0)
return 0.0;
1714 if (cdfi>=0)
return TGeoShape::Big();
1715 un = dir[0]*s1-dir[1]*c1;
1717 s = point[0]*s1-point[1]*c1;
1720 zi = point[2]+s*dir[2];
1721 if (TMath::Abs(zi)<=dz) {
1722 xi = point[0]+s*dir[0];
1723 yi = point[1]+s*dir[1];
1724 if ((yi*cm-xi*sm)<0) {
1728 if ((rin*rin<=r2) && (rout*rout>=r2))
return s;
1735 Double_t ddotn = point[0]*dir[0]+point[1]*dir[1]-tg1*dir[2]*r;
1736 if (ddotn>=0)
return TGeoShape::Big();
1737 if (cdfi>=0)
return TGeoShape::Big();
1738 TGeoCone::DistToCone(point, dir, dz, rmin1, rmin2, b, delta);
1739 if (delta<0)
return TGeoShape::Big();
1741 if (snxt<0)
return TGeoShape::Big();
1743 zi = point[2]+snxt*dir[2];
1744 if (TMath::Abs(zi)>dz)
return TGeoShape::Big();
1745 xi = point[0]+snxt*dir[0];
1746 yi = point[1]+snxt*dir[1];
1749 if (cpsi>=(cdfi*TMath::Sqrt(r2)))
return snxt;
1750 return TGeoShape::Big();
1753 Double_t ddotn = point[0]*dir[0]+point[1]*dir[1]-tg1*dir[2]*r;
1754 if (ddotn>=0)
return 0.0;
1755 TGeoCone::DistToCone(point, dir, dz, rmin1, rmin2, b, delta);
1756 if (delta<0)
return 0.0;
1758 if (snxt<0)
return TGeoShape::Big();
1759 if (TMath::Abs(-b-delta)>snxt)
return TGeoShape::Big();
1760 zi = point[2]+snxt*dir[2];
1761 if (TMath::Abs(zi)>dz)
return TGeoShape::Big();
1763 xi = point[0]+snxt*dir[0];
1764 yi = point[1]+snxt*dir[1];
1767 if (cpsi>=(cdfi*TMath::Sqrt(r2)))
return snxt;
1769 if (cdfi>=0)
return TGeoShape::Big();
1770 Double_t un=-dir[0]*s1+dir[1]*c1;
1772 s=point[0]*s1-point[1]*c1;
1775 zi=point[2]+s*dir[2];
1776 if (TMath::Abs(zi)<=dz) {
1777 xi=point[0]+s*dir[0];
1778 yi=point[1]+s*dir[1];
1779 if ((yi*cm-xi*sm)<=0) {
1783 if ((rin*rin<=r2) && (rout*rout>=r2))
return s;
1788 un=dir[0]*s2-dir[1]*c2;
1790 s=(point[1]*c2-point[0]*s2)/un;
1792 zi=point[2]+s*dir[2];
1793 if (TMath::Abs(zi)<=dz) {
1794 xi=point[0]+s*dir[0];
1795 yi=point[1]+s*dir[1];
1796 if ((yi*cm-xi*sm)>=0) {
1800 if ((rin*rin<=r2) && (rout*rout>=r2))
return s;
1805 return TGeoShape::Big();
1809 Double_t sr1 = TGeoShape::Big();
1812 TGeoCone::DistToCone(point, dir, dz, rmax1, rmax2, b, delta);
1816 zi=point[2]+s*dir[2];
1817 if (TMath::Abs(zi)<=dz) {
1818 xi=point[0]+s*dir[0];
1819 yi=point[1]+s*dir[1];
1822 if (cpsi>=(cdfi*TMath::Sqrt(r2)))
return s;
1827 zi=point[2]+s*dir[2];
1828 if (TMath::Abs(zi)<=dz) {
1829 xi=point[0]+s*dir[0];
1830 yi=point[1]+s*dir[1];
1833 if (cpsi>=(cdfi*TMath::Sqrt(r2))) sr1=s;
1839 Double_t sr2 = TGeoShape::Big();
1840 TGeoCone::DistToCone(point, dir, dz, rmin1, rmin2, b, delta);
1844 zi=point[2]+s*dir[2];
1845 if (TMath::Abs(zi)<=dz) {
1846 xi=point[0]+s*dir[0];
1847 yi=point[1]+s*dir[1];
1850 if (cpsi>=(cdfi*TMath::Sqrt(r2))) sr2=s;
1856 zi=point[2]+s*dir[2];
1857 if (TMath::Abs(zi)<=dz) {
1858 xi=point[0]+s*dir[0];
1859 yi=point[1]+s*dir[1];
1862 if (cpsi>=(cdfi*TMath::Sqrt(r2))) sr2=s;
1867 snxt = TMath::Min(sr1,sr2);
1869 s = TGeoShape::DistToPhiMin(point,dir,s1,c1,s2,c2,sm,cm,kFALSE);
1870 if (s>snxt)
return snxt;
1871 zi=point[2]+s*dir[2];
1872 if (TMath::Abs(zi)>dz)
return snxt;
1873 xi=point[0]+s*dir[0];
1874 yi=point[1]+s*dir[1];
1877 if (r2>rout*rout)
return snxt;
1879 if (r2>=rin*rin)
return s;
1886 Double_t TGeoConeSeg::DistFromOutside(
const Double_t *point,
const Double_t *dir, Int_t iact, Double_t step, Double_t *safe)
const
1889 if (iact<3 && safe) {
1890 *safe = Safety(point, kFALSE);
1891 if (iact==0)
return TGeoShape::Big();
1892 if ((iact==1) && (*safe>step))
return TGeoShape::Big();
1895 Double_t sdist = TGeoBBox::DistFromOutside(point,dir, fDX, fDY, fDZ, fOrigin, step);
1896 if (sdist>=step)
return TGeoShape::Big();
1897 if ((fPhi2-fPhi1)>=360.)
return TGeoCone::DistFromOutsideS(point,dir,fDz,fRmin1,fRmax1,fRmin2,fRmax2);
1898 return TGeoConeSeg::DistFromOutsideS(point,dir,fDz,fRmin1,fRmax1,fRmin2,fRmax2,fC1,fS1,fC2,fS2,fCm,fSm,fCdfi);
1904 Int_t TGeoConeSeg::DistancetoPrimitive(Int_t px, Int_t py)
1906 Int_t n = gGeoManager->GetNsegments()+1;
1907 const Int_t numPoints = 4*n;
1908 return ShapeDistancetoPrimitive(numPoints, px, py);
1919 TGeoVolume *TGeoConeSeg::Divide(TGeoVolume *voldiv,
const char *divname, Int_t iaxis, Int_t ndiv,
1920 Double_t start, Double_t step)
1924 TGeoVolumeMulti *vmulti;
1925 TGeoPatternFinder *finder;
1929 Double_t end = start+ndiv*step;
1932 Error(
"Divide",
"division of a cone segment on R not implemented");
1936 if (dphi<0) dphi+=360.;
1937 finder =
new TGeoPatternCylPhi(voldiv, ndiv, start, end);
1938 voldiv->SetFinder(finder);
1939 finder->SetDivIndex(voldiv->GetNdaughters());
1940 shape =
new TGeoConeSeg(fDz, fRmin1, fRmax1, fRmin2, fRmax2, -step/2, step/2);
1941 vol =
new TGeoVolume(divname, shape, voldiv->GetMedium());
1942 vmulti = gGeoManager->MakeVolumeMulti(divname, voldiv->GetMedium());
1943 vmulti->AddVolume(vol);
1945 for (
id=0;
id<ndiv;
id++) {
1946 voldiv->AddNodeOffset(vol,
id, start+
id*step+step/2, opt.Data());
1947 ((TGeoNodeOffset*)voldiv->GetNodes()->At(voldiv->GetNdaughters()-1))->SetFinder(finder);
1951 finder =
new TGeoPatternZ(voldiv, ndiv, start, end);
1952 vmulti = gGeoManager->MakeVolumeMulti(divname, voldiv->GetMedium());
1953 voldiv->SetFinder(finder);
1954 finder->SetDivIndex(voldiv->GetNdaughters());
1955 for (
id=0;
id<ndiv;
id++) {
1956 Double_t z1 = start+
id*step;
1957 Double_t z2 = start+(
id+1)*step;
1958 Double_t rmin1n = 0.5*(fRmin1*(fDz-z1)+fRmin2*(fDz+z1))/fDz;
1959 Double_t rmax1n = 0.5*(fRmax1*(fDz-z1)+fRmax2*(fDz+z1))/fDz;
1960 Double_t rmin2n = 0.5*(fRmin1*(fDz-z2)+fRmin2*(fDz+z2))/fDz;
1961 Double_t rmax2n = 0.5*(fRmax1*(fDz-z2)+fRmax2*(fDz+z2))/fDz;
1962 shape =
new TGeoConeSeg(step/2, rmin1n, rmax1n, rmin2n, rmax2n, fPhi1, fPhi2);
1963 vol =
new TGeoVolume(divname, shape, voldiv->GetMedium());
1964 vmulti->AddVolume(vol);
1966 voldiv->AddNodeOffset(vol,
id, start+
id*step+step/2, opt.Data());
1967 ((TGeoNodeOffset*)voldiv->GetNodes()->At(voldiv->GetNdaughters()-1))->SetFinder(finder);
1971 Error(
"Divide",
"Wrong axis type for division");
1979 Double_t TGeoConeSeg::GetAxisRange(Int_t iaxis, Double_t &xlo, Double_t &xhi)
const
2003 void TGeoConeSeg::GetBoundingCylinder(Double_t *param)
const
2005 param[0] = TMath::Min(fRmin1, fRmin2);
2006 param[0] *= param[0];
2007 param[1] = TMath::Max(fRmax1, fRmax2);
2008 param[1] *= param[1];
2009 param[2] = (fPhi1<0)?(fPhi1+360.):fPhi1;
2011 while (param[3]<param[2]) param[3]+=360.;
2018 TGeoShape *TGeoConeSeg::GetMakeRuntimeShape(TGeoShape *mother, TGeoMatrix * )
const
2020 if (!TestShapeBit(kGeoRunTimeShape))
return 0;
2021 if (!mother->TestShapeBit(kGeoConeSeg)) {
2022 Error(
"GetMakeRuntimeShape",
"invalid mother");
2025 Double_t rmin1, rmax1, rmin2, rmax2, dz;
2031 if (fDz<0) dz=((TGeoCone*)mother)->GetDz();
2033 rmin1 = ((TGeoCone*)mother)->GetRmin1();
2034 if ((fRmax1<0) || (fRmax1<fRmin1))
2035 rmax1 = ((TGeoCone*)mother)->GetRmax1();
2037 rmin2 = ((TGeoCone*)mother)->GetRmin2();
2038 if ((fRmax2<0) || (fRmax2<fRmin2))
2039 rmax2 = ((TGeoCone*)mother)->GetRmax2();
2041 return (
new TGeoConeSeg(GetName(), dz, rmin1, rmax1, rmin2, rmax2, fPhi1, fPhi2));
2047 void TGeoConeSeg::InspectShape()
const
2049 printf(
"*** Shape %s: TGeoConeSeg ***\n", GetName());
2050 printf(
" dz = %11.5f\n", fDz);
2051 printf(
" Rmin1 = %11.5f\n", fRmin1);
2052 printf(
" Rmax1 = %11.5f\n", fRmax1);
2053 printf(
" Rmin2 = %11.5f\n", fRmin2);
2054 printf(
" Rmax2 = %11.5f\n", fRmax2);
2055 printf(
" phi1 = %11.5f\n", fPhi1);
2056 printf(
" phi2 = %11.5f\n", fPhi2);
2057 printf(
" Bounding box:\n");
2058 TGeoBBox::InspectShape();
2065 TBuffer3D *TGeoConeSeg::MakeBuffer3D()
const
2067 Int_t n = gGeoManager->GetNsegments()+1;
2069 Int_t nbSegs = 2*nbPnts;
2070 Int_t nbPols = nbPnts-2;
2071 TBuffer3D* buff =
new TBuffer3D(TBuffer3DTypes::kGeneric,
2078 SetPoints(buff->fPnts);
2079 SetSegsAndPols(*buff);
2088 void TGeoConeSeg::SetSegsAndPols(TBuffer3D &buffer)
const
2091 Int_t n = gGeoManager->GetNsegments()+1;
2092 Int_t c = GetBasicColor();
2094 memset(buffer.fSegs, 0, buffer.NbSegs()*3*
sizeof(Int_t));
2095 for (i = 0; i < 4; i++) {
2096 for (j = 1; j < n; j++) {
2097 buffer.fSegs[(i*n+j-1)*3 ] = c;
2098 buffer.fSegs[(i*n+j-1)*3+1] = i*n+j-1;
2099 buffer.fSegs[(i*n+j-1)*3+2] = i*n+j;
2102 for (i = 4; i < 6; i++) {
2103 for (j = 0; j < n; j++) {
2104 buffer.fSegs[(i*n+j)*3 ] = c+1;
2105 buffer.fSegs[(i*n+j)*3+1] = (i-4)*n+j;
2106 buffer.fSegs[(i*n+j)*3+2] = (i-2)*n+j;
2109 for (i = 6; i < 8; i++) {
2110 for (j = 0; j < n; j++) {
2111 buffer.fSegs[(i*n+j)*3 ] = c;
2112 buffer.fSegs[(i*n+j)*3+1] = 2*(i-6)*n+j;
2113 buffer.fSegs[(i*n+j)*3+2] = (2*(i-6)+1)*n+j;
2118 memset(buffer.fPols, 0, buffer.NbPols()*6*
sizeof(Int_t));
2120 for (j = 0; j < n-1; j++) {
2121 buffer.fPols[indx++] = c;
2122 buffer.fPols[indx++] = 4;
2123 buffer.fPols[indx++] = (4+i)*n+j+1;
2124 buffer.fPols[indx++] = (2+i)*n+j;
2125 buffer.fPols[indx++] = (4+i)*n+j;
2126 buffer.fPols[indx++] = i*n+j;
2129 for (j = 0; j < n-1; j++) {
2130 buffer.fPols[indx++] = c;
2131 buffer.fPols[indx++] = 4;
2132 buffer.fPols[indx++] = i*n+j;
2133 buffer.fPols[indx++] = (4+i)*n+j;
2134 buffer.fPols[indx++] = (2+i)*n+j;
2135 buffer.fPols[indx++] = (4+i)*n+j+1;
2138 for (j = 0; j < n-1; j++) {
2139 buffer.fPols[indx++] = c+i;
2140 buffer.fPols[indx++] = 4;
2141 buffer.fPols[indx++] = (i-2)*2*n+j;
2142 buffer.fPols[indx++] = (4+i)*n+j;
2143 buffer.fPols[indx++] = ((i-2)*2+1)*n+j;
2144 buffer.fPols[indx++] = (4+i)*n+j+1;
2147 for (j = 0; j < n-1; j++) {
2148 buffer.fPols[indx++] = c+i;
2149 buffer.fPols[indx++] = 4;
2150 buffer.fPols[indx++] = (4+i)*n+j+1;
2151 buffer.fPols[indx++] = ((i-2)*2+1)*n+j;
2152 buffer.fPols[indx++] = (4+i)*n+j;
2153 buffer.fPols[indx++] = (i-2)*2*n+j;
2155 buffer.fPols[indx++] = c+2;
2156 buffer.fPols[indx++] = 4;
2157 buffer.fPols[indx++] = 6*n;
2158 buffer.fPols[indx++] = 4*n;
2159 buffer.fPols[indx++] = 7*n;
2160 buffer.fPols[indx++] = 5*n;
2161 buffer.fPols[indx++] = c+2;
2162 buffer.fPols[indx++] = 4;
2163 buffer.fPols[indx++] = 6*n-1;
2164 buffer.fPols[indx++] = 8*n-1;
2165 buffer.fPols[indx++] = 5*n-1;
2166 buffer.fPols[indx++] = 7*n-1;
2173 Double_t TGeoConeSeg::Safety(
const Double_t *point, Bool_t in)
const
2175 Double_t safe = TGeoCone::Safety(point,in);
2176 if ((fPhi2-fPhi1)>=360.)
return safe;
2177 Double_t safphi = TGeoShape::SafetyPhi(point, in, fPhi1, fPhi2);
2178 if (in)
return TMath::Min(safe, safphi);
2179 if (safe>1.E10)
return safphi;
2180 return TMath::Max(safe, safphi);
2186 Double_t TGeoConeSeg::SafetyS(
const Double_t *point, Bool_t in, Double_t dz, Double_t rmin1, Double_t rmax1,
2187 Double_t rmin2, Double_t rmax2, Double_t phi1, Double_t phi2, Int_t skipz)
2189 Double_t safe = TGeoCone::SafetyS(point,in,dz,rmin1,rmax1,rmin2,rmax2,skipz);
2190 if ((phi2-phi1)>=360.)
return safe;
2191 Double_t safphi = TGeoShape::SafetyPhi(point,in,phi1,phi2);
2192 if (in)
return TMath::Min(safe, safphi);
2193 if (safe>1.E10)
return safphi;
2194 return TMath::Max(safe, safphi);
2200 void TGeoConeSeg::SavePrimitive(std::ostream &out, Option_t * )
2202 if (TObject::TestBit(kGeoSavePrimitive))
return;
2203 out <<
" // Shape: " << GetName() <<
" type: " << ClassName() << std::endl;
2204 out <<
" dz = " << fDz <<
";" << std::endl;
2205 out <<
" rmin1 = " << fRmin1 <<
";" << std::endl;
2206 out <<
" rmax1 = " << fRmax1 <<
";" << std::endl;
2207 out <<
" rmin2 = " << fRmin2 <<
";" << std::endl;
2208 out <<
" rmax2 = " << fRmax2 <<
";" << std::endl;
2209 out <<
" phi1 = " << fPhi1 <<
";" << std::endl;
2210 out <<
" phi2 = " << fPhi2 <<
";" << std::endl;
2211 out <<
" TGeoShape *" << GetPointerName() <<
" = new TGeoConeSeg(\"" << GetName() <<
"\", dz,rmin1,rmax1,rmin2,rmax2,phi1,phi2);" << std::endl;
2212 TObject::SetBit(TGeoShape::kGeoSavePrimitive);
2218 void TGeoConeSeg::SetConsDimensions(Double_t dz, Double_t rmin1, Double_t rmax1,
2219 Double_t rmin2, Double_t rmax2, Double_t phi1, Double_t phi2)
2227 while (fPhi1<0) fPhi1+=360.;
2229 while (fPhi2<=fPhi1) fPhi2+=360.;
2230 if (TGeoShape::IsSameWithinTolerance(fPhi1,fPhi2)) Fatal(
"SetConsDimensions",
"In shape %s invalid phi1=%g, phi2=%g\n", GetName(), fPhi1, fPhi2);
2237 void TGeoConeSeg::SetDimensions(Double_t *param)
2239 Double_t dz = param[0];
2240 Double_t rmin1 = param[1];
2241 Double_t rmax1 = param[2];
2242 Double_t rmin2 = param[3];
2243 Double_t rmax2 = param[4];
2244 Double_t phi1 = param[5];
2245 Double_t phi2 = param[6];
2246 SetConsDimensions(dz, rmin1, rmax1,rmin2, rmax2, phi1, phi2);
2252 void TGeoConeSeg::SetPoints(Double_t *points)
const
2255 Float_t dphi,phi,phi1, phi2,dz;
2257 n = gGeoManager->GetNsegments()+1;
2262 dphi = (phi2-phi1)/(n-1);
2267 for (j = 0; j < n; j++) {
2268 phi = (fPhi1+j*dphi)*TMath::DegToRad();
2269 points[indx++] = fRmin1 * TMath::Cos(phi);
2270 points[indx++] = fRmin1 * TMath::Sin(phi);
2271 points[indx++] = -dz;
2273 for (j = 0; j < n; j++) {
2274 phi = (fPhi1+j*dphi)*TMath::DegToRad();
2275 points[indx++] = fRmax1 * TMath::Cos(phi);
2276 points[indx++] = fRmax1 * TMath::Sin(phi);
2277 points[indx++] = -dz;
2279 for (j = 0; j < n; j++) {
2280 phi = (fPhi1+j*dphi)*TMath::DegToRad();
2281 points[indx++] = fRmin2 * TMath::Cos(phi);
2282 points[indx++] = fRmin2 * TMath::Sin(phi);
2283 points[indx++] = dz;
2285 for (j = 0; j < n; j++) {
2286 phi = (fPhi1+j*dphi)*TMath::DegToRad();
2287 points[indx++] = fRmax2 * TMath::Cos(phi);
2288 points[indx++] = fRmax2 * TMath::Sin(phi);
2289 points[indx++] = dz;
2297 void TGeoConeSeg::SetPoints(Float_t *points)
const
2300 Float_t dphi,phi,phi1, phi2,dz;
2302 n = gGeoManager->GetNsegments()+1;
2307 dphi = (phi2-phi1)/(n-1);
2312 for (j = 0; j < n; j++) {
2313 phi = (fPhi1+j*dphi)*TMath::DegToRad();
2314 points[indx++] = fRmin1 * TMath::Cos(phi);
2315 points[indx++] = fRmin1 * TMath::Sin(phi);
2316 points[indx++] = -dz;
2318 for (j = 0; j < n; j++) {
2319 phi = (fPhi1+j*dphi)*TMath::DegToRad();
2320 points[indx++] = fRmax1 * TMath::Cos(phi);
2321 points[indx++] = fRmax1 * TMath::Sin(phi);
2322 points[indx++] = -dz;
2324 for (j = 0; j < n; j++) {
2325 phi = (fPhi1+j*dphi)*TMath::DegToRad();
2326 points[indx++] = fRmin2 * TMath::Cos(phi);
2327 points[indx++] = fRmin2 * TMath::Sin(phi);
2328 points[indx++] = dz;
2330 for (j = 0; j < n; j++) {
2331 phi = (fPhi1+j*dphi)*TMath::DegToRad();
2332 points[indx++] = fRmax2 * TMath::Cos(phi);
2333 points[indx++] = fRmax2 * TMath::Sin(phi);
2334 points[indx++] = dz;
2342 void TGeoConeSeg::GetMeshNumbers(Int_t &nvert, Int_t &nsegs, Int_t &npols)
const
2344 Int_t n = gGeoManager->GetNsegments()+1;
2353 Int_t TGeoConeSeg::GetNmeshVertices()
const
2355 Int_t n = gGeoManager->GetNsegments()+1;
2356 Int_t numPoints = n*4;
2363 void TGeoConeSeg::Sizeof3D()
const
2370 const TBuffer3D & TGeoConeSeg::GetBuffer3D(Int_t reqSections, Bool_t localFrame)
const
2372 static TBuffer3D buffer(TBuffer3DTypes::kGeneric);
2374 TGeoBBox::FillBuffer3D(buffer, reqSections, localFrame);
2376 if (reqSections & TBuffer3D::kRawSizes) {
2377 Int_t n = gGeoManager->GetNsegments()+1;
2379 Int_t nbSegs = 2*nbPnts;
2380 Int_t nbPols = nbPnts-2;
2381 if (buffer.SetRawSizes(nbPnts, 3*nbPnts, nbSegs, 3*nbSegs, nbPols, 6*nbPols)) {
2382 buffer.SetSectionsValid(TBuffer3D::kRawSizes);
2385 if ((reqSections & TBuffer3D::kRaw) && buffer.SectionsValid(TBuffer3D::kRawSizes)) {
2386 SetPoints(buffer.fPnts);
2387 if (!buffer.fLocalFrame) {
2388 TransformPoints(buffer.fPnts, buffer.NbPnts());
2391 SetSegsAndPols(buffer);
2392 buffer.SetSectionsValid(TBuffer3D::kRaw);
2403 Bool_t TGeoConeSeg::GetPointsOnSegments(Int_t npoints, Double_t *array)
const
2405 if (npoints > (npoints/2)*2) {
2406 Error(
"GetPointsOnSegments",
"Npoints must be even number");
2409 Int_t nc = (Int_t)TMath::Sqrt(0.5*npoints);
2410 Double_t dphi = (fPhi2-fPhi1)*TMath::DegToRad()/(nc-1);
2412 Double_t phi1 = fPhi1 * TMath::DegToRad();
2413 Int_t ntop = npoints/2 - nc*(nc-1);
2414 Double_t dz = 2*fDz/(nc-1);
2421 for (Int_t i=0; i<nc; i++) {
2424 dphi = (fPhi2-fPhi1)*TMath::DegToRad()/(nphi-1);
2427 rmin = 0.5*(fRmin1+fRmin2) + 0.5*(fRmin2-fRmin1)*z/fDz;
2428 rmax = 0.5*(fRmax1+fRmax2) + 0.5*(fRmax2-fRmax1)*z/fDz;
2430 for (Int_t j=0; j<nphi; j++) {
2431 phi = phi1 + j*dphi;
2432 array[icrt++] = rmin * TMath::Cos(phi);
2433 array[icrt++] = rmin * TMath::Sin(phi);
2435 array[icrt++] = rmax * TMath::Cos(phi);
2436 array[icrt++] = rmax * TMath::Sin(phi);
2448 void TGeoConeSeg::Contains_v(
const Double_t *points, Bool_t *inside, Int_t vecsize)
const
2450 for (Int_t i=0; i<vecsize; i++) inside[i] = Contains(&points[3*i]);
2458 void TGeoConeSeg::ComputeNormal_v(
const Double_t *points,
const Double_t *dirs, Double_t *norms, Int_t vecsize)
2460 for (Int_t i=0; i<vecsize; i++) ComputeNormal(&points[3*i], &dirs[3*i], &norms[3*i]);
2466 void TGeoConeSeg::DistFromInside_v(
const Double_t *points,
const Double_t *dirs, Double_t *dists, Int_t vecsize, Double_t* step)
const
2468 for (Int_t i=0; i<vecsize; i++) dists[i] = DistFromInside(&points[3*i], &dirs[3*i], 3, step[i]);
2474 void TGeoConeSeg::DistFromOutside_v(
const Double_t *points,
const Double_t *dirs, Double_t *dists, Int_t vecsize, Double_t* step)
const
2476 for (Int_t i=0; i<vecsize; i++) dists[i] = DistFromOutside(&points[3*i], &dirs[3*i], 3, step[i]);
2484 void TGeoConeSeg::Safety_v(
const Double_t *points,
const Bool_t *inside, Double_t *safe, Int_t vecsize)
const
2486 for (Int_t i=0; i<vecsize; i++) safe[i] = Safety(&points[3*i], inside[i]);