| 1 | 
 C | 
 C | 
| 2 | 
 C  Written by Emiliano Mocchiutti and Mirko Boezio | 
 C  Written by Emiliano Mocchiutti and Mirko Boezio | 
| 3 | 
 C | 
 C | 
| 4 | 
 C     * Version: 3.4.10 * | 
 C     * Version: 3.4.11 * | 
| 5 | 
 C | 
 C | 
| 6 | 
 C Changelog: | 
 C Changelog: | 
| 7 | 
 C | 
 C | 
| 8 | 
  | 
 C 3.4.10 - 3.4.11: (2008-12-04) Process always the data also in case of CRC errors. | 
| 9 | 
  | 
 C | 
| 10 | 
 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 3.4.09 - 3.4.10: (2006-10-19) Bug, crash when length is too big, fixed (introduced error code 143 = packet length problems); | 
| 11 | 
 C | 
 C | 
| 12 | 
 C 3.4.08 - 3.4.09: (2006-09-28) XE is not always correctly found, fixed. | 
 C 3.4.08 - 3.4.09: (2006-09-28) XE is not always correctly found, fixed. | 
| 123 | 
 c      PARAMETER (START=500,SEC1ST=1200) | 
 c      PARAMETER (START=500,SEC1ST=1200) | 
| 124 | 
       PARAMETER (SEC1ST=1200) | 
       PARAMETER (SEC1ST=1200) | 
| 125 | 
       PARAMETER (NPLA=22,NCHA=96,LENSEV=NPLA*NCHA) | 
       PARAMETER (NPLA=22,NCHA=96,LENSEV=NPLA*NCHA) | 
| 126 | 
       PARAMETER (ival='FFFF'x) | 
 c      PARAMETER (ival=-32768) | 
| 127 | 
  | 
 c      PARAMETER (ival='FFFF'x) | 
| 128 | 
 C | 
 C | 
| 129 | 
 C Normal variables definition | 
 C Normal variables definition | 
| 130 | 
 C | 
 C | 
| 146 | 
       integer seemcomp, seemfull, cberaw, yesisco, yesisfu,yesisra | 
       integer seemcomp, seemfull, cberaw, yesisco, yesisfu,yesisra | 
| 147 | 
       integer ca50, ca50a, ca50b | 
       integer ca50, ca50a, ca50b | 
| 148 | 
       integer firsttime | 
       integer firsttime | 
| 149 | 
  | 
       integer scrcerr, sic, sicb | 
| 150 | 
 C      | 
 C      | 
| 151 | 
       real dedx1(11,96),dedx2(11,96),dedx3(11,96),dedx4(11,96) | 
       real dedx1(11,96),dedx2(11,96),dedx3(11,96),dedx4(11,96) | 
| 152 | 
       real dedx1c(11,96),dedx2c(11,96),dedx3c(11,96),dedx4c(11,96) | 
       real dedx1c(11,96),dedx2c(11,96),dedx3c(11,96),dedx4c(11,96) | 
| 173 | 
 C          | 
 C          | 
| 174 | 
 C Begin ! | 
 C Begin ! | 
| 175 | 
 C | 
 C | 
| 176 | 
  | 
 c      dumpo = iev | 
| 177 | 
       start = 320 | 
       start = 320 | 
| 178 | 
       firsttime = 1 | 
       firsttime = 1 | 
| 179 | 
       SOGLIA0 = 70 | 
       SOGLIA0 = 70 | 
| 180 | 
  | 
       sic = 0 | 
| 181 | 
  | 
       sicb = 0 | 
| 182 | 
  2    continue | 
  2    continue | 
| 183 | 
 C | 
 C | 
| 184 | 
 C     input length must be > 0, if not go out with error code 142 | 
 C     input length must be > 0, if not go out with error code 142 | 
| 190 | 
          enddo | 
          enddo | 
| 191 | 
          goto 999 | 
          goto 999 | 
| 192 | 
       endif | 
       endif | 
| 193 | 
  | 
  | 
| 194 | 
  | 
       do bit = 0, 15 | 
| 195 | 
  | 
          ival = ibset(ival,bit) | 
| 196 | 
  | 
       enddo | 
| 197 | 
  | 
 c      print *,' IVAL ',IVAL | 
| 198 | 
  | 
 c      write(*,22)IVAL | 
| 199 | 
 C | 
 C | 
| 200 | 
 C     no debug informations | 
 C     no debug informations | 
| 201 | 
 C | 
 C | 
| 203 | 
 C | 
 C | 
| 204 | 
 C     DEBUG: PRINT OUT THE INPUT VECTOR | 
 C     DEBUG: PRINT OUT THE INPUT VECTOR | 
| 205 | 
 C | 
 C | 
| 206 | 
       if (iev.eq.dumpo) then | 
 c      dumpo=iev | 
| 207 | 
          do l=1,lung | 
 c      if (iev.eq.dumpo) then | 
