--- DarthVader/ToFLevel2/src/tofl2com.for 2007/02/07 08:17:17 1.5 +++ DarthVader/ToFLevel2/src/tofl2com.for 2007/04/30 15:46:30 1.6 @@ -1,3 +1,4 @@ + ****************************************************************************** * * 08-12-06 WM: adc_c-bug : The raw ADc value was multiplied with cos(theta) @@ -14,6 +15,9 @@ * jan-07 WM: flag for PMTs #10 and #35 added, TDC=819 due to bit-shift * jan-07 WM: bug removed: in some cases tdc_tw was calculated due to a * leftover "xhelp" value +* apr-07 WM: attenuation fit curve is now a double exponential fit +* conversion from raw ADC to pC using calibration function +* variables xtr_tof and ytr_tof inserted (filled with default) ****************************************************************************** INTEGER FUNCTION TOFL2COM() @@ -43,7 +47,6 @@ INTEGER tof11_j,tof21_j,tof31_j INTEGER tof12_j,tof22_j,tof32_j - REAL beta_mean @@ -69,6 +72,8 @@ INTEGER ihelp REAL xkorr + real atten,pc_adc + C--------------------------------------- C C Begin ! @@ -85,7 +90,7 @@ secure = 2. C ratio between helium and proton ca. 4 - hepratio = 4.5 ! + hepratio = 4. ! offset = 1 slope = 2 left = 1 @@ -136,55 +141,63 @@ enddo enddo + +C--- Fill xtr_tof and ytr_tof: positions from tracker at ToF layers +C--- since this is standalone ToF fill with default values + do j=1,6 + xtr_tof(j) = 101. + ytr_tof(j) = 101. + enddo + c the calibration files are read in the main program from xxx_tofcalib.rz c-------------------------get ToF data -------------------------------- c put the adc and tdc values from ntuple into tofxx(i,j,k) variables - +c adc valueas are then pC do j=1,8 - tof11(1,j,2) = adc(ch11a(j),hb11a(j)) - tof11(2,j,2) = adc(ch11b(j),hb11b(j)) - tof11(1,j,1) = tdc(ch11a(j),hb11a(j)) - tof11(2,j,1) = tdc(ch11b(j),hb11b(j)) + tof11(1,j,2) = pc_adc(adc(ch11a(j),hb11a(j))) + tof11(2,j,2) = pc_adc(adc(ch11b(j),hb11b(j))) + tof11(1,j,1) = (tdc(ch11a(j),hb11a(j))) + tof11(2,j,1) = (tdc(ch11b(j),hb11b(j))) enddo do j=1,6 - tof12(1,j,2) = adc(ch12a(j),hb12a(j)) - tof12(2,j,2) = adc(ch12b(j),hb12b(j)) - tof12(1,j,1) = tdc(ch12a(j),hb12a(j)) - tof12(2,j,1) = tdc(ch12b(j),hb12b(j)) + tof12(1,j,2) = pc_adc(adc(ch12a(j),hb12a(j))) + tof12(2,j,2) = pc_adc(adc(ch12b(j),hb12b(j))) + tof12(1,j,1) = (tdc(ch12a(j),hb12a(j))) + tof12(2,j,1) = (tdc(ch12b(j),hb12b(j))) enddo do j=1,2 - tof21(1,j,2) = adc(ch21a(j),hb21a(j)) - tof21(2,j,2) = adc(ch21b(j),hb21b(j)) - tof21(1,j,1) = tdc(ch21a(j),hb21a(j)) - tof21(2,j,1) = tdc(ch21b(j),hb21b(j)) + tof21(1,j,2) = pc_adc(adc(ch21a(j),hb21a(j))) + tof21(2,j,2) = pc_adc(adc(ch21b(j),hb21b(j))) + tof21(1,j,1) = (tdc(ch21a(j),hb21a(j))) + tof21(2,j,1) = (tdc(ch21b(j),hb21b(j))) enddo do j=1,2 - tof22(1,j,2) = adc(ch22a(j),hb22a(j)) - tof22(2,j,2) = adc(ch22b(j),hb22b(j)) - tof22(1,j,1) = tdc(ch22a(j),hb22a(j)) - tof22(2,j,1) = tdc(ch22b(j),hb22b(j)) + tof22(1,j,2) = pc_adc(adc(ch22a(j),hb22a(j))) + tof22(2,j,2) = pc_adc(adc(ch22b(j),hb22b(j))) + tof22(1,j,1) = (tdc(ch22a(j),hb22a(j))) + tof22(2,j,1) = (tdc(ch22b(j),hb22b(j))) enddo do j=1,3 - tof31(1,j,2) = adc(ch31a(j),hb31a(j)) - tof31(2,j,2) = adc(ch31b(j),hb31b(j)) - tof31(1,j,1) = tdc(ch31a(j),hb31a(j)) - tof31(2,j,1) = tdc(ch31b(j),hb31b(j)) + tof31(1,j,2) = pc_adc(adc(ch31a(j),hb31a(j))) + tof31(2,j,2) = pc_adc(adc(ch31b(j),hb31b(j))) + tof31(1,j,1) = (tdc(ch31a(j),hb31a(j))) + tof31(2,j,1) = (tdc(ch31b(j),hb31b(j))) enddo do j=1,3 - tof32(1,j,2) = adc(ch32a(j),hb32a(j)) - tof32(2,j,2) = adc(ch32b(j),hb32b(j)) - tof32(1,j,1) = tdc(ch32a(j),hb32a(j)) - tof32(2,j,1) = tdc(ch32b(j),hb32b(j)) + tof32(1,j,2) = pc_adc(adc(ch32a(j),hb32a(j))) + tof32(2,j,2) = pc_adc(adc(ch32b(j),hb32b(j))) + tof32(1,j,1) = (tdc(ch32a(j),hb32a(j))) + tof32(2,j,1) = (tdc(ch32b(j),hb32b(j))) enddo C---------------------------------------------------------------------- @@ -289,7 +302,6 @@ tdcflagtof(ch22b(2),hb22b(2))=2 endif - C---------------------------------------------------------------- C------------ Check Paddles for hits ----------------------- C------ a "hit" means TDC values<4095 on both sides ------------ @@ -626,15 +638,17 @@ IF (tof11_i.GT.none_find.AND.abs(yhelp).lt.100) THEN i = tof11_i - if (tof11(left,i,iadc).eq.4095) then - xkorr=adcx11(left,i,1)*exp(-yhelp/adcx11(left,i,2)) +c if (tof11(left,i,iadc).eq.4095) then + if (adc(ch11a(i),hb11a(i)).eq.4095) then + xkorr = atten(left,11,i,yhelp) xkorr=xkorr/hepratio tof11(left,i,iadc)=xkorr/cos(theta13) c write(*,*) 'tofl2 left ',i, tof11(left,i,iadc) adcflagtof(ch11a(i),hb11a(i)) = 1 endif - if (tof11(right,i,iadc).eq.4095) then - xkorr=adcx11(right,i,1)*exp(yhelp/adcx11(right,i,2)) +c if (tof11(right,i,iadc).eq.4095) then + if (adc(ch11b(i),hb11b(i)).eq.4095) then + xkorr = atten(right,11,i,yhelp) xkorr=xkorr/hepratio tof11(right,i,iadc)=xkorr/cos(theta13) c write(*,*) 'tofl2 right ',i, tof11(right,i,iadc) @@ -648,14 +662,16 @@ IF (tof12_i.GT.none_find.AND.abs(xhelp).lt.100) THEN i = tof12_i - if (tof12(left,i,iadc).eq.4095) then - xkorr=adcx12(left,i,1)*exp(-xhelp/adcx12(left,i,2)) +c if (tof12(left,i,iadc).eq.4095) then + if (adc(ch12a(i),hb12a(i)).eq.4095) then + xkorr = atten(left,12,i,xhelp) xkorr=xkorr/hepratio tof12(left,i,iadc) = xkorr/cos(theta13) adcflagtof(ch12a(i),hb12a(i)) = 1 endif - if (tof12(right,i,iadc).eq.4095) then - xkorr=adcx12(right,i,1)*exp(xhelp/adcx12(right,i,2)) +c if (tof12(right,i,iadc).eq.4095) then + if (adc(ch12b(i),hb12b(i)).eq.4095) then + xkorr = atten(right,12,i,xhelp) xkorr=xkorr/hepratio tof12(right,i,iadc) = xkorr/cos(theta13) adcflagtof(ch12b(i),hb12b(i)) = 1 @@ -670,14 +686,16 @@ IF (tof21_i.GT.none_find.AND.abs(xhelp).lt.100) THEN i = tof21_i - if (tof21(left,i,iadc).eq.4095) then - xkorr=adcx21(left,i,1)*exp(-xhelp/adcx21(left,i,2)) +c if (tof21(left,i,iadc).eq.4095) then + if (adc(ch21a(i),hb21a(i)).eq.4095) then + xkorr = atten(left,21,i,xhelp) xkorr=xkorr/hepratio tof21(left,i,iadc) = xkorr/cos(theta13) adcflagtof(ch21a(i),hb21a(i)) = 1 endif - if (tof21(right,i,iadc).eq.4095) then - xkorr=adcx21(right,i,1)*exp(xhelp/adcx21(right,i,2)) +c if (tof21(right,i,iadc).eq.4095) then + if (adc(ch21b(i),hb21b(i)).eq.4095) then + xkorr = atten(right,21,i,xhelp) xkorr=xkorr/hepratio tof21(right,i,iadc) = xkorr/cos(theta13) adcflagtof(ch21b(i),hb21b(i)) = 1 @@ -691,14 +709,16 @@ IF (tof22_i.GT.none_find.AND.abs(yhelp).lt.100) THEN i = tof22_i - if (tof22(left,i,iadc).eq.4095) then - xkorr=adcx22(left,i,1)*exp(-yhelp/adcx22(left,i,2)) +c if (tof22(left,i,iadc).eq.4095) then + if (adc(ch22a(i),hb22a(i)).eq.4095) then + xkorr = atten(left,22,i,yhelp) xkorr=xkorr/hepratio tof22(left,i,iadc) = xkorr/cos(theta13) adcflagtof(ch22a(i),hb22a(i)) = 1 endif - if (tof22(right,i,iadc).eq.4095) then - xkorr=adcx22(right,i,1)*exp(yhelp/adcx22(right,i,2)) +c if (tof22(right,i,iadc).eq.4095) then + if (adc(ch22b(i),hb22b(i)).eq.4095) then + xkorr = atten(right,22,i,yhelp) xkorr=xkorr/hepratio tof22(right,i,iadc) = xkorr/cos(theta13) adcflagtof(ch22b(i),hb22b(i)) = 1 @@ -713,14 +733,16 @@ IF (tof31_i.GT.none_find.AND.abs(yhelp).lt.100) THEN i = tof31_i - if (tof31(left,i,iadc).eq.4095) then - xkorr=adcx31(left,i,1)*exp(-yhelp/adcx31(left,i,2)) +c if (tof31(left,i,iadc).eq.4095) then + if (adc(ch31a(i),hb31a(i)).eq.4095) then + xkorr = atten(left,31,i,yhelp) xkorr=xkorr/hepratio tof31(left,i,iadc) = xkorr/cos(theta13) adcflagtof(ch31a(i),hb31a(i)) = 1 endif - if (tof31(right,i,iadc).eq.4095) then - xkorr=adcx31(right,i,1)*exp(yhelp/adcx31(right,i,2)) +c if (tof31(right,i,iadc).eq.4095) then + if (adc(ch31b(i),hb31b(i)).eq.4095) then + xkorr = atten(right,31,i,yhelp) xkorr=xkorr/hepratio tof31(right,i,iadc) = xkorr/cos(theta13) adcflagtof(ch31b(i),hb31b(i)) = 1 @@ -733,14 +755,16 @@ IF (tof32_i.GT.none_find.AND.abs(xhelp).lt.100) THEN i = tof32_i - if (tof32(left,i,iadc).eq.4095) then - xkorr=adcx32(left,i,1)*exp(-xhelp/adcx32(left,i,2)) +c if (tof32(left,i,iadc).eq.4095) then + if (adc(ch32a(i),hb32a(i)).eq.4095) then + xkorr = atten(left,32,i,xhelp) xkorr=xkorr/hepratio tof32(left,i,iadc) = xkorr/cos(theta13) adcflagtof(ch32a(i),hb32a(i)) = 1 endif - if (tof32(right,i,iadc).eq.4095) then - xkorr=adcx32(right,i,1)*exp(xhelp/adcx32(right,i,2)) +c if (tof32(right,i,iadc).eq.4095) then + if (adc(ch32b(i),hb32b(i)).eq.4095) then + xkorr = atten(right,32,i,xhelp) xkorr=xkorr/hepratio tof32(right,i,iadc) = xkorr/cos(theta13) adcflagtof(ch32b(i),hb32b(i)) = 1 @@ -756,12 +780,13 @@ xhelp= 0. xhelp_a = tof11(left,i,iadc) xhelp_t = tof11(left,i,itdc) - if(xhelp_a<4095) xhelp = tw11(left,i)/sqrt(xhelp_a) +c if (xhelp_a .eq.0) write (*,*) '11 ',i,xhelp_a + if(xhelp_a<3786) xhelp = tw11(left,i)/sqrt(xhelp_a) tof11(left,i,itdc) = xhelp_t + xhelp tdc_c(ch11a(i),hb11a(i))=tof11(left,i,itdc) xhelp_a = tof11(right,i,iadc) xhelp_t = tof11(right,i,itdc) - if(xhelp_a<4095) xhelp = tw11(right,i)/sqrt(xhelp_a) + if(xhelp_a<3786) xhelp = tw11(right,i)/sqrt(xhelp_a) tof11(right,i,itdc) = xhelp_t + xhelp tdc_c(ch11b(i),hb11b(i))=tof11(right,i,itdc) ENDDO @@ -770,12 +795,13 @@ xhelp= 0. xhelp_a = tof12(left,i,iadc) xhelp_t = tof12(left,i,itdc) - if(xhelp_a<4095) xhelp = tw12(left,i)/sqrt(xhelp_a) +c if (xhelp_a .eq.0) write (*,*) '12 ',i,xhelp_a + if(xhelp_a<3786) xhelp = tw12(left,i)/sqrt(xhelp_a) tof12(left,i,itdc) = xhelp_t + xhelp tdc_c(ch12a(i),hb12a(i))=tof12(left,i,itdc) xhelp_a = tof12(right,i,iadc) xhelp_t = tof12(right,i,itdc) - if(xhelp_a<4095) xhelp = tw12(right,i)/sqrt(xhelp_a) + if(xhelp_a<3786) xhelp = tw12(right,i)/sqrt(xhelp_a) tof12(right,i,itdc) = xhelp_t + xhelp tdc_c(ch12b(i),hb12b(i))=tof12(right,i,itdc) ENDDO @@ -784,12 +810,13 @@ xhelp= 0. xhelp_a = tof21(left,i,iadc) xhelp_t = tof21(left,i,itdc) - if(xhelp_a<4095) xhelp = tw21(left,i)/sqrt(xhelp_a) +c if (xhelp_a .eq.0) write (*,*) '21 ',i,xhelp_a + if(xhelp_a<3786) xhelp = tw21(left,i)/sqrt(xhelp_a) tof21(left,i,itdc) = xhelp_t + xhelp tdc_c(ch21a(i),hb21a(i))=tof21(left,i,itdc) xhelp_a = tof21(right,i,iadc) xhelp_t = tof21(right,i,itdc) - if(xhelp_a<4095) xhelp = tw21(right,i)/sqrt(xhelp_a) + if(xhelp_a<3786) xhelp = tw21(right,i)/sqrt(xhelp_a) tof21(right,i,itdc) = xhelp_t + xhelp tdc_c(ch21b(i),hb21b(i))=tof21(right,i,itdc) ENDDO @@ -798,12 +825,14 @@ xhelp= 0. xhelp_a = tof22(left,i,iadc) xhelp_t = tof22(left,i,itdc) - if(xhelp_a<4095) xhelp = tw22(left,i)/sqrt(xhelp_a) +c if (xhelp_a .eq.0) write (*,*) '22 ',i,xhelp_a + + if(xhelp_a<3786) xhelp = tw22(left,i)/sqrt(xhelp_a) tof22(left,i,itdc) = xhelp_t + xhelp tdc_c(ch22a(i),hb22a(i))=tof22(left,i,itdc) xhelp_a = tof22(right,i,iadc) xhelp_t = tof22(right,i,itdc) - if(xhelp_a<4095) xhelp = tw22(right,i)/sqrt(xhelp_a) + if(xhelp_a<3786) xhelp = tw22(right,i)/sqrt(xhelp_a) tof22(right,i,itdc) = xhelp_t + xhelp tdc_c(ch22b(i),hb22b(i))=tof22(right,i,itdc) ENDDO @@ -813,12 +842,14 @@ xhelp= 0. xhelp_a = tof31(left,i,iadc) xhelp_t = tof31(left,i,itdc) - if(xhelp_a<4095) xhelp = tw31(left,i)/sqrt(xhelp_a) +c if (xhelp_a .eq.0) write (*,*) '31 ',i,xhelp_a + + if(xhelp_a<3786) xhelp = tw31(left,i)/sqrt(xhelp_a) tof31(left,i,itdc) = xhelp_t + xhelp tdc_c(ch31a(i),hb31a(i))=tof31(left,i,itdc) xhelp_a = tof31(right,i,iadc) xhelp_t = tof31(right,i,itdc) - if(xhelp_a<4095) xhelp = tw31(right,i)/sqrt(xhelp_a) + if(xhelp_a<3786) xhelp = tw31(right,i)/sqrt(xhelp_a) tof31(right,i,itdc) = xhelp_t + xhelp tdc_c(ch31b(i),hb31b(i))=tof31(right,i,itdc) ENDDO @@ -827,12 +858,14 @@ xhelp= 0. xhelp_a = tof32(left,i,iadc) xhelp_t = tof32(left,i,itdc) - if(xhelp_a<4095) xhelp = tw32(left,i)/sqrt(xhelp_a) +c if (xhelp_a .eq.0) write (*,*) '32 ',i,xhelp_a + + if(xhelp_a<3786) xhelp = tw32(left,i)/sqrt(xhelp_a) tof32(left,i,itdc) = xhelp_t + xhelp tdc_c(ch32a(i),hb32a(i))=tof32(left,i,itdc) xhelp_a = tof32(right,i,iadc) xhelp_t = tof32(right,i,itdc) - if(xhelp_a<4095) xhelp = tw32(right,i)/sqrt(xhelp_a) + if(xhelp_a<3786) xhelp = tw32(right,i)/sqrt(xhelp_a) tof32(right,i,itdc) = xhelp_t + xhelp tdc_c(ch32b(i),hb32b(i))=tof32(right,i,itdc) ENDDO @@ -856,16 +889,20 @@ IF (tof11_i.GT.none_find.AND.abs(yhelp).lt.100) THEN i = tof11_i - if (tof11(left,i,iadc).lt.4095) then + 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=adcx11(left,i,1)*exp(-yhelp/adcx11(left,i,2)) + 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 - if (tof11(right,i,iadc).lt.4095) then + 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=adcx11(right,i,1)*exp(yhelp/adcx11(right,i,2)) + 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 @@ -878,16 +915,20 @@ IF (tof12_i.GT.none_find.AND.abs(xhelp).lt.100) THEN i = tof12_i - if (tof12(left,i,iadc).lt.4095) then + 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=adcx12(left,i,1)*exp(-xhelp/adcx12(left,i,2)) + 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 - if (tof12(right,i,iadc).lt.4095) then + 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=adcx12(right,i,1)*exp(xhelp/adcx12(right,i,2)) + 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 @@ -902,16 +943,21 @@ IF (tof21_i.GT.none_find.AND.abs(xhelp).lt.100) THEN i = tof21_i - if (tof21(left,i,iadc).lt.4095) then + 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=adcx21(left,i,1)*exp(-xhelp/adcx21(left,i,2)) + 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 - if (tof21(right,i,iadc).lt.4095) then + 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 xkorr=xkorr/hepratio adctof_c(ch21b(i),hb21b(i))=tof21(right,i,iadc)/xkorr endif @@ -925,16 +971,20 @@ IF (tof22_i.GT.none_find.AND.abs(yhelp).lt.100) THEN i = tof22_i - if (tof22(left,i,iadc).lt.4095) then + 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=adcx22(left,i,1)*exp(-yhelp/adcx22(left,i,2)) + 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 - if (tof22(right,i,iadc).lt.4095) then + 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=adcx22(right,i,1)*exp(yhelp/adcx22(right,i,2)) + 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 @@ -949,16 +999,20 @@ IF (tof31_i.GT.none_find.AND.abs(yhelp).lt.100) THEN i = tof31_i - if (tof31(left,i,iadc).lt.4095) then + 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=adcx31(left,i,1)*exp(-yhelp/adcx31(left,i,2)) + 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 - if (tof31(right,i,iadc).lt.4095) then + 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=adcx31(right,i,1)*exp(yhelp/adcx31(right,i,2)) + 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 @@ -971,16 +1025,20 @@ IF (tof32_i.GT.none_find.AND.abs(xhelp).lt.100) THEN i = tof32_i - if (tof32(left,i,iadc).lt.4095) then + 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=adcx32(left,i,1)*exp(-xhelp/adcx32(left,i,2)) + 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 - if (tof32(right,i,iadc).lt.4095) then + 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=adcx32(right,i,1)*exp(xhelp/adcx32(right,i,2)) + 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 @@ -1357,13 +1415,104 @@ c write(*,*) xtofpos c write(*,*) ytofpos -c write(*,*) betatof_a +c write(*,*)'tofl2com beta', betatof_a C write(*,*) adcflagtof - - +c write(*,*) 'tofl2com' +c write(*,*) xtofpos +c write(*,*) ytofpos +c write(*,*) xtr_tof +c write(*,*) ytr_tof + 100 continue C RETURN END + +C------------------------------------------------------------------ +C------------------------------------------------------------------ + + function atten(is,ilay,ipad,x) + include 'input_tof.txt' + real atten + real x + real xmin,xmax + integer ilay,ipad + +* S11 8 paddles 33.0 x 5.1 cm +* S12 6 paddles 40.8 x 5.5 cm +* S21 2 paddles 18.0 x 7.5 cm +* S22 2 paddles 15.0 x 9.0 cm +* S31 3 paddles 15.0 x 6.0 cm +* S32 3 paddles 18.0 x 5.0 cm + + +c if (ilay.eq.11) write(*,*) 'start ',ipad,is,adcx11(is,ipad,1), +c & adcx11(is,ipad,2),adcx11(is,ipad,3),adcx11(is,ipad,4) +c if (ilay.eq.12) write(*,*) 'start ',ipad,is,adcx12(is,ipad,1), +c & adcx12(is,ipad,2),adcx12(is,ipad,3),adcx12(is,ipad,4) + + + if (ilay.eq.11) xmin=-33.0/2. + if (ilay.eq.11) xmax= 33.0/2. + if (ilay.eq.12) xmin=-40.8/2. + if (ilay.eq.12) xmax= 40.8/2. + + if (ilay.eq.21) xmin=-18.0/2. + if (ilay.eq.21) xmax= 18.0/2. + if (ilay.eq.22) xmin=-15.0/2. + if (ilay.eq.22) xmax= 15.0/2. + + if (ilay.eq.31) xmin=-15.0/2. + if (ilay.eq.31) xmax= 15.0/2. + if (ilay.eq.32) xmin=-18.0/2. + if (ilay.eq.32) xmax= 18.0/2. + + if (x .lt. xmin) x=xmin + if (x .gt. xmax) x=xmax + + + if (ilay.eq.11) atten= + & adcx11(is,ipad,1)*exp(x*adcx11(is,ipad,2)) + & + adcx11(is,ipad,3)*exp(x*adcx11(is,ipad,4)) + + if (ilay.eq.12) atten= + & adcx12(is,ipad,1)*exp(x*adcx12(is,ipad,2)) + & + adcx12(is,ipad,3)*exp(x*adcx12(is,ipad,4)) + + if (ilay.eq.21) atten= + & adcx21(is,ipad,1)*exp(x*adcx21(is,ipad,2)) + & + adcx21(is,ipad,3)*exp(x*adcx21(is,ipad,4)) + + if (ilay.eq.22) atten= + & adcx22(is,ipad,1)*exp(x*adcx22(is,ipad,2)) + & + adcx22(is,ipad,3)*exp(x*adcx22(is,ipad,4)) + + if (ilay.eq.31) atten= + & adcx31(is,ipad,1)*exp(x*adcx31(is,ipad,2)) + & + adcx31(is,ipad,3)*exp(x*adcx31(is,ipad,4)) + + if (ilay.eq.32) atten= + & adcx32(is,ipad,1)*exp(x*adcx32(is,ipad,2)) + & + adcx32(is,ipad,3)*exp(x*adcx32(is,ipad,4)) + + if (atten.gt.10000) atten=10000. + + end + +C------------------------------------------------------------------ +C------------------------------------------------------------------ + + function pc_adc(ix) + include 'input_tof.txt' + real pc_adc + integer ix + + pc_adc=28.0407 + 0.628929*ix + & - 5.80901e-05*ix*ix + 3.14092e-08*ix*ix*ix +c write(*,*) ix,pc_adc + end + +C------------------------------------------------------------------ +