83 Fatal(
"TGeoVoxelFinder",
"Null pointer for volume");
186 for (
id=0;
id<nd;
id++) {
190 box->SetBoxPoints(&vert[0]);
191 for (
Int_t point=0; point<8; point++) {
194 xyz[0] = xyz[1] =
pt[0];
195 xyz[2] = xyz[3] =
pt[1];
196 xyz[4] = xyz[5] =
pt[2];
199 for (
Int_t j=0; j<3; j++) {
200 if (
pt[j] < xyz[2*j]) xyz[2*j]=
pt[j];
201 if (
pt[j] > xyz[2*j+1]) xyz[2*j+1]=
pt[j];
205 fBoxes[6*
id+1] = 0.5*(xyz[3]-xyz[2]);
206 fBoxes[6*
id+2] = 0.5*(xyz[5]-xyz[4]);
207 fBoxes[6*
id+3] = 0.5*(xyz[0]+xyz[1]);
208 fBoxes[6*
id+4] = 0.5*(xyz[2]+xyz[3]);
209 fBoxes[6*
id+5] = 0.5*(xyz[4]+xyz[5]);
220 if (!mat) memcpy(master,local,3*
sizeof(
Double_t));
234 Double_t dxyz, minsafe2=minsafe*minsafe;
238 for (i=0; i<3; i++) {
240 if (dxyz>-1E-6) rsq+=dxyz*dxyz;
261 for (
id=0;
id<
fIbx-1;
id++) {
265 else printf(
"Woops : slice X\n");
267 printf(
"X efficiency : %g\n", effslice);
271 for (
id=0;
id<
fIby-1;
id++) {
275 else printf(
"Woops : slice X\n");
277 printf(
"Y efficiency : %g\n", effslice);
281 for (
id=0;
id<
fIbz-1;
id++) {
285 else printf(
"Woops : slice X\n");
287 printf(
"Z efficiency : %g\n", effslice);
290 printf(
"Total efficiency : %g\n", eff);
300 Double_t xmin1, xmax1, ymin1, ymax1, zmin1, zmax1;
314 for (
Int_t ib=0; ib<nd; ib++) {
315 if (ib == inode)
continue;
325 if (ddx1*ddx2 <= 0.)
continue;
328 if (ddx1*ddx2 <= 0.)
continue;
331 if (ddx1*ddx2 <= 0.)
continue;
339 ovlps =
new Int_t[novlp];
340 memcpy(ovlps, otmp, novlp*
sizeof(
Int_t));
455 for (icand=0; icand<ncheck; icand++) {
456 bitnumber = (
UInt_t)list[icand];
459 byte = (~td.fVoxBits1[loc]) & (1<<bit);
475 for (icand=0; icand<ncheck; icand++) {
476 bitnumber = (
UInt_t)list[icand];
479 byte = (~td.fVoxBits1[loc]) & array1[loc] & (1<<bit);
495 for (icand=0; icand<ncheck; icand++) {
496 bitnumber = (
UInt_t)list[icand];
499 byte = (~td.fVoxBits1[loc]) & array1[loc] & array2[loc] & (1<<bit);
539 if (dind[0]<0 || dind[0]>
fIbx-1)
return 0;
552 dforced[0] = dmin[0];
555 if (isXlimit)
return 0;
561 dforced[0] = dmin[0];
564 if (isXlimit)
return 0;
579 if (dind[1]<0 || dind[1]>
fIby-1)
return 0;
593 dforced[1] = dmin[1];
596 if (isYlimit)
return 0;
602 dforced[1] = dmin[1];
605 if (isYlimit)
return 0;
620 if (dind[2]<0 || dind[2]>
fIbz-1)
return 0;
634 dforced[2] = dmin[2];
637 if (isZlimit)
return 0;
643 dforced[2] = dmin[2];
646 if (isZlimit)
return 0;
669 if (dforced[1]>dslice) {
675 if (dforced[2]>dslice) {
684 if (dforced[2]>dslice) {
697 if (dforced[2]>dslice) {
711 dslice = dmin[islice];
712 if (dslice>=maxstep) {
722 Int_t ndd[2] = {0,0};
727 if (isXlimit)
return 0;
734 if ((dslice>dmin[1]) && td.
fVoxInc[1]) {
749 if ((dslice>dmin[2]) && td.
fVoxInc[2]) {
836 return GetValidExtra(ndd[0], slice1, ndd[1], slice2, new_list, ncheck, td);
839 if (isYlimit)
return 0;
846 if ((dslice>dmin[0]) && td.
fVoxInc[0]) {
861 if ((dslice>dmin[2]) && td.
fVoxInc[2]) {
948 return GetValidExtra(ndd[0], slice1, ndd[1], slice2, new_list, ncheck, td);
951 if (isZlimit)
return 0;
958 if ((dslice>dmin[1]) && td.
fVoxInc[1]) {
973 if ((dslice>dmin[0]) && td.
fVoxInc[0]) {
1060 return GetValidExtra(ndd[0], slice1, ndd[1], slice2, new_list, ncheck, td);
1086 for (
Int_t i=0; i<3; i++) {
1089 td.
fVoxInc[i] = (dir[i]>0)?1:-1;
1146 memset(&nd[0], 0, 3*
sizeof(
Int_t));
1168 if (slicex && slicey) {
1213 if (point[0]<
fXb[0] || point[0]>
fXb[1])
return 0;
1216 if (point[1]<
fYb[0] || point[1]>
fYb[1])
return 0;
1220 if (point[2]<
fZb[0] || point[2]>
fZb[1])
return 0;
1230 Int_t nd[3] = {0,0,0};
1234 if ((im==-1) || (im==
fIbx-1))
return 0;
1237 if (!nd[0])
return 0;
1245 if ((im==-1) || (im==
fIby-1))
return 0;
1248 if (!nd[1])
return 0;
1261 if ((im==-1) || (im==
fIbz-1))
return 0;
1264 if (!nd[2])
return 0;
1266 if (slice1 && slice2) {
1307 Int_t nd[3] = {0,0,0};
1311 if (!nd[0])
return 0;
1318 if (!nd[1])
return 0;
1330 if (!nd[2])
return 0;
1332 if (slice1 && slice2) {
1393 Int_t nbytes = 1+((nd-1)>>3);
1398 for (current_byte=0; current_byte<nbytes; current_byte++) {
1399 byte = array1[current_byte];
1400 if (!
byte)
continue;
1401 for (current_bit=0; current_bit<8; current_bit++) {
1402 if (
byte & (1<<current_bit)) {
1403 result[nf++] = (current_byte<<3)+current_bit;
1410 if (ibreak)
return kTRUE;
1423 Int_t nbytes = 1+((nd-1)>>3);
1438 for (current_byte=0; current_byte<nbytes; current_byte++) {
1439 byte = array1[current_byte];
1440 icand = current_byte<<3;
1441 if (!
byte)
continue;
1442 for (current_bit=0; current_bit<8; current_bit++) {
1443 if (
byte & (1<<current_bit)) {
1451 if (ibreak)
return kTRUE;
1465 Int_t nbytes = 1+((nd-1)>>3);
1470 for (current_byte=0; current_byte<nbytes; current_byte++) {
1472 byte = (~td.fVoxBits1[current_byte]) & array1[current_byte];
1473 if (!
byte)
continue;
1474 for (current_bit=0; current_bit<8; current_bit++) {
1475 if (
byte & (1<<current_bit)) {
1484 if (ibreak)
return kTRUE;
1498 Int_t nbytes = 1+((nd-1)>>3);
1502 for (current_byte=0; current_byte<nbytes; current_byte++) {
1503 byte = (~td.fVoxBits1[current_byte]) & (array1[current_byte] & array2[current_byte]);
1504 if (!
byte)
continue;
1505 for (current_bit=0; current_bit<8; current_bit++) {
1506 if (
byte & (1<<current_bit)) {
1525 Int_t nbytes = 1+((nd-1)>>3);
1529 for (current_byte=0; current_byte<nbytes; current_byte++) {
1530 byte = (~td.fVoxBits1[current_byte]) & (array1[current_byte] & array2[current_byte] & array3[current_byte]);
1531 if (!
byte)
continue;
1532 for (current_bit=0; current_bit<8; current_bit++) {
1533 if (
byte & (1<<current_bit)) {
1549 Int_t nbytes = 1+((nd-1)>>3);
1554 for (current_byte=0; current_byte<nbytes; current_byte++) {
1555 byte = array1[current_byte] & array2[current_byte];
1556 if (!
byte)
continue;
1557 for (current_bit=0; current_bit<8; current_bit++) {
1558 if (
byte & (1<<current_bit)) {
1559 result[nf++] = (current_byte<<3)+current_bit;
1560 if ((nf==n1) || (nf==n2)) {
1566 if (ibreak)
return kTRUE;
1579 Int_t nbytes = 1+((nd-1)>>3);
1585 for (current_byte=0; current_byte<nbytes; current_byte++) {
1586 byte = array1[current_byte] & array2[current_byte];
1587 icand = current_byte<<3;
1589 if (!
byte)
continue;
1590 for (current_bit=0; current_bit<8; current_bit++) {
1591 if (
byte & (1<<current_bit)) {
1606 Int_t nbytes = 1+((nd-1)>>3);
1611 for (current_byte=0; current_byte<nbytes; current_byte++) {
1612 byte = array1[current_byte] & array2[current_byte] & array3[current_byte];
1613 if (!
byte)
continue;
1614 for (current_bit=0; current_bit<8; current_bit++) {
1615 if (
byte & (1<<current_bit)) {
1616 result[nf++] = (current_byte<<3)+current_bit;
1617 if ((nf==n1) || (nf==n2) || (nf==n3)) {
1623 if (ibreak)
return kTRUE;
1636 Int_t nbytes = 1+((nd-1)>>3);
1642 for (current_byte=0; current_byte<nbytes; current_byte++) {
1643 byte = array1[current_byte] & array2[current_byte] & array3[current_byte];
1644 icand = current_byte<<3;
1646 if (!
byte)
continue;
1647 for (current_bit=0; current_bit<8; current_bit++) {
1648 if (
byte & (1<<current_bit)) {
1662 Int_t nmaxslices = 2*nd+1;
1670 zmin = (
box->GetOrigin())[2] -
box->GetDZ();
1671 zmax = (
box->GetOrigin())[2] +
box->GetDZ();
1679 for (
id=0;
id<nd;
id++) {
1685 boundaries[2*
id+2*nd+1] =
fBoxes[6*
id+4]+
fBoxes[6*
id+1];
1688 boundaries[2*
id+4*nd+1] =
fBoxes[6*
id+5]+
fBoxes[6*
id+2];
1700 Int_t nleft, nright;
1703 Double_t xxmin, xxmax, xbmin, xbmax, ddx1, ddx2;
1712 for (
id=0;
id<2*nd;
id++) {
1713 if (!ib) {temp[ib++] = boundaries[index[
id]];
continue;}
1714 if (
TMath::Abs(temp[ib-1]-boundaries[index[
id]])>1E-10)
1715 temp[ib++] = boundaries[index[
id]];
1720 delete [] boundaries;
1725 delete [] extra_left;
1726 delete [] extra_right;
1732 if (((temp[0]-
xmin)<1E-10) && ((temp[1]-
xmax)>-1E-10)) {
1760 memset(ind, 0, (nmaxslices*nperslice)*
sizeof(
UChar_t));
1771 for (
id=0;
id<
fNox;
id++) {
1775 extra[indextra] = extra[indextra+1] = 0;
1777 bits = &ind[current];
1780 for (
Int_t ic=0; ic<nd; ic++) {
1784 if (ddx1>-1E-10)
continue;
1786 if (ddx2<1E-10)
continue;
1793 bits[loc] |= 1<<bit;
1798 if ((
id==0) || (ddx1>-1E-10)) {
1799 extra_left[nleft++] = ic;
1802 if ((
id==(
fNoz-1)) || (ddx2<1E-10)) {
1803 extra_right[nright++] = ic;
1807 if (
fNsliceX[
id]>0) current += nperslice;
1809 extra[indextra] = nleft;
1810 extra[indextra+1] = nright;
1811 if (nleft) memcpy(&extra[indextra+2], extra_left, nleft*
sizeof(
Int_t));
1812 if (nright) memcpy(&extra[indextra+2+nleft], extra_right, nright*
sizeof(
Int_t));
1813 indextra += 2+nleft+nright;
1821 if (indextra>nmaxslices*4) printf(
"Woops!!!\n");
1830 for (
id=0;
id<2*nd;
id++) {
1831 if (!ib) {temp[ib++] = boundaries[2*nd+index[
id]];
continue;}
1832 if (
TMath::Abs(temp[ib-1]-boundaries[2*nd+index[
id]])>1E-10)
1833 temp[ib++]=boundaries[2*nd+index[
id]];
1838 delete [] boundaries;
1843 delete [] extra_left;
1844 delete [] extra_right;
1850 if (((temp[0]-
ymin)<1E-10) && ((temp[1]-
ymax)>-1E-10)) {
1880 memset(ind, 0, (nmaxslices*nperslice)*
sizeof(
UChar_t));
1891 for (
id=0;
id<
fNoy;
id++) {
1895 extra[indextra] = extra[indextra+1] = 0;
1897 bits = &ind[current];
1900 for (
Int_t ic=0; ic<nd; ic++) {
1904 if (ddx1>-1E-10)
continue;
1906 if (ddx2<1E-10)
continue;
1913 bits[loc] |= 1<<bit;
1918 if ((
id==0) || (ddx1>-1E-10)) {
1919 extra_left[nleft++] = ic;
1922 if ((
id==(
fNoz-1)) || (ddx2<1E-10)) {
1923 extra_right[nright++] = ic;
1927 if (
fNsliceY[
id]>0) current += nperslice;
1929 extra[indextra] = nleft;
1930 extra[indextra+1] = nright;
1931 if (nleft) memcpy(&extra[indextra+2], extra_left, nleft*
sizeof(
Int_t));
1932 if (nright) memcpy(&extra[indextra+2+nleft], extra_right, nright*
sizeof(
Int_t));
1933 indextra += 2+nleft+nright;
1941 if (indextra>nmaxslices*4) printf(
"Woops!!!\n");
1950 for (
id=0;
id<2*nd;
id++) {
1951 if (!ib) {temp[ib++] = boundaries[4*nd+index[
id]];
continue;}
1952 if ((
TMath::Abs(temp[ib-1]-boundaries[4*nd+index[
id]]))>1E-10)
1953 temp[ib++]=boundaries[4*nd+index[
id]];
1958 delete [] boundaries;
1963 delete [] extra_left;
1964 delete [] extra_right;
1970 if (((temp[0]-zmin)<1E-10) && ((temp[1]-zmax)>-1E-10)) {
2000 memset(ind, 0, (nmaxslices*nperslice)*
sizeof(
UChar_t));
2011 for (
id=0;
id<
fNoz;
id++) {
2015 extra[indextra] = extra[indextra+1] = 0;
2017 bits = &ind[current];
2020 for (
Int_t ic=0; ic<nd; ic++) {
2024 if (ddx1>-1E-10)
continue;
2026 if (ddx2<1E-10)
continue;
2033 bits[loc] |= 1<<bit;
2038 if ((
id==0) || (ddx1>-1E-10)) {
2039 extra_left[nleft++] = ic;
2042 if ((
id==(
fNoz-1)) || (ddx2<1E-10)) {
2043 extra_right[nright++] = ic;
2047 if (
fNsliceZ[
id]>0) current += nperslice;
2049 extra[indextra] = nleft;
2050 extra[indextra+1] = nright;
2051 if (nleft) memcpy(&extra[indextra+2], extra_left, nleft*
sizeof(
Int_t));
2052 if (nright) memcpy(&extra[indextra+2+nleft], extra_right, nright*
sizeof(
Int_t));
2053 indextra += 2+nleft+nright;
2061 if (indextra>nmaxslices*4) printf(
"Woops!!!\n");
2065 delete [] boundaries;
2070 delete [] extra_left;
2071 delete [] extra_right;
2075 if (nd>1)
Error(
"SortAll",
"Volume %s: Cannot make slices on any axis",
fVolume->
GetName());
2100 for (
id=0;
id<
fIbx;
id++) {
2101 printf(
"%15.10f\n",
fXb[
id]);
2102 if (
id == (
fIbx-1))
break;
2103 printf(
"slice %i : %i\n",
id,
fNsliceX[
id]);
2106 for (i=0; i<nbytes; i++) {
2108 for (bit=0; bit<8; bit++) {
2109 if (
byte & (1<<bit)) printf(
" %i ", 8*i+bit);
2115 printf(
" extra_about_left = %i\n", nextra);
2117 printf(
" extra_about_right = %i\n", nextra);
2120 printf(
"%15.10f\n",
fXb[0]);
2121 for (
id=0;
id<nd;
id++) printf(
" %i ",
id);
2123 printf(
"%15.10f\n",
fXb[1]);
2127 for (
id=0;
id<
fIby;
id++) {
2128 printf(
"%15.10f\n",
fYb[
id]);
2129 if (
id == (
fIby-1))
break;
2130 printf(
"slice %i : %i\n",
id,
fNsliceY[
id]);
2133 for (i=0; i<nbytes; i++) {
2135 for (bit=0; bit<8; bit++) {
2136 if (
byte & (1<<bit)) printf(
" %i ", 8*i+bit);
2141 printf(
" extra_about_left = %i\n", nextra);
2143 printf(
" extra_about_right = %i\n", nextra);
2146 printf(
"%15.10f\n",
fYb[0]);
2147 for (
id=0;
id<nd;
id++) printf(
" %i ",
id);
2149 printf(
"%15.10f\n",
fYb[1]);
2154 for (
id=0;
id<
fIbz;
id++) {
2155 printf(
"%15.10f\n",
fZb[
id]);
2156 if (
id == (
fIbz-1))
break;
2157 printf(
"slice %i : %i\n",
id,
fNsliceZ[
id]);
2160 for (i=0; i<nbytes; i++) {
2162 for (bit=0; bit<8; bit++) {
2163 if (
byte & (1<<bit)) printf(
" %i ", 8*i+bit);
2169 printf(
" extra_about_left = %i\n", nextra);
2171 printf(
" extra_about_right = %i\n", nextra);
2174 printf(
"%15.10f\n",
fZb[0]);
2175 for (
id=0;
id<nd;
id++) printf(
" %i ",
id);
2177 printf(
"%15.10f\n",
fZb[1]);
2194 if ((im==-1) || (im==
fIbx-1)) {
2195 printf(
"Voxel X limits: OUT\n");
2197 printf(
"Voxel X limits: %g %g\n",
fXb[im],
fXb[im+1]);
2202 if ((im==-1) || (im==
fIby-1)) {
2203 printf(
"Voxel Y limits: OUT\n");
2205 printf(
"Voxel Y limits: %g %g\n",
fYb[im],
fYb[im+1]);
2210 if ((im==-1) || (im==
fIbz-1)) {
2211 printf(
"Voxel Z limits: OUT\n");
2213 printf(
"Voxel Z limits: %g %g\n",
fZb[im],
fZb[im+1]);
2226 for (
Int_t i=0; i<nd; i++) {
2237void TGeoVoxelFinder::Streamer(
TBuffer &R__b)
2243 R__b.
ReadClassBuffer(TGeoVoxelFinder::Class(),
this, R__v, R__s, R__c);
R__EXTERN TGeoManager * gGeoManager
Buffer base class used for serializing objects.
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
virtual void ReadFastArray(Bool_t *b, Int_t n)=0
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
virtual const Double_t * GetOrigin() const
Geometrical transformation package.
virtual void LocalToMaster(const Double_t *local, Double_t *master) const
convert a point by multiplying its column vector (x, y, z, 1) to matrix inverse
A node represent a volume positioned inside another.They store links to both volumes and to the TGeoM...
TGeoVolume * GetVolume() const
void SetOverlaps(Int_t *ovlp, Int_t novlp)
set the list of overlaps for this node (ovlp must be created with operator new)
virtual TGeoMatrix * GetMatrix() const =0
static Bool_t IsSameWithinTolerance(Double_t a, Double_t b)
Check if two numbers differ with less than a tolerance.
virtual void ComputeBBox()=0
static Double_t Tolerance()
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
void SetCylVoxels(Bool_t flag=kTRUE)
Int_t GetNdaughters() const
void FindOverlaps() const
loop all nodes marked as overlaps and find overlapping brothers
TGeoNode * GetNode(const char *name) const
get the pointer to a daughter node
TGeoShape * GetShape() const
virtual Bool_t IsAssembly() const
Returns true if the volume is an assembly or a scaled assembly.
Finder class handling voxels.
Bool_t Union(Int_t n1, UChar_t *array1, TGeoStateInfo &td)
make union of older bits with new array printf("Union - one slice\n");
void SetNeedRebuild(Bool_t flag=kTRUE)
virtual Int_t * GetCheckList(const Double_t *point, Int_t &nelem, TGeoStateInfo &td)
get the list of daughter indices for which point is inside their bbox
virtual Int_t * GetNextVoxel(const Double_t *point, const Double_t *dir, Int_t &ncheck, TGeoStateInfo &td)
get the list of new candidates for the next voxel crossed by current ray printf("### GetNextVoxel\n")...
virtual ~TGeoVoxelFinder()
Destructor.
virtual void Voxelize(Option_t *option="")
Voxelize attached volume according to option If the volume is an assembly, make sure the bbox is comp...
void DaughterToMother(Int_t id, const Double_t *local, Double_t *master) const
convert a point from the local reference system of node id to reference system of mother volume
Bool_t Intersect(Int_t n1, UChar_t *array1, Int_t &nf, Int_t *result)
return the list of nodes corresponding to one array of bits
virtual Int_t * GetNextCandidates(const Double_t *point, Int_t &ncheck, TGeoStateInfo &td)
Returns list of new candidates in next voxel.
Bool_t GetIndices(const Double_t *point, TGeoStateInfo &td)
Get indices for current slices on x, y, z.
void SortAll(Option_t *option="")
order bounding boxes along x, y, z
Bool_t IsSafeVoxel(const Double_t *point, Int_t inode, Double_t minsafe) const
Computes squared distance from POINT to the voxel(s) containing node INODE.
Int_t * GetExtraY(Int_t islice, Bool_t left, Int_t &nextra) const
Return the list of extra candidates in a given Y slice compared to another (left or right)
void BuildVoxelLimits()
build the array of bounding boxes of the nodes inside
Int_t * GetVoxelCandidates(Int_t i, Int_t j, Int_t k, Int_t &ncheck, TGeoStateInfo &td)
get the list of candidates in voxel (i,j,k) - no check
void SetInvalid(Bool_t flag=kTRUE)
virtual void FindOverlaps(Int_t inode) const
create the list of nodes for which the bboxes overlap with inode's bbox
void PrintVoxelLimits(const Double_t *point) const
print the voxel containing point
Bool_t NeedRebuild() const
Int_t GetNcandidates(TGeoStateInfo &td) const
virtual Double_t Efficiency()
Compute voxelization efficiency.
virtual void Print(Option_t *option="") const
Print the voxels.
virtual void SortCrossedVoxels(const Double_t *point, const Double_t *dir, TGeoStateInfo &td)
get the list in the next voxel crossed by a ray
Int_t * GetExtraZ(Int_t islice, Bool_t left, Int_t &nextra) const
Return the list of extra candidates in a given Z slice compared to another (left or right)
Int_t * GetExtraX(Int_t islice, Bool_t left, Int_t &nextra) const
Return the list of extra candidates in a given X slice compared to another (left or right)
Int_t * GetValidExtra(Int_t *list, Int_t &ncheck, TGeoStateInfo &td)
Get extra candidates that are not contained in current check list.
Bool_t IntersectAndStore(Int_t n1, UChar_t *array1, TGeoStateInfo &td)
return the list of nodes corresponding to one array of bits
TGeoVoxelFinder()
Default constructor.
virtual const char * GetName() const
Returns name of object.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Long64_t LocMin(Long64_t n, const T *a)
Return index of array with the minimum element.
Short_t Min(Short_t a, Short_t b)
void Sort(Index n, const Element *a, Index *index, Bool_t down=kTRUE)
Long64_t BinarySearch(Long64_t n, const T *array, T value)
Statefull info for the current geometry level.