| 208 | 
             write(*,17)l,vecta(l) | 
 c         do l=1,lung | 
| 209 | 
          enddo  | 
 c            write(*,17)l,vecta(l) | 
| 210 | 
       endif | 
 c         enddo  | 
| 211 | 
 C      dumpo = iev | 
 c      endif | 
| 212 | 
 C | 
 C | 
| 213 | 
 C     DETERMINE LENGTH IN WORDS FROM LENGTH IN BYTES | 
 C     DETERMINE LENGTH IN WORDS FROM LENGTH IN BYTES | 
| 214 | 
 C | 
 C | 
| 305 | 
 c | 
 c | 
| 306 | 
  32   continue | 
  32   continue | 
| 307 | 
 C | 
 C | 
| 308 | 
  | 
       if ( ic .lt. 1 ) then | 
| 309 | 
  | 
          if (dumpo.eq.iev) print *,' AGH IC = ',IC       | 
| 310 | 
  | 
          ic = 1 | 
| 311 | 
  | 
       endif | 
| 312 | 
  | 
       if ( icsave .lt. 0 ) then | 
| 313 | 
  | 
          if (dumpo.eq.iev) print *,' AGH ICSAVE = ',ICSAVE       | 
| 314 | 
  | 
          icsave = 0 | 
| 315 | 
  | 
       endif | 
| 316 | 
  | 
 C | 
| 317 | 
       ke = 0 | 
       ke = 0 | 
| 318 | 
       chis = chi | 
       chis = chi | 
| 319 | 
       icold = ic | 
       icold = ic | 
| 320 | 
       DO i = 1, 60000 | 
       DO i = 1, 120000 | 
| 321 | 
          vect(i) = 0 | 
          vect(i) = 0 | 
| 322 | 
       enddo | 
       enddo | 
| 323 | 
       do while (ke.eq.0)  | 
       do while (ke.eq.0)  | 
| 825 | 
       endif | 
       endif | 
| 826 | 
 C | 
 C | 
| 827 | 
       if (check.ne.vect(length)) then | 
       if (check.ne.vect(length)) then | 
| 828 | 
 C | 
 c | 
| 829 | 
  | 
 c     try to process anyway if we have crc errors but only on the second time we have found our section | 
| 830 | 
  | 
 c | 
| 831 | 
  | 
          scrcerr = 0 | 
| 832 | 
  | 
          sic = 0 | 
| 833 | 
  | 
          sicb = 0 | 
| 834 | 
  | 
          if ( headcor.ne.2 ) then | 
| 835 | 
  | 
 C      | 
| 836 | 
 C     clear vectors of that section in the common | 
 C     clear vectors of that section in the common | 
| 837 | 
  | 
 C      | 
| 838 | 
  | 
             call clearsec | 
| 839 | 
 C | 
 C | 
| 840 | 
          call clearsec | 
             calselftrig(k,1) = check | 
| 841 | 
 C | 
             calselftrig(k,2) = vect(length) | 
 | 
          calselftrig(k,1) = check | 
  | 
 | 
          calselftrig(k,2) = vect(length) | 
  | 
| 842 | 
 c          | 
 c          | 
| 843 | 
          merror(contr) = 132 | 
             merror(contr) = 132 | 
| 844 | 
          chi = chi + 4 | 
             chi = chi + 4 | 
| 845 | 
          lleng = 0 | 
             lleng = 0 | 
| 846 | 
          length2 = 0 | 
             length2 = 0 | 
| 847 | 
          length = 0 | 
             length = 0 | 
| 848 | 
  | 
 c      | 
| 849 | 
  | 
             if (ke.eq.1.and.headcor.ne.2) then | 
| 850 | 
  | 
                ic = 10 | 
| 851 | 
  | 
 c     elseif (headcor.eq.2) then | 
| 852 | 
  | 
 c     contr = contr + 1             | 
| 853 | 
  | 
             endif | 
| 854 | 
  | 
             headcor = 1 | 
| 855 | 
  | 
             ichc = ic - 1 | 
| 856 | 
  | 
             if (iev.eq.dumpo) | 
| 857 | 
  | 
      &           print *,' A crc is wrong ',ic, | 
| 858 | 
  | 
      &           ' search section ',contr,' coco = ',coco | 
| 859 | 
  | 
             goto 32      | 
| 860 | 
  | 
          else | 
| 861 | 
  | 
 c      | 
| 862 | 
  | 
 c     set some variables and try to go on | 
| 863 | 
 c | 
 c | 
| 864 | 
          if (ke.eq.1.and.headcor.ne.2) then | 
             merror(contr) = 132 | 
| 865 | 
             ic = 10 | 
             scrcerr = 1 | 
| 866 | 
          elseif (headcor.eq.2) then | 
             sic = ic | 
| 867 | 
             contr = contr + 1             | 
             sicb = icb | 
| 868 | 
  | 
  | 
