C------------------------------------------------ c SUBROUTINE CALPULSE(vect,ERROR,calpulse,CONTR,e2) SUBROUTINE CALPULSE(vect,lung,me) C------------------------------------------------ IMPLICIT NONE C C Normal variables definition C INTEGER ERROR(4) C INTEGER i, j, iev,iev2, lung, me INTEGER NPLA, NCHA, LENSEV PARAMETER (NPLA=22,NCHA=96,LENSEV=NPLA*NCHA) C INTEGER*2 VECT(20000) C integer*2 check, crc,e2(4) C INTEGER ic, k, ke, ic0 INTEGER status, CONTR INTEGER inf, sup INTEGER XO, YO, XE, YE INTEGER*2 length, length2 INTEGER*2 st1, st2 REAL calpuls(4,11,96) DATA XO/177/ ! CODE_DSP_R XO = 101 10001 DATA YO/173/ ! CODE_DSP_R YO = 101 01101 DATA XE/170/ ! CODE_DSP_R XE = 101 01010 DATA YE/182/ ! CODE_DSP_R YE = 101 10110 REAL calped(4,11,96), calgood(4,11,96), calthr(4,11,6) REAL calrms(4,11,96), calbase(4,11,6), calvar(4,11,6) real calselftrig(4,7), calIItrig(4), calstripshit(4) real calDSPtaberr(4), calevnum(4) REAL DEXY(2,NPLA,NCHA), dexyc(2,npla,ncha), base(2,npla,ncha) COMMON / evento / IEV, & dexy,dexyc,base, & calselftrig,calIItrig, & calstripshit,calDSPtaberr,calevnum save / evento / COMMON / calib / IEV2, calped, calgood, calthr, calrms, & calbase, & calvar, & calpuls save / calib / COMMON /VARIE/error, CONTR, E2 SAVE /VARIE/ C C Begin ! C me = 0 ic = 0 c length = ic c 20 continue ic = ic + length + 1 ke = 0 do while (ke.eq.0) C C Check consistency of header. C it is composed by CODE+D# (8 bits) and by SATUS WORD (8 bits) c so we must split vect into the two components: C C ST1 is CODE + D# status = ISHFT(vect(ic),-8) st1 = IAND(status,'00FF'x) C ST2 is the STATUS WORD st2 = IAND(vect(ic),'00FF'x) c e2(contr) = 0 C if (contr.eq.1) then if (st1.eq.YE) then ke = 1 if (st2.ne.0) then E2(contr) = vect(ic) endif else if (st1.eq.YO.or.st1.eq.XE.or.st1.eq.XO) THEN error(contr) = 129 contr = 2 length = -1 goto 20 ELSE ERROR(contr) = 128 GOTO 100 endif endif ENDIF C if (CONTR.eq.2) then if (st1.eq.YO) then ke = 1 if (st2.ne.0) then E2(contr) = vect(ic) endif else if (st1.eq.XE.or.st1.eq.XO) then error(contr) = 129 contr = 3 length = -1 goto 20 ELSE ERROR(contr) = 128 GOTO 100 endif endif ENDIF C if (CONTR.eq.3) then if (st1.eq.XE) then ke = 1 if (st2.ne.0) then E2(contr) = vect(ic) endif else if (st1.eq.XO) then error(contr) = 129 contr = 4 length = -1 goto 20 ELSE ERROR(contr) = 128 GOTO 100 endif endif ENDIF C if (CONTR.eq.4) then if (st1.eq.XO) then ke = 1 if (st2.ne.0) then E2(contr) = vect(ic) endif else ERROR(contr) = 128 GOTO 100 endif endif C 100 CONTINUE ic = ic + 1 if (ic.gt.20000) then ERROR(contr) = 130 if (contr.ne.1) contr=5 me = 1 goto 200 endif enddo C 10 FORMAT(2X,'Error for view:',2X,I1,2X,'Status word:',2X,Z4) 11 FORMAT(2X,'View or command not recognized for view:',2X,I1,2X, & 'Status word:',2X,Z4) 12 FORMAT(2X,'Error - did NOT find view:',2X,I1) 13 FORMAT(2X,'Error - eof reached, exiting') C K = CONTR ic0 = ic - 1 length = ic0 + vect(ic) + 1 length2 = vect(ic) C C Check validity of length. C if (vect(ic).ne.1057) then ERROR(contr) = 131 me = 1 goto 200 endif C C Check consistency of CRC. C check = 0. inf = ic0 sup = length - 1 do i = inf,sup check=crc(check,vect(i)) enddo if (check.ne.vect(length)) then ERROR(contr) = 132 me = 1 goto 200 endif C C Process data. C do j = 1,96 do i = 1,11 ic = ic + 1 calpuls(k,i,j) = vect(ic) enddo enddo CONTR = contr + 1 me = 0 c if (contr.eq.5) contr = 1 c 50 continue c C 200 continue C if (error(1).eq.129.and.error(2).eq.129 & .and.error(3).eq.129.and.error(4).eq.130) then call vzero(error,4) me = 1 contr=1 endif C RETURN END