--- calo/unpacking/calunpack.for 2005/12/05 16:23:20 1.1.1.1 +++ calo/unpacking/calunpack.for 2006/10/19 09:25:53 1.5 @@ -1,10 +1,18 @@ C C Written by Emiliano Mocchiutti and Mirko Boezio C -C * Version: 3.4.06 * +C * Version: 3.4.10 * C C Changelog: C +C 3.4.09 - 3.4.10: (2006-10-19) Bug, crash when length is too big, fixed (introduced error code 143 = packet length problems); +C +C 3.4.08 - 3.4.09: (2006-09-28) XE is not always correctly found, fixed. +C +C 3.4.07 - 3.4.08: (2006-06-29) XO is rotated, not XE!! fixed. +C +C 3.4.06 - 3.4.07: (2006-06-29) save CRC values in calselftrig(section,1) and calselftrig(section,2) in case of CRC errors +C C 3.4.05 - 3.4.06: (2005-01-12) section order wrong in CLEARSEC, fixed. C C 3.4.04 - 3.4.05: (2005-01-05) XE is section y odd not even, fixed. @@ -108,7 +116,10 @@ INTEGER NPLA, NCHA, LENSEV INTEGER*2 ival C - PARAMETER (START=50,SEC1ST=1200) +c PARAMETER (START=50,SEC1ST=1200) +c PARAMETER (START=300,SEC1ST=1200) +c PARAMETER (START=500,SEC1ST=1200) + PARAMETER (SEC1ST=1200) PARAMETER (NPLA=22,NCHA=96,LENSEV=NPLA*NCHA) PARAMETER (ival='FFFF'x) C @@ -116,7 +127,7 @@ C integer lung, SOGLIA0, SEC2ND INTEGER*1 VECTA(lung) - INTEGER*2 vect(60000), test + INTEGER*2 vect(120000), test integer*2 check, crc, e2(4) INTEGER*2 length, length2 integer me, m, dumpo, finoa @@ -131,6 +142,7 @@ integer stwerr(4),yescbra, chis, esci, icprima integer seemcomp, seemfull, cberaw, yesisco, yesisfu,yesisra integer ca50, ca50a, ca50b + integer firsttime C real dedx1(11,96),dedx2(11,96),dedx3(11,96),dedx4(11,96) real dedx1c(11,96),dedx2c(11,96),dedx3c(11,96),dedx4c(11,96) @@ -157,7 +169,10 @@ C C Begin ! C + start = 320 + firsttime = 1 SOGLIA0 = 70 + 2 continue C C input length must be > 0, if not go out with error code 142 C @@ -180,6 +195,7 @@ write(*,17)l,vecta(l) enddo endif +C dumpo = iev C C DETERMINE LENGTH IN WORDS FROM LENGTH IN BYTES C @@ -193,9 +209,15 @@ C C IS LENGTH IS TOO LONG? C - if (lunga.gt.60000.and.dumpo.gt.0) then - print *,'Calorimeter WARNING: more than 60000 words!' - lunga = 60000 + if (lunga.ge.60000.and.dumpo.gt.0) then + print *,'Calorimeter ERROR: more than 60000 words!' + endif + if (lunga.ge.60000) then + if (dumpo.eq.iev) print *,'lung = ',lung + do i=1,4 + merror(i)=143 + enddo + goto 999 endif C C PRE-CLEAR VARIABLES @@ -291,6 +313,13 @@ C IF WE HAVE NO ROOM FOR A SECTION GO OUT C if ((ic+4).gt.lung.or.esci.eq.1) then + if (contr.eq.1.and.firsttime.eq.1) then + if (iev.eq.dumpo) + & print *,' first section not found retry from zero' + firsttime = 0 + start = 1 + goto 1 + endif if (headcor.eq.1.and.contr.lt.5) then headcor=-1 ic=ichc @@ -774,16 +803,20 @@ endif C if (check.ne.vect(length)) then - merror(contr) = 132 - chi = chi + 4 - lleng = 0 - length2 = 0 - length = 0 C C clear vectors of that section in the common C call clearsec C + calselftrig(k,1) = check + calselftrig(k,2) = vect(length) +c + merror(contr) = 132 + chi = chi + 4 + lleng = 0 + length2 = 0 + length = 0 +c if (ke.eq.1.and.headcor.ne.2) then ic = 10 elseif (headcor.eq.2) then @@ -924,19 +957,19 @@ C DO I = 1,11 DO J = 1,96 - DEXY(2,2*I,J) = DEDX2(I,J) + DEXY(2,2*I,97-J) = DEDX2(I,J) DEXY(1,2*I-1,J) = DEDX4(I,J) - DEXY(2,2*I-1,97-J) = DEDX1(I,J) + DEXY(2,2*I-1,J) = DEDX1(I,J) DEXY(1,2*I,J) = DEDX3(I,J) - DEXYC(2,2*I,J) = DEDX2C(I,J) + DEXYC(2,2*I,97-J) = DEDX2C(I,J) DEXYC(1,2*I-1,J) = DEDX4C(I,J) - DEXYC(2,2*I-1,97-J) = DEDX1C(I,J) + DEXYC(2,2*I-1,J) = DEDX1C(I,J) DEXYC(1,2*I,J) = DEDX3C(I,J) enddo do j = 1,6 - base(2,2*i,j) = base2(i,j) + base(2,2*i,7-j) = base2(i,j) base(1,2*i-1,j) = base4(i,j) - base(2,2*i-1,7-j) = base1(i,j) + base(2,2*i-1,j) = base1(i,j) base(1,2*i,j) = base3(i,j) enddo enddo @@ -1052,6 +1085,10 @@ enddo c if ( iev.eq.dumpo ) then + do i = 1, 4 + print *,' perror(',i,') = ',perror(i) + print *,' stwerr(',i,') = ',stwerr(i) + enddo if (perror(3).eq.132.and.perror(4).eq.129) then do i = 1, 2 do j = 1, 22 @@ -1060,10 +1097,10 @@ enddo enddo enddo - do l=1,lung - write(*,17)l,vecta(l) - enddo endif + do l=1,lung + write(*,17)l,vecta(l) + enddo endif iev = iev + 1 RETURN @@ -1412,12 +1449,12 @@ DEXYC(1,2*I-1,J) = 0. endif if (contr.eq.1) then - DEXY(2,2*I-1,97-J) = 0. - DEXYC(2,2*I-1,97-J) = 0. + DEXY(2,2*I-1,J) = 0. + DEXYC(2,2*I-1,J) = 0. endif if (contr.eq.2) then - DEXY(2,2*I,J) = 0. - DEXYC(2,2*I,J) = 0. + DEXY(2,2*I,97-J) = 0. + DEXYC(2,2*I,97-J) = 0. endif enddo do j = 1,6