| 869 | 
          endif | 
          endif | 
 | 
          headcor = 1 | 
  | 
 | 
          ichc = ic - 1 | 
  | 
 | 
          if (iev.eq.dumpo) | 
  | 
 | 
      &        print *,'crc is wrong ',ic, | 
  | 
 | 
      &        ' search section ',contr,' coco = ',coco | 
  | 
 | 
          goto 32      | 
  | 
| 870 | 
       else | 
       else | 
| 871 | 
          chi = chi - 4 | 
          chi = chi - 4 | 
| 872 | 
          if (chi.lt.0) chi = 0 | 
          if (chi.lt.0) chi = 0 | 
| 881 | 
       call clearsec | 
       call clearsec | 
| 882 | 
       do i = 1, 7  | 
       do i = 1, 7  | 
| 883 | 
          icb = icb + 1 | 
          icb = icb + 1 | 
| 884 | 
          auto(i) = vect(icb) | 
          if ( icb.gt.120000 ) then | 
| 885 | 
  | 
 c     out of vector... | 
| 886 | 
  | 
             if (iev.eq.dumpo) then | 
| 887 | 
  | 
                print *,' Run out of vect...'   | 
| 888 | 
  | 
                goto 150 | 
| 889 | 
  | 
             endif | 
| 890 | 
  | 
          endif | 
| 891 | 
  | 
          auto(i) = vect(icb)             | 
| 892 | 
       enddo | 
       enddo | 
| 893 | 
 C      | 
 C      | 
| 894 | 
       st2c = 0 | 
       st2c = 0 | 
| 905 | 
             chi = chi + 4 | 
             chi = chi + 4 | 
| 906 | 
             if (iev.eq.dumpo)  | 
             if (iev.eq.dumpo)  | 
| 907 | 
      &           print *,'raw lung 4' | 
      &           print *,'raw lung 4' | 
| 908 | 
             lleng = 0 | 
             if ( scrcerr.eq.0 ) then | 
| 909 | 
             goto 150 | 
                lleng = 0 | 
| 910 | 
          else                | 
                goto 150 | 
| 911 | 
             if (k.eq.1) call CALRAW(vect,icb+1,length-1,dedx1) | 
             endif | 
 | 
             if (k.eq.2) call CALRAW(vect,icb+1,length-1,dedx2) | 
  | 
 | 
             if (k.eq.3) call CALRAW(vect,icb+1,length-1,dedx3) | 
  | 
 | 
             if (k.eq.4) call CALRAW(vect,icb+1,length-1,dedx4) | 
  | 
| 912 | 
          endif | 
          endif | 
| 913 | 
  | 
 c     else                | 
| 914 | 
  | 
          if (k.eq.1) call CALRAW(vect,icb+1,length-1,dedx1) | 
| 915 | 
  | 
          if (k.eq.2) call CALRAW(vect,icb+1,length-1,dedx2) | 
| 916 | 
  | 
          if (k.eq.3) call CALRAW(vect,icb+1,length-1,dedx3) | 
| 917 | 
  | 
          if (k.eq.4) call CALRAW(vect,icb+1,length-1,dedx4) | 
| 918 | 
  | 
 c     endif | 
| 919 | 
          goto 50 | 
          goto 50 | 
| 920 | 
       endif | 
       endif | 
| 921 | 
 C      | 
 C      | 
| 928 | 
             chi = chi + 4 | 
             chi = chi + 4 | 
| 929 | 
             if (iev.eq.dumpo)  | 
             if (iev.eq.dumpo)  | 
| 930 | 
      &           print *,'compr lung 4' | 
      &           print *,'compr lung 4' | 
| 931 | 
             lleng = 0 | 
             if ( scrcerr.eq.0 ) then | 
| 932 | 
             goto 150 | 
                lleng = 0 | 
| 933 | 
          else | 
                goto 150 | 
| 934 | 
             icb = icb + 1 | 
             endif | 
| 935 | 
             calIItrig(k) = vect(icb) | 
          endif | 
| 936 | 
             icb = icb + 1 | 
 c         else | 
| 937 | 
             calstriphit(k) = vect(icb) | 
          icb = icb + 1 | 
| 938 | 
             icb = icb + 1 | 
          if ( icb.gt.120000 ) then | 
| 939 | 
  | 
 c     out of vector... | 
| 940 | 
  | 
             if (iev.eq.dumpo) then | 
| 941 | 
  | 
                print *,' Run out of vect...'   | 
| 942 | 
  | 
                goto 150 | 
| 943 | 
  | 
             endif | 
| 944 | 
  | 
          endif | 
| 945 | 
  | 
          calIItrig(k) = vect(icb) | 
| 946 | 
  | 
          icb = icb + 1 | 
| 947 | 
  | 
          if ( icb.gt.120000 ) then | 
| 948 | 
  | 
 c     out of vector... | 
| 949 | 
  | 
             if (iev.eq.dumpo) then | 
| 950 | 
  | 
                 print *,' Run out of vect...'   | 
