84 Fatal(
"TGeoVoxelFinder",
"Null pointer for volume");
187 for (
id=0;
id<nd;
id++) {
191 box->SetBoxPoints(&vert[0]);
192 for (
Int_t point=0; point<8; point++) {
195 xyz[0] = xyz[1] =
pt[0];
196 xyz[2] = xyz[3] =
pt[1];
197 xyz[4] = xyz[5] =
pt[2];
200 for (
Int_t j=0; j<3; j++) {
201 if (
pt[j] < xyz[2*j]) xyz[2*j]=
pt[j];
202 if (
pt[j] > xyz[2*j+1]) xyz[2*j+1]=
pt[j];
206 fBoxes[6*
id+1] = 0.5*(xyz[3]-xyz[2]);
207 fBoxes[6*
id+2] = 0.5*(xyz[5]-xyz[4]);
208 fBoxes[6*
id+3] = 0.5*(xyz[0]+xyz[1]);
209 fBoxes[6*
id+4] = 0.5*(xyz[2]+xyz[3]);
210 fBoxes[6*
id+5] = 0.5*(xyz[4]+xyz[5]);
221 if (!mat) memcpy(master,local,3*
sizeof(
Double_t));
235 Double_t dxyz, minsafe2=minsafe*minsafe;
239 for (i=0; i<3; i++) {
241 if (dxyz>-1
E-6) rsq+=dxyz*dxyz;
262 for (
id=0;
id<
fIbx-1;
id++) {
266 else printf(
"Woops : slice X\n");
268 printf(
"X efficiency : %g\n", effslice);
272 for (
id=0;
id<
fIby-1;
id++) {
276 else printf(
"Woops : slice X\n");
278 printf(
"Y efficiency : %g\n", effslice);
282 for (
id=0;
id<
fIbz-1;
id++) {
286 else printf(
"Woops : slice X\n");
288 printf(
"Z efficiency : %g\n", effslice);
291 printf(
"Total efficiency : %g\n", eff);
301 Double_t xmin1, xmax1, ymin1, ymax1, zmin1, zmax1;
315 for (
Int_t ib=0; ib<nd; ib++) {
316 if (ib == inode)
continue;
326 if (ddx1*ddx2 <= 0.)
continue;
329 if (ddx1*ddx2 <= 0.)
continue;
332 if (ddx1*ddx2 <= 0.)
continue;
340 ovlps =
new Int_t[novlp];
341 memcpy(ovlps, otmp, novlp*
sizeof(
Int_t));
456 for (icand=0; icand<ncheck; icand++) {
457 bitnumber = (
UInt_t)list[icand];
460 byte = (~td.fVoxBits1[loc]) & (1<<bit);
476 for (icand=0; icand<ncheck; icand++) {
477 bitnumber = (
UInt_t)list[icand];
480 byte = (~td.fVoxBits1[loc]) & array1[loc] & (1<<bit);
496 for (icand=0; icand<ncheck; icand++) {
497 bitnumber = (
UInt_t)list[icand];
500 byte = (~td.fVoxBits1[loc]) & array1[loc] & array2[loc] & (1<<bit);
540 if (dind[0]<0 || dind[0]>
fIbx-1)
return 0;
553 dforced[0] = dmin[0];
556 if (isXlimit)
return 0;
562 dforced[0] = dmin[0];
565 if (isXlimit)
return 0;
580 if (dind[1]<0 || dind[1]>
fIby-1)
return 0;
594 dforced[1] = dmin[1];
597 if (isYlimit)
return 0;
603 dforced[1] = dmin[1];
606 if (isYlimit)
return 0;
621 if (dind[2]<0 || dind[2]>
fIbz-1)
return 0;
635 dforced[2] = dmin[2];
638 if (isZlimit)
return 0;
644 dforced[2] = dmin[2];
647 if (isZlimit)
return 0;
670 if (dforced[1]>dslice) {
676 if (dforced[2]>dslice) {
685 if (dforced[2]>dslice) {
698 if (dforced[2]>dslice) {
712 dslice = dmin[islice];
713 if (dslice>=maxstep) {
723 Int_t ndd[2] = {0,0};
728 if (isXlimit)
return 0;
735 if ((dslice>dmin[1]) && td.
fVoxInc[1]) {
750 if ((dslice>dmin[2]) && td.
fVoxInc[2]) {
837 return GetValidExtra(ndd[0], slice1, ndd[1], slice2, new_list, ncheck, td);
840 if (isYlimit)
return 0;
847 if ((dslice>dmin[0]) && td.
fVoxInc[0]) {
862 if ((dslice>dmin[2]) && td.
fVoxInc[2]) {
949 return GetValidExtra(ndd[0], slice1, ndd[1], slice2, new_list, ncheck, td);
952 if (isZlimit)
return 0;
959 if ((dslice>dmin[1]) && td.
fVoxInc[1]) {
974 if ((dslice>dmin[0]) && td.
fVoxInc[0]) {
1061 return GetValidExtra(ndd[0], slice1, ndd[1], slice2, new_list, ncheck, td);
1087 for (
Int_t i=0; i<3; i++) {
1090 td.
fVoxInc[i] = (dir[i]>0)?1:-1;
1147 memset(&nd[0], 0, 3*
sizeof(
Int_t));
1169 if (slicex && slicey) {
1214 if (point[0]<
fXb[0] || point[0]>
fXb[1])
return 0;
1217 if (point[1]<
fYb[0] || point[1]>
fYb[1])
return 0;
1221 if (point[2]<
fZb[0] || point[2]>
fZb[1])
return 0;
1231 Int_t nd[3] = {0,0,0};
1235 if ((im==-1) || (im==
fIbx-1))
return 0;
1238 if (!nd[0])
return 0;
1246 if ((im==-1) || (im==
fIby-1))
return 0;
1249 if (!nd[1])
return 0;
1262 if ((im==-1) || (im==
fIbz-1))
return 0;
1265 if (!nd[2])
return 0;
1267 if (slice1 && slice2) {
1308 Int_t nd[3] = {0,0,0};
1312 if (!nd[0])
return 0;
1319 if (!nd[1])
return 0;
1331 if (!nd[2])
return 0;
1333 if (slice1 && slice2) {
1394 Int_t nbytes = 1+((nd-1)>>3);
1399 for (current_byte=0; current_byte<nbytes; current_byte++) {
1400 byte = array1[current_byte];
1401 if (!
byte)
continue;
1402 for (current_bit=0; current_bit<8; current_bit++) {
1403 if (
byte & (1<<current_bit)) {
1404 result[nf++] = (current_byte<<3)+current_bit;
1411 if (ibreak)
return kTRUE;
1424 Int_t nbytes = 1+((nd-1)>>3);
1439 for (current_byte=0; current_byte<nbytes; current_byte++) {
1440 byte = array1[current_byte];
1441 icand = current_byte<<3;
1442 if (!
byte)
continue;
1443 for (current_bit=0; current_bit<8; current_bit++) {
1444 if (
byte & (1<<current_bit)) {
1452 if (ibreak)
return kTRUE;
1466 Int_t nbytes = 1+((nd-1)>>3);
1471 for (current_byte=0; current_byte<nbytes; current_byte++) {
1473 byte = (~td.fVoxBits1[current_byte]) & array1[current_byte];
1474 if (!
byte)
continue;
1475 for (current_bit=0; current_bit<8; current_bit++) {
1476 if (
byte & (1<<current_bit)) {
1485 if (ibreak)
return kTRUE;
1499 Int_t nbytes = 1+((nd-1)>>3);
1503 for (current_byte=0; current_byte<nbytes; current_byte++) {
1504 byte = (~td.fVoxBits1[current_byte]) & (array1[current_byte] & array2[current_byte]);
1505 if (!
byte)
continue;
1506 for (current_bit=0; current_bit<8; current_bit++) {
1507 if (
byte & (1<<current_bit)) {
1526 Int_t nbytes = 1+((nd-1)>>3);
1530 for (current_byte=0; current_byte<nbytes; current_byte++) {
1531 byte = (~td.fVoxBits1[current_byte]) & (array1[current_byte] & array2[current_byte] & array3[current_byte]);
1532 if (!
byte)
continue;
1533 for (current_bit=0; current_bit<8; current_bit++) {
1534 if (
byte & (1<<current_bit)) {
1550 Int_t nbytes = 1+((nd-1)>>3);
1555 for (current_byte=0; current_byte<nbytes; current_byte++) {
1556 byte = array1[current_byte] & array2[current_byte];
1557 if (!
byte)
continue;
1558 for (current_bit=0; current_bit<8; current_bit++) {
1559 if (
byte & (1<<current_bit)) {
1560 result[nf++] = (current_byte<<3)+current_bit;
1561 if ((nf==n1) || (nf==n2)) {
1567 if (ibreak)
return kTRUE;
1580 Int_t nbytes = 1+((nd-1)>>3);
1586 for (current_byte=0; current_byte<nbytes; current_byte++) {
1587 byte = array1[current_byte] & array2[current_byte];
1588 icand = current_byte<<3;
1590 if (!
byte)
continue;
1591 for (current_bit=0; current_bit<8; current_bit++) {
1592 if (
byte & (1<<current_bit)) {
1607 Int_t nbytes = 1+((nd-1)>>3);
1612 for (current_byte=0; current_byte<nbytes; current_byte++) {
1613 byte = array1[current_byte] & array2[current_byte] & array3[current_byte];
1614 if (!
byte)
continue;
1615 for (current_bit=0; current_bit<8; current_bit++) {
1616 if (
byte & (1<<current_bit)) {
1617 result[nf++] = (current_byte<<3)+current_bit;
1618 if ((nf==n1) || (nf==n2) || (nf==n3)) {
1624 if (ibreak)
return kTRUE;
1637 Int_t nbytes = 1+((nd-1)>>3);
1643 for (current_byte=0; current_byte<nbytes; current_byte++) {
1644 byte = array1[current_byte] & array2[current_byte] & array3[current_byte];
1645 icand = current_byte<<3;
1647 if (!
byte)
continue;
1648 for (current_bit=0; current_bit<8; current_bit++) {
1649 if (
byte & (1<<current_bit)) {
1663 Int_t nmaxslices = 2*nd+1;
1671 zmin = (
box->GetOrigin())[2] -
box->GetDZ();
1672 zmax = (
box->GetOrigin())[2] +
box->GetDZ();
1680 for (
id=0;
id<nd;
id++) {
1686 boundaries[2*
id+2*nd+1] =
fBoxes[6*
id+4]+
fBoxes[6*
id+1];
1689 boundaries[2*
id+4*nd+1] =
fBoxes[6*
id+5]+
fBoxes[6*
id+2];
1701 Int_t nleft, nright;
1704 Double_t xxmin, xxmax, xbmin, xbmax, ddx1, ddx2;
1713 for (
id=0;
id<2*nd;
id++) {
1714 if (!ib) {temp[ib++] = boundaries[index[
id]];
continue;}
1715 if (
TMath::Abs(temp[ib-1]-boundaries[index[
id]])>1
E-10)
1716 temp[ib++] = boundaries[index[
id]];
1721 delete [] boundaries;
1726 delete [] extra_left;
1727 delete [] extra_right;
1733 if (((temp[0]-
xmin)<1
E-10) && ((temp[1]-
xmax)>-1
E-10)) {
1761 memset(ind, 0, (nmaxslices*nperslice)*
sizeof(
UChar_t));
1772 for (
id=0;
id<
fNox;
id++) {
1776 extra[indextra] = extra[indextra+1] = 0;
1778 bits = &ind[current];
1781 for (
Int_t ic=0; ic<nd; ic++) {
1785 if (ddx1>-1
E-10)
continue;
1787 if (ddx2<1
E-10)
continue;
1794 bits[loc] |= 1<<bit;
1799 if ((
id==0) || (ddx1>-1
E-10)) {
1800 extra_left[nleft++] = ic;
1803 if ((
id==(
fNoz-1)) || (ddx2<1
E-10)) {
1804 extra_right[nright++] = ic;
1808 if (
fNsliceX[
id]>0) current += nperslice;
1810 extra[indextra] = nleft;
1811 extra[indextra+1] = nright;
1812 if (nleft) memcpy(&extra[indextra+2], extra_left, nleft*
sizeof(
Int_t));
1813 if (nright) memcpy(&extra[indextra+2+nleft], extra_right, nright*
sizeof(
Int_t));
1814 indextra += 2+nleft+nright;
1822 if (indextra>nmaxslices*4) printf(
"Woops!!!\n");
1831 for (
id=0;
id<2*nd;
id++) {
1832 if (!ib) {temp[ib++] = boundaries[2*nd+index[
id]];
continue;}
1833 if (
TMath::Abs(temp[ib-1]-boundaries[2*nd+index[
id]])>1
E-10)
1834 temp[ib++]=boundaries[2*nd+index[
id]];
1839 delete [] boundaries;
1844 delete [] extra_left;
1845 delete [] extra_right;
1851 if (((temp[0]-
ymin)<1
E-10) && ((temp[1]-
ymax)>-1
E-10)) {
1881 memset(ind, 0, (nmaxslices*nperslice)*
sizeof(
UChar_t));
1892 for (
id=0;
id<
fNoy;
id++) {
1896 extra[indextra] = extra[indextra+1] = 0;
1898 bits = &ind[current];
1901 for (
Int_t ic=0; ic<nd; ic++) {
1905 if (ddx1>-1
E-10)
continue;
1907 if (ddx2<1
E-10)
continue;
1914 bits[loc] |= 1<<bit;
1919 if ((
id==0) || (ddx1>-1
E-10)) {
1920 extra_left[nleft++] = ic;
1923 if ((
id==(
fNoz-1)) || (ddx2<1
E-10)) {
1924 extra_right[nright++] = ic;
1928 if (
fNsliceY[
id]>0) current += nperslice;
1930 extra[indextra] = nleft;
1931 extra[indextra+1] = nright;
1932 if (nleft) memcpy(&extra[indextra+2], extra_left, nleft*
sizeof(
Int_t));
1933 if (nright) memcpy(&extra[indextra+2+nleft], extra_right, nright*
sizeof(
Int_t));
1934 indextra += 2+nleft+nright;
1942 if (indextra>nmaxslices*4) printf(
"Woops!!!\n");
1951 for (
id=0;
id<2*nd;
id++) {
1952 if (!ib) {temp[ib++] = boundaries[4*nd+index[
id]];
continue;}
1953 if ((
TMath::Abs(temp[ib-1]-boundaries[4*nd+index[
id]]))>1
E-10)
1954 temp[ib++]=boundaries[4*nd+index[
id]];
1959 delete [] boundaries;
1964 delete [] extra_left;
1965 delete [] extra_right;
1971 if (((temp[0]-zmin)<1
E-10) && ((temp[1]-zmax)>-1
E-10)) {
2001 memset(ind, 0, (nmaxslices*nperslice)*
sizeof(
UChar_t));
2012 for (
id=0;
id<
fNoz;
id++) {
2016 extra[indextra] = extra[indextra+1] = 0;
2018 bits = &ind[current];
2021 for (
Int_t ic=0; ic<nd; ic++) {
2025 if (ddx1>-1
E-10)
continue;
2027 if (ddx2<1
E-10)
continue;
2034 bits[loc] |= 1<<bit;
2039 if ((
id==0) || (ddx1>-1
E-10)) {
2040 extra_left[nleft++] = ic;
2043 if ((
id==(
fNoz-1)) || (ddx2<1
E-10)) {
2044 extra_right[nright++] = ic;
2048 if (
fNsliceZ[
id]>0) current += nperslice;
2050 extra[indextra] = nleft;
2051 extra[indextra+1] = nright;
2052 if (nleft) memcpy(&extra[indextra+2], extra_left, nleft*
sizeof(
Int_t));
2053 if (nright) memcpy(&extra[indextra+2+nleft], extra_right, nright*
sizeof(
Int_t));
2054 indextra += 2+nleft+nright;
2062 if (indextra>nmaxslices*4) printf(
"Woops!!!\n");
2066 delete [] boundaries;
2071 delete [] extra_left;
2072 delete [] extra_right;
2076 if (nd>1)
Error(
"SortAll",
"Volume %s: Cannot make slices on any axis",
fVolume->
GetName());
2101 for (
id=0;
id<
fIbx;
id++) {
2102 printf(
"%15.10f\n",
fXb[
id]);
2103 if (
id == (
fIbx-1))
break;
2104 printf(
"slice %i : %i\n",
id,
fNsliceX[
id]);
2107 for (i=0; i<nbytes; i++) {
2109 for (bit=0; bit<8; bit++) {
2110 if (
byte & (1<<bit)) printf(
" %i ", 8*i+bit);
2116 printf(
" extra_about_left = %i\n", nextra);
2118 printf(
" extra_about_right = %i\n", nextra);
2121 printf(
"%15.10f\n",
fXb[0]);
2122 for (
id=0;
id<nd;
id++) printf(
" %i ",
id);
2124 printf(
"%15.10f\n",
fXb[1]);
2128 for (
id=0;
id<
fIby;
id++) {
2129 printf(
"%15.10f\n",
fYb[
id]);
2130 if (
id == (
fIby-1))
break;
2131 printf(
"slice %i : %i\n",
id,
fNsliceY[
id]);
2134 for (i=0; i<nbytes; i++) {
2136 for (bit=0; bit<8; bit++) {
2137 if (
byte & (1<<bit)) printf(
" %i ", 8*i+bit);
2142 printf(
" extra_about_left = %i\n", nextra);
2144 printf(
" extra_about_right = %i\n", nextra);
2147 printf(
"%15.10f\n",
fYb[0]);
2148 for (
id=0;
id<nd;
id++) printf(
" %i ",
id);
2150 printf(
"%15.10f\n",
fYb[1]);
2155 for (
id=0;
id<
fIbz;
id++) {
2156 printf(
"%15.10f\n",
fZb[
id]);
2157 if (
id == (
fIbz-1))
break;
2158 printf(
"slice %i : %i\n",
id,
fNsliceZ[
id]);
2161 for (i=0; i<nbytes; i++) {
2163 for (bit=0; bit<8; bit++) {
2164 if (
byte & (1<<bit)) printf(
" %i ", 8*i+bit);
2170 printf(
" extra_about_left = %i\n", nextra);
2172 printf(
" extra_about_right = %i\n", nextra);
2175 printf(
"%15.10f\n",
fZb[0]);
2176 for (
id=0;
id<nd;
id++) printf(
" %i ",
id);
2178 printf(
"%15.10f\n",
fZb[1]);
2195 if ((im==-1) || (im==
fIbx-1)) {
2196 printf(
"Voxel X limits: OUT\n");
2198 printf(
"Voxel X limits: %g %g\n",
fXb[im],
fXb[im+1]);
2203 if ((im==-1) || (im==
fIby-1)) {
2204 printf(
"Voxel Y limits: OUT\n");
2206 printf(
"Voxel Y limits: %g %g\n",
fYb[im],
fYb[im+1]);
2211 if ((im==-1) || (im==
fIbz-1)) {
2212 printf(
"Voxel Z limits: OUT\n");
2214 printf(
"Voxel Z limits: %g %g\n",
fZb[im],
fZb[im+1]);
2227 for (
Int_t i=0; i<nd; i++) {
2238void TGeoVoxelFinder::Streamer(
TBuffer &R__b)
static RooMathCoreReg dummy
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
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.
constexpr Double_t E()
Base of natural log:
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.