--- DarthVader/TrackerLevel2/src/F77/filladc.f 2006/09/29 08:13:04 1.5 +++ DarthVader/TrackerLevel2/src/F77/filladc.f 2007/08/20 16:07:16 1.10 @@ -9,7 +9,6 @@ include 'common_reduction.f' - external nvk external nst @@ -44,9 +43,11 @@ C jump to next view C --------------------------- + nword_DSP = 0 if(DSPn.eq.0 + $ .or.DSPn.gt.nviews $ .or.datalength(iv).eq.0)goto 333 - + C++++++++++++++++++++++++++++++++++++++++++++++++++++++ if( iand(DAQmode(iv),z'0003').eq.z'0002'.or. $ iand(DAQmode(iv),z'0003').eq.z'0003'.or. @@ -54,21 +55,38 @@ $ .false.) then C++++++++++++++++++++++++++++++++++++++++++++++++++++++ C--------------------------------------compressed mode + if(debug.eq.1)print*,'DSP #',DSPn,' --> compressed ' is = 0 il = 0 prec_ind = 0 222 continue idata = idata+1 - word=datatracker(idata) + if( idata.gt.NWORDMAX )goto 335 !end to end + nword_DSP = nword_DSP +1 + if( nword_DSP.gt.datalength(iv) )then + if( debug.eq.1 ) + $ print*,'filladc --> missing end-of-ladder', + $ ' in COMPRESSED mode - DSP ',DSPn + if(debug.eq.1) + $ print*,'datalength = ',datalength(iv) + iflag=1 +c GOOD1(DSPn) = 10 +c GOOD1(DSPn) = GOOD1(DSPn) + 2**4 + GOOD1(DSPn) = ior(GOOD1(DSPn),2**4) + goto 334 !next view + endif + word = datatracker(idata) C------------------------------------------------------ C call routine to uncompress data C------------------------------------------------------ call compdecode(word,flag,tipo,info,errflag) if(errflag.ne.0.) then - if(verbose)print*,'filladc --> ERROR on compdecode' + if(debug.eq.1)print*,'filladc --> ERROR on compdecode' iflag=1 - GOOD1(DSPn) = 10 +c GOOD1(DSPn) = 10 +c GOOD1(DSPn) = GOOD1(DSPn) + 2**4 + GOOD1(DSPn) = ior(GOOD1(DSPn),2**4) c return goto 221 endif @@ -76,13 +94,15 @@ if(flag.eq.1) then ! flag: fine messaggio (ladder) if(info.ne.1.and.info.ne.2.and.info.ne.3) then - if(verbose)print*, + if(debug.eq.1)print*, $ 'filladc --> wrong end-of-ladder ' $ //'in COMPRESSED mode' - if(verbose)print*, + if(debug.eq.1)print*, $ ' info(=ladder) ',info,' type ',tipo iflag=1 - GOOD1(DSPn) = 10 +c GOOD1(DSPn) = 10 +c GOOD1(DSPn) = GOOD1(DSPn) + 2**4 + GOOD1(DSPn) = ior(GOOD1(DSPn),2**4) c return goto 221 endif @@ -90,23 +110,31 @@ il = info do js=is+1,1024*il - if( DSPn.le.nviews + if( DSPn.le.nviews + $ .and.nvk(js).gt.0 $ .and.nvk(js).le.nva1_view + $ .and.nst(js).gt.0 $ .and.nst(js).le.nstrips_va1 - $ .and.nvk(is).le.nva1_view - $ .and.nst(is).le.nstrips_va1 $ )then - newVAL=oldVAL-pedestal_t(DSPn,nvk(is),nst(is)) - $ +pedestal_t(DSPn,nvk(js),nst(js)) - newVAL=max(0,newVAL) - newVAL=min(4095,newVAL) + newVAL = 0 + if( + $ nvk(is).gt.0.and. + $ nvk(is).le.nva1_view.and. + $ nst(is).gt.0.and. + $ nst(is).le.nstrips_va1.and. + $ .true.)then + newVAL=oldVAL-pedestal_t(DSPn,nvk(is),nst(is)) + $ +pedestal_t(DSPn,nvk(js),nst(js)) + newVAL=max(0,newVAL) + newVAL=min(4095,newVAL) + endif adc(DSPn,nvk(js),nst(js))=newVAL - else + else print*,'filladc -->' - $ ,' attempt to access array elements (1)' - $ ,'(',DSPn,nvk(is),nst(is),')' - $ ,'(',DSPn,nvk(js),nst(js),')' + $ ,' attempt to access array element (1)' +c $ ,'(',DSPn,nvk(is),nst(is),')' + $ ,'pedestal_t(',DSPn,nvk(js),nst(js),')' endif c$$$ print*,DSPn,nvk(js),nst(js) c$$$ $ ,pedestal_t(DSPn,nvk(js),nst(js)),newval @@ -123,26 +151,46 @@ if(tipo.eq.1) then ! tipo: indirizzo iaddr = info + il*1024 if(iaddr.ge.is+1.and.iaddr.le.3072) then + + if(is.eq.0.or.is.eq.1024.or.is.eq.2048)then + if(debug.eq.1)print*,'filladc -->' + $ ,' previous transmitted strip ',is + $ ,' - missing first ADC value' + iflag=1 +c GOOD1(DSPn) = 10 +c GOOD1(DSPn) = GOOD1(DSPn) + 2**4 + GOOD1(DSPn) = ior(GOOD1(DSPn),2**4) + endif do js = is+1,iaddr-1 - if( DSPn.le.nviews + if( DSPn.le.nviews + $ .and.nvk(js).gt.0 $ .and.nvk(js).le.nva1_view + $ .and.nst(js).gt.0 $ .and.nst(js).le.nstrips_va1 - $ .and.nvk(is).le.nva1_view - $ .and.nst(is).le.nstrips_va1 $ )then - - newVAL=oldVAL - $ -pedestal_t(DSPn,nvk(is),nst(is)) - $ +pedestal_t(DSPn,nvk(js),nst(js)) - newVAL=max(0,newVAL) - newVAL=min(4095,newVAL) + + newVAL = 0 + if( + $ nvk(is).gt.0.and. + $ nvk(is).le.nva1_view.and. + $ nst(is).gt.0.and. + $ nst(is).le.nstrips_va1.and. + $ .true.)then + newVAL=oldVAL + $ -pedestal_t(DSPn,nvk(is),nst(is)) + $ +pedestal_t(DSPn,nvk(js),nst(js)) + newVAL=max(0,newVAL) + newVAL=min(4095,newVAL) + endif adc(DSPn,nvk(js),nst(js))=newVAL else print*,'filladc -->' - $ ,' attempt to access array elements (2)' - $ ,'(',DSPn,nvk(is),nst(is),')' - $ ,'(',DSPn,nvk(js),nst(js),')' + $ ,' attempt to access array element (2) ' +c $ ,'(',DSPn,nvk(is),nst(is),')' + $ ,'pedestal_t(',DSPn,nvk(js),nst(js),')' +c iflag=1 +c if(DSPn.le.nviews)GOOD1(DSPn) = 10 endif c print*,DSPn,nvk(js),nst(js),newval @@ -151,10 +199,12 @@ is = iaddr prec_ind = 1 else - if(verbose)print*,'filladc --> address '// + if(debug.eq.1)print*,'filladc --> address '// $ 'out of range - iaddr,is',iaddr,is iflag=1 - GOOD1(DSPn) = 10 +c GOOD1(DSPn) = 10 +c GOOD1(DSPn) = GOOD1(DSPn) + 2**4 + GOOD1(DSPn) = ior(GOOD1(DSPn),2**4) c return goto 221 endif @@ -163,11 +213,13 @@ if(prec_ind.eq.0) is=is+1 if(info.ge.0.and.info.le.4095) then if(is.gt.3072)then - if(verbose)print*, + if(debug.eq.1)print*, $ 'filladc --> strip out of range - DSPn,is' $ ,DSPn,is iflag=1 - GOOD1(DSPn) = 10 +c GOOD1(DSPn) = 10 +c GOOD1(DSPn) = GOOD1(DSPn) + 2**4 + GOOD1(DSPn) = ior(GOOD1(DSPn),2**4) c return goto 221 @@ -186,11 +238,13 @@ oldVAL=newVAL else - if(verbose) + if(debug.eq.1) $ print*,'filladc --> datum out of range - info' $ ,info iflag=1 - GOOD1(DSPn) = 10 +c GOOD1(DSPn) = 10 +c GOOD1(DSPn) = GOOD1(DSPn) + 2**4 + GOOD1(DSPn) = ior(GOOD1(DSPn),2**4) c return goto 221 endif @@ -214,10 +268,20 @@ C++++++++++++++++++++++++++++++++++++++++++++++++++++++ C--------------------------------------------full mode + if(debug.eq.1)print*,'DSP #',DSPn,' --> full ' do i=1,3 !loop over ladder do j=1,1024 !loop over strips idata = idata+1 + if( idata.gt.NWORDMAX )goto 335 !go to end + nword_DSP = nword_DSP +1 + if( nword_DSP.gt.datalength(iv) )then + if( debug.eq.1 ) + $ print*,'filladc --> missing end-of-ladder', + $ ' in FULL mode - DSP ',DSPn + if(debug.eq.1)print*,'datalength = ',datalength + goto 334 !next view + endif is=j+1024*(i-1) c adcadc=adc(DSPn,nvk(is),nst(is)) if( DSPn.le.nviews @@ -237,29 +301,45 @@ c endif enddo !loop over strips idata = idata+1 + if( idata.gt.NWORDMAX )goto 335 !go to end + nword_DSP = nword_DSP +1 + if( nword_DSP.gt.datalength(iv) )then + if( debug.eq.1 ) + $ print*,'filladc --> missing end-of-ladder', + $ ' in FULL mode - DSP ',DSPn + if(debug.eq.1)print*,'datalength = ',datalength + goto 334 !next view + endif if(datatracker(idata).ne.ior(z'1800',i+3)) then - if(verbose) + if(debug.eq.1) $ print*,'filladc --> ', $ 'wrong end-of-ladder in FULL mode' - if(verbose) + if(debug.eq.1) $ print*,' word ',datatracker(idata) - if(verbose) + if(debug.eq.1) $ print*,' should be ',ior(z'1800',i+3) iflag=1 - GOOD1(DSPn) = 10 +c GOOD1(DSPn) = 10 +c GOOD1(DSPn) = GOOD1(DSPn) + 2**4 + GOOD1(DSPn) = ior(GOOD1(DSPn),2**4) c return endif enddo!endl loop over ladder endif goto 334 - 333 continue - if(verbose)print*,'filladc --> ',iv - $ ,'^ DSP packet missing or corrupted: ' - $ ,'DSPn, datalength(iv) => ' - $ ,DSPn,datalength(iv) - 334 continue + 333 continue + if(debug.eq.1)print*,'filladc --> ',iv + $ ,'^ DSP packet missing or corrupted: ' + $ ,'DSPn, datalength(iv) => ' + $ ,DSPn,datalength(iv) + 334 continue enddo - + goto 336 + 335 continue + if(debug.eq.1)print*,'filladc --> reached end of buffer:', + $ ' datatracker(',NWORDMAX,')' + + 336 continue return end @@ -285,11 +365,11 @@ if(flag.ne.0.and.flag.ne.1) then c print*,'compdecode --> error on uncompression: flag=',flag - errflag=1. + errflag=1. endif if(flag.eq.0) then ! valore ADC - tipo=0 - info=iand(word,z'0fff') + tipo=0 + info=iand(word,z'0fff') endif if(flag.eq.1) then ! indirizzo OR fine vista info=iand(word,z'03ff')