| 951 | 
  | 
                goto 150 | 
| 952 | 
  | 
             endif | 
| 953 | 
  | 
          endif | 
| 954 | 
  | 
          calstriphit(k) = vect(icb) | 
| 955 | 
  | 
          icb = icb + 1 | 
| 956 | 
  | 
          if ( icb.gt.120000 ) then | 
| 957 | 
  | 
 c     out of vector... | 
| 958 | 
  | 
             if (iev.eq.dumpo) then | 
| 959 | 
  | 
                 print *,' Run out of vect...'   | 
| 960 | 
  | 
                goto 150 | 
| 961 | 
  | 
             endif | 
| 962 | 
  | 
          endif | 
| 963 | 
 C     FIRST CALORIMETER SIGNATURE:  CA50 | 
 C     FIRST CALORIMETER SIGNATURE:  CA50 | 
| 964 | 
             icb = icb + 1 | 
          icb = icb + 1 | 
| 965 | 
  | 
          if ( icb.gt.120000 ) then | 
| 966 | 
  | 
 c     out of vector... | 
| 967 | 
  | 
             if (iev.eq.dumpo) then | 
| 968 | 
  | 
                 print *,' Run out of vect...'   | 
| 969 | 
  | 
                goto 150 | 
| 970 | 
  | 
             endif | 
| 971 | 
  | 
          endif | 
| 972 | 
 C     SECOND CALORIMETER SIGNATURE:  CA50      | 
 C     SECOND CALORIMETER SIGNATURE:  CA50      | 
| 973 | 
             icb = icb + 1 | 
          icb = icb + 1 | 
| 974 | 
  | 
          if ( icb.gt.120000 ) then | 
| 975 | 
  | 
 c     out of vector... | 
| 976 | 
  | 
             if (iev.eq.dumpo) then | 
| 977 | 
  | 
                 print *,' Run out of vect...'   | 
| 978 | 
  | 
                goto 150 | 
| 979 | 
  | 
             endif | 
| 980 | 
  | 
          endif | 
| 981 | 
 C     test is here! | 
 C     test is here! | 
| 982 | 
             icb = icb + 1 | 
          icb = icb + 1 | 
| 983 | 
             calDSPtaberr(k) = vect(icb) | 
          if ( icb.gt.120000 ) then | 
| 984 | 
             icb = icb + 1 | 
 c     out of vector... | 
| 985 | 
             calevnum(k) = vect(icb) | 
             if (iev.eq.dumpo) then | 
| 986 | 
             if (k.eq.1) call CALCOMPRESS(vect,icb+1,length-1,dedx1c, | 
                 print *,' Run out of vect...'   | 
| 987 | 
      &           base1) | 
                goto 150 | 
| 988 | 
             if (k.eq.2) call CALCOMPRESS(vect,icb+1,length-1,dedx2c, | 
             endif | 
| 989 | 
      &           base2) | 
          endif | 
| 990 | 
             if (k.eq.3) call CALCOMPRESS(vect,icb+1,length-1,dedx3c, | 
          calDSPtaberr(k) = vect(icb) | 
| 991 | 
      &           base3) | 
          icb = icb + 1 | 
| 992 | 
             if (k.eq.4) call CALCOMPRESS(vect,icb+1,length-1,dedx4c, | 
          if ( icb.gt.120000 ) then | 
| 993 | 
      &           base4) | 
 c     out of vector... | 
| 994 | 
             goto 50 | 
             if (iev.eq.dumpo) then | 
| 995 | 
  | 
                 print *,' Run out of vect...'   | 
| 996 | 
  | 
                goto 150 | 
| 997 | 
  | 
             endif | 
| 998 | 
          endif | 
          endif | 
| 999 | 
  | 
          calevnum(k) = vect(icb) | 
| 1000 | 
  | 
          if (k.eq.1) call CALCOMPRESS(vect,icb+1,length-1,dedx1c, | 
| 1001 | 
  | 
      &        base1,scrcerr) | 
| 1002 | 
  | 
          if (k.eq.2) call CALCOMPRESS(vect,icb+1,length-1,dedx2c, | 
| 1003 | 
  | 
      &        base2,scrcerr) | 
| 1004 | 
  | 
          if (k.eq.3) call CALCOMPRESS(vect,icb+1,length-1,dedx3c, | 
| 1005 | 
  | 
      &        base3,scrcerr) | 
| 1006 | 
  | 
          if (k.eq.4) call CALCOMPRESS(vect,icb+1,length-1,dedx4c, | 
| 1007 | 
  | 
      &        base4,scrcerr) | 
| 1008 | 
  | 
          goto 50 | 
| 1009 | 
  | 
 c      endif | 
| 1010 | 
       else if (test.eq.0) then | 
       else if (test.eq.0) then | 
| 1011 | 
          if (length2.gt.2257) then | 
          if (length2.gt.2257) then | 
| 1012 | 
             merror(contr) = 135 | 
             merror(contr) = 135 | 
