Rev 72 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 72 | Rev 73 | ||
---|---|---|---|
Line 18... | Line 18... | ||
18 | int sign(double in) |
18 | int sign(double in) |
19 | { |
19 | { |
20 | if(in >= 0.0) return 1; |
20 | if(in >= 0.0) return 1; |
21 | else return -1; |
21 | else return -1; |
22 | } |
22 | } |
23 | //================================================================================= |
- | |
24 | 23 | ||
25 | //----------------------------------------------------------------------------- |
- | |
26 | void CRay::Set(TVector3 r0, TVector3 |
24 | void CRay::Set(TVector3 r0, TVector3 k0) |
27 | { |
25 | { |
28 | r = r0; |
26 | r = r0; k = k0.Unit(); |
29 | } |
27 | } |
30 | //----------------------------------------------------------------------------- |
28 | //----------------------------------------------------------------------------- |
31 | //void CRay::Set(double x0, double y0, double z0, double l0, double m0, double n0) |
29 | //void CRay::Set(double x0, double y0, double z0, double l0, double m0, double n0) |
32 | //{ |
30 | //{ |
33 | //r.SetXYZ(x0, y0, z0); |
31 | //r.SetXYZ(x0, y0, z0); |
Line 40... | Line 38... | ||
40 | r.SetXYZ(p.GetR().x(), p.GetR().y(), p.GetR().z()); |
38 | r.SetXYZ(p.GetR().x(), p.GetR().y(), p.GetR().z()); |
41 | //this->r.SetXYZ(p.x(), p.y(), p.z()); |
39 | //this->r.SetXYZ(p.x(), p.y(), p.z()); |
42 | n.SetXYZ(p.GetN().x(), p.GetN().y(), p.GetN().z()); |
40 | n.SetXYZ(p.GetN().x(), p.GetN().y(), p.GetN().z()); |
43 | return *this; |
41 | return *this; |
44 | } */ |
42 | } */ |
45 | //----------------------------------------------------------------------------- |
- | |
46 | void CRay::Print() |
43 | void CRay::Print() |
47 | { |
44 | { |
48 | printf("---> CRay::Print() <---\n"); |
45 | printf("---> CRay::Print() <---\n"); |
49 | printf("(x,y,z)=(%.2lf, %.2lf, %.2lf); (l,m,n)=(%.2lf, %.2lf, %.2lf)\n", |
46 | printf("(x,y,z)=(%.2lf, %.2lf, %.2lf); (l,m,n)=(%.2lf, %.2lf, %.2lf)\n", |
50 | r.x(), r.y(), r.z(), |
47 | r.x(), r.y(), r.z(), k.x(), k.y(), k.z()); |
51 | } |
48 | } |
52 | //----------------------------------------------------------------------------- |
- | |
53 | void CRay::Draw() |
49 | void CRay::Draw() |
54 | { |
50 | { |
55 | double t = 50.0; |
51 | double t = 50.0; |
56 | TPolyLine3D *line3d = new TPolyLine3D(2); |
52 | TPolyLine3D *line3d = new TPolyLine3D(2); |
57 | //line3d->SetPoint(0, r.x() - t*n.x(), r.y() - t*n.y(), r.z() - t*n.z()); |
53 | //line3d->SetPoint(0, r.x() - t*n.x(), r.y() - t*n.y(), r.z() - t*n.z()); |
58 | line3d->SetPoint(0, r.x(), r.y(), r.z()); |
54 | line3d->SetPoint(0, r.x(), r.y(), r.z()); |
59 | line3d->SetPoint(1, r.x() + t* |
55 | line3d->SetPoint(1, r.x() + t*k.x(), k.y() + t*k.y(), r.z() + t*k.z()); |
60 | line3d->SetLineWidth(1); |
56 | line3d->SetLineWidth(1); |
61 | line3d->SetLineColor(color); |
57 | line3d->SetLineColor(color); |
62 | 58 | ||
63 | line3d->Draw(); |
59 | line3d->Draw(); |
64 | } |
60 | } |
65 | //----------------------------------------------------------------------------- |
- | |
66 | void CRay::Draw(double x_from, double x_to) |
61 | void CRay::Draw(double x_from, double x_to) |
67 | { |
62 | { |
68 | double A1, A2; |
63 | double A1, A2; |
69 | TPolyLine3D *line3d = new TPolyLine3D(2); |
64 | TPolyLine3D *line3d = new TPolyLine3D(2); |
70 | 65 | ||
71 | if( |
66 | if(k.x() < MARGIN) { |
72 | A1 = A2 = 0.0; |
67 | A1 = A2 = 0.0; |
73 | } else { |
68 | } else { |
74 | A1 = (x_from - r.x())/ |
69 | A1 = (x_from - r.x())/k.x(); |
75 | A2 = (x_to - r.x())/ |
70 | A2 = (x_to - r.x())/k.x(); |
76 | } |
71 | } |
77 | 72 | ||
78 | line3d->SetPoint(0, x_from, A1* |
73 | line3d->SetPoint(0, x_from, A1*k.y()+r.y(), A1*k.z()+r.z()); |
79 | line3d->SetPoint(1, x_to, A2* |
74 | line3d->SetPoint(1, x_to, A2*k.y()+r.y(), A2*k.z()+r.z()); |
80 | line3d->SetLineWidth(1); |
75 | line3d->SetLineWidth(1); |
81 | line3d->SetLineColor(color); |
76 | line3d->SetLineColor(color); |
82 | 77 | ||
83 | line3d->Draw(); |
78 | line3d->Draw(); |
84 | } |
79 | } |
85 | //----------------------------------------------------------------------------- |
- | |
86 | void CRay::DrawS(double x_from, double t) |
80 | void CRay::DrawS(double x_from, double t) |
87 | { |
81 | { |
88 | double A1; |
82 | double A1; |
89 | TPolyLine3D *line3d = new TPolyLine3D(2); |
83 | TPolyLine3D *line3d = new TPolyLine3D(2); |
90 | 84 | ||
91 | if( |
85 | if(k.x() < MARGIN) |
92 | A1 = 0.0; |
86 | A1 = 0.0; |
93 | else |
87 | else |
94 | A1 = (x_from - r.x())/ |
88 | A1 = (x_from - r.x())/k.x(); |
95 | 89 | ||
96 | line3d->SetPoint(0, x_from, A1* |
90 | line3d->SetPoint(0, x_from, A1*k.y()+r.y(), A1*k.z()+r.z()); |
97 | line3d->SetPoint(1, r.x() + t* |
91 | line3d->SetPoint(1, r.x() + t*k.x(), r.y() + t*k.y(), r.z() + t*k.z()); |
98 | line3d->SetLineWidth(1); |
92 | line3d->SetLineWidth(1); |
99 | line3d->SetLineColor(color); |
93 | line3d->SetLineColor(color); |
100 | 94 | ||
101 | line3d->Draw(); |
95 | line3d->Draw(); |
102 | } |
96 | } |
103 | //================================================================================= |
- | |
104 | 97 | ||
105 | 98 | ||
106 | //================================================================================= |
- | |
107 | CPlane4::CPlane4() : |
99 | CPlane4::CPlane4() : |
108 | n(TVector3(1.0, 0.0, 0.0)), |
100 | n(TVector3(1.0, 0.0, 0.0)), |
109 | A(0), |
101 | A(0), |
110 | B(0), |
102 | B(0), |
111 | C(0), |
103 | C(0), |
Line 115... | Line 107... | ||
115 | r[2] = TVector3(0.0, 1.0, 1.0); |
107 | r[2] = TVector3(0.0, 1.0, 1.0); |
116 | r[3] = TVector3(0.0, 1.0,-1.0); |
108 | r[3] = TVector3(0.0, 1.0,-1.0); |
117 | for(int i=0;i<4;i++) edge[i] = TVector3(0,0,0); |
109 | for(int i=0;i<4;i++) edge[i] = TVector3(0,0,0); |
118 | for(int i=0;i<4;i++) angle_r[i] = 0; |
110 | for(int i=0;i<4;i++) angle_r[i] = 0; |
119 | }; |
111 | }; |
120 | //----------------------------------------------------------------------------- |
- | |
121 | CPlane4::CPlane4(TVector3 r1, TVector3 r2, TVector3 r3, TVector3 r4) |
112 | CPlane4::CPlane4(TVector3 r1, TVector3 r2, TVector3 r3, TVector3 r4) |
122 | { |
113 | { |
123 | //Set(r1, r2, r3, r4); |
114 | //Set(r1, r2, r3, r4); |
124 | //} |
115 | //} |
125 | //----------------------------------------------------------------------------- |
116 | //----------------------------------------------------------------------------- |
Line 207... | Line 198... | ||
207 | TVector3 tmp; |
198 | TVector3 tmp; |
208 | 199 | ||
209 | N.SetXYZ(A,B,C); |
200 | N.SetXYZ(A,B,C); |
210 | 201 | ||
211 | num = N*ray.GetR() + D; |
202 | num = N*ray.GetR() + D; |
212 | den = N*ray. |
203 | den = N*ray.GetK(); |
213 | 204 | ||
214 | if (dbg) printf("t = %6.3lf / %6.3lf = %6.3lf\n", num, den, num/den); |
205 | if (dbg) printf("t = %6.3lf / %6.3lf = %6.3lf\n", num, den, num/den); |
215 | 206 | ||
216 | //if(den == 0) |
207 | //if(den == 0) |
217 | if(TMath::Abs(den) < MARGIN) { |
208 | if(TMath::Abs(den) < MARGIN) { |
Line 227... | Line 218... | ||
227 | } |
218 | } |
228 | 219 | ||
229 | t = num / den; |
220 | t = num / den; |
230 | 221 | ||
231 | tmp = ray.GetR(); |
222 | tmp = ray.GetR(); |
232 | tmp -= t*ray. |
223 | tmp -= t*ray.GetK(); |
233 | *vec = tmp; |
224 | *vec = tmp; |
234 | return 1; |
225 | return 1; |
235 | } |
226 | } |
236 | //----------------------------------------------------------------------------- |
227 | //----------------------------------------------------------------------------- |
237 | // ali je vektor vec, ki lezi na ravnini skupaj z e1 in e2, med njima |
228 | // ali je vektor vec, ki lezi na ravnini skupaj z e1 in e2, med njima |
Line 273... | Line 264... | ||
273 | if(!status) return 0; |
264 | if(!status) return 0; |
274 | } |
265 | } |
275 | 266 | ||
276 | return 1; |
267 | return 1; |
277 | } |
268 | } |
278 | //----------------------------------------------------------------------------- |
- | |
279 | int CPlane4::TestIntersection(CRay in) |
269 | int CPlane4::TestIntersection(CRay in) |
280 | { |
270 | { |
281 | TVector3 tmp; |
271 | TVector3 tmp; |
282 | 272 | ||
283 | if( GetIntersection(&tmp, in) ) |
273 | if( GetIntersection(&tmp, in) ) |
284 | if( IsVectorIn(tmp) ) |
274 | if( IsVectorIn(tmp) ) |
285 | return 1; |
275 | return 1; |
286 | 276 | ||
287 | return 0; |
277 | return 0; |
288 | } |
278 | } |
289 | //----------------------------------------------------------------------------- |
- | |
290 | int CPlane4::TestIntersection(TVector3 *vec, CRay in) |
279 | int CPlane4::TestIntersection(TVector3 *vec, CRay in) |
291 | { |
280 | { |
292 | TVector3 tmp; |
281 | TVector3 tmp; |
293 | 282 | ||
294 | if( GetIntersection(&tmp, in) ) |
283 | if( GetIntersection(&tmp, in) ) |
Line 297... | Line 286... | ||
297 | return 1; |
286 | return 1; |
298 | } |
287 | } |
299 | 288 | ||
300 | return 0; |
289 | return 0; |
301 | } |
290 | } |
302 | //----------------------------------------------------------------------------- |
- | |
303 | void CPlane4::Print() |
291 | void CPlane4::Print() |
304 | { |
292 | { |
305 | printf("--- CPlane4::Print() ---\n"); |
293 | printf("--- CPlane4::Print() ---\n"); |
306 | printf(" r=(%.2lf, %.2lf, %.2lf); n=(%.2lf, %.2lf, %.2lf); ", |
294 | printf(" r=(%.2lf, %.2lf, %.2lf); n=(%.2lf, %.2lf, %.2lf); ", |
307 | r[0].x(), r[0].y(), r[0].z(), n.x(), n.y(), n.z()); |
295 | r[0].x(), r[0].y(), r[0].z(), n.x(), n.y(), n.z()); |
308 | printf( "(A,B,C,D)=(%.2lf, %.2lf, %.2lf, %.2lf) \n", A, B, C, D); |
296 | printf( "(A,B,C,D)=(%.2lf, %.2lf, %.2lf, %.2lf) \n", A, B, C, D); |
309 | for(int i=0;i<4;i++) printf(" edge[%d] = (%lf, %lf, %lf)\n", i, edge[i].x(), edge[i].y(), edge[i].z()); |
297 | for(int i=0;i<4;i++) printf(" edge[%d] = (%lf, %lf, %lf)\n", i, edge[i].x(), edge[i].y(), edge[i].z()); |
310 | for(int i=0;i<4;i++) printf(" angle[%d] = %lf\n", i, angle_r[i]*DEGREE); |
298 | for(int i=0;i<4;i++) printf(" angle[%d] = %lf\n", i, angle_r[i]*DEGREE); |
311 | } |
299 | } |
312 | //----------------------------------------------------------------------------- |
- | |
313 | void CPlane4::Draw(int color, int width) |
300 | void CPlane4::Draw(int color, int width) |
314 | { |
301 | { |
315 | TPolyLine3D *line3d = new TPolyLine3D(5); |
302 | TPolyLine3D *line3d = new TPolyLine3D(5); |
316 | 303 | ||
317 | for(int i=0;i<4;i++) line3d->SetPoint(i, r[i].x(), r[i].y(), r[i].z()); |
304 | for(int i=0;i<4;i++) line3d->SetPoint(i, r[i].x(), r[i].y(), r[i].z()); |
318 | line3d->SetPoint(4, r[0].x(), r[0].y(), r[0].z()); |
305 | line3d->SetPoint(4, r[0].x(), r[0].y(), r[0].z()); |
319 | line3d->SetLineWidth(width); line3d->SetLineColor(color); |
306 | line3d->SetLineWidth(width); line3d->SetLineColor(color); |
320 | 307 | ||
321 | line3d->Draw(); |
308 | line3d->Draw(); |
322 | } |
309 | } |
323 | //================================================================================= |
- | |
324 | 310 | ||
325 | 311 | ||
326 | //================================================================================= |
- | |
327 | CSurface::CSurface(int type0): |
312 | CSurface::CSurface(int type0): |
328 | type(type0) |
313 | type(type0) |
329 | { |
314 | { |
330 | TVector3 vr[4]; |
315 | TVector3 vr[4]; |
331 | TDatime now; |
316 | TDatime now; |
Line 336... | Line 321... | ||
336 | vr[3].SetXYZ(0.0, 1.0,-1.0); |
321 | vr[3].SetXYZ(0.0, 1.0,-1.0); |
337 | //CPlane4::Set(vr); |
322 | //CPlane4::Set(vr); |
338 | SetIndex(1.0, 1.5); |
323 | SetIndex(1.0, 1.5); |
339 | 324 | ||
340 | reflection = c_reflectivity; |
325 | reflection = c_reflectivity; |
341 | rand.SetSeed(now.Get()); |
326 | rand.SetSeed(now.Get()); |
342 | 327 | ||
343 | SetFresnel(); |
328 | SetFresnel(); |
344 | } |
329 | } |
345 | //----------------------------------------------------------------------------- |
- | |
346 | CSurface::CSurface(int type0, TVector3 r1, TVector3 r2, TVector3 r3, TVector3 r4, double n10, double n20, double reflectivity) |
330 | CSurface::CSurface(int type0, TVector3 r1, TVector3 r2, TVector3 r3, TVector3 r4, double n10, double n20, double reflectivity) |
347 | { |
331 | { |
348 | TDatime now; |
332 | TDatime now; |
349 | 333 | ||
350 | type = type0; CPlane4::Set(r1, r2, r3, r4); |
334 | type = type0; CPlane4::Set(r1, r2, r3, r4); |
351 | SetIndex(n10, n20); |
335 | SetIndex(n10, n20); |
352 | 336 | ||
353 | reflection = reflectivity; |
337 | reflection = reflectivity; |
354 | rand.SetSeed(now.Get()); |
338 | rand.SetSeed(now.Get()); |
355 | 339 | ||
356 | SetFresnel(); |
340 | SetFresnel(); |
357 | } |
341 | } |
358 | //----------------------------------------------------------------------------- |
- | |
359 | CSurface::CSurface(int type0, TVector3 *vr, double n10, double n20, double reflectivity) |
342 | CSurface::CSurface(int type0, TVector3 *vr, double n10, double n20, double reflectivity) |
360 | { |
343 | { |
361 | TDatime now; |
344 | TDatime now; |
362 | 345 | ||
363 | type = type0; CPlane4::Set(vr); |
346 | type = type0; CPlane4::Set(vr); |
364 | SetIndex(n10, n20); |
347 | SetIndex(n10, n20); |
365 | 348 | ||
366 | reflection = reflectivity; |
349 | reflection = reflectivity; |
367 | rand.SetSeed(now.Get()); |
350 | rand.SetSeed(now.Get()); |
368 | 351 | ||
369 | SetFresnel(); |
352 | SetFresnel(); |
370 | } |
353 | } |
371 | //----------------------------------------------------------------------------- |
- | |
372 | void CSurface::SetIndex(double n10, double n20) |
354 | void CSurface::SetIndex(double n10, double n20) |
373 | { |
355 | { |
374 | n1 = n10; n2 = n20; n1_n2 = n1/n2; |
356 | n1 = n10; n2 = n20; n1_n2 = n1/n2; |
375 | 357 | ||
376 | if(n1 > n2) |
358 | if(n1 > n2) |
377 | cosTtotal = TMath::Sqrt( 1 - TMath::Power(n2/n1, 2) ); |
359 | cosTtotal = TMath::Sqrt( 1 - TMath::Power(n2/n1, 2) ); |
378 | else |
360 | else |
Line 408... | Line 390... | ||
408 | double a_te = 0.0; // s-wave amplitude, cos Alpha |
390 | double a_te = 0.0; // s-wave amplitude, cos Alpha |
409 | double a_tm = 0.0; // p-wave amplitude, sin Alpha |
391 | double a_tm = 0.0; // p-wave amplitude, sin Alpha |
410 | TVector3 v_te; // unit s-polarization vector |
392 | TVector3 v_te; // unit s-polarization vector |
411 | TVector3 v_tm; // unit p-polarization vector |
393 | TVector3 v_tm; // unit p-polarization vector |
412 | TVector3 v_tm_t;// transmited polarization parallel with the plane of incidence |
394 | TVector3 v_tm_t;// transmited polarization parallel with the plane of incidence |
413 | TVector3 pol_t = in.GetP(); // |
395 | TVector3 pol_t = in.GetP(); // incident polarization |
414 | int sign_n; // sign of normal direction vs. inbound ray |
396 | int sign_n; // sign of normal direction vs. inbound ray |
415 | double cosTN; // debug |
397 | double cosTN; // debug |
416 | 398 | ||
- | 399 | // Decomposition of incident polarization vector |
|
- | 400 | // using unit vectors v_tm & v_te |
|
- | 401 | // in a_tm and a_te components |
|
417 |
|
402 | //if(fresnel) { |
418 | // |
403 | // s-polarization unit vector v_te |
419 | // is in the plane orthogonal to the plane of incidence |
404 | // is in the plane orthogonal to the plane of incidence |
420 | // defined as the plane spanned by |
405 | // defined as the plane spanned by |
421 | // incident surface vector n and wave vector k |
406 | // incident surface vector n and wave vector k |
422 | // k in this notation is in. |
407 | // k in this notation is in.GetK() |
423 | v_te = n.Cross(in. |
408 | v_te = n.Cross(in.GetK()); |
424 | v_te = v_te.Unit(); |
409 | v_te = v_te.Unit(); |
425 | v_tm = -v_te.Cross(in. |
410 | v_tm = -v_te.Cross(in.GetK()); |
426 | v_tm = v_tm.Unit(); |
411 | v_tm = v_tm.Unit(); |
427 | if(dbg) { |
412 | if(dbg) { |
428 | printf(" v_te = "); printv(v_te); |
413 | printf(" v_te = "); printv(v_te); |
429 | printf(" v_tm = "); printv(v_tm); |
414 | printf(" v_tm = "); printv(v_tm); |
430 | } |
415 | } |
431 | 416 | ||
432 | double cosAf = v_te * in.GetP(); |
417 | double cosAf = v_te * in.GetP(); |
- | 418 | double alpha = acos(cosAf); |
|
433 | if(dbg) printf(" cosAf = %lf (Af = %lf)\n", cosAf, |
419 | if(dbg) printf(" cosAf = %lf (Af = %lf)\n", cosAf, alpha*DEGREE); |
434 | 420 | ||
435 | a_te = cosAf; |
421 | a_te = cosAf; |
436 | a_tm = TMath::Sqrt(1 - cosAf*cosAf); |
422 | a_tm = TMath::Sqrt(1 - cosAf*cosAf); |
437 | if(dbg) printf(" a_te = %lf, a_tm = %lf\n", a_te, a_tm); |
423 | if(dbg) printf(" a_te = %lf, a_tm = %lf\n", a_te, a_tm); |
438 |
|
424 | //} |
439 | // ---------------------------------------------------------------------------- |
425 | // ---------------------------------------------------------------------------- |
440 | 426 | ||
441 | // reflection probability |
427 | // reflection probability |
442 | double p_ref = rand.Uniform(0.0, 1.0); |
428 | double p_ref = rand.Uniform(0.0, 1.0); |
443 | 429 | ||
Line 445... | Line 431... | ||
445 | switch(type){ |
431 | switch(type){ |
446 | // ---------------------------------------------------------------------------- |
432 | // ---------------------------------------------------------------------------- |
447 | // --------------- refraction from n1 to n2 ----------------------------------- |
433 | // --------------- refraction from n1 to n2 ----------------------------------- |
448 | // ---------------------------------------------------------------------------- |
434 | // ---------------------------------------------------------------------------- |
449 | case SURF_REFRA: |
435 | case SURF_REFRA: |
450 | cosTi = in. |
436 | cosTi = in.GetK() * n; |
451 | if(dbg) printf(" cosTi = %lf (Ti = %lf)\n", cosTi, TMath::ACos(cosTi)*DEGREE); |
437 | if(dbg) printf(" cosTi = %lf (Ti = %lf)\n", cosTi, TMath::ACos(cosTi)*DEGREE); |
452 | sign_n = -sign(cosTi); |
438 | sign_n = -sign(cosTi); |
453 | if(dbg) printf(" sign_n = %d\n", sign_n); |
439 | if(dbg) printf(" sign_n = %d\n", sign_n); |
454 | cosTi = TMath::Abs(cosTi); |
440 | cosTi = TMath::Abs(cosTi); |
455 | 441 | ||
Line 465... | Line 451... | ||
465 | if (dbg) printf(" reflection probability = %f\n", p_ref); |
451 | if (dbg) printf(" reflection probability = %f\n", p_ref); |
466 | 452 | ||
467 | // If n1>n2 and theta>thetaCritical, total reflection |
453 | // If n1>n2 and theta>thetaCritical, total reflection |
468 | if(cosTi < cosTtotal) { |
454 | if(cosTi < cosTtotal) { |
469 | if(dbg) printf(" TOTAL\n"); |
455 | if(dbg) printf(" TOTAL\n"); |
470 | transmit = in. |
456 | transmit = in.GetK() + sign_n*2*cosTi*n; |
471 | 457 | ||
472 | if(dbg) { |
458 | if(dbg) { |
473 | cosTN = TMath::Abs(transmit.Unit() * n); |
459 | cosTN = TMath::Abs(transmit.Unit() * n); |
474 | printf(" cosTN = %lf (TN = %lf) (Abs(TN) = %lf)\n", cosTN, TMath::ACos(cosTN)*DEGREE, TMath::ACos(TMath::Abs(cosTN))*DEGREE); |
460 | printf(" cosTN = %lf (TN = %lf) (Abs(TN) = %lf)\n", cosTN, TMath::ACos(cosTN)*DEGREE, TMath::ACos(TMath::Abs(cosTN))*DEGREE); |
475 | } |
461 | } |
476 | out->Set(intersect, transmit); |
462 | out->Set(intersect, transmit); |
477 | 463 | ||
- | 464 | // Shift implemented, but only linear polarization is implemented |
|
- | 465 | if (dbg) printf("CSurface: Propagate TOTAL\n"); |
|
- | 466 | v_tm_t = -v_te.Cross(transmit); |
|
- | 467 | v_tm_t = v_tm_t.Unit(); |
|
- | 468 | // shift the p and s components |
|
- | 469 | double n12 = N1_N2(-sign_n); |
|
- | 470 | double deltaP = 2 * atan(sqrt(1 - cosTi*cosTi - pow(n12,2))/(pow(n12,2)*cosTi)); |
|
- | 471 | double deltaS = 2 * atan(sqrt(1 - cosTi*cosTi - pow(n12,2))/cosTi); |
|
- | 472 | double delta = deltaP - deltaS; |
|
478 |
|
473 | alpha += delta; |
- | 474 | a_tm = sin(alpha); |
|
- | 475 | a_te = cos(alpha); |
|
- | 476 | if (dbg) printf(" deltaP = %f deltaS = %f; new a_tm = %f, a_te = %f", |
|
- | 477 | deltaP, deltaS, a_tm, a_te); |
|
479 | pol_t = |
478 | pol_t = a_tm*v_tm_t + a_te*v_te; |
- | 479 | if (dbg) printv(pol_t); |
|
480 | out-> |
480 | out->setPolarization(pol_t); |
- | 481 | ||
481 | return REFLECTION; |
482 | return REFLECTION; |
482 | } else { |
483 | } else { |
483 | // reflection or refraction according to Fresnel equations |
484 | // reflection or refraction according to Fresnel equations |
484 | if(dbg) printf(" REFRACTION\n"); |
485 | if(dbg) printf(" REFRACTION\n"); |
485 | if(dbg) printf(" N1_N2(sign_n) = %lf\n", N1_N2(sign_n)); |
486 | if(dbg) printf(" N1_N2(sign_n) = %lf\n", N1_N2(sign_n)); |
486 | cosTt = TMath::Sqrt(1 - TMath::Power(N1_N2(sign_n), 2)*(1 - TMath::Power(cosTi, 2))); |
487 | cosTt = TMath::Sqrt(1 - TMath::Power(N1_N2(sign_n), 2)*(1 - TMath::Power(cosTi, 2))); |
487 | if(dbg) printf(" cosTt = %lf (Tt = %lf) \n", cosTt, TMath::ACos(cosTt)*DEGREE); |
488 | if(dbg) printf(" cosTt = %lf (Tt = %lf) \n", cosTt, TMath::ACos(cosTt)*DEGREE); |
488 | 489 | ||
489 | transmit = N1_N2(sign_n)*in. |
490 | transmit = N1_N2(sign_n)*in.GetK() + sign_n*(N1_N2(sign_n)*cosTi - cosTt)*n; |
490 | if(dbg) {printf(" transmit.Unit() = "); printv(transmit.Unit());} |
491 | if(dbg) {printf(" transmit.Unit() = "); printv(transmit.Unit());} |
491 | if(dbg) { |
492 | if(dbg) { |
492 | cosTN = transmit.Unit() * n; |
493 | cosTN = transmit.Unit() * n; |
493 | printf(" cosTN = %lf (TN = %lf) (Abs(TN) = %lf)\n", cosTN, TMath::ACos(cosTN)*DEGREE, TMath::ACos(TMath::Abs(cosTN))*DEGREE); |
494 | printf(" cosTN = %lf (TN = %lf) (Abs(TN) = %lf)\n", cosTN, TMath::ACos(cosTN)*DEGREE, TMath::ACos(TMath::Abs(cosTN))*DEGREE); |
494 | } |
495 | } |
Line 501... | Line 502... | ||
501 | if(dbg) printf(" r_te = %lf, r_tm = %lf\n", r_te, r_tm); |
502 | if(dbg) printf(" r_te = %lf, r_tm = %lf\n", r_te, r_tm); |
502 | 503 | ||
503 | // transmited polarization |
504 | // transmited polarization |
504 | v_tm_t = -v_te.Cross(transmit); |
505 | v_tm_t = -v_te.Cross(transmit); |
505 | v_tm_t = v_tm_t.Unit(); |
506 | v_tm_t = v_tm_t.Unit(); |
506 | pol_t = a_te |
507 | pol_t = a_te*(1.0 - TMath::Abs(r_te))*v_te + a_tm*(1.0 - TMath::Abs(r_tm))*v_tm_t; |
507 | 508 | ||
508 | if(dbg) { |
509 | if(dbg) { |
509 | printf(" v_tm_t = "); printv(v_tm_t); |
510 | printf(" v_tm_t = "); printv(v_tm_t); |
510 | printf(" pol_t = "); printv(pol_t); |
511 | printf(" pol_t = "); printv(pol_t); |
511 | } |
512 | } |
Line 519... | Line 520... | ||
519 | } |
520 | } |
520 | 521 | ||
521 | if(p_ref >= R_f) { // se lomi |
522 | if(p_ref >= R_f) { // se lomi |
522 | if (dbg) printf(" SURFACE REFRACTED. Return.\n"); |
523 | if (dbg) printf(" SURFACE REFRACTED. Return.\n"); |
523 | out->Set(intersect, transmit); |
524 | out->Set(intersect, transmit); |
524 | out-> |
525 | out->setPolarization(pol_t); |
525 | return REFRACTION; |
526 | return REFRACTION; |
526 | } else { // se odbije |
527 | } else { // se odbije |
527 | if (dbg) printf(" SURFACE REFLECTED. p_ref=%f, R_f=%f\n", p_ref, R_f); |
528 | if (dbg) printf(" SURFACE REFLECTED. p_ref=%f, R_f=%f\n", p_ref, R_f); |
528 | transmit = in. |
529 | transmit = in.GetK() + sign_n*2*cosTi*n; |
- | 530 | TVector3 v_tm_r = -v_te.Cross(transmit); |
|
- | 531 | v_tm_r = v_tm_r.Unit(); |
|
529 | out->Set(intersect, transmit); |
532 | out->Set(intersect, transmit); |
530 | pol_t |
533 | //pol_t = -in.GetP() + sign_n*2*cosTi*n; |
- | 534 | pol_t = a_te*(1.0 - TMath::Abs(r_te))*v_te + a_tm*(1.0 - TMath::Abs(r_tm))*v_tm_r; |
|
531 | out-> |
535 | out->setPolarization(pol_t); |
532 | return REFLECTION; |
536 | return REFLECTION; |
533 | } |
537 | } |
534 | 538 | ||
535 | //} |
539 | //} |
536 | break; |
540 | break; |
Line 539... | Line 543... | ||
539 | // --------------- reflection at "reflection" probability --------------------- |
543 | // --------------- reflection at "reflection" probability --------------------- |
540 | // ---------------------------------------------------------------------------- |
544 | // ---------------------------------------------------------------------------- |
541 | case SURF_REFLE: |
545 | case SURF_REFLE: |
542 | p_ref = rand.Uniform(0.0, 1.0); |
546 | p_ref = rand.Uniform(0.0, 1.0); |
543 | if(p_ref < reflection) { // se odbije |
547 | if(p_ref < reflection) { // se odbije |
544 | cosTi = in. |
548 | cosTi = in.GetK() * n; |
545 | transmit = in. |
549 | transmit = in.GetK() - 2*cosTi*n; |
546 | out->Set(intersect, transmit); |
550 | out->Set(intersect, transmit); |
547 | return REFLECTION; //sdhfvjhsdbfjhsdbcvjhsb |
551 | return REFLECTION; //sdhfvjhsdbfjhsdbcvjhsb |
548 | } else { // se ne odbije |
552 | } else { // se ne odbije |
549 | transmit = in. |
553 | transmit = in.GetK(); |
550 | out->Set(intersect, transmit); |
554 | out->Set(intersect, transmit); |
551 | return ABSORBED; |
555 | return ABSORBED; |
552 | } |
556 | } |
553 | break; |
557 | break; |
554 | 558 | ||
555 | // total reflection from n1 to n2 with R probbability |
559 | // total reflection from n1 to n2 with R probbability |
556 | case SURF_IMPER: |
560 | case SURF_IMPER: |
557 | p_ref = rand.Uniform(0.0, 1.0); |
561 | p_ref = rand.Uniform(0.0, 1.0); |
558 | if(p_ref < reflection) { // se odbije |
562 | if(p_ref < reflection) { // se odbije |
559 | cosTi = in. |
563 | cosTi = in.GetK() * n; |
560 | if(TMath::Abs(cosTi) < cosTtotal) { // totalni odboj |
564 | if(TMath::Abs(cosTi) < cosTtotal) { // totalni odboj |
561 | transmit = in. |
565 | transmit = in.GetK() - 2*cosTi*n; |
562 | out->Set(intersect, transmit); |
566 | out->Set(intersect, transmit); |
563 | } else { // ni tot. odboja |
567 | } else { // ni tot. odboja |
564 | transmit = in. |
568 | transmit = in.GetK(); |
565 | out->Set(intersect, transmit); |
569 | out->Set(intersect, transmit); |
566 | return ABSORBED; |
570 | return ABSORBED; |
567 | } |
571 | } |
568 | } else { // se ne odbije |
572 | } else { // se ne odbije |
569 | transmit = in. |
573 | transmit = in.GetK(); |
570 | out->Set(intersect, transmit); |
574 | out->Set(intersect, transmit); |
571 | return ABSORBED; |
575 | return ABSORBED; |
572 | } |
576 | } |
573 | break; |
577 | break; |
574 | 578 | ||
Line 577... | Line 581... | ||
577 | break; |
581 | break; |
578 | } |
582 | } |
579 | 583 | ||
580 | return REFRACTION; |
584 | return REFRACTION; |
581 | } |
585 | } |
582 | //================================================================================= |
- | |
583 | 586 | ||
584 | - | ||
585 | //================================================================================= |
- | |
586 | Guide::Guide(TVector3 center0, DetectorParameters ¶meters) : |
587 | Guide::Guide(TVector3 center0, DetectorParameters ¶meters) : |
587 | _d(parameters.getD()), |
588 | _d(parameters.getD()), |
588 | _n1(parameters.getN1()), |
589 | _n1(parameters.getN1()), |
589 | _n2(parameters.getN2()), |
590 | _n2(parameters.getN2()), |
590 | _n3(parameters.getN3()), |
591 | _n3(parameters.getN3()), |
Line 638... | Line 639... | ||
638 | noCoupling->FlipN(); |
639 | noCoupling->FlipN(); |
639 | // grease = specific pattern area of coupling |
640 | // grease = specific pattern area of coupling |
640 | TVector3 activePosition(center); |
641 | TVector3 activePosition(center); |
641 | activePosition += TVector3(_d, 0, 0); |
642 | activePosition += TVector3(_d, 0, 0); |
642 | TVector3 normal(1,0,0); |
643 | TVector3 normal(1,0,0); |
643 | grease = new CPlaneR(activePosition, normal, a/2.0); |
644 | grease = new CPlaneR(activePosition, normal, 0.95*a/2.0); |
644 | 645 | ||
645 | if(fresnel) for(int i=0; i<6; i++) s_side[i]->SetFresnel(1); |
646 | if(fresnel) for(int i=0; i<6; i++) s_side[i]->SetFresnel(1); |
646 | 647 | ||
647 | // statistics histograms |
648 | // statistics histograms |
648 | hfate = (TH1F*)gROOT->FindObject("hfate"); if(hfate) delete hfate; |
649 | hfate = (TH1F*)gROOT->FindObject("hfate"); if(hfate) delete hfate; |
Line 681... | Line 682... | ||
681 | Fate Guide::PropagateRay(CRay in, CRay *out, int *n_points, TVector3 *points) |
682 | Fate Guide::PropagateRay(CRay in, CRay *out, int *n_points, TVector3 *points) |
682 | { |
683 | { |
683 | if (dbg) printf("--- GUIDE::PropagateRay ---\n"); |
684 | if (dbg) printf("--- GUIDE::PropagateRay ---\n"); |
684 | // ray0 - incident ray |
685 | // ray0 - incident ray |
685 | // ray1 - trans/refl ray |
686 | // ray1 - trans/refl ray |
686 | CRay ray0; |
687 | CRay ray0; |
687 | CRay ray1; |
688 | CRay ray1; |
688 | TVector3 vec0, vec1; |
689 | TVector3 vec0, vec1; |
689 | int inters_i = 0; |
690 | int inters_i = 0; |
690 | 691 | ||
691 | ray0 = in; |
692 | ray0 = in; |
692 | int n_odb = 0; |
693 | int n_odb = 0; |
Line 748... | Line 749... | ||
748 | bool hitActive = grease->TestIntersection(&hitVector, ray0); |
749 | bool hitActive = grease->TestIntersection(&hitVector, ray0); |
749 | if (hitActive and dbg) printf(" GUIDE: hit grease\n"); |
750 | if (hitActive and dbg) printf(" GUIDE: hit grease\n"); |
750 | if (!hitActive) propagation = noCoupling->PropagateRay(ray0, &ray1, &vec1); |
751 | if (!hitActive) propagation = noCoupling->PropagateRay(ray0, &ray1, &vec1); |
751 | } |
752 | } |
752 | // check on which side the vector is? |
753 | // check on which side the vector is? |
753 | TVector3 ray = ray1. |
754 | TVector3 ray = ray1.GetK(); |
754 | TVector3 exitNormal = s_side[5]->GetN(); |
755 | TVector3 exitNormal = s_side[5]->GetN(); |
755 | if (dbg) printf("ray*n_5 = %lf\n", ray*exitNormal); |
756 | if (dbg) printf("ray*n_5 = %lf\n", ray*exitNormal); |
756 | if (ray*exitNormal > 0) { |
757 | if (ray*exitNormal > 0) { |
757 | if (dbg) printf(" GUIDE: ray is backreflected from exit window.\n"); |
758 | if (dbg) printf(" GUIDE: ray is backreflected from exit window.\n"); |
758 | fate = backreflected; |
759 | fate = backreflected; |
Line 804... | Line 805... | ||
804 | hnodb_all->Fill(n_odb-2); |
805 | hnodb_all->Fill(n_odb-2); |
805 | *n_points = n_odb+1; |
806 | *n_points = n_odb+1; |
806 | *out = ray0; |
807 | *out = ray0; |
807 | return fate; |
808 | return fate; |
808 | } |
809 | } |
809 | //----------------------------------------------------------------------------- |
- | |
810 | void Guide::GetVFate(int *out) |
810 | void Guide::GetVFate(int *out) |
811 | { |
811 | { |
812 | for(int i=0;i<7;i++) out[i] = (int)hfate->GetBinContent(i+1); |
812 | for(int i=0;i<7;i++) out[i] = (int)hfate->GetBinContent(i+1); |
813 | } |
813 | } |
814 | //----------------------------------------------------------------------------- |
- | |
815 | void Guide::Draw(int color, int width) |
814 | void Guide::Draw(int color, int width) |
816 | { |
815 | { |
817 | for(int i = 0; i<6; i++) s_side[i]->Draw(color, width); |
816 | for(int i = 0; i<6; i++) s_side[i]->Draw(color, width); |
818 | } |
817 | } |
819 | //----------------------------------------------------------------------------- |
- | |
820 | void Guide::DrawSkel(int color, int width) |
818 | void Guide::DrawSkel(int color, int width) |
821 | { |
819 | { |
822 | TPolyLine3D *line3d = new TPolyLine3D(2); |
820 | TPolyLine3D *line3d = new TPolyLine3D(2); |
823 | line3d->SetLineWidth(width); line3d->SetLineColor(color); |
821 | line3d->SetLineWidth(width); line3d->SetLineColor(color); |
824 | 822 | ||
Line 826... | Line 824... | ||
826 | line3d->SetPoint(0, vodnik_edge[i+0].x(), vodnik_edge[i+0].y(), vodnik_edge[i+0].z()); |
824 | line3d->SetPoint(0, vodnik_edge[i+0].x(), vodnik_edge[i+0].y(), vodnik_edge[i+0].z()); |
827 | line3d->SetPoint(1, vodnik_edge[i+4].x(), vodnik_edge[i+4].y(), vodnik_edge[i+4].z()); |
825 | line3d->SetPoint(1, vodnik_edge[i+4].x(), vodnik_edge[i+4].y(), vodnik_edge[i+4].z()); |
828 | line3d->DrawClone(); |
826 | line3d->DrawClone(); |
829 | } |
827 | } |
830 | } |
828 | } |
831 | //================================================================================= |
- | |
832 | 829 | ||
833 | //================================================================================= |
- | |
- | 830 | ||
834 | int CPlaneR::TestIntersection(TVector3 *vec, CRay ray) |
831 | int CPlaneR::TestIntersection(TVector3 *vec, CRay ray) |
835 | { |
832 | { |
836 | double num, den; //stevec, imenovalec |
833 | double num, den; //stevec, imenovalec |
837 | double t; |
834 | double t; |
838 | TVector3 tmp; |
835 | TVector3 tmp; |
Line 840... | Line 837... | ||
840 | if(dbg) printf("---> CPlaneR::TestIntersection <---\n"); |
837 | if(dbg) printf("---> CPlaneR::TestIntersection <---\n"); |
841 | if(dbg) {printf("c = "); printv(center); printf(" | n = "); printv(n); printf("\n");} |
838 | if(dbg) {printf("c = "); printv(center); printf(" | n = "); printv(n); printf("\n");} |
842 | 839 | ||
843 | double D = - n*center; |
840 | double D = - n*center; |
844 | num = n*ray.GetR() + D; |
841 | num = n*ray.GetR() + D; |
845 | den = n*ray. |
842 | den = n*ray.GetK(); |
846 | 843 | ||
847 | if(dbg) printf("D = %.4lf | num = %.4lf | den = %.4lf\n", D, num, den); |
844 | if(dbg) printf("D = %.4lf | num = %.4lf | den = %.4lf\n", D, num, den); |
848 | 845 | ||
849 | if(TMath::Abs(den) < MARGIN) { |
846 | if(TMath::Abs(den) < MARGIN) { |
850 | if(TMath::Abs(num) < MARGIN) |
847 | if(TMath::Abs(num) < MARGIN) |
Line 856... | Line 853... | ||
856 | t = num / den; |
853 | t = num / den; |
857 | 854 | ||
858 | if(dbg) printf("t = %.4lf | ", t); |
855 | if(dbg) printf("t = %.4lf | ", t); |
859 | 856 | ||
860 | tmp = ray.GetR(); |
857 | tmp = ray.GetR(); |
861 | tmp -= t*ray. |
858 | tmp -= t*ray.GetK(); |
862 | *vec = tmp; |
859 | *vec = tmp; |
863 | 860 | ||
864 | if(dbg) {printv(tmp); printf(" | Rv = %.4lf <> R = %.4lf\n", ((tmp - center).Mag()), _r);} |
861 | if(dbg) {printv(tmp); printf(" | Rv = %.4lf <> R = %.4lf\n", ((tmp - center).Mag()), _r);} |
865 | 862 | ||
866 | 863 | ||
867 | if( ((tmp - center).Mag()) < _r ) |
864 | if( ((tmp - center).Mag()) < _r ) |
868 | return 1; |
865 | return 1; |
869 | else |
866 | else |
870 | return 0; |
867 | return 0; |
871 | } |
868 | } |
872 | //----------------------------------------------------------------------------- |
- | |
- | 869 | ||
873 | void CPlaneR::Draw(int color, int width) |
870 | void CPlaneR::Draw(int color, int width) |
874 | { |
871 | { |
875 | const int NN = 32; |
872 | const int NN = 32; |
876 | double phi, x, y; |
873 | double phi, x, y; |
877 | 874 | ||
Line 886... | Line 883... | ||
886 | y = _r*TMath::Sin(phi); |
883 | y = _r*TMath::Sin(phi); |
887 | arc->SetPoint(i, center.x(), x, y); |
884 | arc->SetPoint(i, center.x(), x, y); |
888 | } |
885 | } |
889 | arc->Draw(); |
886 | arc->Draw(); |
890 | } |
887 | } |
891 | //================================================================================= |
- | |
892 | 888 | ||
893 | 889 | ||
894 | //================================================================================= |
- | |
895 | CDetector::CDetector(TVector3 center0, DetectorParameters& parameters) : |
890 | CDetector::CDetector(TVector3 center0, DetectorParameters& parameters) : |
896 | center(center0), |
891 | center(center0), |
897 | glass_on(parameters.getGlassOn()), |
892 | glass_on(parameters.getGlassOn()), |
898 | glass_d(parameters.getGlassD()), |
893 | glass_d(parameters.getGlassD()), |
899 | col_in(2), |
894 | col_in(2), |
Line 1046... | Line 1041... | ||
1046 | if(fatePlate == missed) { |
1041 | if(fatePlate == missed) { |
1047 | rayout->SetColor(col_in); |
1042 | rayout->SetColor(col_in); |
1048 | rayout->DrawS(center.x() - _plateWidth, -10.0); |
1043 | rayout->DrawS(center.x() - _plateWidth, -10.0); |
1049 | } |
1044 | } |
1050 | else if(fatePlate == backreflected){ |
1045 | else if(fatePlate == backreflected){ |
- | 1046 | rayout->SetColor(kBlack); |
|
- | 1047 | rayout->DrawS(center.x() - _plateWidth, 7.0); |
|
1051 | if (dbg) printf("Backreflected at plate!\n"); |
1048 | if (dbg) printf("Backreflected at plate!\n"); |
1052 | } |
1049 | } |
1053 | else { |
1050 | else { |
1054 | int p_i; |
1051 | int p_i; |
1055 | for(p_i = 0; p_i < nPointsPlate-1; p_i++) { |
1052 | for(p_i = 0; p_i < nPointsPlate-1; p_i++) { |
Line 1108... | Line 1105... | ||
1108 | if(guide_on) { |
1105 | if(guide_on) { |
1109 | if(draw) { |
1106 | if(draw) { |
1110 | if(fate == missed) { |
1107 | if(fate == missed) { |
1111 | if (dbg) printf("Detector: fate=missed\n"); |
1108 | if (dbg) printf("Detector: fate=missed\n"); |
1112 | TVector3 r = ray1->GetR(); |
1109 | TVector3 r = ray1->GetR(); |
1113 | TVector3 |
1110 | TVector3 k = ray1->GetK(); |
1114 | ray1->Set( |
1111 | ray1->Set(r,k); |
1115 | ray1->DrawS(center.x(), 10.0); |
1112 | ray1->DrawS(center.x(), 10.0); |
1116 | } else { |
1113 | } else { |
1117 | for(p_i = 0; p_i < n_points-1; p_i++) { |
1114 | for(p_i = 0; p_i < n_points-1; p_i++) { |
1118 | line3d->SetPoint(0, points[p_i].x(), points[p_i].y(), points[p_i].z()); |
1115 | line3d->SetPoint(0, points[p_i].x(), points[p_i].y(), points[p_i].z()); |
1119 | line3d->SetPoint(1, points[p_i+1].x(), points[p_i+1].y(), points[p_i+1].z()); |
1116 | line3d->SetPoint(1, points[p_i+1].x(), points[p_i+1].y(), points[p_i+1].z()); |
Line 1145... | Line 1142... | ||
1145 | ray1 = ray0; |
1142 | ray1 = ray0; |
1146 | if(draw) { |
1143 | if(draw) { |
1147 | //double epoxy = parameters->getGlassD(); |
1144 | //double epoxy = parameters->getGlassD(); |
1148 | if(glass_on) ray1->Draw(center.x(), center.x() + glass_d); |
1145 | if(glass_on) ray1->Draw(center.x(), center.x() + glass_d); |
1149 | else ray1->DrawS(center.x(), 10.0); |
1146 | else ray1->DrawS(center.x(), 10.0); |
1150 | } |
1147 | } |
1151 | } |
1148 | } |
1152 | 1149 | ||
1153 | fate = missed; // zgresil aktivno povrsino |
1150 | fate = missed; // zgresil aktivno povrsino |
1154 | if(glass_on) { |
1151 | if(glass_on) { |
1155 | *ray0 = *ray1; |
1152 | *ray0 = *ray1; |
1156 | ray1->SetColor(col_rgla); |
1153 | ray1->SetColor(col_rgla); |
1157 | fate_glass = glass->PropagateRay(*ray0, ray1, &presecisce); |
1154 | fate_glass = glass->PropagateRay(*ray0, ray1, &presecisce); |
Line 1166... | Line 1163... | ||
1166 | //if(detector->TestIntersection(&presecisce, *ray1)) |
1163 | //if(detector->TestIntersection(&presecisce, *ray1)) |
1167 | //hdetector->Fill(offsetY + presecisce.y(), offsetZ + presecisce.z()); |
1164 | //hdetector->Fill(offsetY + presecisce.y(), offsetZ + presecisce.z()); |
1168 | //} else if(fate_glass == REFLECTION) { |
1165 | //} else if(fate_glass == REFLECTION) { |
1169 | else |
1166 | else |
1170 | if(draw) ray1->DrawS(presecisce.x(), 10.0); |
1167 | if(draw) ray1->DrawS(presecisce.x(), 10.0); |
1171 | } |
1168 | } |
1172 | } |
1169 | } |
1173 | 1170 | ||
1174 | // Main test: ray and SiPM surface |
1171 | // Main test: ray and SiPM surface |
1175 | if(active->TestIntersection(&presecisce, *ray1)) { |
1172 | if(active->TestIntersection(&presecisce, *ray1)) { |
1176 | fate = hitExit; |
1173 | fate = hitExit; |
Line 1190... | Line 1187... | ||
1190 | delete ray1; |
1187 | delete ray1; |
1191 | delete rayout; |
1188 | delete rayout; |
1192 | delete rayin; |
1189 | delete rayin; |
1193 | return fate; |
1190 | return fate; |
1194 | } |
1191 | } |
1195 | //----------------------------------------------------------------------------- |
- | |
- | 1192 | ||
1196 | void CDetector::Draw(int width) |
1193 | void CDetector::Draw(int width) |
1197 | { |
1194 | { |
1198 | if(guide_on) { |
1195 | if(guide_on) { |
1199 | if( TMath::Abs(guide->getN1()-guide->getN2()) < MARGIN ) { |
1196 | if( TMath::Abs(guide->getN1()-guide->getN2()) < MARGIN ) { |
1200 | if(_plateOn) plate->drawSkel(col_LG, width); |
1197 | if(_plateOn) plate->drawSkel(col_LG, width); |
Line 1208... | Line 1205... | ||
1208 | 1205 | ||
1209 | if(glass_on) glass_circle->Draw(col_glass, width); |
1206 | if(glass_on) glass_circle->Draw(col_glass, width); |
1210 | //window_circle->Draw(col_glass, width); |
1207 | //window_circle->Draw(col_glass, width); |
1211 | active->Draw(col_active, width); |
1208 | active->Draw(col_active, width); |
1212 | } |
1209 | } |
1213 | //================================================================================= |
- | |
- | 1210 | ||
1214 | 1211 | ||
1215 | Plate::Plate(DetectorParameters& parameters) |
1212 | Plate::Plate(DetectorParameters& parameters) |
1216 | { |
1213 | { |
1217 | TVector3 center = CENTER; |
1214 | TVector3 center = CENTER; |
1218 | const double b = parameters.getB(); |
1215 | const double b = parameters.getB(); |
Line 1282... | Line 1279... | ||
1282 | if( !result ) { |
1279 | if( !result ) { |
1283 | // ce -NI- presecisca z vstopno |
1280 | // ce -NI- presecisca z vstopno |
1284 | fate = missed; |
1281 | fate = missed; |
1285 | } else if(result == REFLECTION) { |
1282 | } else if(result == REFLECTION) { |
1286 | if (dbg) printf("PLATE: reflected\n"); |
1283 | if (dbg) printf("PLATE: reflected\n"); |
- | 1284 | ray0 = ray1; |
|
1287 | fate = backreflected; |
1285 | fate = backreflected; |
1288 | } else { |
1286 | } else { |
1289 | points[0] = ray1.GetR(); |
1287 | points[0] = ray1.GetR(); |
1290 | //hfate->Fill(enter); |
1288 | //hfate->Fill(enter); |
1291 | //hin->Fill(vec1.y(), vec1.z()); |
1289 | //hin->Fill(vec1.y(), vec1.z()); |
Line 1298... | Line 1296... | ||
1298 | if( sides[inters_i]->TestIntersection(&vec1, ray1) ) break; |
1296 | if( sides[inters_i]->TestIntersection(&vec1, ray1) ) break; |
1299 | } |
1297 | } |
1300 | } |
1298 | } |
1301 | points[n_odb] = vec1; |
1299 | points[n_odb] = vec1; |
1302 | if(inters_i == 0) { |
1300 | if(inters_i == 0) { |
- | 1301 | ray0 = ray1; |
|
1303 | fate = backreflected; |
1302 | fate = backreflected; |
1304 | break;} // backreflection |
1303 | break;} // backreflection |
1305 | 1304 | ||
1306 | propagation = sides[inters_i]->PropagateRay(ray0, &ray1, &vec1); |
1305 | propagation = sides[inters_i]->PropagateRay(ray0, &ray1, &vec1); |
1307 | if(inters_i == 5) { // successfull exit |
1306 | if(inters_i == 5) { // successfull exit |
Line 1331... | Line 1330... | ||
1331 | 1330 | ||
1332 | *n_points = n_odb+1; |
1331 | *n_points = n_odb+1; |
1333 | *out = ray0; |
1332 | *out = ray0; |
1334 | return fate; |
1333 | return fate; |
1335 | }; |
1334 | }; |
1336 | //=============================================================================================================================== <<<<<<<< |
- | |
1337 | 1335 | ||
1338 | 1336 |