101{
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
139
140
141
142
143
144
145
146
147 G4double rnorm = MaxRadius - MinRadius;
148 rho = MinRadius*MinRadius / (rnorm*rnorm);
149 a0 = 4. * MaxRadius*MaxRadius;
150 b0 = MaxRadius*MaxRadius - MinRadius*MinRadius;
151
152
153 f = 1. - DCos.
y()*DCos.
y();
154 l = 2. * (Base.
x()*DCos.
x() + Base.
z()*DCos.
z());
155 t = Base.
x()*Base.
x() + Base.
z()*Base.
z();
156 g1 = f + rho * DCos.
y()*DCos.
y();
157 q = a0 / (g1*g1);
158 m1 = (l + 2.*rho*DCos.
y()*Base.
y()) / g1;
159 u = (t + rho*Base.
y()*Base.
y() + b0) / g1;
160
161
162
163 C[4] = 1.0;
164 C[3] = 2. * m1;
165 C[2] = m1*m1 + 2.*u - q*f;
166 C[1] = 2.*m1*u - q*l;
167 C[0] = u*u - q*t;
168
169
170 nhits = SolveQuartic (C,rhits);
171
172
173 m1 = rhits[0]; u = rhits[1]; rhits[0] = u; rhits[1] = m1;
174 m1 = rhits[2]; u = rhits[3]; rhits[2] = u; rhits[3] = m1;
175
176
177
178 if(nhits != 0)
179 {
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
202
203 for(
G4int a=0;a<nhits;a++)
204 {
205 while ( (c1 < 4) && (hits[c1] <= rhits[a]) )
206 {
207 tempVec[c1]=hits[c1];
208 c1++;
209 }
210
211 for(c2=c1+1;c2<4;c2++)
212 tempVec[c2]=hits[c2-1];
213
214 if(c1<4)
215 {
216 tempVec[c1]=rhits[a];
217
218 for(c2=0;c2<4;c2++)
219 hits[c2]=tempVec[c2];
220 }
221 }
222
223 for(
G4int b=0;b<nhits;b++)
224 {
225
227 {
228 Hit = Base + (hits[b]*DCos);
229
230 if( (Hit.
x() > BoxMin.
x()) &&
231 (Hit.
x() < BoxMax.
x()) &&
232 (Hit.
y() > BoxMin.
y()) &&
233 (Hit.
y() < BoxMax.
y()) &&
234 (Hit.
z() > BoxMin.
z()) &&
235 (Hit.
z() < BoxMax.
z()) )
236 {
239 return 1;
240 }
241
242
243 }
244 }
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260 return 1;
261 }
262 return 0;
263}
G4Point3D GetBoxMin() const
G4Point3D GetBoxMax() const
const G4Vector3D & GetDir() const
const G4Point3D & GetStart() const