| 1013 | 
             chi = chi + 4 | 
             chi = chi + 4 | 
| 1014 | 
             if (iev.eq.dumpo)  | 
             if (iev.eq.dumpo)  | 
| 1015 | 
      &           print *,'full lung 4' | 
      &           print *,'full lung 4' | 
| 1016 | 
             lleng = 0 | 
             if ( scrcerr.eq.0 ) then | 
| 1017 | 
             goto 150 | 
                lleng = 0 | 
| 1018 | 
          else | 
                goto 150 | 
| 1019 | 
             icb = icb + 1 | 
             endif | 
| 1020 | 
             calIItrig(k) = vect(icb) | 
          endif | 
| 1021 | 
             icb = icb + 1 | 
 c     else | 
| 1022 | 
             calstriphit(k) = vect(icb) | 
          icb = icb + 1 | 
| 1023 | 
             icb = icb + 1 | 
          if ( icb.gt.120000 ) then | 
| 1024 | 
  | 
 c     out of vector... | 
| 1025 | 
  | 
             if (iev.eq.dumpo) then | 
| 1026 | 
  | 
                print *,' Run out of vect...'   | 
| 1027 | 
  | 
                goto 150 | 
| 1028 | 
  | 
             endif | 
| 1029 | 
  | 
          endif | 
| 1030 | 
  | 
          calIItrig(k) = vect(icb) | 
| 1031 | 
  | 
          icb = icb + 1 | 
| 1032 | 
  | 
          if ( icb.gt.120000 ) then | 
| 1033 | 
  | 
 c     out of vector... | 
| 1034 | 
  | 
             if (iev.eq.dumpo) then | 
| 1035 | 
  | 
                print *,' Run out of vect...'   | 
| 1036 | 
  | 
                goto 150 | 
| 1037 | 
  | 
             endif | 
| 1038 | 
  | 
          endif | 
| 1039 | 
  | 
          calstriphit(k) = vect(icb) | 
| 1040 | 
  | 
          icb = icb + 1 | 
| 1041 | 
  | 
          if ( icb.gt.120000 ) then | 
| 1042 | 
  | 
 c     out of vector... | 
| 1043 | 
  | 
             if (iev.eq.dumpo) then | 
| 1044 | 
  | 
                print *,' Run out of vect...'   | 
| 1045 | 
  | 
                goto 150 | 
| 1046 | 
  | 
             endif | 
| 1047 | 
  | 
          endif | 
| 1048 | 
 C     FIRST CALORIMETER SIGNATURE:  CA50 | 
 C     FIRST CALORIMETER SIGNATURE:  CA50 | 
| 1049 | 
             icb = icb + 1 | 
          icb = icb + 1 | 
| 1050 | 
  | 
          if ( icb.gt.120000 ) then | 
| 1051 | 
  | 
 c     out of vector... | 
| 1052 | 
  | 
             if (iev.eq.dumpo) then | 
| 1053 | 
  | 
                print *,' Run out of vect...'   | 
| 1054 | 
  | 
                goto 150 | 
| 1055 | 
  | 
             endif | 
| 1056 | 
  | 
          endif | 
| 1057 | 
 C     SECOND CALORIMETER SIGNATURE:  CA50      | 
 C     SECOND CALORIMETER SIGNATURE:  CA50      | 
| 1058 | 
             icb = icb + 1 | 
          icb = icb + 1 | 
| 1059 | 
  | 
          if ( icb.gt.120000 ) then | 
| 1060 | 
  | 
 c     out of vector... | 
| 1061 | 
  | 
             if (iev.eq.dumpo) then | 
| 1062 | 
  | 
                print *,' Run out of vect...'   | 
| 1063 | 
  | 
                goto 150 | 
| 1064 | 
  | 
             endif | 
| 1065 | 
  | 
          endif | 
| 1066 | 
 C     test is here! | 
 C     test is here! | 
| 1067 | 
             icb = icb + 1 | 
          icb = icb + 1 | 
| 1068 | 
             calDSPtaberr(k) = vect(icb) | 
          if ( icb.gt.120000 ) then | 
| 1069 | 
             icb = icb + 1 | 
 c     out of vector... | 
| 1070 | 
             calevnum(k) = vect(icb) | 
             if (iev.eq.dumpo) then | 
| 1071 | 
             if (k.eq.1) call CALFULL(vect,icb+1,length-1,dedx1, | 
                print *,' Run out of vect...'   | 
| 1072 | 
      &           dedx1c,base1) | 
                goto 150 | 
| 1073 | 
             if (k.eq.2) call CALFULL(vect,icb+1,length-1,dedx2, | 
             endif | 
| 1074 | 
      &           dedx2c,base2) | 
          endif | 
| 1075 | 
             if (k.eq.3) call CALFULL(vect,icb+1,length-1,dedx3, | 
          calDSPtaberr(k) = vect(icb) | 
| 1076 | 
      &           dedx3c,base3) | 
          icb = icb + 1 | 
