82 Fatal(
"TGeoVoxelFinder",
"Null pointer for volume");
176 return td.fVoxNcandidates;
184 return td.fVoxCheckList;
206 for (
id = 0;
id < nd;
id++) {
211 for (
Int_t point = 0; point < 8; point++) {
214 xyz[0] = xyz[1] =
pt[0];
215 xyz[2] = xyz[3] =
pt[1];
216 xyz[4] = xyz[5] =
pt[2];
220 if (
pt[
j] < xyz[2 *
j])
222 if (
pt[
j] > xyz[2 *
j + 1])
223 xyz[2 *
j + 1] =
pt[
j];
226 fBoxes[6 *
id] = 0.5 * (xyz[1] - xyz[0]);
227 fBoxes[6 *
id + 1] = 0.5 * (xyz[3] - xyz[2]);
228 fBoxes[6 *
id + 2] = 0.5 * (xyz[5] - xyz[4]);
229 fBoxes[6 *
id + 3] = 0.5 * (xyz[0] + xyz[1]);
230 fBoxes[6 *
id + 4] = 0.5 * (xyz[2] + xyz[3]);
231 fBoxes[6 *
id + 5] = 0.5 * (xyz[4] + xyz[5]);
262 for (i = 0; i < 3; i++) {
287 for (
id = 0;
id <
fIbx - 1;
id++) {
293 printf(
"Woops : slice X\n");
299 for (
id = 0;
id <
fIby - 1;
id++) {
305 printf(
"Woops : slice X\n");
311 for (
id = 0;
id <
fIbz - 1;
id++) {
317 printf(
"Woops : slice X\n");
322 printf(
"Total efficiency : %g\n", eff);
387 td.fVoxSlices[0] = -2;
388 td.fVoxSlices[1] = -2;
389 td.fVoxSlices[2] = -2;
393 if ((
td.fVoxSlices[0] < 0) || (
td.fVoxSlices[0] >=
fIbx - 1)) {
406 if ((
td.fVoxSlices[1] < 0) || (
td.fVoxSlices[1] >=
fIby - 1)) {
419 if ((
td.fVoxSlices[2] < 0) || (
td.fVoxSlices[2] >=
fIbz - 1))
436 Int_t *list =
nullptr;
456 Int_t *list =
nullptr;
476 Int_t *list =
nullptr;
495 td.fVoxNcandidates = 0;
503 byte = (
~td.fVoxBits1[
loc]) & (1 <<
bit);
505 td.fVoxCheckList[
td.fVoxNcandidates++] = list[
icand];
508 return td.fVoxCheckList;
516 td.fVoxNcandidates = 0;
526 td.fVoxCheckList[
td.fVoxNcandidates++] = list[
icand];
529 return td.fVoxCheckList;
538 td.fVoxNcandidates = 0;
548 td.fVoxCheckList[
td.fVoxNcandidates++] = list[
icand];
551 return td.fVoxCheckList;
565 if (
td.fVoxLimits[0] < 0)
567 if (
td.fVoxLimits[1] < 0)
569 if (
td.fVoxLimits[2] < 0)
589 if (
td.fVoxInc[0] == 1) {
594 if (
td.fVoxSlices[0] < 0 ||
td.fVoxSlices[0] >
fIbx - 1)
596 dmin[0] = (
fXb[
td.fVoxSlices[0]] - point[0]) *
td.fVoxInvdir[0];
603 if ((
td.fVoxSlices[0] == -1) || (
td.fVoxSlices[0] ==
fIbx - 1)) {
626 dmin[0] =
td.fVoxLimits[0];
633 if (
td.fVoxInc[1] == 1) {
638 if (
td.fVoxSlices[1] < 0 ||
td.fVoxSlices[1] >
fIby - 1)
640 dmin[1] = (
fYb[
td.fVoxSlices[1]] - point[1]) *
td.fVoxInvdir[1];
648 if ((
td.fVoxSlices[1] == -1) || (
td.fVoxSlices[1] ==
fIby - 1)) {
671 dmin[1] =
td.fVoxLimits[1];
678 if (
td.fVoxInc[2] == 1) {
683 if (
td.fVoxSlices[2] < 0 ||
td.fVoxSlices[2] >
fIbz - 1)
685 dmin[2] = (
fZb[
td.fVoxSlices[2]] - point[2]) *
td.fVoxInvdir[2];
693 if ((
td.fVoxSlices[2] == -1) || (
td.fVoxSlices[2] ==
fIbz - 1)) {
716 dmin[2] =
td.fVoxLimits[2];
793 td.fVoxSlices[0] =
dind[0];
804 td.fVoxSlices[1] +=
td.fVoxInc[1];
805 if (
td.fVoxInc[1] == 1) {
806 if (
td.fVoxSlices[1] < -1 ||
td.fVoxSlices[1] >
fIby - 2)
811 if (
td.fVoxSlices[1] < 0 ||
td.fVoxSlices[1] >
fIby - 1)
823 td.fVoxSlices[2] +=
td.fVoxInc[2];
824 if (
td.fVoxInc[2] == 1) {
825 if (
td.fVoxSlices[2] < -1 ||
td.fVoxSlices[2] >
fIbz - 2)
830 if (
td.fVoxSlices[2] < 0 ||
td.fVoxSlices[2] >
fIbz - 1)
844 if (
td.fVoxSlices[1] < 0 ||
td.fVoxSlices[1] >=
fIby - 1)
845 return td.fVoxCheckList;
848 return td.fVoxCheckList;
853 if (
td.fVoxSlices[2] < 0 ||
td.fVoxSlices[2] >=
fIbz - 1)
854 return td.fVoxCheckList;
857 return td.fVoxCheckList;
872 return td.fVoxCheckList;
879 return td.fVoxCheckList;
881 if (
td.fVoxSlices[1] < 0 ||
td.fVoxSlices[1] >=
fIby - 1) {
883 return td.fVoxCheckList;
888 return td.fVoxCheckList;
894 if (
td.fVoxSlices[2] < 0 ||
td.fVoxSlices[2] >=
fIbz - 1) {
896 return td.fVoxCheckList;
901 return td.fVoxCheckList;
922 td.fVoxSlices[1] =
dind[1];
933 td.fVoxSlices[0] +=
td.fVoxInc[0];
934 if (
td.fVoxInc[0] == 1) {
935 if (
td.fVoxSlices[0] < -1 ||
td.fVoxSlices[0] >
fIbx - 2)
940 if (
td.fVoxSlices[0] < 0 ||
td.fVoxSlices[0] >
fIbx - 1)
952 td.fVoxSlices[2] +=
td.fVoxInc[2];
953 if (
td.fVoxInc[2] == 1) {
954 if (
td.fVoxSlices[2] < -1 ||
td.fVoxSlices[2] >
fIbz - 2)
959 if (
td.fVoxSlices[2] < 0 ||
td.fVoxSlices[2] >
fIbz - 1)
973 if (
td.fVoxSlices[0] < 0 ||
td.fVoxSlices[0] >=
fIbx - 1)
974 return td.fVoxCheckList;
977 return td.fVoxCheckList;
982 if (
td.fVoxSlices[2] < 0 ||
td.fVoxSlices[2] >=
fIbz - 1)
983 return td.fVoxCheckList;
986 return td.fVoxCheckList;
1001 return td.fVoxCheckList;
1008 return td.fVoxCheckList;
1010 if (
td.fVoxSlices[0] < 0 ||
td.fVoxSlices[0] >=
fIbx - 1) {
1012 return td.fVoxCheckList;
1017 return td.fVoxCheckList;
1023 if (
td.fVoxSlices[2] < 0 ||
td.fVoxSlices[2] >=
fIbz - 1) {
1025 return td.fVoxCheckList;
1030 return td.fVoxCheckList;
1051 td.fVoxSlices[2] =
dind[2];
1062 td.fVoxSlices[1] +=
td.fVoxInc[1];
1063 if (
td.fVoxInc[1] == 1) {
1064 if (
td.fVoxSlices[1] < -1 ||
td.fVoxSlices[1] >
fIby - 2)
1069 if (
td.fVoxSlices[1] < 0 ||
td.fVoxSlices[1] >
fIby - 1)
1081 td.fVoxSlices[0] +=
td.fVoxInc[0];
1082 if (
td.fVoxInc[0] == 1) {
1083 if (
td.fVoxSlices[0] < -1 ||
td.fVoxSlices[0] >
fIbx - 2)
1088 if (
td.fVoxSlices[0] < 0 ||
td.fVoxSlices[0] >
fIbx - 1)
1102 if (
td.fVoxSlices[1] < 0 ||
td.fVoxSlices[1] >=
fIby - 1)
1103 return td.fVoxCheckList;
1106 return td.fVoxCheckList;
1111 if (
td.fVoxSlices[0] < 0 ||
td.fVoxSlices[0] >=
fIbx - 1)
1112 return td.fVoxCheckList;
1115 return td.fVoxCheckList;
1130 return td.fVoxCheckList;
1137 return td.fVoxCheckList;
1139 if (
td.fVoxSlices[1] < 0 ||
td.fVoxSlices[1] >=
fIby - 1) {
1141 return td.fVoxCheckList;
1146 return td.fVoxCheckList;
1152 if (
td.fVoxSlices[0] < 0 ||
td.fVoxSlices[0] >=
fIbx - 1) {
1154 return td.fVoxCheckList;
1159 return td.fVoxCheckList;
1193 td.fVoxNcandidates = 0;
1199 for (
Int_t i = 0; i < 3; i++) {
1203 td.fVoxInc[i] = (dir[i] > 0) ? 1 : -1;
1204 td.fVoxInvdir[i] = 1. / dir[i];
1209 if (
td.fVoxInc[0] == 0) {
1212 if (
td.fVoxSlices[0] == -2) {
1214 td.fVoxLimits[0] = (
box_orig[0] - point[0] +
td.fVoxInc[0] *
box->GetDX()) *
td.fVoxInvdir[0];
1216 if (
td.fVoxInc[0] == 1) {
1217 td.fVoxLimits[0] = (
fXb[
fIbx - 1] - point[0]) *
td.fVoxInvdir[0];
1219 td.fVoxLimits[0] = (
fXb[0] - point[0]) *
td.fVoxInvdir[0];
1223 if (
td.fVoxInc[1] == 0) {
1226 if (
td.fVoxSlices[1] == -2) {
1228 td.fVoxLimits[1] = (
box_orig[1] - point[1] +
td.fVoxInc[1] *
box->GetDY()) *
td.fVoxInvdir[1];
1230 if (
td.fVoxInc[1] == 1) {
1231 td.fVoxLimits[1] = (
fYb[
fIby - 1] - point[1]) *
td.fVoxInvdir[1];
1233 td.fVoxLimits[1] = (
fYb[0] - point[1]) *
td.fVoxInvdir[1];
1237 if (
td.fVoxInc[2] == 0) {
1240 if (
td.fVoxSlices[2] == -2) {
1242 td.fVoxLimits[2] = (
box_orig[2] - point[2] +
td.fVoxInc[2] *
box->GetDZ()) *
td.fVoxInvdir[2];
1244 if (
td.fVoxInc[2] == 1) {
1245 td.fVoxLimits[2] = (
fZb[
fIbz - 1] - point[2]) *
td.fVoxInvdir[2];
1247 td.fVoxLimits[2] = (
fZb[0] - point[2]) *
td.fVoxInvdir[2];
1323 if (point[0] <
fXb[0] || point[0] >
fXb[1])
1327 if (point[1] <
fYb[0] || point[1] >
fYb[1])
1332 if (point[2] <
fZb[0] || point[2] >
fZb[1])
1335 td.fVoxCheckList[0] = 0;
1337 return td.fVoxCheckList;
1343 Int_t nd[3] = {0, 0, 0};
1347 if ((
im == -1) || (
im ==
fIbx - 1))
1360 if ((
im == -1) || (
im ==
fIby - 1))
1378 if ((
im == -1) || (
im ==
fIbz - 1))
1408 return td.fVoxCheckList;
1420 Int_t nd[3] = {0, 0, 0};
1468 return td.fVoxCheckList;
1482 if (
td.fVoxCurrent == 0) {
1487 return td.fVoxCheckList;
1534 td.fVoxNcandidates = 0;
1538 while (
td.fVoxNcandidates < nd) {
1539 td.fVoxCheckList[
td.fVoxNcandidates] =
td.fVoxNcandidates;
1540 ++
td.fVoxNcandidates;
1558 if (
td.fVoxNcandidates ==
n1) {
1578 td.fVoxNcandidates = 0;
1592 if (
td.fVoxNcandidates ==
n1) {
1602 return (
td.fVoxNcandidates > 0);
1613 td.fVoxNcandidates = 0;
1629 return (
td.fVoxNcandidates > 0);
1642 td.fVoxNcandidates = 0;
1658 return (
td.fVoxNcandidates > 0);
1700 td.fVoxNcandidates = 0;
1719 return (
td.fVoxNcandidates > 0);
1762 td.fVoxNcandidates = 0;
1781 return (
td.fVoxNcandidates > 0);
1798 zmin = (
box->GetOrigin())[2] -
box->GetDZ();
1799 zmax = (
box->GetOrigin())[2] +
box->GetDZ();
1807 for (
id = 0;
id < nd;
id++) {
1812 boundaries[2 *
id + 2 * nd] =
fBoxes[6 *
id + 4] -
fBoxes[6 *
id + 1];
1813 boundaries[2 *
id + 2 * nd + 1] =
fBoxes[6 *
id + 4] +
fBoxes[6 *
id + 1];
1815 boundaries[2 *
id + 4 * nd] =
fBoxes[6 *
id + 5] -
fBoxes[6 *
id + 2];
1816 boundaries[2 *
id + 4 * nd + 1] =
fBoxes[6 *
id + 5] +
fBoxes[6 *
id + 2];
1846 for (
id = 0;
id < 2 * nd;
id++) {
1857 delete[] boundaries;
1869 if (((temp[0] -
xmin) < 1E-10) && ((temp[1] -
xmax) > -1E-10)) {
1915 for (
id = 0;
id <
fNox;
id++) {
1921 bits = &
ind[current];
1944 if ((
id == 0) || (
ddx1 > -1E-10)) {
1948 if ((
id == (
fNoz - 1)) || (
ddx2 < 1E-10)) {
1982 for (
id = 0;
id < 2 * nd;
id++) {
1984 temp[
ib++] = boundaries[2 * nd +
index[
id]];
1988 temp[
ib++] = boundaries[2 * nd +
index[
id]];
1993 delete[] boundaries;
2005 if (((temp[0] -
ymin) < 1E-10) && ((temp[1] -
ymax) > -1E-10)) {
2052 for (
id = 0;
id <
fNoy;
id++) {
2058 bits = &
ind[current];
2081 if ((
id == 0) || (
ddx1 > -1E-10)) {
2085 if ((
id == (
fNoz - 1)) || (
ddx2 < 1E-10)) {
2119 for (
id = 0;
id < 2 * nd;
id++) {
2121 temp[
ib++] = boundaries[4 * nd +
index[
id]];
2125 temp[
ib++] = boundaries[4 * nd +
index[
id]];
2130 delete[] boundaries;
2142 if (((temp[0] - zmin) < 1E-10) && ((temp[1] - zmax) > -1E-10)) {
2189 for (
id = 0;
id <
fNoz;
id++) {
2195 bits = &
ind[current];
2218 if ((
id == 0) || (
ddx1 > -1E-10)) {
2222 if ((
id == (
fNoz - 1)) || (
ddx2 < 1E-10)) {
2251 delete[] boundaries;
2288 for (
id = 0;
id <
fIbx;
id++) {
2290 if (
id == (
fIbx - 1))
2295 for (i = 0; i <
nbytes; i++) {
2298 if (
byte & (1 <<
bit))
2311 for (
id = 0;
id < nd;
id++)
2318 for (
id = 0;
id <
fIby;
id++) {
2320 if (
id == (
fIby - 1))
2325 for (i = 0; i <
nbytes; i++) {
2328 if (
byte & (1 <<
bit))
2340 for (
id = 0;
id < nd;
id++)
2348 for (
id = 0;
id <
fIbz;
id++) {
2350 if (
id == (
fIbz - 1))
2355 for (i = 0; i <
nbytes; i++) {
2358 if (
byte & (1 <<
bit))
2371 for (
id = 0;
id < nd;
id++)
2391 if ((
im == -1) || (
im ==
fIbx - 1)) {
2392 printf(
"Voxel X limits: OUT\n");
2399 if ((
im == -1) || (
im ==
fIby - 1)) {
2400 printf(
"Voxel Y limits: OUT\n");
2407 if ((
im == -1) || (
im ==
fIbz - 1)) {
2408 printf(
"Voxel Z limits: OUT\n");
2424 for (
Int_t i = 0; i < nd; i++) {
2426 if (
vd->IsAssembly())
2427 vd->GetShape()->ComputeBBox();
2438 if (
R__b.IsReading()) {
2448 R__b.ReadFastArray(dummy,
R__c - 2);
bool Bool_t
Boolean (0=false, 1=true) (bool)
short Version_t
Class version identifier (short)
unsigned char UChar_t
Unsigned Character 1 byte (unsigned char)
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
double Double_t
Double 8 bytes.
const char Option_t
Option string (const char)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
R__EXTERN TGeoManager * gGeoManager
Buffer base class used for serializing objects.
Geometrical transformation package.
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.
void Print(Option_t *option="") const override
Print the 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)
void Streamer(TBuffer &) override
Stream an object of class TGeoVoxelFinder.
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")...
~TGeoVoxelFinder() override
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 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.
const char * GetName() const override
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)
Returns index of array with the minimum element.
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
void Sort(Index n, const Element *a, Index *index, Bool_t down=kTRUE)
Sort the n elements of the array a of generic templated type Element.
Long64_t BinarySearch(Long64_t n, const T *array, T value)
Binary search in an array of n values to locate value.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Statefull info for the current geometry level.