26 |
C then in a second step we check the residuals of the single |
C then in a second step we check the residuals of the single |
27 |
C measurements, reject if > 10 sigma, calculate chi2 and "quality" |
C measurements, reject if > 10 sigma, calculate chi2 and "quality" |
28 |
C beta is taken as good if chi2<20 and quality>10 |
C beta is taken as good if chi2<20 and quality>10 |
29 |
|
C mar-08 WM: Call to "newbeta" changed, now a flag tells the function if the |
30 |
|
C call comes from "tofl2com" or form "toftrack" |
31 |
|
C mar-08 WM: Bug found in dEdx if check_charge>1 |
32 |
|
C oct-08 WM: Calculation of zenith angle debugged, sometimes strange values |
33 |
|
C were possible |
34 |
C****************************************************************************** |
C****************************************************************************** |
35 |
|
|
36 |
INTEGER FUNCTION TOFL2COM() |
INTEGER FUNCTION TOFL2COM() |
50 |
INTEGER j,hitvec(6) |
INTEGER j,hitvec(6) |
51 |
|
|
52 |
REAL dx,dy,dr,ds |
REAL dx,dy,dr,ds |
53 |
REAL yhelp,xhelp,xhelp1,xhelp2 |
REAL yhelp,yhelp1,yhelp2,xhelp,xhelp1,xhelp2 |
54 |
REAL c1,c2 |
REAL c1,c2 |
55 |
|
|
56 |
C REAL sw,sxw,w_i |
C REAL sw,sxw,w_i |
580 |
hitvec(5)=tof31_i |
hitvec(5)=tof31_i |
581 |
hitvec(6)=tof32_i |
hitvec(6)=tof32_i |
582 |
|
|
|
c write(*,*) 'tofl2com', |
|
|
c & tof11_i,tof12_i,tof21_i,tof22_i,tof31_i,tof32_i |
|
583 |
|
|
584 |
C------------------------------------------------------------------ |
C------------------------------------------------------------------ |
585 |
C-- calculate track position in paddle using timing difference |
C-- calculate track position in paddle using timing difference |
636 |
C---------------------------------------------------------------------- |
C---------------------------------------------------------------------- |
637 |
C--------------------- zenith angle theta --------------------------- |
C--------------------- zenith angle theta --------------------------- |
638 |
C---------------------------------------------------------------------- |
C---------------------------------------------------------------------- |
639 |
|
C----------------------------- old ---------------------------------- |
640 |
|
c dx=0. |
641 |
|
c dy=0. |
642 |
|
c dr=0. |
643 |
|
c theta13 = 0. |
644 |
|
c |
645 |
|
c IF ((tof12_i.GT.none_find).AND.(tof32_i.GT.none_find)) |
646 |
|
c & dx = xtofpos(1) - xtofpos(3) |
647 |
|
c IF ((tof11_i.GT.none_find).AND.(tof31_i.GT.none_find)) |
648 |
|
c & dy = ytofpos(1) - ytofpos(3) |
649 |
|
c dr = sqrt(dx*dx+dy*dy) |
650 |
|
c theta13 = atan(dr/tofarm13) |
651 |
|
c |
652 |
|
c |
653 |
|
C----------------------------- new ------------------------------ |
654 |
|
|
655 |
|
xhelp1=0. |
656 |
|
if (tof11_i.GT.none_find) xhelp1=tof11_x(tof11_i) |
657 |
|
if (xtofpos(1).lt.100) xhelp1=xtofpos(1) |
658 |
|
|
659 |
|
yhelp1=0. |
660 |
|
if (tof12_i.GT.none_find) yhelp1=tof12_y(tof12_i) |
661 |
|
if (ytofpos(1).lt.100) yhelp1=ytofpos(1) |
662 |
|
|
663 |
|
|
664 |
|
yhelp2=0. |
665 |
|
if (tof32_i.GT.none_find) yhelp2=tof32_y(tof32_i) |
666 |
|
if (ytofpos(3).lt.100) yhelp2=ytofpos(3) |
667 |
|
|
668 |
|
xhelp2=0. |
669 |
|
if (tof31_i.GT.none_find) xhelp2=tof31_x(tof31_i) |
670 |
|
if (xtofpos(3).lt.100) xhelp2=xtofpos(3) |
671 |
|
|
672 |
|
|
673 |
dx=0. |
dx=0. |
674 |
dy=0. |
dy=0. |
675 |
dr=0. |
dr=0. |
676 |
theta13 = 0. |
theta13 = 0. |
677 |
|
|
678 |
IF ((tof12_i.GT.none_find).AND.(tof32_i.GT.none_find)) |
dx = xhelp1 - xhelp2 |
679 |
& dx = xtofpos(1) - xtofpos(3) |
dy = yhelp1 - yhelp2 |
680 |
IF ((tof11_i.GT.none_find).AND.(tof31_i.GT.none_find)) |
dr = sqrt(dx*dx+dy*dy) |
681 |
& dy = ytofpos(1) - ytofpos(3) |
theta13 = atan(dr/tofarm13) |
|
dr = sqrt(dx*dx+dy*dy) |
|
|
theta13 = atan(dr/tofarm13) |
|
682 |
|
|
683 |
|
|
684 |
C---------------------------------------------------------------------- |
C---------------------------------------------------------------------- |
690 |
C---------------------------------------------------------------------- |
C---------------------------------------------------------------------- |
691 |
|
|
692 |
iz = int(check_charge(theta13,hitvec)) |
iz = int(check_charge(theta13,hitvec)) |
693 |
C write(*,*) 'in tofl2com',iz |
c write(*,*) 'charge in tofl2com',iz |
694 |
|
|
695 |
C-------------------------------------------------------------------- |
C-------------------------------------------------------------------- |
696 |
C---- if TDCleft.and.TDCright and NO ADC insert artificial ADC |
C---- if TDCleft.and.TDCright and NO ADC insert artificial ADC |
707 |
|
|
708 |
C---------------------------- S1 ------------------------------------- |
C---------------------------- S1 ------------------------------------- |
709 |
|
|
710 |
yhelp=0. |
c yhelp=0. |
711 |
|
yhelp=100. ! WM |
712 |
if (tof12_i.GT.none_find) yhelp=tof12_y(tof12_i) |
if (tof12_i.GT.none_find) yhelp=tof12_y(tof12_i) |
713 |
if (ytofpos(1).lt.100) yhelp=ytofpos(1) |
if (ytofpos(1).lt.100) yhelp=ytofpos(1) |
714 |
|
|
728 |
endif |
endif |
729 |
ENDIF |
ENDIF |
730 |
|
|
731 |
xhelp=0. |
c xhelp=0. |
732 |
|
xhelp=100. ! WM |
733 |
if (tof11_i.GT.none_find) xhelp=tof11_x(tof11_i) |
if (tof11_i.GT.none_find) xhelp=tof11_x(tof11_i) |
734 |
if (xtofpos(1).lt.100) xhelp=xtofpos(1) |
if (xtofpos(1).lt.100) xhelp=xtofpos(1) |
735 |
|
|
751 |
|
|
752 |
C-----------------------------S2 -------------------------------- |
C-----------------------------S2 -------------------------------- |
753 |
|
|
754 |
xhelp=0. |
c xhelp=0. |
755 |
|
xhelp=100. ! WM |
756 |
if (tof22_i.GT.none_find) xhelp=tof22_x(tof22_i) |
if (tof22_i.GT.none_find) xhelp=tof22_x(tof22_i) |
757 |
if (xtofpos(2).lt.100) xhelp=xtofpos(2) |
if (xtofpos(2).lt.100) xhelp=xtofpos(2) |
758 |
|
|
773 |
ENDIF |
ENDIF |
774 |
|
|
775 |
|
|
776 |
yhelp=0. |
c yhelp=0. |
777 |
|
yhelp=100. ! WM |
778 |
if (tof21_i.GT.none_find) yhelp=tof21_y(tof21_i) |
if (tof21_i.GT.none_find) yhelp=tof21_y(tof21_i) |
779 |
if (ytofpos(2).lt.100) yhelp=ytofpos(2) |
if (ytofpos(2).lt.100) yhelp=ytofpos(2) |
780 |
|
|
796 |
|
|
797 |
C-----------------------------S3 -------------------------------- |
C-----------------------------S3 -------------------------------- |
798 |
|
|
799 |
yhelp=0. |
c yhelp=0. |
800 |
|
yhelp=100. ! WM |
801 |
if (tof32_i.GT.none_find) yhelp=tof32_y(tof32_i) |
if (tof32_i.GT.none_find) yhelp=tof32_y(tof32_i) |
802 |
if (ytofpos(3).lt.100) yhelp=ytofpos(3) |
if (ytofpos(3).lt.100) yhelp=ytofpos(3) |
803 |
|
|
817 |
endif |
endif |
818 |
ENDIF |
ENDIF |
819 |
|
|
820 |
xhelp=0. |
c xhelp=0. |
821 |
|
xhelp=100. ! WM |
822 |
if (tof31_i.GT.none_find) xhelp=tof31_x(tof31_i) |
if (tof31_i.GT.none_find) xhelp=tof31_x(tof31_i) |
823 |
if (xtofpos(3).lt.100) xhelp=xtofpos(3) |
if (xtofpos(3).lt.100) xhelp=xtofpos(3) |
824 |
|
|
959 |
ENDIF |
ENDIF |
960 |
ENDDO |
ENDDO |
961 |
|
|
962 |
|
|
963 |
C--------------------------------------------------------------- |
C--------------------------------------------------------------- |
964 |
C--- calculate track position in paddle using timing difference |
C--- calculate track position in paddle using timing difference |
965 |
C--- now using the time-walk corrected TDC values |
C--- now using the time-walk corrected TDC values |
975 |
IF (tof11_i.GT.none_find) THEN |
IF (tof11_i.GT.none_find) THEN |
976 |
ytofpos(1) = ((tof11(1,tof11_i,itdc)-tof11(2,tof11_i,itdc))/2. |
ytofpos(1) = ((tof11(1,tof11_i,itdc)-tof11(2,tof11_i,itdc))/2. |
977 |
+ -y_coor_lin11(tof11_i,offset))/y_coor_lin11(tof11_i,slope) |
+ -y_coor_lin11(tof11_i,offset))/y_coor_lin11(tof11_i,slope) |
978 |
|
i=tof11_i |
979 |
endif |
endif |
980 |
|
|
981 |
IF (tof12_i.GT.none_find) THEN |
IF (tof12_i.GT.none_find) THEN |
982 |
xtofpos(1) = ((tof12(1,tof12_i,itdc)-tof12(2,tof12_i,itdc))/2. |
xtofpos(1) = ((tof12(1,tof12_i,itdc)-tof12(2,tof12_i,itdc))/2. |
983 |
+ -x_coor_lin12(tof12_i,offset))/x_coor_lin12(tof12_i,slope) |
+ -x_coor_lin12(tof12_i,offset))/x_coor_lin12(tof12_i,slope) |
984 |
|
i=tof12_i |
985 |
endif |
endif |
986 |
|
|
987 |
|
|
990 |
IF (tof21_i.GT.none_find) THEN |
IF (tof21_i.GT.none_find) THEN |
991 |
xtofpos(2) = ((tof21(1,tof21_i,itdc)-tof21(2,tof21_i,itdc))/2. |
xtofpos(2) = ((tof21(1,tof21_i,itdc)-tof21(2,tof21_i,itdc))/2. |
992 |
+ -x_coor_lin21(tof21_i,offset))/x_coor_lin21(tof21_i,slope) |
+ -x_coor_lin21(tof21_i,offset))/x_coor_lin21(tof21_i,slope) |
993 |
|
i=tof21_i |
994 |
endif |
endif |
995 |
|
|
996 |
IF (tof22_i.GT.none_find) THEN |
IF (tof22_i.GT.none_find) THEN |
997 |
ytofpos(2) = ((tof22(1,tof22_i,itdc)-tof22(2,tof22_i,itdc))/2. |
ytofpos(2) = ((tof22(1,tof22_i,itdc)-tof22(2,tof22_i,itdc))/2. |
998 |
+ -y_coor_lin22(tof22_i,offset))/y_coor_lin22(tof22_i,slope) |
+ -y_coor_lin22(tof22_i,offset))/y_coor_lin22(tof22_i,slope) |
999 |
|
i=tof22_i |
1000 |
endif |
endif |
1001 |
|
|
1002 |
|
|
1005 |
IF (tof31_i.GT.none_find) THEN |
IF (tof31_i.GT.none_find) THEN |
1006 |
ytofpos(3) = ((tof31(1,tof31_i,itdc)-tof31(2,tof31_i,itdc))/2. |
ytofpos(3) = ((tof31(1,tof31_i,itdc)-tof31(2,tof31_i,itdc))/2. |
1007 |
+ -y_coor_lin31(tof31_i,offset))/y_coor_lin31(tof31_i,slope) |
+ -y_coor_lin31(tof31_i,offset))/y_coor_lin31(tof31_i,slope) |
1008 |
|
i=tof31_i |
1009 |
endif |
endif |
1010 |
|
|
1011 |
IF (tof32_i.GT.none_find) THEN |
IF (tof32_i.GT.none_find) THEN |
1012 |
xtofpos(3) = ((tof32(1,tof32_i,itdc)-tof32(2,tof32_i,itdc))/2. |
xtofpos(3) = ((tof32(1,tof32_i,itdc)-tof32(2,tof32_i,itdc))/2. |
1013 |
+ -x_coor_lin32(tof32_i,offset))/x_coor_lin32(tof32_i,slope) |
+ -x_coor_lin32(tof32_i,offset))/x_coor_lin32(tof32_i,slope) |
1014 |
|
i=tof32_i |
1015 |
endif |
endif |
1016 |
|
|
1017 |
|
|
1024 |
c endif |
c endif |
1025 |
c enddo |
c enddo |
1026 |
|
|
1027 |
|
|
1028 |
C-- restrict TDC measurements to physical paddle dimensions +/- 10 cm |
C-- restrict TDC measurements to physical paddle dimensions +/- 10 cm |
1029 |
C-- this cut is now stronger than in the old versions |
C-- this cut is now stronger than in the old versions |
1030 |
|
|
1036 |
if (abs(ytofpos(2)).gt.18.) ytofpos(2)=101. |
if (abs(ytofpos(2)).gt.18.) ytofpos(2)=101. |
1037 |
if (abs(ytofpos(3)).gt.18.) ytofpos(3)=101. |
if (abs(ytofpos(3)).gt.18.) ytofpos(3)=101. |
1038 |
|
|
|
|
|
1039 |
C---------------------------------------------------------------------- |
C---------------------------------------------------------------------- |
1040 |
C--------------------- zenith angle theta --------------------------- |
C--------------------- zenith angle theta --------------------------- |
1041 |
C---------------------------------------------------------------------- |
C---------------------------------------------------------------------- |
1042 |
|
C------------------- improved calculation --------------------------- |
1043 |
|
|
1044 |
|
xhelp1=0. |
1045 |
|
if (tof11_i.GT.none_find) xhelp1=tof11_x(tof11_i) |
1046 |
|
if (xtofpos(1).lt.100) xhelp1=xtofpos(1) |
1047 |
|
|
1048 |
|
yhelp1=0. |
1049 |
|
if (tof12_i.GT.none_find) yhelp1=tof12_y(tof12_i) |
1050 |
|
if (ytofpos(1).lt.100) yhelp1=ytofpos(1) |
1051 |
|
|
1052 |
|
yhelp2=0. |
1053 |
|
if (tof32_i.GT.none_find) yhelp2=tof32_y(tof32_i) |
1054 |
|
if (ytofpos(3).lt.100) yhelp2=ytofpos(3) |
1055 |
|
|
1056 |
|
xhelp2=0. |
1057 |
|
if (tof31_i.GT.none_find) xhelp2=tof31_x(tof31_i) |
1058 |
|
if (xtofpos(3).lt.100) xhelp2=xtofpos(3) |
1059 |
|
|
1060 |
|
|
1061 |
|
dx=0. |
1062 |
|
dy=0. |
1063 |
|
dr=0. |
1064 |
|
theta13 = 0. |
1065 |
|
|
1066 |
|
dx = xhelp1 - xhelp2 |
1067 |
|
dy = yhelp1 - yhelp2 |
1068 |
|
dr = sqrt(dx*dx+dy*dy) |
1069 |
|
theta13 = atan(dr/tofarm13) |
1070 |
|
|
|
dx=0. |
|
|
dy=0. |
|
|
dr=0. |
|
|
theta13 = 0. |
|
|
|
|
|
IF ((tof12_i.GT.none_find).AND.(tof32_i.GT.none_find)) |
|
|
& dx = xtofpos(1) - xtofpos(3) |
|
|
IF ((tof11_i.GT.none_find).AND.(tof31_i.GT.none_find)) |
|
|
& dy = ytofpos(1) - ytofpos(3) |
|
|
dr = sqrt(dx*dx+dy*dy) |
|
|
theta13 = atan(dr/tofarm13) |
|
1071 |
|
|
1072 |
C------------------------------------------------------------------ |
C------------------------------------------------------------------ |
|
c dx=0. |
|
|
c dy=0. |
|
|
c dr=0. |
|
|
c theta12 = 0. |
|
|
c |
|
|
c IF ((tof12_i.GT.none_find).AND.(tof21_i.GT.none_find)) |
|
|
c & dx = xtofpos(1) - xtofpos(2) |
|
|
c IF ((tof11_i.GT.none_find).AND.(tof22_i.GT.none_find)) |
|
|
c & dy = ytofpos(1) - ytofpos(2) |
|
|
c dr = sqrt(dx*dx+dy*dy) |
|
|
c theta12 = atan(dr/tofarm12) |
|
|
c |
|
|
c dx=0. |
|
|
c dy=0. |
|
|
c dr=0. |
|
|
c theta23 = 0. |
|
|
c |
|
|
c IF ((tof21_i.GT.none_find).AND.(tof32_i.GT.none_find)) |
|
|
c & dx = xtofpos(2) - xtofpos(3) |
|
|
c IF ((tof22_i.GT.none_find).AND.(tof31_i.GT.none_find)) |
|
|
c & dy = ytofpos(2) - ytofpos(3) |
|
|
c dr = sqrt(dx*dx+dy*dy) |
|
|
c theta23 = atan(dr/tofarm23) |
|
|
c |
|
1073 |
C---------------------------------------------------------------------- |
C---------------------------------------------------------------------- |
1074 |
C------------------angle and ADC(x) correction |
C------------------angle and ADC(x) correction |
1075 |
C---------------------------------------------------------------------- |
C---------------------------------------------------------------------- |
1083 |
c DATA tof32_y/ -5.0,0.0,5.0/ |
c DATA tof32_y/ -5.0,0.0,5.0/ |
1084 |
|
|
1085 |
yhelp=0. |
yhelp=0. |
1086 |
|
c yhelp=100. |
1087 |
if (tof12_i.GT.none_find) yhelp=tof12_y(tof12_i) |
if (tof12_i.GT.none_find) yhelp=tof12_y(tof12_i) |
1088 |
if (ytofpos(1).lt.100) yhelp=ytofpos(1) |
if (ytofpos(1).lt.100) yhelp=ytofpos(1) |
1089 |
|
|
1094 |
c if (adc(ch11a(i),hb11a(i)).lt.4095) then |
c if (adc(ch11a(i),hb11a(i)).lt.4095) then |
1095 |
tof11(left,i,iadc) = tof11(left,i,iadc)*cos(theta13) |
tof11(left,i,iadc) = tof11(left,i,iadc)*cos(theta13) |
1096 |
xkorr = atten(left,11,i,yhelp) |
xkorr = atten(left,11,i,yhelp) |
1097 |
c write(40+i,*) yhelp,xkorr |
xkorr=xkorr/hepratio |
|
if (iz.le.1) xkorr=xkorr/hepratio |
|
1098 |
adctof_c(ch11a(i),hb11a(i))=tof11(left,i,iadc)/xkorr |
adctof_c(ch11a(i),hb11a(i))=tof11(left,i,iadc)/xkorr |
1099 |
endif |
endif |
1100 |
|
|
1102 |
c if (adc(ch11b(i),hb11b(i)).lt.4095) then |
c if (adc(ch11b(i),hb11b(i)).lt.4095) then |
1103 |
tof11(right,i,iadc) = tof11(right,i,iadc)*cos(theta13) |
tof11(right,i,iadc) = tof11(right,i,iadc)*cos(theta13) |
1104 |
xkorr = atten(right,11,i,yhelp) |
xkorr = atten(right,11,i,yhelp) |
1105 |
c write(40+i,*) yhelp,xkorr |
xkorr=xkorr/hepratio |
|
if (iz.le.1) xkorr=xkorr/hepratio |
|
1106 |
adctof_c(ch11b(i),hb11b(i))=tof11(right,i,iadc)/xkorr |
adctof_c(ch11b(i),hb11b(i))=tof11(right,i,iadc)/xkorr |
1107 |
endif |
endif |
1108 |
ENDIF |
ENDIF |
1109 |
|
|
1110 |
xhelp=0. |
xhelp=0. |
1111 |
|
c xhelp=100. |
1112 |
if (tof11_i.GT.none_find) xhelp=tof11_x(tof11_i) |
if (tof11_i.GT.none_find) xhelp=tof11_x(tof11_i) |
1113 |
if (xtofpos(1).lt.100) xhelp=xtofpos(1) |
if (xtofpos(1).lt.100) xhelp=xtofpos(1) |
1114 |
|
|
1119 |
c if (adc(ch12a(i),hb12a(i)).lt.4095) then |
c if (adc(ch12a(i),hb12a(i)).lt.4095) then |
1120 |
tof12(left,i,iadc) = tof12(left,i,iadc)*cos(theta13) |
tof12(left,i,iadc) = tof12(left,i,iadc)*cos(theta13) |
1121 |
xkorr = atten(left,12,i,xhelp) |
xkorr = atten(left,12,i,xhelp) |
1122 |
c write(50+i,*) xhelp,xkorr |
xkorr=xkorr/hepratio |
|
if (iz.le.1) xkorr=xkorr/hepratio |
|
1123 |
adctof_c(ch12a(i),hb12a(i))=tof12(left,i,iadc)/xkorr |
adctof_c(ch12a(i),hb12a(i))=tof12(left,i,iadc)/xkorr |
1124 |
endif |
endif |
1125 |
|
|
1127 |
c if (adc(ch12b(i),hb12b(i)).lt.4095) then |
c if (adc(ch12b(i),hb12b(i)).lt.4095) then |
1128 |
tof12(right,i,iadc) = tof12(right,i,iadc)*cos(theta13) |
tof12(right,i,iadc) = tof12(right,i,iadc)*cos(theta13) |
1129 |
xkorr = atten(right,12,i,xhelp) |
xkorr = atten(right,12,i,xhelp) |
1130 |
c write(50+i,*) xhelp,xkorr |
xkorr=xkorr/hepratio |
|
if (iz.le.1) xkorr=xkorr/hepratio |
|
1131 |
adctof_c(ch12b(i),hb12b(i))=tof12(right,i,iadc)/xkorr |
adctof_c(ch12b(i),hb12b(i))=tof12(right,i,iadc)/xkorr |
1132 |
endif |
endif |
1133 |
ENDIF |
ENDIF |
1135 |
C-----------------------------S2 -------------------------------- |
C-----------------------------S2 -------------------------------- |
1136 |
|
|
1137 |
xhelp=0. |
xhelp=0. |
1138 |
|
c xhelp=100. |
1139 |
if (tof22_i.GT.none_find) xhelp=tof22_x(tof22_i) |
if (tof22_i.GT.none_find) xhelp=tof22_x(tof22_i) |
1140 |
if (xtofpos(2).lt.100) xhelp=xtofpos(2) |
if (xtofpos(2).lt.100) xhelp=xtofpos(2) |
1141 |
|
|
1146 |
c if (adc(ch21a(i),hb21a(i)).lt.4095) then |
c if (adc(ch21a(i),hb21a(i)).lt.4095) then |
1147 |
tof21(left,i,iadc) = tof21(left,i,iadc)*cos(theta13) |
tof21(left,i,iadc) = tof21(left,i,iadc)*cos(theta13) |
1148 |
xkorr = atten(left,21,i,xhelp) |
xkorr = atten(left,21,i,xhelp) |
1149 |
c write(60+i,*) xhelp,xkorr |
xkorr=xkorr/hepratio |
|
if (iz.le.1) xkorr=xkorr/hepratio |
|
1150 |
adctof_c(ch21a(i),hb21a(i))=tof21(left,i,iadc)/xkorr |
adctof_c(ch21a(i),hb21a(i))=tof21(left,i,iadc)/xkorr |
1151 |
endif |
endif |
1152 |
|
|
1155 |
tof21(right,i,iadc) = tof21(right,i,iadc)*cos(theta13) |
tof21(right,i,iadc) = tof21(right,i,iadc)*cos(theta13) |
1156 |
xkorr=adcx21(right,i,1)*exp(xhelp/adcx21(right,i,2)) |
xkorr=adcx21(right,i,1)*exp(xhelp/adcx21(right,i,2)) |
1157 |
xkorr = atten(right,21,i,xhelp) |
xkorr = atten(right,21,i,xhelp) |
1158 |
c write(60+i,*) xhelp,xkorr |
xkorr=xkorr/hepratio |
|
if (iz.le.1) xkorr=xkorr/hepratio |
|
1159 |
adctof_c(ch21b(i),hb21b(i))=tof21(right,i,iadc)/xkorr |
adctof_c(ch21b(i),hb21b(i))=tof21(right,i,iadc)/xkorr |
1160 |
endif |
endif |
1161 |
ENDIF |
ENDIF |
1162 |
|
|
1163 |
|
|
1164 |
yhelp=0. |
yhelp=0. |
1165 |
|
c yhelp=100. |
1166 |
if (tof21_i.GT.none_find) yhelp=tof21_y(tof21_i) |
if (tof21_i.GT.none_find) yhelp=tof21_y(tof21_i) |
1167 |
if (ytofpos(2).lt.100) yhelp=ytofpos(2) |
if (ytofpos(2).lt.100) yhelp=ytofpos(2) |
1168 |
|
|
1173 |
c if (adc(ch22a(i),hb22a(i)).lt.4095) then |
c if (adc(ch22a(i),hb22a(i)).lt.4095) then |
1174 |
tof22(left,i,iadc) = tof22(left,i,iadc)*cos(theta13) |
tof22(left,i,iadc) = tof22(left,i,iadc)*cos(theta13) |
1175 |
xkorr = atten(left,22,i,yhelp) |
xkorr = atten(left,22,i,yhelp) |
1176 |
c write(70+i,*) yhelp,xkorr |
xkorr=xkorr/hepratio |
|
if (iz.le.1) xkorr=xkorr/hepratio |
|
1177 |
adctof_c(ch22a(i),hb22a(i))=tof22(left,i,iadc)/xkorr |
adctof_c(ch22a(i),hb22a(i))=tof22(left,i,iadc)/xkorr |
1178 |
endif |
endif |
1179 |
|
|
1181 |
c if (adc(ch22b(i),hb22b(i)).lt.4095) then |
c if (adc(ch22b(i),hb22b(i)).lt.4095) then |
1182 |
tof22(right,i,iadc) = tof22(right,i,iadc)*cos(theta13) |
tof22(right,i,iadc) = tof22(right,i,iadc)*cos(theta13) |
1183 |
xkorr = atten(right,22,i,yhelp) |
xkorr = atten(right,22,i,yhelp) |
1184 |
c write(70+i,*) yhelp,xkorr |
xkorr=xkorr/hepratio |
|
if (iz.le.1) xkorr=xkorr/hepratio |
|
1185 |
adctof_c(ch22b(i),hb22b(i))=tof22(right,i,iadc)/xkorr |
adctof_c(ch22b(i),hb22b(i))=tof22(right,i,iadc)/xkorr |
1186 |
endif |
endif |
1187 |
ENDIF |
ENDIF |
1189 |
C-----------------------------S3 -------------------------------- |
C-----------------------------S3 -------------------------------- |
1190 |
|
|
1191 |
yhelp=0. |
yhelp=0. |
1192 |
|
c yhelp=100. |
1193 |
if (tof32_i.GT.none_find) yhelp=tof32_y(tof32_i) |
if (tof32_i.GT.none_find) yhelp=tof32_y(tof32_i) |
1194 |
if (ytofpos(3).lt.100) yhelp=ytofpos(3) |
if (ytofpos(3).lt.100) yhelp=ytofpos(3) |
1195 |
|
|
1200 |
c if (adc(ch31a(i),hb31a(i)).lt.4095) then |
c if (adc(ch31a(i),hb31a(i)).lt.4095) then |
1201 |
tof31(left,i,iadc) = tof31(left,i,iadc)*cos(theta13) |
tof31(left,i,iadc) = tof31(left,i,iadc)*cos(theta13) |
1202 |
xkorr = atten(left,31,i,yhelp) |
xkorr = atten(left,31,i,yhelp) |
1203 |
c write(80+i,*) yhelp,xkorr |
xkorr=xkorr/hepratio |
|
if (iz.le.1) xkorr=xkorr/hepratio |
|
1204 |
adctof_c(ch31a(i),hb31a(i))=tof31(left,i,iadc)/xkorr |
adctof_c(ch31a(i),hb31a(i))=tof31(left,i,iadc)/xkorr |
1205 |
endif |
endif |
1206 |
|
|
1208 |
c if (adc(ch31b(i),hb31b(i)).lt.4095) then |
c if (adc(ch31b(i),hb31b(i)).lt.4095) then |
1209 |
tof31(right,i,iadc) = tof31(right,i,iadc)*cos(theta13) |
tof31(right,i,iadc) = tof31(right,i,iadc)*cos(theta13) |
1210 |
xkorr = atten(right,31,i,yhelp) |
xkorr = atten(right,31,i,yhelp) |
1211 |
c write(80+i,*) yhelp,xkorr |
xkorr=xkorr/hepratio |
|
if (iz.le.1) xkorr=xkorr/hepratio |
|
1212 |
adctof_c(ch31b(i),hb31b(i))=tof31(right,i,iadc)/xkorr |
adctof_c(ch31b(i),hb31b(i))=tof31(right,i,iadc)/xkorr |
1213 |
endif |
endif |
1214 |
ENDIF |
ENDIF |
1215 |
|
|
1216 |
xhelp=0. |
xhelp=0. |
1217 |
|
c xhelp=100. |
1218 |
if (tof31_i.GT.none_find) xhelp=tof31_x(tof31_i) |
if (tof31_i.GT.none_find) xhelp=tof31_x(tof31_i) |
1219 |
if (xtofpos(3).lt.100) xhelp=xtofpos(3) |
if (xtofpos(3).lt.100) xhelp=xtofpos(3) |
1220 |
|
|
1225 |
c if (adc(ch32a(i),hb32a(i)).lt.4095) then |
c if (adc(ch32a(i),hb32a(i)).lt.4095) then |
1226 |
tof32(left,i,iadc) = tof32(left,i,iadc)*cos(theta13) |
tof32(left,i,iadc) = tof32(left,i,iadc)*cos(theta13) |
1227 |
xkorr = atten(left,32,i,xhelp) |
xkorr = atten(left,32,i,xhelp) |
1228 |
c write(90+i,*) xhelp,xkorr |
xkorr=xkorr/hepratio |
|
if (iz.le.1) xkorr=xkorr/hepratio |
|
1229 |
adctof_c(ch32a(i),hb32a(i))=tof32(left,i,iadc)/xkorr |
adctof_c(ch32a(i),hb32a(i))=tof32(left,i,iadc)/xkorr |
1230 |
endif |
endif |
1231 |
|
|
1233 |
c if (adc(ch32b(i),hb32b(i)).lt.4095) then |
c if (adc(ch32b(i),hb32b(i)).lt.4095) then |
1234 |
tof32(right,i,iadc) = tof32(right,i,iadc)*cos(theta13) |
tof32(right,i,iadc) = tof32(right,i,iadc)*cos(theta13) |
1235 |
xkorr = atten(right,32,i,xhelp) |
xkorr = atten(right,32,i,xhelp) |
1236 |
c write(90+i,*) xhelp,xkorr |
xkorr=xkorr/hepratio |
|
if (iz.le.1) xkorr=xkorr/hepratio |
|
1237 |
adctof_c(ch32b(i),hb32b(i))=tof32(right,i,iadc)/xkorr |
adctof_c(ch32b(i),hb32b(i))=tof32(right,i,iadc)/xkorr |
1238 |
endif |
endif |
1239 |
ENDIF |
ENDIF |
1618 |
C if (icount.gt.0) beta_mean=sxw/sw |
C if (icount.gt.0) beta_mean=sxw/sw |
1619 |
C betatof_a(13) = beta_mean |
C betatof_a(13) = beta_mean |
1620 |
C |
C |
1621 |
|
|
1622 |
C-------- New mean beta calculation ----------------------- |
C-------- New mean beta calculation ----------------------- |
1623 |
|
|
1624 |
do i=1,12 |
do i=1,12 |
1625 |
btemp(i) = betatof_a(i) |
btemp(i) = betatof_a(i) |
1626 |
enddo |
enddo |
1627 |
|
|
1628 |
betatof_a(13)=newbeta(btemp,hitvec,10.,10.,20.) |
betatof_a(13)=newbeta(1,btemp,hitvec,10.,10.,20.) |
1629 |
|
|
1630 |
C-------------------------------------------------------------- |
C-------------------------------------------------------------- |
1631 |
C write(*,*) betatof_a |
C write(*,*) betatof_a |
2148 |
C**************************************************************************** |
C**************************************************************************** |
2149 |
C**************************************************************************** |
C**************************************************************************** |
2150 |
|
|
2151 |
function newbeta(b,hitvec,resmax,qualitycut,chi2cut) |
function newbeta(iflag,b,hitvec,resmax,qualitycut,chi2cut) |
2152 |
|
|
2153 |
include 'input_tof.txt' |
include 'input_tof.txt' |
2154 |
include 'output_tof.txt' |
include 'output_tof.txt' |
2158 |
REAL resmax,qualitycut,chi2cut |
REAL resmax,qualitycut,chi2cut |
2159 |
REAL w_i(12),w_il(6),quality,res,betachi,beta_mean_inv |
REAL w_i(12),w_il(6),quality,res,betachi,beta_mean_inv |
2160 |
REAL sw,sxw,b(12),beta_mean,chi2,xhelp |
REAL sw,sxw,b(12),beta_mean,chi2,xhelp |
2161 |
|
REAL tdcfl(4,12) |
2162 |
|
|
2163 |
INTEGER icount,hitvec(6) |
INTEGER iflag,icount,hitvec(6) |
2164 |
|
|
2165 |
INTEGER itop(12),ibot(12) |
INTEGER itop(12),ibot(12) |
2166 |
DATA itop /1,1,2,2,3,3,4,4,1,1,2,2/ |
DATA itop /1,1,2,2,3,3,4,4,1,1,2,2/ |
2175 |
tof31_i = hitvec(5) |
tof31_i = hitvec(5) |
2176 |
tof32_i = hitvec(6) |
tof32_i = hitvec(6) |
2177 |
|
|
2178 |
c write(*,*) '------------ In NEWBETA ----------------' |
if (iflag.eq.1) then ! call from tofl2com |
2179 |
c write(*,*) hitvec |
do i=1,4 |
2180 |
c write(*,*) b |
do j=1,12 |
2181 |
|
tdcfl(i,j) = tdcflagtof(i,j) |
2182 |
|
enddo |
2183 |
|
enddo |
2184 |
|
endif |
2185 |
|
|
2186 |
|
if (iflag.eq.2) then ! call from toftrk |
2187 |
|
do i=1,4 |
2188 |
|
do j=1,12 |
2189 |
|
tdcfl(i,j) = tdcflag(i,j) |
2190 |
|
enddo |
2191 |
|
enddo |
2192 |
|
endif |
2193 |
|
|
2194 |
|
|
2195 |
C--- Find out ToF layers with artificial TDC values ------------- |
C--- Find out ToF layers with artificial TDC values ------------- |
2196 |
|
|
2198 |
w_il(jj) = 1000. |
w_il(jj) = 1000. |
2199 |
enddo |
enddo |
2200 |
|
|
|
C write(*,*) tdcflagtof |
|
2201 |
|
|
2202 |
if (tof11_i.gt.0) then |
if (tof11_i.gt.0) then |
2203 |
if ((tofmask(ch11a(tof11_i),hb11a(tof11_i)).gt.0).or. |
if ((tofmask(ch11a(tof11_i),hb11a(tof11_i)).gt.0).or. |
2204 |
& (tofmask(ch11b(tof11_i),hb11b(tof11_i)).gt.0)) then |
& (tofmask(ch11b(tof11_i),hb11b(tof11_i)).gt.0)) then |
2205 |
w_il(1)=0 |
w_il(1)=0 |
2206 |
i1=tdcflagtof(ch11a(tof11_i),hb11a(tof11_i)) |
i1=tdcfl(ch11a(tof11_i),hb11a(tof11_i)) |
2207 |
i2=tdcflagtof(ch11b(tof11_i),hb11b(tof11_i)) |
i2=tdcfl(ch11b(tof11_i),hb11b(tof11_i)) |
|
c write(*,*) '11 ',i1,i2 |
|
2208 |
if ((i1.eq.1).or.(i2.eq.1)) w_il(1) = 1 ! tdcflag |
if ((i1.eq.1).or.(i2.eq.1)) w_il(1) = 1 ! tdcflag |
2209 |
endif |
endif |
2210 |
endif |
endif |
2213 |
if ((tofmask(ch12a(tof12_i),hb12a(tof12_i)).gt.0).or. |
if ((tofmask(ch12a(tof12_i),hb12a(tof12_i)).gt.0).or. |
2214 |
& (tofmask(ch12b(tof12_i),hb12b(tof12_i)).gt.0)) then |
& (tofmask(ch12b(tof12_i),hb12b(tof12_i)).gt.0)) then |
2215 |
w_il(2)=0 |
w_il(2)=0 |
2216 |
i1=tdcflagtof(ch12a(tof12_i),hb12a(tof12_i)) |
i1=tdcfl(ch12a(tof12_i),hb12a(tof12_i)) |
2217 |
i2=tdcflagtof(ch12b(tof12_i),hb12b(tof12_i)) |
i2=tdcfl(ch12b(tof12_i),hb12b(tof12_i)) |
|
c write(*,*) '12 ',i1,i2 |
|
2218 |
if ((i1.eq.1).or.(i2.eq.1)) w_il(2) = 1 ! tdcflag |
if ((i1.eq.1).or.(i2.eq.1)) w_il(2) = 1 ! tdcflag |
2219 |
endif |
endif |
2220 |
endif |
endif |
2223 |
if ((tofmask(ch21a(tof21_i),hb21a(tof21_i)).gt.0).or. |
if ((tofmask(ch21a(tof21_i),hb21a(tof21_i)).gt.0).or. |
2224 |
& (tofmask(ch21b(tof21_i),hb21b(tof21_i)).gt.0)) then |
& (tofmask(ch21b(tof21_i),hb21b(tof21_i)).gt.0)) then |
2225 |
w_il(3)=0 |
w_il(3)=0 |
2226 |
i1=tdcflagtof(ch21a(tof21_i),hb21a(tof21_i)) |
i1=tdcfl(ch21a(tof21_i),hb21a(tof21_i)) |
2227 |
i2=tdcflagtof(ch21b(tof21_i),hb21b(tof21_i)) |
i2=tdcfl(ch21b(tof21_i),hb21b(tof21_i)) |
|
c write(*,*) '21 ',i1,i2 |
|
2228 |
if ((i1.eq.1).or.(i2.eq.1)) w_il(3) = 1 ! tdcflag |
if ((i1.eq.1).or.(i2.eq.1)) w_il(3) = 1 ! tdcflag |
2229 |
endif |
endif |
2230 |
endif |
endif |
2233 |
if ((tofmask(ch22a(tof22_i),hb22a(tof22_i)).gt.0).or. |
if ((tofmask(ch22a(tof22_i),hb22a(tof22_i)).gt.0).or. |
2234 |
& (tofmask(ch22b(tof22_i),hb22b(tof22_i)).gt.0)) then |
& (tofmask(ch22b(tof22_i),hb22b(tof22_i)).gt.0)) then |
2235 |
w_il(4)=0 |
w_il(4)=0 |
2236 |
i1=tdcflagtof(ch22a(tof22_i),hb22a(tof22_i)) |
i1=tdcfl(ch22a(tof22_i),hb22a(tof22_i)) |
2237 |
i2=tdcflagtof(ch22b(tof22_i),hb22b(tof22_i)) |
i2=tdcfl(ch22b(tof22_i),hb22b(tof22_i)) |
|
c write(*,*) '22 ',i1,i2 |
|
2238 |
if ((i1.eq.1).or.(i2.eq.1)) w_il(4) = 1 ! tdcflag |
if ((i1.eq.1).or.(i2.eq.1)) w_il(4) = 1 ! tdcflag |
2239 |
endif |
endif |
2240 |
endif |
endif |
2243 |
if ((tofmask(ch31a(tof31_i),hb11a(tof31_i)).gt.0).or. |
if ((tofmask(ch31a(tof31_i),hb11a(tof31_i)).gt.0).or. |
2244 |
& (tofmask(ch31b(tof31_i),hb31b(tof31_i)).gt.0)) then |
& (tofmask(ch31b(tof31_i),hb31b(tof31_i)).gt.0)) then |
2245 |
w_il(5)=0 |
w_il(5)=0 |
2246 |
i1=tdcflagtof(ch31a(tof31_i),hb31a(tof31_i)) |
i1=tdcfl(ch31a(tof31_i),hb31a(tof31_i)) |
2247 |
i2=tdcflagtof(ch31b(tof31_i),hb31b(tof31_i)) |
i2=tdcfl(ch31b(tof31_i),hb31b(tof31_i)) |
|
c write(*,*) '31 ',i1,i2 |
|
2248 |
if ((i1.eq.1).or.(i2.eq.1)) w_il(5) = 1 ! tdcflag |
if ((i1.eq.1).or.(i2.eq.1)) w_il(5) = 1 ! tdcflag |
2249 |
endif |
endif |
2250 |
endif |
endif |
2253 |
if ((tofmask(ch32a(tof32_i),hb32a(tof32_i)).gt.0).or. |
if ((tofmask(ch32a(tof32_i),hb32a(tof32_i)).gt.0).or. |
2254 |
& (tofmask(ch32b(tof32_i),hb32b(tof32_i)).gt.0)) then |
& (tofmask(ch32b(tof32_i),hb32b(tof32_i)).gt.0)) then |
2255 |
w_il(6)=0 |
w_il(6)=0 |
2256 |
i1=tdcflagtof(ch32a(tof32_i),hb32a(tof32_i)) |
i1=tdcfl(ch32a(tof32_i),hb32a(tof32_i)) |
2257 |
i2=tdcflagtof(ch32b(tof32_i),hb32b(tof32_i)) |
i2=tdcfl(ch32b(tof32_i),hb32b(tof32_i)) |
|
c write(*,*) '32 ',i1,i2 |
|
2258 |
if ((i1.eq.1).or.(i2.eq.1)) w_il(6) = 1 ! tdcflag |
if ((i1.eq.1).or.(i2.eq.1)) w_il(6) = 1 ! tdcflag |
2259 |
endif |
endif |
2260 |
endif |
endif |
2261 |
|
|
|
c write(*,*) w_il |
|
2262 |
C------------------------------------------------------------------------ |
C------------------------------------------------------------------------ |
2263 |
C--- Set weights for the 12 measurements using information for top and bottom: |
C--- Set weights for the 12 measurements using information for top and bottom: |
2264 |
C--- if no measurements: weight = set to very high value=> not used |
C--- if no measurements: weight = set to very high value=> not used |
2278 |
w_i(jj) = 1./xhelp |
w_i(jj) = 1./xhelp |
2279 |
ENDDO |
ENDDO |
2280 |
|
|
|
c write(*,*) w_i |
|
|
|
|
2281 |
C======================================================================== |
C======================================================================== |
2282 |
C--- Calculate mean beta for the first time ----------------------------- |
C--- Calculate mean beta for the first time ----------------------------- |
2283 |
C--- We are using "1/beta" since its error is gaussian ------------------ |
C--- We are using "1/beta" since its error is gaussian ------------------ |
2298 |
if (icount.gt.0) beta_mean=1./(sxw/sw) |
if (icount.gt.0) beta_mean=1./(sxw/sw) |
2299 |
beta_mean_inv = 1./beta_mean |
beta_mean_inv = 1./beta_mean |
2300 |
|
|
|
c write(*,*) icount,beta_mean |
|
2301 |
|
|
2302 |
C--- Calculate beta for the second time, use residuals of the single |
C--- Calculate beta for the second time, use residuals of the single |
2303 |
C--- measurements to get a chi2 value |
C--- measurements to get a chi2 value |
2313 |
IF ((abs(1./b(jj)).gt.0.1).and.(abs(1./b(jj)).lt.15.) |
IF ((abs(1./b(jj)).gt.0.1).and.(abs(1./b(jj)).lt.15.) |
2314 |
& .and.(w_i(jj).GT.0.01)) THEN |
& .and.(w_i(jj).GT.0.01)) THEN |
2315 |
res = beta_mean_inv - (1./b(jj)) ; |
res = beta_mean_inv - (1./b(jj)) ; |
|
C write(*,*) jj,abs(res*w_i(jj)) |
|
2316 |
if (abs(res*w_i(jj)).lt.resmax) THEN |
if (abs(res*w_i(jj)).lt.resmax) THEN |
2317 |
chi2 = chi2 + (res*w_i(jj))**2. |
chi2 = chi2 + (res*w_i(jj))**2. |
2318 |
icount = icount+1 |
icount = icount+1 |
2333 |
beta_mean=100. |
beta_mean=100. |
2334 |
if ((chi2.lt.chi2cut).and.(quality.gt.qualitycut)) |
if ((chi2.lt.chi2cut).and.(quality.gt.qualitycut)) |
2335 |
& beta_mean = betachi |
& beta_mean = betachi |
|
c write(*,*) icount,chi2,quality,beta_mean |
|
2336 |
newbeta = beta_mean |
newbeta = beta_mean |
2337 |
|
|
2338 |
END |
END |
2339 |
|
|
2340 |
C**************************************************************************** |
C**************************************************************************** |
2341 |
|
|
|
|
|
|
|
|