| 1077 | 
             if (k.eq.4) call CALFULL(vect,icb+1,length-1,dedx4, | 
          if ( icb.gt.120000 ) then | 
| 1078 | 
      &           dedx4c,base4) | 
 c     out of vector... | 
| 1079 | 
             goto 50 | 
             if (iev.eq.dumpo) then | 
| 1080 | 
  | 
                print *,' Run out of vect...'   | 
| 1081 | 
  | 
                goto 150 | 
| 1082 | 
  | 
             endif | 
| 1083 | 
          endif | 
          endif | 
| 1084 | 
  | 
          calevnum(k) = vect(icb) | 
| 1085 | 
  | 
          if (k.eq.1) call CALFULL(vect,icb+1,length-1,dedx1, | 
| 1086 | 
  | 
      &        dedx1c,base1,scrcerr) | 
| 1087 | 
  | 
          if (k.eq.2) call CALFULL(vect,icb+1,length-1,dedx2, | 
| 1088 | 
  | 
      &        dedx2c,base2,scrcerr) | 
| 1089 | 
  | 
          if (k.eq.3) call CALFULL(vect,icb+1,length-1,dedx3, | 
| 1090 | 
  | 
      &        dedx3c,base3,scrcerr) | 
| 1091 | 
  | 
          if (k.eq.4) call CALFULL(vect,icb+1,length-1,dedx4, | 
| 1092 | 
  | 
      &        dedx4c,base4,scrcerr) | 
| 1093 | 
  | 
          goto 50 | 
| 1094 | 
  | 
 c     endif | 
| 1095 | 
       else | 
       else | 
| 1096 | 
          merror(contr) = 136 | 
          merror(contr) = 136 | 
| 1097 | 
          chi = chi + 4 | 
          chi = chi + 4 | 
| 1126 | 
             base(1,2*i,j) = base3(i,j) | 
             base(1,2*i,j) = base3(i,j) | 
| 1127 | 
          enddo | 
          enddo | 
| 1128 | 
       enddo | 
       enddo | 
| 1129 | 
 C | 
 C      | 
| 1130 | 
  150  continue | 
  150  continue | 
| 1131 | 
 C | 
 C      | 
| 1132 | 
       contr = contr + 1 | 
       contr = contr + 1 | 
| 1133 | 
  | 
  | 
| 1134 | 
  | 
 c | 
| 1135 | 
  | 
 c should never happen that we find MORE than 4 sections.. | 
| 1136 | 
  | 
 c | 
| 1137 | 
  | 
       if (contr.gt.100) then | 
| 1138 | 
  | 
          if (iev.eq.dumpo) | 
| 1139 | 
  | 
      &        print *,'contr ????????????? ',contr | 
| 1140 | 
  | 
  | 
| 1141 | 
  | 
          me = 1 | 
| 1142 | 
  | 
          do i = 1, 4 | 
| 1143 | 
  | 
             merror(i) = 129             | 
| 1144 | 
  | 
             e2(i) = 0             | 
| 1145 | 
  | 
             stwerr(i) = 0 | 
| 1146 | 
  | 
          enddo | 
| 1147 | 
  | 
          call clearall | 
| 1148 | 
  | 
          goto 999 | 
| 1149 | 
  | 
       endif | 
| 1150 | 
  | 
 c | 
| 1151 | 
  | 
 c     in case of crc error proceed as if we never processed this section | 
| 1152 | 
  | 
 c | 
| 1153 | 
  | 
       if ( scrcerr.eq.1 ) then | 
| 1154 | 
  | 
           | 
| 1155 | 
  | 
          chi = chi + 4 | 
| 1156 | 
  | 
          lleng = 0 | 
| 1157 | 
  | 
          length2 = 0 | 
| 1158 | 
  | 
          length = 0 | 
| 1159 | 
  | 
 c      | 
| 1160 | 
  | 
          headcor = 1 | 
| 1161 | 
  | 
          ichc = sic - 1 | 
| 1162 | 
  | 
          icb = sicb | 
| 1163 | 
  | 
          if (iev.eq.dumpo) | 
| 1164 | 
  | 
      &        print *,' B crc is wrong ',sic, | 
| 1165 | 
  | 
      &        ' search section ',contr,' coco = ',coco | 
| 1166 | 
  | 
          goto 32      | 
| 1167 | 
  | 
 c | 
| 1168 | 
  | 
       endif | 
| 1169 | 
  | 
  | 
| 1170 | 
 C | 
 C | 
| 1171 | 
 c     go on till we have found all the four sections | 
 c     go on till we have found all the four sections | 
| 1172 | 
 c | 
 c | 
| 1288 | 
                enddo | 
                enddo | 
| 1289 | 
             enddo    | 
             enddo    | 
| 1290 | 
          endif | 
          endif | 
| 1291 | 
          do l=1,lung | 
 c         do l=1,lung | 
