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 nov-09 WM: the dEdx part ("adctof_c") moved to the new dEdx routine from Napoli |
35 |
C****************************************************************************** |
C****************************************************************************** |
36 |
|
|
37 |
INTEGER FUNCTION TOFL2COM() |
INTEGER FUNCTION TOFL2COM() |
51 |
INTEGER j,hitvec(6) |
INTEGER j,hitvec(6) |
52 |
|
|
53 |
REAL dx,dy,dr,ds |
REAL dx,dy,dr,ds |
54 |
REAL yhelp,xhelp,xhelp1,xhelp2 |
REAL yhelp,yhelp1,yhelp2,xhelp,xhelp1,xhelp2 |
55 |
REAL c1,c2 |
REAL c1,c2 |
56 |
|
|
57 |
C REAL sw,sxw,w_i |
C REAL sw,sxw,w_i |
108 |
C-- DATA ZTOF/53.74,53.04,23.94,23.44,-23.49,-24.34/ !Sergio 9.05.2006 |
C-- DATA ZTOF/53.74,53.04,23.94,23.44,-23.49,-24.34/ !Sergio 9.05.2006 |
109 |
REAL tofarm12 |
REAL tofarm12 |
110 |
PARAMETER (tofarm12 = 29.70) ! from 53.39 to 23.69 |
PARAMETER (tofarm12 = 29.70) ! from 53.39 to 23.69 |
111 |
REAL tofarm23 |
REAL tofarm23 |
112 |
PARAMETER (tofarm23 = 47.61) ! from 23.69 to -23.92 |
PARAMETER (tofarm23 = 47.61) ! from 23.69 to -23.92 |
113 |
REAL tofarm13 |
REAL tofarm13 |
114 |
PARAMETER (tofarm13 = 77.31) ! from 53.39 to -23.92 |
PARAMETER (tofarm13 = 77.31) ! from 53.39 to -23.92 |
581 |
hitvec(5)=tof31_i |
hitvec(5)=tof31_i |
582 |
hitvec(6)=tof32_i |
hitvec(6)=tof32_i |
583 |
|
|
|
c write(*,*) 'tofl2com', |
|
|
c & tof11_i,tof12_i,tof21_i,tof22_i,tof31_i,tof32_i |
|
584 |
|
|
585 |
C------------------------------------------------------------------ |
C------------------------------------------------------------------ |
586 |
C-- calculate track position in paddle using timing difference |
C-- calculate track position in paddle using timing difference |
638 |
C--------------------- zenith angle theta --------------------------- |
C--------------------- zenith angle theta --------------------------- |
639 |
C---------------------------------------------------------------------- |
C---------------------------------------------------------------------- |
640 |
|
|
641 |
dx=0. |
xhelp1=0. |
642 |
dy=0. |
if (tof11_i.GT.none_find) xhelp1=tof11_x(tof11_i) |
643 |
dr=0. |
if (xtofpos(1).lt.100) xhelp1=xtofpos(1) |
644 |
theta13 = 0. |
|
645 |
|
yhelp1=0. |
646 |
IF ((tof12_i.GT.none_find).AND.(tof32_i.GT.none_find)) |
if (tof12_i.GT.none_find) yhelp1=tof12_y(tof12_i) |
647 |
& dx = xtofpos(1) - xtofpos(3) |
if (ytofpos(1).lt.100) yhelp1=ytofpos(1) |
648 |
IF ((tof11_i.GT.none_find).AND.(tof31_i.GT.none_find)) |
|
649 |
& dy = ytofpos(1) - ytofpos(3) |
|
650 |
dr = sqrt(dx*dx+dy*dy) |
yhelp2=0. |
651 |
theta13 = atan(dr/tofarm13) |
if (tof32_i.GT.none_find) yhelp2=tof32_y(tof32_i) |
652 |
|
if (ytofpos(3).lt.100) yhelp2=ytofpos(3) |
653 |
|
|
654 |
|
xhelp2=0. |
655 |
|
if (tof31_i.GT.none_find) xhelp2=tof31_x(tof31_i) |
656 |
|
if (xtofpos(3).lt.100) xhelp2=xtofpos(3) |
657 |
|
|
658 |
|
|
659 |
|
dx=0. |
660 |
|
dy=0. |
661 |
|
dr=0. |
662 |
|
theta13 = 0. |
663 |
|
|
664 |
|
dx = xhelp1 - xhelp2 |
665 |
|
dy = yhelp1 - yhelp2 |
666 |
|
dr = sqrt(dx*dx+dy*dy) |
667 |
|
theta13 = atan(dr/tofarm13) |
668 |
|
|
669 |
|
|
670 |
C---------------------------------------------------------------------- |
C---------------------------------------------------------------------- |
676 |
C---------------------------------------------------------------------- |
C---------------------------------------------------------------------- |
677 |
|
|
678 |
iz = int(check_charge(theta13,hitvec)) |
iz = int(check_charge(theta13,hitvec)) |
679 |
C write(*,*) 'in tofl2com',iz |
c write(*,*) 'charge in tofl2com',iz |
680 |
|
|
681 |
C-------------------------------------------------------------------- |
C-------------------------------------------------------------------- |
682 |
C---- if TDCleft.and.TDCright and NO ADC insert artificial ADC |
C---- if TDCleft.and.TDCright and NO ADC insert artificial ADC |
693 |
|
|
694 |
C---------------------------- S1 ------------------------------------- |
C---------------------------- S1 ------------------------------------- |
695 |
|
|
696 |
yhelp=0. |
c yhelp=0. |
697 |
|
yhelp=100. ! WM |
698 |
if (tof12_i.GT.none_find) yhelp=tof12_y(tof12_i) |
if (tof12_i.GT.none_find) yhelp=tof12_y(tof12_i) |
699 |
if (ytofpos(1).lt.100) yhelp=ytofpos(1) |
if (ytofpos(1).lt.100) yhelp=ytofpos(1) |
700 |
|
|
714 |
endif |
endif |
715 |
ENDIF |
ENDIF |
716 |
|
|
717 |
xhelp=0. |
c xhelp=0. |
718 |
|
xhelp=100. ! WM |
719 |
if (tof11_i.GT.none_find) xhelp=tof11_x(tof11_i) |
if (tof11_i.GT.none_find) xhelp=tof11_x(tof11_i) |
720 |
if (xtofpos(1).lt.100) xhelp=xtofpos(1) |
if (xtofpos(1).lt.100) xhelp=xtofpos(1) |
721 |
|
|
737 |
|
|
738 |
C-----------------------------S2 -------------------------------- |
C-----------------------------S2 -------------------------------- |
739 |
|
|
740 |
xhelp=0. |
c xhelp=0. |
741 |
|
xhelp=100. ! WM |
742 |
if (tof22_i.GT.none_find) xhelp=tof22_x(tof22_i) |
if (tof22_i.GT.none_find) xhelp=tof22_x(tof22_i) |
743 |
if (xtofpos(2).lt.100) xhelp=xtofpos(2) |
if (xtofpos(2).lt.100) xhelp=xtofpos(2) |
744 |
|
|
759 |
ENDIF |
ENDIF |
760 |
|
|
761 |
|
|
762 |
yhelp=0. |
c yhelp=0. |
763 |
|
yhelp=100. ! WM |
764 |
if (tof21_i.GT.none_find) yhelp=tof21_y(tof21_i) |
if (tof21_i.GT.none_find) yhelp=tof21_y(tof21_i) |
765 |
if (ytofpos(2).lt.100) yhelp=ytofpos(2) |
if (ytofpos(2).lt.100) yhelp=ytofpos(2) |
766 |
|
|
782 |
|
|
783 |
C-----------------------------S3 -------------------------------- |
C-----------------------------S3 -------------------------------- |
784 |
|
|
785 |
yhelp=0. |
c yhelp=0. |
786 |
|
yhelp=100. ! WM |
787 |
if (tof32_i.GT.none_find) yhelp=tof32_y(tof32_i) |
if (tof32_i.GT.none_find) yhelp=tof32_y(tof32_i) |
788 |
if (ytofpos(3).lt.100) yhelp=ytofpos(3) |
if (ytofpos(3).lt.100) yhelp=ytofpos(3) |
789 |
|
|
803 |
endif |
endif |
804 |
ENDIF |
ENDIF |
805 |
|
|
806 |
xhelp=0. |
c xhelp=0. |
807 |
|
xhelp=100. ! WM |
808 |
if (tof31_i.GT.none_find) xhelp=tof31_x(tof31_i) |
if (tof31_i.GT.none_find) xhelp=tof31_x(tof31_i) |
809 |
if (xtofpos(3).lt.100) xhelp=xtofpos(3) |
if (xtofpos(3).lt.100) xhelp=xtofpos(3) |
810 |
|
|
944 |
tdc_c(ch32b(i),hb32b(i))=tof32(right,i,itdc) |
tdc_c(ch32b(i),hb32b(i))=tof32(right,i,itdc) |
945 |
ENDIF |
ENDIF |
946 |
ENDDO |
ENDDO |
947 |
|
|
948 |
|
|
949 |
C--------------------------------------------------------------- |
C--------------------------------------------------------------- |
950 |
C--- calculate track position in paddle using timing difference |
C--- calculate track position in paddle using timing difference |
951 |
C--- now using the time-walk corrected TDC values |
C--- now using the time-walk corrected TDC values |
961 |
IF (tof11_i.GT.none_find) THEN |
IF (tof11_i.GT.none_find) THEN |
962 |
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. |
963 |
+ -y_coor_lin11(tof11_i,offset))/y_coor_lin11(tof11_i,slope) |
+ -y_coor_lin11(tof11_i,offset))/y_coor_lin11(tof11_i,slope) |
964 |
|
i=tof11_i |
965 |
endif |
endif |
966 |
|
|
967 |
IF (tof12_i.GT.none_find) THEN |
IF (tof12_i.GT.none_find) THEN |
968 |
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. |
969 |
+ -x_coor_lin12(tof12_i,offset))/x_coor_lin12(tof12_i,slope) |
+ -x_coor_lin12(tof12_i,offset))/x_coor_lin12(tof12_i,slope) |
970 |
|
i=tof12_i |
971 |
endif |
endif |
972 |
|
|
973 |
|
|
976 |
IF (tof21_i.GT.none_find) THEN |
IF (tof21_i.GT.none_find) THEN |
977 |
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. |
978 |
+ -x_coor_lin21(tof21_i,offset))/x_coor_lin21(tof21_i,slope) |
+ -x_coor_lin21(tof21_i,offset))/x_coor_lin21(tof21_i,slope) |
979 |
|
i=tof21_i |
980 |
endif |
endif |
981 |
|
|
982 |
IF (tof22_i.GT.none_find) THEN |
IF (tof22_i.GT.none_find) THEN |
983 |
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. |
984 |
+ -y_coor_lin22(tof22_i,offset))/y_coor_lin22(tof22_i,slope) |
+ -y_coor_lin22(tof22_i,offset))/y_coor_lin22(tof22_i,slope) |
985 |
|
i=tof22_i |
986 |
endif |
endif |
987 |
|
|
988 |
|
|
991 |
IF (tof31_i.GT.none_find) THEN |
IF (tof31_i.GT.none_find) THEN |
992 |
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. |
993 |
+ -y_coor_lin31(tof31_i,offset))/y_coor_lin31(tof31_i,slope) |
+ -y_coor_lin31(tof31_i,offset))/y_coor_lin31(tof31_i,slope) |
994 |
|
i=tof31_i |
995 |
endif |
endif |
996 |
|
|
997 |
IF (tof32_i.GT.none_find) THEN |
IF (tof32_i.GT.none_find) THEN |
998 |
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. |
999 |
+ -x_coor_lin32(tof32_i,offset))/x_coor_lin32(tof32_i,slope) |
+ -x_coor_lin32(tof32_i,offset))/x_coor_lin32(tof32_i,slope) |
1000 |
|
i=tof32_i |
1001 |
endif |
endif |
1002 |
|
|
1003 |
|
|
1010 |
c endif |
c endif |
1011 |
c enddo |
c enddo |
1012 |
|
|
1013 |
|
|
1014 |
C-- restrict TDC measurements to physical paddle dimensions +/- 10 cm |
C-- restrict TDC measurements to physical paddle dimensions +/- 10 cm |
1015 |
C-- this cut is now stronger than in the old versions |
C-- this cut is now stronger than in the old versions |
1016 |
|
|
1022 |
if (abs(ytofpos(2)).gt.18.) ytofpos(2)=101. |
if (abs(ytofpos(2)).gt.18.) ytofpos(2)=101. |
1023 |
if (abs(ytofpos(3)).gt.18.) ytofpos(3)=101. |
if (abs(ytofpos(3)).gt.18.) ytofpos(3)=101. |
1024 |
|
|
|
|
|
1025 |
C---------------------------------------------------------------------- |
C---------------------------------------------------------------------- |
1026 |
C--------------------- zenith angle theta --------------------------- |
C--------------------- zenith angle theta --------------------------- |
1027 |
C---------------------------------------------------------------------- |
C---------------------------------------------------------------------- |
1028 |
|
C------------------- improved calculation --------------------------- |
1029 |
|
|
1030 |
dx=0. |
xhelp1=0. |
1031 |
dy=0. |
if (tof11_i.GT.none_find) xhelp1=tof11_x(tof11_i) |
1032 |
dr=0. |
if (xtofpos(1).lt.100) xhelp1=xtofpos(1) |
1033 |
theta13 = 0. |
|
1034 |
|
yhelp1=0. |
1035 |
IF ((tof12_i.GT.none_find).AND.(tof32_i.GT.none_find)) |
if (tof12_i.GT.none_find) yhelp1=tof12_y(tof12_i) |
1036 |
& dx = xtofpos(1) - xtofpos(3) |
if (ytofpos(1).lt.100) yhelp1=ytofpos(1) |
1037 |
IF ((tof11_i.GT.none_find).AND.(tof31_i.GT.none_find)) |
|
1038 |
& dy = ytofpos(1) - ytofpos(3) |
yhelp2=0. |
1039 |
dr = sqrt(dx*dx+dy*dy) |
if (tof32_i.GT.none_find) yhelp2=tof32_y(tof32_i) |
1040 |
theta13 = atan(dr/tofarm13) |
if (ytofpos(3).lt.100) yhelp2=ytofpos(3) |
1041 |
|
|
1042 |
C------------------------------------------------------------------ |
xhelp2=0. |
1043 |
c dx=0. |
if (tof31_i.GT.none_find) xhelp2=tof31_x(tof31_i) |
1044 |
c dy=0. |
if (xtofpos(3).lt.100) xhelp2=xtofpos(3) |
1045 |
c dr=0. |
|
1046 |
c theta12 = 0. |
|
1047 |
c |
dx=0. |
1048 |
c IF ((tof12_i.GT.none_find).AND.(tof21_i.GT.none_find)) |
dy=0. |
1049 |
c & dx = xtofpos(1) - xtofpos(2) |
dr=0. |
1050 |
c IF ((tof11_i.GT.none_find).AND.(tof22_i.GT.none_find)) |
theta13 = 0. |
1051 |
c & dy = ytofpos(1) - ytofpos(2) |
|
1052 |
c dr = sqrt(dx*dx+dy*dy) |
dx = xhelp1 - xhelp2 |
1053 |
c theta12 = atan(dr/tofarm12) |
dy = yhelp1 - yhelp2 |
1054 |
c |
dr = sqrt(dx*dx+dy*dy) |
1055 |
c dx=0. |
theta13 = atan(dr/tofarm13) |
|
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 |
|
|
C---------------------------------------------------------------------- |
|
|
C------------------angle and ADC(x) correction |
|
|
C---------------------------------------------------------------------- |
|
|
C-----------------------------S1 -------------------------------- |
|
|
c middle y (or x) position of the upper and middle ToF-Paddle |
|
|
c DATA tof11_x/ -17.85,-12.75,-7.65,-2.55,2.55,7.65,12.75,17.85/ |
|
|
c DATA tof12_y/ -13.75,-8.25,-2.75,2.75,8.25,13.75/ |
|
|
c DATA tof21_y/ 3.75,-3.75/ ! paddles in different order |
|
|
c DATA tof22_x/ -4.5,4.5/ |
|
|
c DATA tof31_x/ -6.0,0.,6.0/ |
|
|
c DATA tof32_y/ -5.0,0.0,5.0/ |
|
|
|
|
|
yhelp=0. |
|
|
if (tof12_i.GT.none_find) yhelp=tof12_y(tof12_i) |
|
|
if (ytofpos(1).lt.100) yhelp=ytofpos(1) |
|
|
|
|
|
IF (tof11_i.GT.none_find.AND.abs(yhelp).lt.100) THEN |
|
|
|
|
|
i = tof11_i |
|
|
if (tof11(left,i,iadc).lt.3786) then |
|
|
c if (adc(ch11a(i),hb11a(i)).lt.4095) then |
|
|
tof11(left,i,iadc) = tof11(left,i,iadc)*cos(theta13) |
|
|
xkorr = atten(left,11,i,yhelp) |
|
|
c write(40+i,*) yhelp,xkorr |
|
|
if (iz.le.1) xkorr=xkorr/hepratio |
|
|
adctof_c(ch11a(i),hb11a(i))=tof11(left,i,iadc)/xkorr |
|
|
endif |
|
|
|
|
|
if (tof11(right,i,iadc).lt.3786) then |
|
|
c if (adc(ch11b(i),hb11b(i)).lt.4095) then |
|
|
tof11(right,i,iadc) = tof11(right,i,iadc)*cos(theta13) |
|
|
xkorr = atten(right,11,i,yhelp) |
|
|
c write(40+i,*) yhelp,xkorr |
|
|
if (iz.le.1) xkorr=xkorr/hepratio |
|
|
adctof_c(ch11b(i),hb11b(i))=tof11(right,i,iadc)/xkorr |
|
|
endif |
|
|
ENDIF |
|
|
|
|
|
xhelp=0. |
|
|
if (tof11_i.GT.none_find) xhelp=tof11_x(tof11_i) |
|
|
if (xtofpos(1).lt.100) xhelp=xtofpos(1) |
|
|
|
|
|
IF (tof12_i.GT.none_find.AND.abs(xhelp).lt.100) THEN |
|
|
|
|
|
i = tof12_i |
|
|
if (tof12(left,i,iadc).lt.3786) then |
|
|
c if (adc(ch12a(i),hb12a(i)).lt.4095) then |
|
|
tof12(left,i,iadc) = tof12(left,i,iadc)*cos(theta13) |
|
|
xkorr = atten(left,12,i,xhelp) |
|
|
c write(50+i,*) xhelp,xkorr |
|
|
if (iz.le.1) xkorr=xkorr/hepratio |
|
|
adctof_c(ch12a(i),hb12a(i))=tof12(left,i,iadc)/xkorr |
|
|
endif |
|
|
|
|
|
if (tof12(right,i,iadc).lt.3786) then |
|
|
c if (adc(ch12b(i),hb12b(i)).lt.4095) then |
|
|
tof12(right,i,iadc) = tof12(right,i,iadc)*cos(theta13) |
|
|
xkorr = atten(right,12,i,xhelp) |
|
|
c write(50+i,*) xhelp,xkorr |
|
|
if (iz.le.1) xkorr=xkorr/hepratio |
|
|
adctof_c(ch12b(i),hb12b(i))=tof12(right,i,iadc)/xkorr |
|
|
endif |
|
|
ENDIF |
|
|
|
|
|
C-----------------------------S2 -------------------------------- |
|
|
|
|
|
xhelp=0. |
|
|
if (tof22_i.GT.none_find) xhelp=tof22_x(tof22_i) |
|
|
if (xtofpos(2).lt.100) xhelp=xtofpos(2) |
|
|
|
|
|
IF (tof21_i.GT.none_find.AND.abs(xhelp).lt.100) THEN |
|
|
|
|
|
i = tof21_i |
|
|
if (tof21(left,i,iadc).lt.3786) then |
|
|
c if (adc(ch21a(i),hb21a(i)).lt.4095) then |
|
|
tof21(left,i,iadc) = tof21(left,i,iadc)*cos(theta13) |
|
|
xkorr = atten(left,21,i,xhelp) |
|
|
c write(60+i,*) xhelp,xkorr |
|
|
if (iz.le.1) xkorr=xkorr/hepratio |
|
|
adctof_c(ch21a(i),hb21a(i))=tof21(left,i,iadc)/xkorr |
|
|
endif |
|
|
|
|
|
if (tof21(right,i,iadc).lt.3786) then |
|
|
c if (adc(ch21b(i),hb21b(i)).lt.4095) then |
|
|
tof21(right,i,iadc) = tof21(right,i,iadc)*cos(theta13) |
|
|
xkorr=adcx21(right,i,1)*exp(xhelp/adcx21(right,i,2)) |
|
|
xkorr = atten(right,21,i,xhelp) |
|
|
c write(60+i,*) xhelp,xkorr |
|
|
if (iz.le.1) xkorr=xkorr/hepratio |
|
|
adctof_c(ch21b(i),hb21b(i))=tof21(right,i,iadc)/xkorr |
|
|
endif |
|
|
ENDIF |
|
|
|
|
|
|
|
|
yhelp=0. |
|
|
if (tof21_i.GT.none_find) yhelp=tof21_y(tof21_i) |
|
|
if (ytofpos(2).lt.100) yhelp=ytofpos(2) |
|
|
|
|
|
IF (tof22_i.GT.none_find.AND.abs(yhelp).lt.100) THEN |
|
|
|
|
|
i = tof22_i |
|
|
if (tof22(left,i,iadc).lt.3786) then |
|
|
c if (adc(ch22a(i),hb22a(i)).lt.4095) then |
|
|
tof22(left,i,iadc) = tof22(left,i,iadc)*cos(theta13) |
|
|
xkorr = atten(left,22,i,yhelp) |
|
|
c write(70+i,*) yhelp,xkorr |
|
|
if (iz.le.1) xkorr=xkorr/hepratio |
|
|
adctof_c(ch22a(i),hb22a(i))=tof22(left,i,iadc)/xkorr |
|
|
endif |
|
|
|
|
|
if (tof22(right,i,iadc).lt.3786) then |
|
|
c if (adc(ch22b(i),hb22b(i)).lt.4095) then |
|
|
tof22(right,i,iadc) = tof22(right,i,iadc)*cos(theta13) |
|
|
xkorr = atten(right,22,i,yhelp) |
|
|
c write(70+i,*) yhelp,xkorr |
|
|
if (iz.le.1) xkorr=xkorr/hepratio |
|
|
adctof_c(ch22b(i),hb22b(i))=tof22(right,i,iadc)/xkorr |
|
|
endif |
|
|
ENDIF |
|
|
|
|
|
C-----------------------------S3 -------------------------------- |
|
1056 |
|
|
|
yhelp=0. |
|
|
if (tof32_i.GT.none_find) yhelp=tof32_y(tof32_i) |
|
|
if (ytofpos(3).lt.100) yhelp=ytofpos(3) |
|
|
|
|
|
IF (tof31_i.GT.none_find.AND.abs(yhelp).lt.100) THEN |
|
|
|
|
|
i = tof31_i |
|
|
if (tof31(left,i,iadc).lt.3786) then |
|
|
c if (adc(ch31a(i),hb31a(i)).lt.4095) then |
|
|
tof31(left,i,iadc) = tof31(left,i,iadc)*cos(theta13) |
|
|
xkorr = atten(left,31,i,yhelp) |
|
|
c write(80+i,*) yhelp,xkorr |
|
|
if (iz.le.1) xkorr=xkorr/hepratio |
|
|
adctof_c(ch31a(i),hb31a(i))=tof31(left,i,iadc)/xkorr |
|
|
endif |
|
|
|
|
|
if (tof31(right,i,iadc).lt.3786) then |
|
|
c if (adc(ch31b(i),hb31b(i)).lt.4095) then |
|
|
tof31(right,i,iadc) = tof31(right,i,iadc)*cos(theta13) |
|
|
xkorr = atten(right,31,i,yhelp) |
|
|
c write(80+i,*) yhelp,xkorr |
|
|
if (iz.le.1) xkorr=xkorr/hepratio |
|
|
adctof_c(ch31b(i),hb31b(i))=tof31(right,i,iadc)/xkorr |
|
|
endif |
|
|
ENDIF |
|
1057 |
|
|
1058 |
xhelp=0. |
C------------------------------------------------------------------ |
1059 |
if (tof31_i.GT.none_find) xhelp=tof31_x(tof31_i) |
C------------------------------------------------------------------ |
1060 |
if (xtofpos(3).lt.100) xhelp=xtofpos(3) |
C-------angle and ADC(x) correction: moved to new dEdx routine |
1061 |
|
C------------------------------------------------------------------ |
1062 |
IF (tof32_i.GT.none_find.AND.abs(xhelp).lt.100) THEN |
C------------------------------------------------------------------ |
|
|
|
|
i = tof32_i |
|
|
if (tof32(left,i,iadc).lt.3786) then |
|
|
c if (adc(ch32a(i),hb32a(i)).lt.4095) then |
|
|
tof32(left,i,iadc) = tof32(left,i,iadc)*cos(theta13) |
|
|
xkorr = atten(left,32,i,xhelp) |
|
|
c write(90+i,*) xhelp,xkorr |
|
|
if (iz.le.1) xkorr=xkorr/hepratio |
|
|
adctof_c(ch32a(i),hb32a(i))=tof32(left,i,iadc)/xkorr |
|
|
endif |
|
|
|
|
|
if (tof32(right,i,iadc).lt.3786) then |
|
|
c if (adc(ch32b(i),hb32b(i)).lt.4095) then |
|
|
tof32(right,i,iadc) = tof32(right,i,iadc)*cos(theta13) |
|
|
xkorr = atten(right,32,i,xhelp) |
|
|
c write(90+i,*) xhelp,xkorr |
|
|
if (iz.le.1) xkorr=xkorr/hepratio |
|
|
adctof_c(ch32b(i),hb32b(i))=tof32(right,i,iadc)/xkorr |
|
|
endif |
|
|
ENDIF |
|
1063 |
|
|
1064 |
C-------------------------------------------------------------------- |
C-------------------------------------------------------------------- |
1065 |
C----------------------calculate Beta ------------------------------ |
C----------------------calculate Beta ------------------------------ |
1432 |
C icount= icount+1 |
C icount= icount+1 |
1433 |
C if (i.le.4) w_i=1./(0.13**2.) |
C if (i.le.4) w_i=1./(0.13**2.) |
1434 |
C if ((i.ge.5).and.(i.le.8)) w_i=1./(0.16**2.) |
C if ((i.ge.5).and.(i.le.8)) w_i=1./(0.16**2.) |
1435 |
C if (i.ge.9) w_i=1./(0.25**2.) ! to be checked |
C if (i.ge.9) w_i=1./(0.25**2.) ! to be checked |
1436 |
C sxw=sxw + betatof_a(i)*w_i |
C sxw=sxw + betatof_a(i)*w_i |
1437 |
C sw =sw + w_i |
C sw =sw + w_i |
1438 |
C endif |
C endif |
1441 |
C if (icount.gt.0) beta_mean=sxw/sw |
C if (icount.gt.0) beta_mean=sxw/sw |
1442 |
C betatof_a(13) = beta_mean |
C betatof_a(13) = beta_mean |
1443 |
C |
C |
1444 |
|
|
1445 |
C-------- New mean beta calculation ----------------------- |
C-------- New mean beta calculation ----------------------- |
1446 |
|
|
1447 |
do i=1,12 |
do i=1,12 |
1448 |
btemp(i) = betatof_a(i) |
btemp(i) = betatof_a(i) |
1449 |
enddo |
enddo |
1450 |
|
|
1451 |
betatof_a(13)=newbeta(btemp,hitvec,10.,10.,20.) |
betatof_a(13)=newbeta(1,btemp,hitvec,10.,10.,20.) |
1452 |
|
|
1453 |
C-------------------------------------------------------------- |
C-------------------------------------------------------------- |
1454 |
C write(*,*) betatof_a |
C write(*,*) betatof_a |
1462 |
c write(*,*) xtr_tof |
c write(*,*) xtr_tof |
1463 |
c write(*,*) ytr_tof |
c write(*,*) ytr_tof |
1464 |
|
|
1465 |
100 continue |
c 100 continue |
1466 |
|
continue |
1467 |
|
|
1468 |
C |
C |
1469 |
RETURN |
RETURN |
1607 |
REAL a1,a2 |
REAL a1,a2 |
1608 |
INTEGER jj |
INTEGER jj |
1609 |
|
|
1610 |
|
c get rid of warnings EMILIANO |
1611 |
|
i = 0 |
1612 |
|
slope = 0 |
1613 |
|
offset = 0 |
1614 |
|
none_find = 0 |
1615 |
|
none_ev = 0 |
1616 |
|
adc_ev = 0 |
1617 |
|
tdc_ev = 0 |
1618 |
|
iadc = 0 |
1619 |
|
itdc = 0 |
1620 |
|
right = 0 |
1621 |
|
left = 0 |
1622 |
|
tof12_y(1) = tof12_y(1) |
1623 |
|
tof11_x(1) = tof11_x(1) |
1624 |
|
tof21_y(1) = tof21_y(1) |
1625 |
|
tof22_x(1) = tof22_x(1) |
1626 |
|
tof32_y(1) = tof32_y(1) |
1627 |
|
tof31_x(1) = tof31_x(1) |
1628 |
|
c get rid of warnings |
1629 |
|
|
1630 |
C----------------------------------------------------------- |
C----------------------------------------------------------- |
1631 |
C--- get data |
C--- get data |
1632 |
C----------------------------------------------------------- |
C----------------------------------------------------------- |
1992 |
C**************************************************************************** |
C**************************************************************************** |
1993 |
C**************************************************************************** |
C**************************************************************************** |
1994 |
|
|
1995 |
function newbeta(b,hitvec,resmax,qualitycut,chi2cut) |
function newbeta(iflag,b,hitvec,resmax,qualitycut,chi2cut) |
1996 |
|
|
1997 |
include 'input_tof.txt' |
include 'input_tof.txt' |
1998 |
include 'output_tof.txt' |
include 'output_tof.txt' |
2002 |
REAL resmax,qualitycut,chi2cut |
REAL resmax,qualitycut,chi2cut |
2003 |
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 |
2004 |
REAL sw,sxw,b(12),beta_mean,chi2,xhelp |
REAL sw,sxw,b(12),beta_mean,chi2,xhelp |
2005 |
|
REAL tdcfl(4,12) |
2006 |
|
|
2007 |
INTEGER icount,hitvec(6) |
INTEGER iflag,icount,hitvec(6) |
2008 |
|
|
2009 |
INTEGER itop(12),ibot(12) |
INTEGER itop(12),ibot(12) |
2010 |
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/ |
2011 |
DATA ibot /5,6,5,6,5,6,5,6,3,4,3,4/ |
DATA ibot /5,6,5,6,5,6,5,6,3,4,3,4/ |
2012 |
|
|
2013 |
|
|
2014 |
|
c get rid of warnings EMILIANO |
2015 |
|
slope = 0 |
2016 |
|
offset = 0 |
2017 |
|
none_find = 0 |
2018 |
|
none_ev = 0 |
2019 |
|
adc_ev = 0 |
2020 |
|
tdc_ev = 0 |
2021 |
|
iadc = 0 |
2022 |
|
itdc = 0 |
2023 |
|
right = 0 |
2024 |
|
left = 0 |
2025 |
|
tof12_y(1) = tof12_y(1) |
2026 |
|
tof11_x(1) = tof11_x(1) |
2027 |
|
tof21_y(1) = tof21_y(1) |
2028 |
|
tof22_x(1) = tof22_x(1) |
2029 |
|
tof32_y(1) = tof32_y(1) |
2030 |
|
tof31_x(1) = tof31_x(1) |
2031 |
|
c get rid of warnings |
2032 |
|
|
2033 |
C==================================================================== |
C==================================================================== |
2034 |
|
|
2035 |
tof11_i = hitvec(1) |
tof11_i = hitvec(1) |
2039 |
tof31_i = hitvec(5) |
tof31_i = hitvec(5) |
2040 |
tof32_i = hitvec(6) |
tof32_i = hitvec(6) |
2041 |
|
|
2042 |
c write(*,*) '------------ In NEWBETA ----------------' |
if (iflag.eq.1) then ! call from tofl2com |
2043 |
c write(*,*) hitvec |
do i=1,4 |
2044 |
c write(*,*) b |
do j=1,12 |
2045 |
|
tdcfl(i,j) = tdcflagtof(i,j) |
2046 |
|
enddo |
2047 |
|
enddo |
2048 |
|
endif |
2049 |
|
|
2050 |
|
if (iflag.eq.2) then ! call from toftrk |
2051 |
|
do i=1,4 |
2052 |
|
do j=1,12 |
2053 |
|
tdcfl(i,j) = tdcflag(i,j) |
2054 |
|
enddo |
2055 |
|
enddo |
2056 |
|
endif |
2057 |
|
|
2058 |
|
|
2059 |
C--- Find out ToF layers with artificial TDC values ------------- |
C--- Find out ToF layers with artificial TDC values ------------- |
2060 |
|
|
2062 |
w_il(jj) = 1000. |
w_il(jj) = 1000. |
2063 |
enddo |
enddo |
2064 |
|
|
|
C write(*,*) tdcflagtof |
|
2065 |
|
|
2066 |
if (tof11_i.gt.0) then |
if (tof11_i.gt.0) then |
2067 |
if ((tofmask(ch11a(tof11_i),hb11a(tof11_i)).gt.0).or. |
if ((tofmask(ch11a(tof11_i),hb11a(tof11_i)).gt.0).or. |
2068 |
& (tofmask(ch11b(tof11_i),hb11b(tof11_i)).gt.0)) then |
& (tofmask(ch11b(tof11_i),hb11b(tof11_i)).gt.0)) then |
2069 |
w_il(1)=0 |
w_il(1)=0 |
2070 |
i1=tdcflagtof(ch11a(tof11_i),hb11a(tof11_i)) |
i1=tdcfl(ch11a(tof11_i),hb11a(tof11_i)) |
2071 |
i2=tdcflagtof(ch11b(tof11_i),hb11b(tof11_i)) |
i2=tdcfl(ch11b(tof11_i),hb11b(tof11_i)) |
|
c write(*,*) '11 ',i1,i2 |
|
2072 |
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 |
2073 |
endif |
endif |
2074 |
endif |
endif |
2077 |
if ((tofmask(ch12a(tof12_i),hb12a(tof12_i)).gt.0).or. |
if ((tofmask(ch12a(tof12_i),hb12a(tof12_i)).gt.0).or. |
2078 |
& (tofmask(ch12b(tof12_i),hb12b(tof12_i)).gt.0)) then |
& (tofmask(ch12b(tof12_i),hb12b(tof12_i)).gt.0)) then |
2079 |
w_il(2)=0 |
w_il(2)=0 |
2080 |
i1=tdcflagtof(ch12a(tof12_i),hb12a(tof12_i)) |
i1=tdcfl(ch12a(tof12_i),hb12a(tof12_i)) |
2081 |
i2=tdcflagtof(ch12b(tof12_i),hb12b(tof12_i)) |
i2=tdcfl(ch12b(tof12_i),hb12b(tof12_i)) |
|
c write(*,*) '12 ',i1,i2 |
|
2082 |
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 |
2083 |
endif |
endif |
2084 |
endif |
endif |
2087 |
if ((tofmask(ch21a(tof21_i),hb21a(tof21_i)).gt.0).or. |
if ((tofmask(ch21a(tof21_i),hb21a(tof21_i)).gt.0).or. |
2088 |
& (tofmask(ch21b(tof21_i),hb21b(tof21_i)).gt.0)) then |
& (tofmask(ch21b(tof21_i),hb21b(tof21_i)).gt.0)) then |
2089 |
w_il(3)=0 |
w_il(3)=0 |
2090 |
i1=tdcflagtof(ch21a(tof21_i),hb21a(tof21_i)) |
i1=tdcfl(ch21a(tof21_i),hb21a(tof21_i)) |
2091 |
i2=tdcflagtof(ch21b(tof21_i),hb21b(tof21_i)) |
i2=tdcfl(ch21b(tof21_i),hb21b(tof21_i)) |
|
c write(*,*) '21 ',i1,i2 |
|
2092 |
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 |
2093 |
endif |
endif |
2094 |
endif |
endif |
2097 |
if ((tofmask(ch22a(tof22_i),hb22a(tof22_i)).gt.0).or. |
if ((tofmask(ch22a(tof22_i),hb22a(tof22_i)).gt.0).or. |
2098 |
& (tofmask(ch22b(tof22_i),hb22b(tof22_i)).gt.0)) then |
& (tofmask(ch22b(tof22_i),hb22b(tof22_i)).gt.0)) then |
2099 |
w_il(4)=0 |
w_il(4)=0 |
2100 |
i1=tdcflagtof(ch22a(tof22_i),hb22a(tof22_i)) |
i1=tdcfl(ch22a(tof22_i),hb22a(tof22_i)) |
2101 |
i2=tdcflagtof(ch22b(tof22_i),hb22b(tof22_i)) |
i2=tdcfl(ch22b(tof22_i),hb22b(tof22_i)) |
|
c write(*,*) '22 ',i1,i2 |
|
2102 |
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 |
2103 |
endif |
endif |
2104 |
endif |
endif |
2107 |
if ((tofmask(ch31a(tof31_i),hb11a(tof31_i)).gt.0).or. |
if ((tofmask(ch31a(tof31_i),hb11a(tof31_i)).gt.0).or. |
2108 |
& (tofmask(ch31b(tof31_i),hb31b(tof31_i)).gt.0)) then |
& (tofmask(ch31b(tof31_i),hb31b(tof31_i)).gt.0)) then |
2109 |
w_il(5)=0 |
w_il(5)=0 |
2110 |
i1=tdcflagtof(ch31a(tof31_i),hb31a(tof31_i)) |
i1=tdcfl(ch31a(tof31_i),hb31a(tof31_i)) |
2111 |
i2=tdcflagtof(ch31b(tof31_i),hb31b(tof31_i)) |
i2=tdcfl(ch31b(tof31_i),hb31b(tof31_i)) |
|
c write(*,*) '31 ',i1,i2 |
|
2112 |
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 |
2113 |
endif |
endif |
2114 |
endif |
endif |
2117 |
if ((tofmask(ch32a(tof32_i),hb32a(tof32_i)).gt.0).or. |
if ((tofmask(ch32a(tof32_i),hb32a(tof32_i)).gt.0).or. |
2118 |
& (tofmask(ch32b(tof32_i),hb32b(tof32_i)).gt.0)) then |
& (tofmask(ch32b(tof32_i),hb32b(tof32_i)).gt.0)) then |
2119 |
w_il(6)=0 |
w_il(6)=0 |
2120 |
i1=tdcflagtof(ch32a(tof32_i),hb32a(tof32_i)) |
i1=tdcfl(ch32a(tof32_i),hb32a(tof32_i)) |
2121 |
i2=tdcflagtof(ch32b(tof32_i),hb32b(tof32_i)) |
i2=tdcfl(ch32b(tof32_i),hb32b(tof32_i)) |
|
c write(*,*) '32 ',i1,i2 |
|
2122 |
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 |
2123 |
endif |
endif |
2124 |
endif |
endif |
2125 |
|
|
|
c write(*,*) w_il |
|
2126 |
C------------------------------------------------------------------------ |
C------------------------------------------------------------------------ |
2127 |
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: |
2128 |
C--- if no measurements: weight = set to very high value=> not used |
C--- if no measurements: weight = set to very high value=> not used |
2142 |
w_i(jj) = 1./xhelp |
w_i(jj) = 1./xhelp |
2143 |
ENDDO |
ENDDO |
2144 |
|
|
|
c write(*,*) w_i |
|
|
|
|
2145 |
C======================================================================== |
C======================================================================== |
2146 |
C--- Calculate mean beta for the first time ----------------------------- |
C--- Calculate mean beta for the first time ----------------------------- |
2147 |
C--- We are using "1/beta" since its error is gaussian ------------------ |
C--- We are using "1/beta" since its error is gaussian ------------------ |
2162 |
if (icount.gt.0) beta_mean=1./(sxw/sw) |
if (icount.gt.0) beta_mean=1./(sxw/sw) |
2163 |
beta_mean_inv = 1./beta_mean |
beta_mean_inv = 1./beta_mean |
2164 |
|
|
|
c write(*,*) icount,beta_mean |
|
2165 |
|
|
2166 |
C--- Calculate beta for the second time, use residuals of the single |
C--- Calculate beta for the second time, use residuals of the single |
2167 |
C--- measurements to get a chi2 value |
C--- measurements to get a chi2 value |
2177 |
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.) |
2178 |
& .and.(w_i(jj).GT.0.01)) THEN |
& .and.(w_i(jj).GT.0.01)) THEN |
2179 |
res = beta_mean_inv - (1./b(jj)) ; |
res = beta_mean_inv - (1./b(jj)) ; |
|
C write(*,*) jj,abs(res*w_i(jj)) |
|
2180 |
if (abs(res*w_i(jj)).lt.resmax) THEN |
if (abs(res*w_i(jj)).lt.resmax) THEN |
2181 |
chi2 = chi2 + (res*w_i(jj))**2. |
chi2 = chi2 + (res*w_i(jj))**2. |
2182 |
icount = icount+1 |
icount = icount+1 |
2197 |
beta_mean=100. |
beta_mean=100. |
2198 |
if ((chi2.lt.chi2cut).and.(quality.gt.qualitycut)) |
if ((chi2.lt.chi2cut).and.(quality.gt.qualitycut)) |
2199 |
& beta_mean = betachi |
& beta_mean = betachi |
|
c write(*,*) icount,chi2,quality,beta_mean |
|
2200 |
newbeta = beta_mean |
newbeta = beta_mean |
2201 |
|
|
2202 |
END |
END |
2203 |
|
|
2204 |
C**************************************************************************** |
C**************************************************************************** |
2205 |
|
|
|
|
|
|
|
|