--- DarthVader/ToFLevel2/src/tofl2com.for 2008/03/31 19:24:04 1.8 +++ DarthVader/ToFLevel2/src/tofl2com.for 2008/11/27 13:47:54 1.9 @@ -29,6 +29,8 @@ C mar-08 WM: Call to "newbeta" changed, now a flag tells the function if the C call comes from "tofl2com" or form "toftrack" C mar-08 WM: Bug found in dEdx if check_charge>1 +C oct-08 WM: Calculation of zenith angle debugged, sometimes strange values +C were possible C****************************************************************************** INTEGER FUNCTION TOFL2COM() @@ -48,7 +50,7 @@ INTEGER j,hitvec(6) REAL dx,dy,dr,ds - REAL yhelp,xhelp,xhelp1,xhelp2 + REAL yhelp,yhelp1,yhelp2,xhelp,xhelp1,xhelp2 REAL c1,c2 C REAL sw,sxw,w_i @@ -578,8 +580,6 @@ hitvec(5)=tof31_i hitvec(6)=tof32_i -c write(*,*) 'tofl2com', -c & tof11_i,tof12_i,tof21_i,tof22_i,tof31_i,tof32_i C------------------------------------------------------------------ C-- calculate track position in paddle using timing difference @@ -636,18 +636,49 @@ C---------------------------------------------------------------------- C--------------------- zenith angle theta --------------------------- C---------------------------------------------------------------------- +C----------------------------- old ---------------------------------- +c dx=0. +c dy=0. +c dr=0. +c theta13 = 0. +c +c IF ((tof12_i.GT.none_find).AND.(tof32_i.GT.none_find)) +c & dx = xtofpos(1) - xtofpos(3) +c IF ((tof11_i.GT.none_find).AND.(tof31_i.GT.none_find)) +c & dy = ytofpos(1) - ytofpos(3) +c dr = sqrt(dx*dx+dy*dy) +c theta13 = atan(dr/tofarm13) +c +c +C----------------------------- new ------------------------------ + + xhelp1=0. + if (tof11_i.GT.none_find) xhelp1=tof11_x(tof11_i) + if (xtofpos(1).lt.100) xhelp1=xtofpos(1) - 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) + yhelp1=0. + if (tof12_i.GT.none_find) yhelp1=tof12_y(tof12_i) + if (ytofpos(1).lt.100) yhelp1=ytofpos(1) + + + yhelp2=0. + if (tof32_i.GT.none_find) yhelp2=tof32_y(tof32_i) + if (ytofpos(3).lt.100) yhelp2=ytofpos(3) + + xhelp2=0. + if (tof31_i.GT.none_find) xhelp2=tof31_x(tof31_i) + if (xtofpos(3).lt.100) xhelp2=xtofpos(3) + + + dx=0. + dy=0. + dr=0. + theta13 = 0. + + dx = xhelp1 - xhelp2 + dy = yhelp1 - yhelp2 + dr = sqrt(dx*dx+dy*dy) + theta13 = atan(dr/tofarm13) C---------------------------------------------------------------------- @@ -659,7 +690,7 @@ C---------------------------------------------------------------------- iz = int(check_charge(theta13,hitvec)) -C write(*,*) 'in tofl2com',iz +c write(*,*) 'charge in tofl2com',iz C-------------------------------------------------------------------- C---- if TDCleft.and.TDCright and NO ADC insert artificial ADC @@ -676,7 +707,8 @@ C---------------------------- S1 ------------------------------------- - yhelp=0. +c yhelp=0. + yhelp=100. ! WM if (tof12_i.GT.none_find) yhelp=tof12_y(tof12_i) if (ytofpos(1).lt.100) yhelp=ytofpos(1) @@ -696,7 +728,8 @@ endif ENDIF - xhelp=0. +c xhelp=0. + xhelp=100. ! WM if (tof11_i.GT.none_find) xhelp=tof11_x(tof11_i) if (xtofpos(1).lt.100) xhelp=xtofpos(1) @@ -718,7 +751,8 @@ C-----------------------------S2 -------------------------------- - xhelp=0. +c xhelp=0. + xhelp=100. ! WM if (tof22_i.GT.none_find) xhelp=tof22_x(tof22_i) if (xtofpos(2).lt.100) xhelp=xtofpos(2) @@ -739,7 +773,8 @@ ENDIF - yhelp=0. +c yhelp=0. + yhelp=100. ! WM if (tof21_i.GT.none_find) yhelp=tof21_y(tof21_i) if (ytofpos(2).lt.100) yhelp=ytofpos(2) @@ -761,7 +796,8 @@ C-----------------------------S3 -------------------------------- - yhelp=0. +c yhelp=0. + yhelp=100. ! WM if (tof32_i.GT.none_find) yhelp=tof32_y(tof32_i) if (ytofpos(3).lt.100) yhelp=ytofpos(3) @@ -781,7 +817,8 @@ endif ENDIF - xhelp=0. +c xhelp=0. + xhelp=100. ! WM if (tof31_i.GT.none_find) xhelp=tof31_x(tof31_i) if (xtofpos(3).lt.100) xhelp=xtofpos(3) @@ -922,6 +959,7 @@ ENDIF ENDDO + C--------------------------------------------------------------- C--- calculate track position in paddle using timing difference C--- now using the time-walk corrected TDC values @@ -937,11 +975,13 @@ IF (tof11_i.GT.none_find) THEN ytofpos(1) = ((tof11(1,tof11_i,itdc)-tof11(2,tof11_i,itdc))/2. + -y_coor_lin11(tof11_i,offset))/y_coor_lin11(tof11_i,slope) + i=tof11_i endif IF (tof12_i.GT.none_find) THEN xtofpos(1) = ((tof12(1,tof12_i,itdc)-tof12(2,tof12_i,itdc))/2. + -x_coor_lin12(tof12_i,offset))/x_coor_lin12(tof12_i,slope) + i=tof12_i endif @@ -950,11 +990,13 @@ IF (tof21_i.GT.none_find) THEN xtofpos(2) = ((tof21(1,tof21_i,itdc)-tof21(2,tof21_i,itdc))/2. + -x_coor_lin21(tof21_i,offset))/x_coor_lin21(tof21_i,slope) + i=tof21_i endif IF (tof22_i.GT.none_find) THEN ytofpos(2) = ((tof22(1,tof22_i,itdc)-tof22(2,tof22_i,itdc))/2. + -y_coor_lin22(tof22_i,offset))/y_coor_lin22(tof22_i,slope) + i=tof22_i endif @@ -963,11 +1005,13 @@ IF (tof31_i.GT.none_find) THEN ytofpos(3) = ((tof31(1,tof31_i,itdc)-tof31(2,tof31_i,itdc))/2. + -y_coor_lin31(tof31_i,offset))/y_coor_lin31(tof31_i,slope) + i=tof31_i endif IF (tof32_i.GT.none_find) THEN xtofpos(3) = ((tof32(1,tof32_i,itdc)-tof32(2,tof32_i,itdc))/2. + -x_coor_lin32(tof32_i,offset))/x_coor_lin32(tof32_i,slope) + i=tof32_i endif @@ -980,6 +1024,7 @@ c endif c enddo + C-- restrict TDC measurements to physical paddle dimensions +/- 10 cm C-- this cut is now stronger than in the old versions @@ -991,48 +1036,40 @@ if (abs(ytofpos(2)).gt.18.) ytofpos(2)=101. if (abs(ytofpos(3)).gt.18.) ytofpos(3)=101. - C---------------------------------------------------------------------- C--------------------- zenith angle theta --------------------------- C---------------------------------------------------------------------- +C------------------- improved calculation --------------------------- + + xhelp1=0. + if (tof11_i.GT.none_find) xhelp1=tof11_x(tof11_i) + if (xtofpos(1).lt.100) xhelp1=xtofpos(1) + + yhelp1=0. + if (tof12_i.GT.none_find) yhelp1=tof12_y(tof12_i) + if (ytofpos(1).lt.100) yhelp1=ytofpos(1) + + yhelp2=0. + if (tof32_i.GT.none_find) yhelp2=tof32_y(tof32_i) + if (ytofpos(3).lt.100) yhelp2=ytofpos(3) + + xhelp2=0. + if (tof31_i.GT.none_find) xhelp2=tof31_x(tof31_i) + if (xtofpos(3).lt.100) xhelp2=xtofpos(3) + + + dx=0. + dy=0. + dr=0. + theta13 = 0. + + dx = xhelp1 - xhelp2 + dy = yhelp1 - yhelp2 + dr = sqrt(dx*dx+dy*dy) + theta13 = atan(dr/tofarm13) - 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) 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 C---------------------------------------------------------------------- C------------------angle and ADC(x) correction C---------------------------------------------------------------------- @@ -1046,6 +1083,7 @@ c DATA tof32_y/ -5.0,0.0,5.0/ yhelp=0. +c yhelp=100. if (tof12_i.GT.none_find) yhelp=tof12_y(tof12_i) if (ytofpos(1).lt.100) yhelp=ytofpos(1) @@ -1056,7 +1094,6 @@ 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 xkorr=xkorr/hepratio adctof_c(ch11a(i),hb11a(i))=tof11(left,i,iadc)/xkorr endif @@ -1065,13 +1102,13 @@ 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 xkorr=xkorr/hepratio adctof_c(ch11b(i),hb11b(i))=tof11(right,i,iadc)/xkorr endif ENDIF xhelp=0. +c xhelp=100. if (tof11_i.GT.none_find) xhelp=tof11_x(tof11_i) if (xtofpos(1).lt.100) xhelp=xtofpos(1) @@ -1082,7 +1119,6 @@ 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 xkorr=xkorr/hepratio adctof_c(ch12a(i),hb12a(i))=tof12(left,i,iadc)/xkorr endif @@ -1091,7 +1127,6 @@ 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 xkorr=xkorr/hepratio adctof_c(ch12b(i),hb12b(i))=tof12(right,i,iadc)/xkorr endif @@ -1100,6 +1135,7 @@ C-----------------------------S2 -------------------------------- xhelp=0. +c xhelp=100. if (tof22_i.GT.none_find) xhelp=tof22_x(tof22_i) if (xtofpos(2).lt.100) xhelp=xtofpos(2) @@ -1110,7 +1146,6 @@ 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 xkorr=xkorr/hepratio adctof_c(ch21a(i),hb21a(i))=tof21(left,i,iadc)/xkorr endif @@ -1120,7 +1155,6 @@ 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 xkorr=xkorr/hepratio adctof_c(ch21b(i),hb21b(i))=tof21(right,i,iadc)/xkorr endif @@ -1128,6 +1162,7 @@ yhelp=0. +c yhelp=100. if (tof21_i.GT.none_find) yhelp=tof21_y(tof21_i) if (ytofpos(2).lt.100) yhelp=ytofpos(2) @@ -1138,7 +1173,6 @@ 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 xkorr=xkorr/hepratio adctof_c(ch22a(i),hb22a(i))=tof22(left,i,iadc)/xkorr endif @@ -1147,7 +1181,6 @@ 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 xkorr=xkorr/hepratio adctof_c(ch22b(i),hb22b(i))=tof22(right,i,iadc)/xkorr endif @@ -1156,6 +1189,7 @@ C-----------------------------S3 -------------------------------- yhelp=0. +c yhelp=100. if (tof32_i.GT.none_find) yhelp=tof32_y(tof32_i) if (ytofpos(3).lt.100) yhelp=ytofpos(3) @@ -1166,7 +1200,6 @@ 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 xkorr=xkorr/hepratio adctof_c(ch31a(i),hb31a(i))=tof31(left,i,iadc)/xkorr endif @@ -1175,13 +1208,13 @@ 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 xkorr=xkorr/hepratio adctof_c(ch31b(i),hb31b(i))=tof31(right,i,iadc)/xkorr endif ENDIF xhelp=0. +c xhelp=100. if (tof31_i.GT.none_find) xhelp=tof31_x(tof31_i) if (xtofpos(3).lt.100) xhelp=xtofpos(3) @@ -1192,7 +1225,6 @@ 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 xkorr=xkorr/hepratio adctof_c(ch32a(i),hb32a(i))=tof32(left,i,iadc)/xkorr endif @@ -1201,7 +1233,6 @@ 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 xkorr=xkorr/hepratio adctof_c(ch32b(i),hb32b(i))=tof32(right,i,iadc)/xkorr endif @@ -2308,4 +2339,3 @@ C**************************************************************************** -