| 1292 | 
             write(*,17)l,vecta(l) | 
 c            write(*,17)l,vecta(l) | 
| 1293 | 
          enddo  | 
 c         enddo  | 
| 1294 | 
       endif | 
       endif | 
| 1295 | 
       iev = iev + 1       | 
       iev = iev + 1       | 
| 1296 | 
       RETURN | 
       RETURN | 
| 1332 | 
       do j = 1,96 | 
       do j = 1,96 | 
| 1333 | 
          do i = 1,11 | 
          do i = 1,11 | 
| 1334 | 
             DEDX(I,J) = 0. | 
             DEDX(I,J) = 0. | 
| 1335 | 
             dedx(i,j) = vect(k) | 
             if ( k.le.120000 ) dedx(i,j) = vect(k) | 
| 1336 | 
             k = k + 1 | 
             k = k + 1 | 
| 1337 | 
          enddo | 
          enddo | 
| 1338 | 
       enddo | 
       enddo | 
| 1341 | 
       END | 
       END | 
| 1342 | 
  | 
  | 
| 1343 | 
 C------------------------------------------------ | 
 C------------------------------------------------ | 
| 1344 | 
       SUBROUTINE CALCOMPRESS(vect,inf,sup,dedx,basse) | 
       SUBROUTINE CALCOMPRESS(vect,inf,sup,dedx,basse,cer) | 
| 1345 | 
 C------------------------------------------------ | 
 C------------------------------------------------ | 
| 1346 | 
  | 
  | 
| 1347 | 
       IMPLICIT NONE | 
       IMPLICIT NONE | 
| 1358 | 
       INTEGER merror(4) | 
       INTEGER merror(4) | 
| 1359 | 
       INTEGER contr | 
       INTEGER contr | 
| 1360 | 
       integer stwerr(4),dumpo | 
       integer stwerr(4),dumpo | 
| 1361 | 
       integer bit,bi | 
       integer bit,bi,cer | 
| 1362 | 
 C | 
 C | 
| 1363 | 
       REAL DEXY(2,NPLA,NCHA), dexyc(2,npla,ncha), base(2,npla,6)  | 
       REAL DEXY(2,NPLA,NCHA), dexyc(2,npla,ncha), base(2,npla,6)  | 
| 1364 | 
       real calselftrig(4,7), calIItrig(4), calstriphit(4), | 
       real calselftrig(4,7), calIItrig(4), calstriphit(4), | 
| 1387 | 
       i = inf | 
       i = inf | 
| 1388 | 
 c | 
 c | 
| 1389 | 
  10   continue | 
  10   continue | 
| 1390 | 
       if (i.gt.sup) then | 
       if (i.gt.sup.or.i.gt.120000) then | 
| 1391 | 
          RETURN | 
          RETURN | 
| 1392 | 
       endif | 
       endif | 
| 1393 | 
 C | 
 C | 
| 1411 | 
                write(*,43)vect(i) | 
                write(*,43)vect(i) | 
| 1412 | 
             endif | 
             endif | 
| 1413 | 
             merror(contr) = 139 | 
             merror(contr) = 139 | 
| 1414 | 
             RETURN | 
             if ( cer.eq.0 ) then | 
| 1415 | 
  | 
                RETURN | 
| 1416 | 
  | 
             else | 
| 1417 | 
  | 
                i = i + 1 | 
| 1418 | 
  | 
                goto 10 | 
| 1419 | 
  | 
             endif | 
| 1420 | 
          endif | 
          endif | 
| 1421 | 
       endif | 
       endif | 
| 1422 | 
 C | 
 C | 
| 1427 | 
          ipl = int(st/6) + 1 | 
          ipl = int(st/6) + 1 | 
| 1428 | 
          ipr = st - (ipl - 1) * 6 + 1 | 
          ipr = st - (ipl - 1) * 6 + 1 | 
| 1429 | 
          i = i + 1 | 
          i = i + 1 | 
| 1430 | 
          if (i.gt.sup) RETURN | 
          if (i.gt.sup.or.i.gt.120000) RETURN | 
| 1431 | 
          basse(ipl,ipr) = vect(i) | 
          if ( ipl.ge.1.and.ipl.le.11.and.ipr.ge.1.and.ipr.le.6)  | 
| 1432 | 
  | 
      +        basse(ipl,ipr) = vect(i)             | 
| 1433 | 
 c          | 
 c          | 
| 1434 | 
  20      continue | 
  20      continue | 
| 1435 | 
          if (i.gt.sup) RETURN | 
          if (i.gt.sup.or.i.gt.120000) RETURN | 
| 1436 | 
 C | 
 C | 
| 1437 | 
          i = i + 1 | 
          i = i + 1 | 
| 1438 | 
          if (i.gt.sup) RETURN | 
          if (i.gt.sup.or.i.gt.120000) RETURN | 
| 1439 | 
          if ((vect(i)+1).gt.16.or.(vect(i)+1).lt.1) then | 
          if ((vect(i)+1).gt.16.or.(vect(i)+1).lt.1) then | 
 | 
  | 
  | 
