7 #include "cetlib_except/exception.h" 16 double xlo,
double xhi,
17 double ylo,
double yhi,
18 double zlo,
double zhi,
21 const double intercept[],
22 const double slopes[],
26 double x_lo,
double x_hi,
27 double y_lo,
double y_hi,
28 double z_lo,
double z_hi,
51 double xlo,
double xhi,
52 double ylo,
double yhi,
53 double zlo,
double zhi,
57 if( !(xyz[0]>=xlo && xyz[0]<=xhi) ||
58 !(xyz[1]>=ylo && xyz[1]<=yhi) ||
59 !(xyz[2]>=zlo && xyz[2]<=zhi) )
61 <<
" in the specififed box\n";
67 if (dxyz[0]>0.0) { dx = (xhi-xyz[0])/dxyz[0]; }
68 else if (dxyz[0]<0.0) { dx = (xlo-xyz[0])/dxyz[0]; }
69 if (dxyz[1]>0.0) { dy = (yhi-xyz[1])/dxyz[1]; }
70 else if (dxyz[1]<0.0) { dy = (ylo-xyz[1])/dxyz[1]; }
71 if (dxyz[2]>0.0) { dz = (zhi-xyz[2])/dxyz[2]; }
72 else if (dxyz[2]<0.0) { dz = (zlo-xyz[2])/dxyz[2]; }
76 if (dx<dy && dx<dz) d = dx;
77 else if (dy<dz && dy<dx) d = dy;
78 else if (dz<dx && dz<dy) d = dz;
81 for (
int i=0; i<3; ++i) {
82 xyzout[i] = xyz[i] + dxyz[i]*
d;
97 const double intercept[],
98 const double slopes[],
102 (slopes[0]*(point[0]-intercept[0]) +
103 slopes[1]*(point[1]-intercept[1]) +
104 slopes[2]*(point[2]-intercept[2]));
106 (slopes[0]*slopes[0] +
107 slopes[1]*slopes[1] +
108 slopes[2]*slopes[2]);
111 closest[0] = intercept[0] + s*slopes[0];
112 closest[1] = intercept[1] + s*slopes[1];
113 closest[2] = intercept[2] + s*slopes[2];
120 closest[0] = intercept[0];
121 closest[1] = intercept[1];
122 closest[2] = intercept[2];
124 return std::sqrt(
pow((point[0]-closest[0]),2)+
125 pow((point[1]-closest[1]),2)+
126 pow((point[2]-closest[2]),2));
162 double lo[3] = { x_lo , y_lo , z_lo };
163 double hi[3] = { x_hi , y_hi , z_hi };
166 double facecoord[6] = { lo[0] , hi[0] ,
170 int intersect[6]={0,0,0,0,0,0};
173 for(
int i=0; i<3; i++) {
175 for(
int p=0;
p<2;
p++ ) {
177 point[i] = facecoord[
count];
178 distance[i] = point[i] - x0[i];
180 double C_dg = distance[i] / gradient[i];
182 for(
int m=0;
m<3;
m++){ distance[
m] = C_dg * gradient[
m]; }
183 for(
int n=0;
n<3;
n++){ point[
n] = x0[
n] + distance[
n]; }
187 case 0: j=1; k=2;
break;
188 case 1: j=2; k=0;
break;
189 case 2: j=0; k=1;
break;
191 throw std::logic_error(
"Big trouble");
195 if ( lo[j] < point[j] && point[j] < hi[j]
196 && lo[k] < point[k] && point[k] < hi[k] ) {
204 / std::sqrt( (distance[i]*distance[i]) * (gradient[i]*gradient[i]) );
205 bool directed = ( direction + 1 ) / 2;
211 int normal =
pow( -1 , count + 1 );
212 int thru = normal * gradient[i] / std::sqrt(gradient[i]*gradient[i]) ;
213 intersect[
count]=thru;
223 for (
int face=0; face<6; ++face ) {
224 passes+=(intersect[face]*intersect[face]);
bool CrossesBoundary(double x0[], double gradient[], double x_lo, double x_hi, double y_lo, double y_hi, double z_lo, double z_hi, double point[])
double distance(double x1, double y1, double z1, double x2, double y2, double z2)
double ClosestApproach(const double point[], const double intercept[], const double slopes[], double closest[])
void ProjectToBoxEdge(const double xyz[], const double dxyz[], double xlo, double xhi, double ylo, double yhi, double zlo, double zhi, double xyzout[])
LArSoft geometry interface.
cet::coded_exception< error, detail::translate > exception