Rev 54 | Rev 71 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 54 | Rev 70 | ||
|---|---|---|---|
| Line 245... | Line 245... | ||
| 245 | angle_ve1 = TMath::ACos(/*TMath::Abs*/( (e1.Unit()) * (vec.Unit()) )); |
245 | angle_ve1 = TMath::ACos(/*TMath::Abs*/( (e1.Unit()) * (vec.Unit()) )); |
| 246 | angle_ve2 = TMath::ACos(/*TMath::Abs*/( (e2.Unit()) * (vec.Unit()) )); |
246 | angle_ve2 = TMath::ACos(/*TMath::Abs*/( (e2.Unit()) * (vec.Unit()) )); |
| 247 | 247 | ||
| 248 | if(dbg) |
248 | if(dbg) |
| 249 | { |
249 | { |
| 250 |
|
250 | printf("angle_ve1 = %lf\n", angle_ve1*DEGREE); |
| 251 |
|
251 | printf("angle_ve2 = %lf\n", angle_ve2*DEGREE); |
| 252 |
|
252 | printf("angle_sum = %lf\n", (angle_ve1 + angle_ve2)*DEGREE); |
| 253 | printf(" angle_r = %lf\n", angle*DEGREE); |
253 | printf(" angle_r = %lf\n", angle*DEGREE); |
| 254 | } |
254 | } |
| 255 | 255 | ||
| 256 | bool difference = (MARGIN < TMath::Abs(angle - (angle_ve1 + angle_ve2))); |
256 | bool difference = (MARGIN < TMath::Abs(angle - (angle_ve1 + angle_ve2))); |
| 257 | if (dbg) printf(" MARGIN < Difference = %d\n", difference); |
257 | if (dbg) printf(" MARGIN < Difference = %d\n", difference); |
| Line 395... | Line 395... | ||
| 395 | if( !IsVectorIn(intersect) ) |
395 | if( !IsVectorIn(intersect) ) |
| 396 | return 0; |
396 | return 0; |
| 397 | 397 | ||
| 398 | // --------------- Fresnel ---------------------------------------------------- |
398 | // --------------- Fresnel ---------------------------------------------------- |
| 399 | // R_f = a_te * R_te + a_tm * R_tm |
399 | // R_f = a_te * R_te + a_tm * R_tm |
| - | 400 | // e - electrical/perependicular |
|
| - | 401 | // m - magnetic polarization/parallel |
|
| 400 | double r_te=0; |
402 | double r_te=0; |
| 401 | double r_tm=0; |
403 | double r_tm=0; |
| 402 | double R_te=0; |
404 | double R_te=0; // s reflection coefficient |
| 403 | double R_tm=0; |
405 | double R_tm=0; // p reflection coefficient |
| 404 | double R_f = 0.0; |
406 | double R_f = 0.0; |
| 405 | double a_te = 0.0; |
407 | double a_te = 0.0; // s-wave amplitude, cos Alpha |
| 406 | double a_tm = 0.0; |
408 | double a_tm = 0.0; // p-wave amplitude, sin Alpha |
| 407 | TVector3 v_te; // polarization |
409 | TVector3 v_te; // unit s-polarization vector |
| 408 | TVector3 v_tm; // |
410 | TVector3 v_tm; // unit p-polarization vector |
| 409 | TVector3 v_tm_t;// transmited polarization parallel with the plane of incidence |
411 | TVector3 v_tm_t;// transmited polarization parallel with the plane of incidence |
| 410 | TVector3 pol_t = in.GetP(); // transmited polarization |
412 | TVector3 pol_t = in.GetP(); // transmited polarization |
| 411 | int sign_n; // sign of normal direction vs. inbound ray |
413 | int sign_n; // sign of normal direction vs. inbound ray |
| 412 | double cosTN; // debug |
414 | double cosTN; // debug |
| 413 | 415 | ||
| 414 | if(fresnel) { |
416 | if(fresnel) { |
| - | 417 | // p-polarization unit vector v_te |
|
| - | 418 | // is in the plane orthogonal to the plane of incidence |
|
| - | 419 | // defined as the plane spanned by |
|
| - | 420 | // incident surface vector n and wave vector k |
|
| - | 421 | // k in this notation is in.GetN() |
|
| 415 | v_te = n.Cross(in.GetN() |
422 | v_te = n.Cross(in.GetN()); |
| - | 423 | v_te = v_te.Unit(); |
|
| 416 | v_tm = -v_te.Cross(in.GetN() |
424 | v_tm = -v_te.Cross(in.GetN()); |
| - | 425 | v_tm = v_tm.Unit(); |
|
| 417 | if(dbg) { |
426 | if(dbg) { |
| 418 | printf(" v_te = "); printv(v_te); |
427 | printf(" v_te = "); printv(v_te); |
| 419 | printf(" v_tm = "); printv(v_tm); |
428 | printf(" v_tm = "); printv(v_tm); |
| 420 | } |
429 | } |
| 421 | 430 | ||
| Line 426... | Line 435... | ||
| 426 | a_tm = TMath::Sqrt(1 - cosAf*cosAf); |
435 | a_tm = TMath::Sqrt(1 - cosAf*cosAf); |
| 427 | if(dbg) printf(" a_te = %lf, a_tm = %lf\n", a_te, a_tm); |
436 | if(dbg) printf(" a_te = %lf, a_tm = %lf\n", a_te, a_tm); |
| 428 | } |
437 | } |
| 429 | // ---------------------------------------------------------------------------- |
438 | // ---------------------------------------------------------------------------- |
| 430 | 439 | ||
| 431 | if(type == |
440 | if(type == SURF_TOTAL) type = SURF_REFRA; |
| 432 | switch(type){ |
441 | switch(type){ |
| 433 | // ---------------------------------------------------------------------------- |
442 | // ---------------------------------------------------------------------------- |
| 434 | // --------------- refraction from n1 to n2 ----------------------------------- |
443 | // --------------- refraction from n1 to n2 ----------------------------------- |
| 435 | // ---------------------------------------------------------------------------- |
444 | // ---------------------------------------------------------------------------- |
| 436 | case SURF_REFRA: |
445 | case SURF_REFRA: |
| Line 450... | Line 459... | ||
| 450 | // reflection dependance on polarization missing |
459 | // reflection dependance on polarization missing |
| 451 | // reflection hardcoded to 0.96 |
460 | // reflection hardcoded to 0.96 |
| 452 | p_ref = rand.Uniform(0.0, 1.0); |
461 | p_ref = rand.Uniform(0.0, 1.0); |
| 453 | if (dbg) printf(" reflection probability = %f\n", p_ref); |
462 | if (dbg) printf(" reflection probability = %f\n", p_ref); |
| 454 | 463 | ||
| 455 | // |
464 | // If n1>n2 and theta>thetaCritical, total reflection |
| 456 | /* |
- | |
| 457 |
|
465 | if( (cosTi < cosTtotal) && (p_ref < reflection) ) { // totalni odboj z verjetnostjo "reflection" |
| 458 | if(dbg) printf(" TOTAL\n"); |
466 | if(dbg) printf(" TOTAL\n"); |
| 459 | transmit = in.GetN() + sign_n*2*cosTi*n; |
467 | transmit = in.GetN() + sign_n*2*cosTi*n; |
| 460 | |
468 | |
| 461 | if(dbg) { |
469 | if(dbg) { |
| 462 | cosTN = TMath::Abs(transmit.Unit() * n); |
470 | cosTN = TMath::Abs(transmit.Unit() * n); |
| Line 465... | Line 473... | ||
| 465 | out->Set(intersect, transmit); |
473 | out->Set(intersect, transmit); |
| 466 | |
474 | |
| 467 | pol_t = -in.GetP() + sign_n*2*cosTi*n; |
475 | pol_t = -in.GetP() + sign_n*2*cosTi*n; |
| 468 | out->SetPolarization(pol_t); |
476 | out->SetPolarization(pol_t); |
| 469 | return REFLECTION; |
477 | return REFLECTION; |
| 470 |
|
478 | } else { |
| 471 | // reflection or refraction according to Fresnel equations |
479 | // reflection or refraction according to Fresnel equations |
| 472 | if(dbg) printf(" REFRACTION\n"); |
480 | if(dbg) printf(" REFRACTION\n"); |
| 473 | if(dbg) printf(" N1_N2(sign_n) = %lf\n", N1_N2(sign_n)); |
481 | if(dbg) printf(" N1_N2(sign_n) = %lf\n", N1_N2(sign_n)); |
| 474 | cosTt = TMath::Sqrt(1 - TMath::Power(N1_N2(sign_n), 2)*(1 - TMath::Power(cosTi, 2))); |
482 | cosTt = TMath::Sqrt(1 - TMath::Power(N1_N2(sign_n), 2)*(1 - TMath::Power(cosTi, 2))); |
| 475 | if(dbg) printf(" cosTt = %lf (Tt = %lf) \n", cosTt, TMath::ACos(cosTt)*DEGREE); |
483 | if(dbg) printf(" cosTt = %lf (Tt = %lf) \n", cosTt, TMath::ACos(cosTt)*DEGREE); |
| Line 486... | Line 494... | ||
| 486 | r_te = (n1*cosTi - n2*cosTt)/(n1*cosTi + n2*cosTt); // transverse |
494 | r_te = (n1*cosTi - n2*cosTt)/(n1*cosTi + n2*cosTt); // transverse |
| 487 | r_tm = (n2*cosTi - n1*cosTt)/(n1*cosTt + n2*cosTi); // paralel |
495 | r_tm = (n2*cosTi - n1*cosTt)/(n1*cosTt + n2*cosTi); // paralel |
| 488 | 496 | ||
| 489 | if(dbg) printf(" r_te = %lf, r_tm = %lf\n", r_te, r_tm); |
497 | if(dbg) printf(" r_te = %lf, r_tm = %lf\n", r_te, r_tm); |
| 490 | 498 | ||
| - | 499 | // transmited polarization |
|
| 491 | v_tm_t = -v_te.Cross(transmit); |
500 | v_tm_t = -v_te.Cross(transmit); |
| 492 | v_tm_t = v_tm_t.Unit(); |
501 | v_tm_t = v_tm_t.Unit(); |
| 493 | pol_t = a_te * (1.0 - TMath::Abs(r_te)) * v_te + a_tm * (1.0 - TMath::Abs(r_tm)) * v_tm_t; |
502 | pol_t = a_te * (1.0 - TMath::Abs(r_te)) * v_te + a_tm * (1.0 - TMath::Abs(r_tm)) * v_tm_t; |
| 494 | 503 | ||
| 495 | if(dbg) { |
504 | if(dbg) { |
| 496 | printf(" v_tm_t = "); printv(v_tm_t); |
505 | printf(" v_tm_t = "); printv(v_tm_t); |
| 497 | printf(" pol_t = "); printv(pol_t); |
506 | printf(" pol_t = "); printv(pol_t); |
| 498 | } |
507 | } |
| 499 | 508 | ||
| - | 509 | // Fresnel coefficients |
|
| 500 | R_te = TMath::Power(r_te, 2); |
510 | R_te = TMath::Power(r_te, 2); |
| 501 | R_tm = TMath::Power(r_tm, 2); |
511 | R_tm = TMath::Power(r_tm, 2); |
| 502 | R_f = a_te*a_te*R_te + a_tm*a_tm*R_tm; |
512 | R_f = a_te*a_te*R_te + a_tm*a_tm*R_tm; |
| 503 | 513 | ||
| 504 | if (dbg) printf(" R_te = %lf, R_tm = %lf, R_f = %lf\n", R_te, R_tm, R_f); |
514 | if (dbg) printf(" R_te = %lf, R_tm = %lf, R_f = %lf\n", R_te, R_tm, R_f); |
| 505 |
|
515 | } |
| 506 | 516 | ||
| 507 | if(p_ref >= R_f) { // se lomi |
517 | if(p_ref >= R_f) { // se lomi |
| 508 | if (dbg) printf(" SURFACE REFRACTED. Return.\n"); |
518 | if (dbg) printf(" SURFACE REFRACTED. Return.\n"); |
| 509 | out->Set(intersect, transmit); |
519 | out->Set(intersect, transmit); |
| 510 | out->SetPolarization(pol_t); |
520 | out->SetPolarization(pol_t); |
| Line 571... | Line 581... | ||
| 571 | //================================================================================= |
581 | //================================================================================= |
| 572 | Guide::Guide(TVector3 center0, DetectorParameters ¶meters) |
582 | Guide::Guide(TVector3 center0, DetectorParameters ¶meters) |
| 573 | { |
583 | { |
| 574 | double t; |
584 | double t; |
| 575 | 585 | ||
| - | 586 | TDatime now; |
|
| 576 |
|
587 | rand.SetSeed(now.Get()); |
| 577 | 588 | ||
| 578 | center = center0; |
589 | center = center0; |
| 579 | double b = parameters.getB(); |
590 | double b = parameters.getB(); |
| 580 | double a = parameters.getA(); |
591 | double a = parameters.getA(); |
| 581 | _d = parameters.getD(); |
592 | _d = parameters.getD(); |
| 582 | n1 = parameters.getN1(); |
593 | n1 = parameters.getN1(); |
| 583 | n2 = parameters.getN2(); |
594 | n2 = parameters.getN2(); |
| 584 | // if PlateOn, then n0 = n3 (optical grease), else = n1 (air) |
595 | // if PlateOn, then n0 = n3 (optical grease), else = n1 (air) |
| 585 |
|
596 | //double n0 = (parameters.getPlateOn() ? parameters.getN3(): n1); |
| - | 597 | double n0 = (parameters.getPlateOn() ? n2 : n1); |
|
| 586 | n3 = parameters.getN3(); |
598 | n3 = parameters.getN3(); |
| 587 | _r = c_reflectivity; |
599 | _r = c_reflectivity; |
| 588 | int fresnel = parameters.getFresnel(); |
600 | int fresnel = parameters.getFresnel(); |
| 589 | 601 | ||
| - | 602 | // light guide edges |
|
| 590 | t = b/2.0; |
603 | t = b/2.0; |
| 591 | vodnik_edge[0].SetXYZ(0.0, t,- |
604 | vodnik_edge[0].SetXYZ(0.0, t,-t); |
| - | 605 | vodnik_edge[1].SetXYZ(0.0, t, t); |
|
| 592 | vodnik_edge[2].SetXYZ(0.0,-t, |
606 | vodnik_edge[2].SetXYZ(0.0,-t, t); |
| - | 607 | vodnik_edge[3].SetXYZ(0.0,-t,-t); |
|
| 593 | t = a/2.0; |
608 | t = a/2.0; |
| 594 | vodnik_edge[4].SetXYZ(_d, t,- |
609 | vodnik_edge[4].SetXYZ(_d, t,-t); |
| - | 610 | vodnik_edge[5].SetXYZ(_d, t, t); |
|
| 595 | vodnik_edge[6].SetXYZ(_d,-t, |
611 | vodnik_edge[6].SetXYZ(_d,-t, t); |
| - | 612 | vodnik_edge[7].SetXYZ(_d,-t,-t); |
|
| 596 | 613 | ||
| 597 | for(int i = 0; i<8; i++) vodnik_edge[i] += center; |
614 | for(int i = 0; i<8; i++) vodnik_edge[i] += center; |
| 598 | 615 | ||
| - | 616 | // light guide surfaces |
|
| 599 | s_side[0] = new CSurface(SURF_REFRA, vodnik_edge, n0, n2, _r); |
617 | s_side[0] = new CSurface(SURF_REFRA, vodnik_edge, n0, n2, _r); |
| 600 | s_side[0]->FlipN(); |
618 | s_side[0]->FlipN(); |
| 601 | 619 | ||
| 602 | s_side[1] = new CSurface(SURF_REFRA, vodnik_edge[3], vodnik_edge[2], vodnik_edge[6], vodnik_edge[7], n2, n1, _r); |
620 | s_side[1] = new CSurface(SURF_REFRA, vodnik_edge[3], vodnik_edge[2], vodnik_edge[6], vodnik_edge[7], n2, n1, _r); |
| 603 | s_side[2] = new CSurface(SURF_REFRA, vodnik_edge[2], vodnik_edge[1], vodnik_edge[5], vodnik_edge[6], n2, n1, _r); |
621 | s_side[2] = new CSurface(SURF_REFRA, vodnik_edge[2], vodnik_edge[1], vodnik_edge[5], vodnik_edge[6], n2, n1, _r); |
| 604 | s_side[3] = new CSurface(SURF_REFRA, vodnik_edge[1], vodnik_edge[0], vodnik_edge[4], vodnik_edge[5], n2, n1, _r); |
622 | s_side[3] = new CSurface(SURF_REFRA, vodnik_edge[1], vodnik_edge[0], vodnik_edge[4], vodnik_edge[5], n2, n1, _r); |
| 605 | s_side[4] = new CSurface(SURF_REFRA, vodnik_edge[0], vodnik_edge[3], vodnik_edge[7], vodnik_edge[4], n2, n1, _r); |
623 | s_side[4] = new CSurface(SURF_REFRA, vodnik_edge[0], vodnik_edge[3], vodnik_edge[7], vodnik_edge[4], n2, n1, _r); |
| 606 | 624 | ||
| 607 | s_side[5] = new CSurface(SURF_REFRA, &vodnik_edge[4], n2, n3, _r); |
625 | s_side[5] = new CSurface(SURF_REFRA, &vodnik_edge[4], n2, n3, _r); // n3 - ref ind at the exit, grease, air, epoxy |
| 608 | s_side[5]->FlipN(); |
626 | s_side[5]->FlipN(); |
| 609 | 627 | ||
| 610 | if(fresnel) for(int i=0; i<6; i++) s_side[i]->SetFresnel(1); |
628 | if(fresnel) for(int i=0; i<6; i++) s_side[i]->SetFresnel(1); |
| 611 | 629 | ||
| - | 630 | // statistics histograms |
|
| 612 | hfate = (TH1F*)gROOT->FindObject("hfate"); if(hfate) delete hfate; |
631 | hfate = (TH1F*)gROOT->FindObject("hfate"); if(hfate) delete hfate; |
| 613 | hfate = new TH1F("hfate", "Ray fate", 8, -3.5, 4.5); |
632 | hfate = new TH1F("hfate", "Ray fate", 8, -3.5, 4.5); |
| 614 | (hfate->GetXaxis())->SetBinLabel(1, "Back Ref"); |
633 | (hfate->GetXaxis())->SetBinLabel(1, "Back Ref"); |
| 615 | (hfate->GetXaxis())->SetBinLabel(2, "No Ref"); |
634 | (hfate->GetXaxis())->SetBinLabel(2, "No Ref"); |
| 616 | (hfate->GetXaxis())->SetBinLabel(3, "Refrac"); |
635 | (hfate->GetXaxis())->SetBinLabel(3, "Refrac"); |
| Line 668... | Line 687... | ||
| 668 | fate = backreflected; |
687 | fate = backreflected; |
| 669 | //hfate->Fill(-3); |
688 | //hfate->Fill(-3); |
| 670 | } else { |
689 | } else { |
| 671 | if (dbg) printf(" GUIDE: ray entered\n"); |
690 | if (dbg) printf(" GUIDE: ray entered\n"); |
| 672 | points[0] = ray1.GetR(); |
691 | points[0] = ray1.GetR(); |
| 673 | hfate->Fill( |
692 | hfate->Fill(enter); // enter |
| 674 | hin->Fill(vec1.y(), vec1.z()); |
693 | hin->Fill(vec1.y(), vec1.z()); |
| 675 | if (dbg) printf(" GUIDE: n_odb = %d\n", n_odb); |
694 | if (dbg) printf(" GUIDE: n_odb = %d\n", n_odb); |
| 676 | 695 | ||
| 677 | while (n_odb++ < MAX_REFLECTIONS) { |
696 | while (n_odb++ < MAX_REFLECTIONS) { |
| 678 | if (dbg) printf(" GUIDE: Boundary test: %d\n",n_odb); |
697 | if (dbg) printf(" GUIDE: Boundary test: %d\n",n_odb); |
| Line 807... | Line 826... | ||
| 807 | if(TMath::Abs(den) < MARGIN) { |
826 | if(TMath::Abs(den) < MARGIN) { |
| 808 | if(TMath::Abs(num) < MARGIN) |
827 | if(TMath::Abs(num) < MARGIN) |
| 809 | return 0; |
828 | return 0; |
| 810 | else |
829 | else |
| 811 | return 0; |
830 | return 0; |
| 812 | } |
831 | } |
| 813 | 832 | ||
| 814 | t = num / den; |
833 | t = num / den; |
| 815 | 834 | ||
| 816 | if(dbg) printf("t = %.4lf | ", t); |
835 | if(dbg) printf("t = %.4lf | ", t); |
| 817 | 836 | ||
| 818 | tmp = ray.GetR(); |
837 | tmp = ray.GetR(); |
| 819 | tmp -= t*ray.GetN(); |
838 | tmp -= t*ray.GetN(); |
| 820 | *vec = tmp; |
839 | *vec = tmp; |
| Line 888... | Line 907... | ||
| 888 | else x_offset = center.x() - d; |
907 | else x_offset = center.x() - d; |
| 889 | 908 | ||
| 890 | //guide = new CVodnik(center, SiPM, M, d, type_in, type_side, type_out, n1, n2, n3, reflectivity, fresnel, absorption, A); |
909 | //guide = new CVodnik(center, SiPM, M, d, type_in, type_side, type_out, n1, n2, n3, reflectivity, fresnel, absorption, A); |
| 891 | 910 | ||
| 892 | double b = parameters.getB(); |
911 | double b = parameters.getB(); |
| 893 |
|
912 | //double n1 = parameters.getN1(); |
| 894 |
|
913 | //double n2 = parameters.getN2(); |
| 895 |
|
914 | double n3 = parameters.getN3(); |
| 896 | double reflectivity = c_reflectivity; |
915 | double reflectivity = c_reflectivity; |
| 897 | double x_gap = parameters.getGap().X(); |
916 | double x_gap = parameters.getGap().X(); |
| 898 | double y_gap = parameters.getGap().Y(); |
917 | double y_gap = parameters.getGap().Y(); |
| 899 | double z_gap = parameters.getGap().Z(); |
918 | double z_gap = parameters.getGap().Z(); |
| 900 | 919 | ||
| - | 920 | // additional glass between at top of SiPM |
|
| - | 921 | // example: epoxy n=1.60 |
|
| - | 922 | double n4 = 1.60; |
|
| 901 | TVector3 plane_v[4]; |
923 | TVector3 plane_v[4]; |
| 902 | int nBins = nch + 1; |
924 | int nBins = nch + 1; |
| 903 | double p_size = b/2.0; |
925 | double p_size = b/2.0; |
| 904 | plane_v[0].SetXYZ(x_offset+d+glass_d, y_gap + p_size, z_gap - p_size); |
926 | plane_v[0].SetXYZ(x_offset+d+glass_d, y_gap + p_size, z_gap - p_size); |
| 905 | plane_v[1].SetXYZ(x_offset+d+glass_d, y_gap + p_size, z_gap + p_size); |
927 | plane_v[1].SetXYZ(x_offset+d+glass_d, y_gap + p_size, z_gap + p_size); |
| 906 | plane_v[2].SetXYZ(x_offset+d+glass_d, y_gap - p_size, z_gap + p_size); |
928 | plane_v[2].SetXYZ(x_offset+d+glass_d, y_gap - p_size, z_gap + p_size); |
| 907 | plane_v[3].SetXYZ(x_offset+d+glass_d, y_gap - p_size, z_gap - p_size); |
929 | plane_v[3].SetXYZ(x_offset+d+glass_d, y_gap - p_size, z_gap - p_size); |
| 908 | glass = new CSurface(SURF_REFRA, plane_v, |
930 | glass = new CSurface(SURF_REFRA, plane_v, n3, n4, reflectivity); |
| - | 931 | glass->FlipN(); |
|
| 909 | 932 | ||
| - | 933 | // additional circular glass between LG and SiPM |
|
| 910 | glass_circle = new CPlaneR(TVector3(x_offset+d+glass_d, y_gap, z_gap), TVector3(-1.0, 0.0, 0.0), b); |
934 | glass_circle = new CPlaneR(TVector3(x_offset+d+glass_d, y_gap, z_gap), TVector3(-1.0, 0.0, 0.0), b); |
| 911 | 935 | ||
| 912 | hglass = (TH2F*)gROOT->FindObject("hglass"); if(hglass) delete hglass; |
936 | hglass = (TH2F*)gROOT->FindObject("hglass"); if(hglass) delete hglass; |
| 913 | hglass = new TH2F("hglass", "Hits glass", |
937 | hglass = new TH2F("hglass", "Hits glass", |
| 914 | nBins, y_gap - p_size, y_gap + p_size, |
938 | nBins, y_gap - p_size, y_gap + p_size, |
| 915 | nBins, z_gap - p_size, z_gap + p_size); |
939 | nBins, z_gap - p_size, z_gap + p_size); |
| 916 | 940 | ||
| 917 | 941 | // SiPM active surface |
|
| 918 | p_size = parameters.getActive()/2.0; |
942 | p_size = parameters.getActive()/2.0; |
| 919 | //cout<<"SiPM active length "<<detectorActive<<endl; |
943 | //cout<<"SiPM active length "<<detectorActive<<endl; |
| 920 | //p_size = 1.0/2.0; |
944 | //p_size = 1.0/2.0; |
| 921 | plane_v[0].SetXYZ(x_offset+d+x_gap, y_gap + p_size, z_gap - p_size); |
945 | plane_v[0].SetXYZ(x_offset+d+x_gap, y_gap + p_size, z_gap - p_size); |
| 922 | plane_v[1].SetXYZ(x_offset+d+x_gap, y_gap + p_size, z_gap + p_size); |
946 | plane_v[1].SetXYZ(x_offset+d+x_gap, y_gap + p_size, z_gap + p_size); |
| 923 | plane_v[2].SetXYZ(x_offset+d+x_gap, y_gap - p_size, z_gap + p_size); |
947 | plane_v[2].SetXYZ(x_offset+d+x_gap, y_gap - p_size, z_gap + p_size); |
| 924 | plane_v[3].SetXYZ(x_offset+d+x_gap, y_gap - p_size, z_gap - p_size); |
948 | plane_v[3].SetXYZ(x_offset+d+x_gap, y_gap - p_size, z_gap - p_size); |
| 925 | active = new CPlane4(plane_v); |
949 | active = new CPlane4(plane_v); |
| 926 | 950 | ||
| 927 | hactive = (TH2F*)gROOT->FindObject("hactive"); if(hactive) delete hactive; |
951 | hactive = (TH2F*)gROOT->FindObject("hactive"); if(hactive) delete hactive; |
| 928 | //hactive = new TH2F("hactive", "Active area hits", nBins, y_gap - p_size, y_gap + p_size, nBins, z_gap - p_size, z_gap + p_size); |
952 | //hactive = new TH2F("hactive", "Active area hits", nBins, y_gap - p_size, y_gap + p_size, nBins, z_gap - p_size, z_gap + p_size); |
| 929 | hactive = new TH2F("hactive", "Active area hits", nBins, y_gap - p_size + offsetY, y_gap + p_size + offsetY, nBins, z_gap - p_size + offsetZ, z_gap + p_size + offsetZ); |
953 | hactive = new TH2F("hactive", "Active area hits", nBins, y_gap - p_size + offsetY, y_gap + p_size + offsetY, nBins, z_gap - p_size + offsetZ, z_gap + p_size + offsetZ); |
| 930 | 954 | ||
| 931 | p_size = b/2.0; |
955 | p_size = b/2.0; |
| 932 | //p_size = 2.5; |
956 | //p_size = 2.5; |
| 933 | //p_size = M*0.6; |
957 | //p_size = M*0.6; |
| 934 | hlaser = (TH2F*)gROOT->FindObject("hlaser"); if(hlaser) delete hlaser; |
958 | hlaser = (TH2F*)gROOT->FindObject("hlaser"); if(hlaser) delete hlaser; |
| 935 | hlaser = new TH2F("hlaser", ";x [mm]; y [mm]", nBins, -p_size+offsetY, p_size+offsetY, nBins, -p_size+offsetZ, p_size+offsetZ); |
959 | hlaser = new TH2F("hlaser", ";x [mm]; y [mm]", nBins, -p_size+offsetY, p_size+offsetY, nBins, -p_size+offsetZ, p_size+offsetZ); |
| 936 | 960 | ||
| 937 | - | ||
| - | 961 | // collection surface in SiPM plane |
|
| 938 | p_size = 1.4*b/2.0; |
962 | p_size = 1.4*b/2.0; |
| 939 | plane_v[0].SetXYZ(x_offset+d+x_gap, y_gap + p_size, z_gap - p_size); |
963 | plane_v[0].SetXYZ(x_offset+d+x_gap, y_gap + p_size, z_gap - p_size); |
| 940 | plane_v[1].SetXYZ(x_offset+d+x_gap, y_gap + p_size, z_gap + p_size); |
964 | plane_v[1].SetXYZ(x_offset+d+x_gap, y_gap + p_size, z_gap + p_size); |
| 941 | plane_v[2].SetXYZ(x_offset+d+x_gap, y_gap - p_size, z_gap + p_size); |
965 | plane_v[2].SetXYZ(x_offset+d+x_gap, y_gap - p_size, z_gap + p_size); |
| 942 | plane_v[3].SetXYZ(x_offset+d+x_gap, y_gap - p_size, z_gap - p_size); |
966 | plane_v[3].SetXYZ(x_offset+d+x_gap, y_gap - p_size, z_gap - p_size); |
| Line 980... | Line 1004... | ||
| 980 | { |
1004 | { |
| 981 | if (dbg) printf("--- Detector::Propagate ---\n"); |
1005 | if (dbg) printf("--- Detector::Propagate ---\n"); |
| 982 | //CRay *ray0 = new CRay; ray0->Set(in.GetR(), in.GetN()); ray0->SetColor(col_in); |
1006 | //CRay *ray0 = new CRay; ray0->Set(in.GetR(), in.GetN()); ray0->SetColor(col_in); |
| 983 | CRay *rayin = new CRay(in); |
1007 | CRay *rayin = new CRay(in); |
| 984 | rayin->SetColor(col_in); |
1008 | rayin->SetColor(col_in); |
| 985 | CRay *rayout = new CRay; |
1009 | CRay *rayout = new CRay(in); |
| - | 1010 | rayout->SetColor(col_in); |
|
| 986 | 1011 | ||
| 987 | const int max_n_points = guide->GetMAXODB() + 2; |
1012 | const int max_n_points = guide->GetMAXODB() + 2; |
| 988 | TVector3 pointsPlate[max_n_points]; |
1013 | TVector3 pointsPlate[max_n_points]; |
| 989 | //TVector3 intersection; |
1014 | //TVector3 intersection; |
| 990 | Fate fatePlate; |
1015 | Fate fatePlate; |
| Line 997... | Line 1022... | ||
| 997 | // check if the ray should be reflected?? |
1022 | // check if the ray should be reflected?? |
| 998 | 1023 | ||
| 999 | if(_plateOn) { |
1024 | if(_plateOn) { |
| 1000 | 1025 | ||
| 1001 | fatePlate = plate->propagateRay(*rayin, rayout, &nPointsPlate, pointsPlate); |
1026 | fatePlate = plate->propagateRay(*rayin, rayout, &nPointsPlate, pointsPlate); |
| 1002 | if(draw) rayin->DrawS(center.x()- _plateWidth, -10.0); |
1027 | if(draw) rayin->DrawS(center.x()- _plateWidth, -10.0); |
| 1003 | - | ||
| 1004 | if(draw) { |
1028 | if(draw) { |
| 1005 | if(fatePlate == missed) { |
1029 | if(fatePlate == missed) { |
| 1006 | rayout->SetColor(col_in); |
1030 | rayout->SetColor(col_in); |
| 1007 | rayout->DrawS(center.x() - _plateWidth, -10.0); |
1031 | rayout->DrawS(center.x() - _plateWidth, -10.0); |
| 1008 | } |
1032 | } |
| - | 1033 | else if(fatePlate == backreflected){ |
|
| - | 1034 | if (dbg) printf("Backreflected at plate!\n"); |
|
| - | 1035 | } |
|
| 1009 |
|
1036 | else { |
| 1010 | int p_i; |
1037 | int p_i; |
| 1011 | for(p_i = 0; p_i < nPointsPlate-1; p_i++) { |
1038 | for(p_i = 0; p_i < nPointsPlate-1; p_i++) { |
| 1012 | line3d->SetPoint(0, pointsPlate[p_i].x(), pointsPlate[p_i].y(), pointsPlate[p_i].z()); |
1039 | line3d->SetPoint(0, pointsPlate[p_i].x(), pointsPlate[p_i].y(), pointsPlate[p_i].z()); |
| 1013 | line3d->SetPoint(1, pointsPlate[p_i+1].x(), pointsPlate[p_i+1].y(), pointsPlate[p_i+1].z()); |
1040 | line3d->SetPoint(1, pointsPlate[p_i+1].x(), pointsPlate[p_i+1].y(), pointsPlate[p_i+1].z()); |
| 1014 | line3d->DrawClone(); |
1041 | line3d->DrawClone(); |
| 1015 | } |
1042 | } |
| - | 1043 | rayout->DrawS(pointsPlate[p_i].x(), -0.1); |
|
| 1016 | if(fatePlate |
1044 | if(fatePlate == noreflection) { // lost on plate side |
| 1017 |
|
1045 | rayout->SetColor(col_out); |
| 1018 | rayout->DrawS(pointsPlate[p_i].x(), |
1046 | rayout->DrawS(pointsPlate[p_i].x(), 10.0); |
| 1019 | } |
1047 | } |
| 1020 |
|
1048 | } |
| 1021 |
|
1049 | } |
| 1022 | 1050 | ||
| 1023 | if(! (fatePlate == hitExit or fatePlate == refracted) ) { |
1051 | if(! (fatePlate == hitExit or fatePlate == refracted) ) { |
| 1024 | 1052 | guide->GetHFate()->Fill(rays); |
|
| 1025 | if (dbg) |
1053 | if (dbg)printf("CDetector::propagate Simulated ray missed the entry surface!\n"); |
| - | 1054 | if (fatePlate == backreflected) |
|
| - | 1055 | guide->GetHFate()->Fill(fatePlate); // reflected back |
|
| - | 1056 | else |
|
| - | 1057 | guide->GetHFate()->Fill(noreflection); //lost on plate side |
|
| 1026 | return fatePlate; |
1058 | return fatePlate; |
| 1027 | } |
1059 | } |
| - | 1060 | ||
| 1028 |
|
1061 | //Ray hits light guide |
| 1029 | //if (fatePlate == refracted) return fatePlate; |
- | |
| 1030 | histoPlate->Fill(pointsPlate[0].y(), pointsPlate[0].z()); // entry point |
1062 | histoPlate->Fill(pointsPlate[0].y(), pointsPlate[0].z()); // entry point |
| - | 1063 | ||
| 1031 | } |
1064 | } |
| 1032 | else { |
1065 | else { |
| 1033 | rayout |
1066 | //rayout = rayin; |
| 1034 | if(draw) rayout->DrawS(center.x(), -10.0); |
1067 | if(draw) rayout->DrawS(center.x(), -10.0); |
| 1035 | } |
1068 | } |
| 1036 | 1069 | ||
| 1037 | // If the ray is not reflected in the plate |
1070 | // If the ray is not reflected in the plate |
| 1038 | // Draw the light guide and propagate the ray through |
1071 | // Draw the light guide and propagate the ray through |
| Line 1043... | Line 1076... | ||
| 1043 | 1076 | ||
| 1044 | int n_points; |
1077 | int n_points; |
| 1045 | int fate_glass; |
1078 | int fate_glass; |
| 1046 | CRay *ray0 = new CRay(*rayout); |
1079 | CRay *ray0 = new CRay(*rayout); |
| 1047 | // delete rayout; -> creates dangling reference when tries to delete ray0! |
1080 | // delete rayout; -> creates dangling reference when tries to delete ray0! |
| 1048 |
|
1081 | //delete rayin; -> delete rayout! |
| 1049 | CRay *ray1 = new CRay; |
1082 | CRay *ray1 = new CRay; |
| 1050 | 1083 | ||
| 1051 | fate = guide->PropagateRay(*ray0, ray1, &n_points, points); |
1084 | fate = guide->PropagateRay(*ray0, ray1, &n_points, points); |
| 1052 | if (dbg) { |
1085 | if (dbg) { |
| 1053 | if (fate == backreflected) printf("DETECTOR::backreflected\n"); |
1086 | if (fate == backreflected) printf("DETECTOR::backreflected\n"); |
| Line 1082... | Line 1115... | ||
| 1082 | 1115 | ||
| 1083 | 1116 | ||
| 1084 | if(! (fate == hitExit or fate == refracted) ) { |
1117 | if(! (fate == hitExit or fate == refracted) ) { |
| 1085 | if (dbg) printf("Detector: fate != hit, refracted\n"); |
1118 | if (dbg) printf("Detector: fate != hit, refracted\n"); |
| 1086 | *out = *ray1; |
1119 | *out = *ray1; |
| - | 1120 | delete ray0; |
|
| - | 1121 | delete ray1; |
|
| - | 1122 | delete rayout; |
|
| - | 1123 | delete rayin; |
|
| 1087 | return fate; |
1124 | return fate; |
| 1088 | } |
1125 | } |
| 1089 | } else { |
1126 | } else { |
| 1090 | if (dbg) printf("Detector: fate = hit or refracted"); |
1127 | if (dbg) printf("Detector: fate = hit or refracted"); |
| 1091 | ray1 = ray0; |
1128 | ray1 = ray0; |
| Line 1093... | Line 1130... | ||
| 1093 | if(glass_on) ray1->Draw(center.x(), center.x() /*+ window_d*/); |
1130 | if(glass_on) ray1->Draw(center.x(), center.x() /*+ window_d*/); |
| 1094 | else ray1->DrawS(center.x(), 10.0); |
1131 | else ray1->DrawS(center.x(), 10.0); |
| 1095 | } |
1132 | } |
| 1096 | } |
1133 | } |
| 1097 | 1134 | ||
| 1098 | /* |
- | |
| 1099 | TVector3 pres_wind; |
- | |
| 1100 | fate = window_circle->TestIntersection(&pres_wind, *ray1); |
- | |
| 1101 | if(fate == 1) { |
- | |
| 1102 | hwindow->Fill(pres_wind.y(), pres_wind.z()); |
- | |
| 1103 | |
- | |
| 1104 | if(!guide_on) { |
- | |
| 1105 | window->PropagateRay(*ray0, ray1, &presecisce); |
- | |
| 1106 | if(draw) ray1->Draw(center.x() + window_d, center.x() + glass_d); |
- | |
| 1107 | *ray0 = *ray1; |
- | |
| 1108 | } |
- | |
| 1109 | */ |
- | |
| 1110 | fate = missed; // zgresil aktivno povrsino |
1135 | fate = missed; // zgresil aktivno povrsino |
| 1111 | if(glass_on) { |
1136 | if(glass_on) { |
| 1112 | *ray0 = *ray1; ray1->SetColor(col_rgla); |
1137 | *ray0 = *ray1; ray1->SetColor(col_rgla); |
| 1113 | fate_glass = glass->PropagateRay(*ray0, ray1, &presecisce); |
1138 | fate_glass = glass->PropagateRay(*ray0, ray1, &presecisce); |
| 1114 | if(fate_glass == 1) { |
1139 | if(fate_glass == 1) { |
| 1115 | hglass->Fill(presecisce.y(), presecisce.z()); |
1140 | hglass->Fill(presecisce.y(), presecisce.z()); |
| 1116 | if(draw) ray1->DrawS(presecisce.x(), 10.0); |
1141 | if(draw) ray1->DrawS(presecisce.x(), 10.0); |
| 1117 | if(active->TestIntersection(&presecisce, *ray1)) { |
1142 | if(active->TestIntersection(&presecisce, *ray1)) { |
| 1118 | fate = hitExit; |
1143 | fate = hitExit; |
| 1119 | hactive->Fill(offsetY + presecisce.y(), offsetZ + presecisce.z()); |
1144 | hactive->Fill(offsetY + presecisce.y(), offsetZ + presecisce.z()); |
| 1120 | hlaser->Fill((in.GetR()).y(), (in.GetR()).z()); |
1145 | hlaser->Fill((in.GetR()).y(), (in.GetR()).z()); |
| 1121 | } |
1146 | } |
| Line 1128... | Line 1153... | ||
| 1128 | // Main test: ray and SiPM surface |
1153 | // Main test: ray and SiPM surface |
| 1129 | if(active->TestIntersection(&presecisce, *ray1)) { |
1154 | if(active->TestIntersection(&presecisce, *ray1)) { |
| 1130 | fate = hitExit; |
1155 | fate = hitExit; |
| 1131 | hactive->Fill(offsetY + presecisce.y(), offsetZ + presecisce.z()); |
1156 | hactive->Fill(offsetY + presecisce.y(), offsetZ + presecisce.z()); |
| 1132 | hlaser->Fill((in.GetR()).y() + offsetY, (in.GetR()).z() + offsetZ); |
1157 | hlaser->Fill((in.GetR()).y() + offsetY, (in.GetR()).z() + offsetZ); |
| 1133 | } |
1158 | } |
| 1134 | // If it is on the same plane as SiPM |
1159 | // If it is on the same plane as SiPM |
| 1135 | if(detector->TestIntersection(&presecisce, *ray1)) |
1160 | if(detector->TestIntersection(&presecisce, *ray1)) |
| 1136 | hdetector->Fill(offsetY + presecisce.y(), offsetZ + presecisce.z()); |
1161 | hdetector->Fill(offsetY + presecisce.y(), offsetZ + presecisce.z()); |
| 1137 | } |
1162 | } |
| 1138 | //} else { |
1163 | //} else { |
| Line 1141... | Line 1166... | ||
| 1141 | 1166 | ||
| 1142 | *out = *ray1; |
1167 | *out = *ray1; |
| 1143 | delete ray0; |
1168 | delete ray0; |
| 1144 | delete ray1; |
1169 | delete ray1; |
| 1145 | delete rayout; |
1170 | delete rayout; |
| - | 1171 | delete rayin; |
|
| 1146 | return fate; |
1172 | return fate; |
| 1147 | } |
1173 | } |
| 1148 | //----------------------------------------------------------------------------- |
1174 | //----------------------------------------------------------------------------- |
| 1149 | void CDetector::Draw(int width) |
1175 | void CDetector::Draw(int width) |
| 1150 | { |
1176 | { |
| Line 1169... | Line 1195... | ||
| 1169 | { |
1195 | { |
| 1170 | TVector3 center = CENTER; |
1196 | TVector3 center = CENTER; |
| 1171 | const double b = parameters.getB(); |
1197 | const double b = parameters.getB(); |
| 1172 | const double n1 = parameters.getN1(); |
1198 | const double n1 = parameters.getN1(); |
| 1173 | const double n2 = parameters.getN2(); |
1199 | const double n2 = parameters.getN2(); |
| 1174 | const double n3 = parameters.getN3(); |
- | |
| 1175 | const double reflectivity = c_reflectivity; |
- | |
| 1176 | const double t = b/2.; |
1200 | const double t = b/2.; |
| 1177 | const double plateWidth = parameters.getPlateWidth(); |
1201 | const double plateWidth = parameters.getPlateWidth(); |
| 1178 | center.SetX( CENTER.X() - plateWidth ); |
1202 | center.SetX( CENTER.X() - plateWidth ); |
| - | 1203 | ||
| 1179 | plate_edge[0].SetXYZ(0.0, t,- |
1204 | plate_edge[0].SetXYZ(0.0, t,-t); |
| - | 1205 | plate_edge[1].SetXYZ(0.0, t, t); |
|
| - | 1206 | plate_edge[2].SetXYZ(0.0,-t, t); |
|
| - | 1207 | plate_edge[3].SetXYZ(0.0,-t,-t); |
|
| 1180 | plate_edge[ |
1208 | plate_edge[4].SetXYZ(plateWidth, t,-t); |
| 1181 |
|
1209 | plate_edge[5].SetXYZ(plateWidth, t, t); |
| 1182 | plate_edge[6].SetXYZ(plateWidth,-t, |
1210 | plate_edge[6].SetXYZ(plateWidth,-t, t); |
| - | 1211 | plate_edge[7].SetXYZ(plateWidth,-t,-t); |
|
| 1183 | 1212 | ||
| 1184 | for(int i = 0; i<8; i++) plate_edge[i] += center; |
1213 | for(int i = 0; i<8; i++) plate_edge[i] += center; |
| 1185 | 1214 | ||
| 1186 | sides[0] = new CSurface(SURF_REFRA, plate_edge, n1, n2, |
1215 | sides[0] = new CSurface(SURF_REFRA, plate_edge, n1, n2, c_reflectivity); |
| 1187 | sides[0]->FlipN(); |
1216 | sides[0]->FlipN(); |
| 1188 | 1217 | ||
| 1189 | sides[1] = new CSurface(SURF_REFRA, plate_edge[3], plate_edge[2], plate_edge[6], plate_edge[7], n2, n2, |
1218 | sides[1] = new CSurface(SURF_REFRA, plate_edge[3], plate_edge[2], plate_edge[6], plate_edge[7], n2, n2, c_reflectivity); |
| 1190 | sides[2] = new CSurface(SURF_REFRA, plate_edge[2], plate_edge[1], plate_edge[5], plate_edge[6], n2, n2, |
1219 | sides[2] = new CSurface(SURF_REFRA, plate_edge[2], plate_edge[1], plate_edge[5], plate_edge[6], n2, n2, c_reflectivity); |
| 1191 | sides[3] = new CSurface(SURF_REFRA, plate_edge[1], plate_edge[0], plate_edge[4], plate_edge[5], n2, n2, |
1220 | sides[3] = new CSurface(SURF_REFRA, plate_edge[1], plate_edge[0], plate_edge[4], plate_edge[5], n2, n2, c_reflectivity); |
| 1192 | sides[4] = new CSurface(SURF_REFRA, plate_edge[0], plate_edge[3], plate_edge[7], plate_edge[4], n2, n2, |
1221 | sides[4] = new CSurface(SURF_REFRA, plate_edge[0], plate_edge[3], plate_edge[7], plate_edge[4], n2, n2, c_reflectivity); |
| 1193 | 1222 | ||
| 1194 | sides[5] = new CSurface(SURF_REFRA, &plate_edge[4], n2, |
1223 | sides[5] = new CSurface(SURF_REFRA, &plate_edge[4], n2, n2, c_reflectivity); |
| 1195 | sides[5]->FlipN(); |
1224 | sides[5]->FlipN(); |
| 1196 | 1225 | ||
| 1197 | for(int i=0; i<6; i++) sides[i]->SetFresnel(1); |
1226 | for(int i=0; i<6; i++) sides[i]->SetFresnel(1); |
| 1198 | } |
1227 | } |
| 1199 | 1228 | ||
| Line 1235... | Line 1264... | ||
| 1235 | } else if(result == REFLECTION) { |
1264 | } else if(result == REFLECTION) { |
| 1236 | if (dbg) printf("PLATE: reflected\n"); |
1265 | if (dbg) printf("PLATE: reflected\n"); |
| 1237 | fate = backreflected; |
1266 | fate = backreflected; |
| 1238 | } else { |
1267 | } else { |
| 1239 | points[0] = ray1.GetR(); |
1268 | points[0] = ray1.GetR(); |
| 1240 | //hfate->Fill( |
1269 | //hfate->Fill(enter); |
| 1241 | //hin->Fill(vec1.y(), vec1.z()); |
1270 | //hin->Fill(vec1.y(), vec1.z()); |
| 1242 | while (n_odb++ < MAX_REFLECTIONS) { |
1271 | while (n_odb++ < MAX_REFLECTIONS) { |
| 1243 | ray0 = ray1; |
1272 | ray0 = ray1; |
| 1244 | vec0 = vec1; |
1273 | vec0 = vec1; |
| 1245 | propagation = 11; |
1274 | propagation = 11; |
| Line 1262... | Line 1291... | ||
| 1262 | points[n_odb] = vec1; |
1291 | points[n_odb] = vec1; |
| 1263 | ray0 = ray1; |
1292 | ray0 = ray1; |
| 1264 | break; |
1293 | break; |
| 1265 | } |
1294 | } |
| 1266 | if(propagation == 1) { |
1295 | if(propagation == 1) { |
| 1267 | fate = |
1296 | fate = noreflection; //at side |
| 1268 | n_odb++; |
1297 | n_odb++; |
| 1269 | points[n_odb] = vec1; |
1298 | points[n_odb] = vec1; |
| 1270 | ray0 = ray1; |
1299 | ray0 = ray1; |
| 1271 | break;} // no total reflection when should be |
1300 | break;} // no total reflection when should be |
| 1272 | 1301 | ||