| 1440 | 
             goto 10 | 
             goto 10 | 
| 1441 | 
          endif | 
          endif | 
| 1442 | 
          ist = vect(i) + 1 + 16 * (ipr - 1) | 
          ist = vect(i) + 1 + 16 * (ipr - 1) | 
| 1443 | 
          i = i + 1 | 
          i = i + 1 | 
| 1444 | 
          if (i.gt.sup) RETURN | 
          if (i.gt.sup.or.i.gt.120000) RETURN | 
| 1445 | 
          dedx(ipl,ist) = vect(i) | 
          if ( ipl.ge.1.and.ipl.le.11.and.ist.ge.1.and.ist.le.96)  | 
| 1446 | 
  | 
      +        dedx(ipl,ist) = vect(i) | 
| 1447 | 
          goto 20 | 
          goto 20 | 
| 1448 | 
       else | 
       else | 
| 1449 | 
 C | 
 C | 
| 1450 | 
          st = IAND(vect(i),'00FF'x) | 
          st = IAND(vect(i),'00FF'x) | 
| 1451 | 
          ipl = int(st/6) + 1  | 
          ipl = int(st/6) + 1  | 
| 1452 | 
          ipr = st - (ipl - 1) * 6 + 1 | 
          ipr = st - (ipl - 1) * 6 + 1 | 
| 1453 | 
          do j = 1,16 | 
          if ( ipl.ge.1.and.ipl.le.11 ) then | 
| 1454 | 
             i = i + 1 | 
             do j = 1,16 | 
| 1455 | 
             if (i.gt.sup) RETURN | 
                i = i + 1 | 
| 1456 | 
             ist = j + 16 * (ipr - 1) | 
                if (i.gt.sup.or.i.gt.120000) RETURN | 
| 1457 | 
             dedx(ipl,ist) = vect(i) | 
                ist = j + 16 * (ipr - 1) | 
| 1458 | 
          enddo | 
                if (ist.ge.1.and.ist.le.96) dedx(ipl,ist) = vect(i) | 
| 1459 | 
  | 
             enddo | 
| 1460 | 
  | 
          endif | 
| 1461 | 
          i = i + 1 | 
          i = i + 1 | 
| 1462 | 
          if (i.gt.sup) RETURN | 
          if (i.gt.sup.or.i.gt.120000) RETURN | 
| 1463 | 
          goto 10 | 
          goto 10 | 
| 1464 | 
 C          | 
 C          | 
| 1465 | 
       endif | 
       endif | 
| 1470 | 
  | 
  | 
| 1471 | 
  | 
  | 
| 1472 | 
 C---------------------------------------------------------- | 
 C---------------------------------------------------------- | 
| 1473 | 
       SUBROUTINE CALFULL(vect,inf,sup,dedx,dedxc,basse) | 
       SUBROUTINE CALFULL(vect,inf,sup,dedx,dedxc,basse,cer) | 
| 1474 | 
 C-------------------------------------------------------------- | 
 C-------------------------------------------------------------- | 
| 1475 | 
  | 
  | 
| 1476 | 
       IMPLICIT NONE | 
       IMPLICIT NONE | 
| 1480 | 
 C | 
 C | 
| 1481 | 
       INTEGER*2 VECT(30000)  | 
       INTEGER*2 VECT(30000)  | 
| 1482 | 
       INTEGER inf, sup | 
       INTEGER inf, sup | 
| 1483 | 
       INTEGER i,j,k, iev | 
       INTEGER i,j,k, iev, cer | 
| 1484 | 
       INTEGER contr | 
       INTEGER contr | 
| 1485 | 
       integer stwerr(4),dumpo,merror(4) | 
       integer stwerr(4),dumpo,merror(4) | 
| 1486 | 
 C | 
 C | 
| 1504 | 
       do i = 1,11 | 
       do i = 1,11 | 
| 1505 | 
          do j = 1,96 | 
          do j = 1,96 | 
| 1506 | 
             DEDX(I,J) = 0. | 
             DEDX(I,J) = 0. | 
| 1507 | 
             dedx(i,j) = vect(k) | 
             if ( k.le.120000 ) dedx(i,j) = vect(k) | 
| 1508 | 
             k = k + 1 | 
             k = k + 1 | 
| 1509 | 
          enddo | 
          enddo | 
| 1510 | 
       enddo | 
       enddo | 
| 1511 | 
 C | 
 C | 
| 1512 | 
       call CALCOMPRESS(vect,k,sup,dedxc,basse) | 
       call CALCOMPRESS(vect,k,sup,dedxc,basse,cer) | 
| 1513 | 
 C | 
 C | 
| 1514 | 
  10   FORMAT(2X,'Status word:',2X,Z8)       | 
  10   FORMAT(2X,'Status word:',2X,Z8)       | 
| 1515 | 
  | 
  |