| 23 | integer ierror | integer ierror | 
| 24 | ierror = 0 | ierror = 0 | 
| 25 |  |  | 
| 26 |  | c$$$      debug = .true. | 
| 27 |  | c$$$      verbose = .true. | 
| 28 |  | c$$$      warning = .true. | 
| 29 |  |  | 
| 30 |  | *     ////////////////////////// | 
| 31 |  | *     initialize some parameters | 
| 32 |  | *     ////////////////////////// | 
| 33 |  |  | 
| 34 | call init_level1 | call init_level1 | 
| 35 |  |  | 
| 36 |  | if(debug)print*,'-- check LEVEL0 status' | 
| 37 |  |  | 
| 38 | c      good1 = good0 | c      good1 = good0 | 
| 39 | c-------------------------------------------------- | c-------------------------------------------------- | 
| 40 | c     check the LEVEL0 event status for missing | c     check the LEVEL0 event status for missing | 
| 96 | good_old(iv)   = good1(iv) | good_old(iv)   = good1(iv) | 
| 97 | ngood = ngood + good1(iv) | ngood = ngood + good1(iv) | 
| 98 | enddo | enddo | 
| 99 | c      if(ngood.ne.0)print*,'* WARNING * LEVEL0 event status: ' | if(debug.and.ngood.ne.0)print*,'* WARNING * LEVEL0 event status: ' | 
| 100 | c     $     ,(good1(i),i=1,nviews) | $     ,(good1(i),i=1,nviews) | 
| 101 | c-------------------------------------------------- | c-------------------------------------------------- | 
| 102 | c     read the variable DATATRACKER from LEVEL0 | c     read the variable DATATRACKER from LEVEL0 | 
| 103 | c     and fill the variable ADC (invertin view 11) | c     and fill the variable ADC (invertin view 11) | 
| 104 | c-------------------------------------------------- | c-------------------------------------------------- | 
| 105 |  |  | 
| 106 |  | if(debug)print*,'-- fill ADC vectors' | 
| 107 |  |  | 
| 108 | call filladc(iflag) | call filladc(iflag) | 
| 109 | if(iflag.ne.0)then | if(iflag.ne.0)then | 
| 110 | ierror = 220 | ierror = 220 | 
| 115 | c     (excluding strips with signal, | c     (excluding strips with signal, | 
| 116 | c     tagged with the flag CLSTR) | c     tagged with the flag CLSTR) | 
| 117 | c-------------------------------------------------- | c-------------------------------------------------- | 
| 118 |  | if(debug)print*,'-- compute CN' | 
| 119 |  |  | 
| 120 | do iv=1,nviews | do iv=1,nviews | 
| 121 | ima=0 | ima=0 | 
| 122 | do ik=1,nva1_view | do ik=1,nva1_view | 
| 123 | cn(iv,ik)  = 0 | cn(iv,ik)    = 0 | 
| 124 | cnrms(iv,ik)  = 0 | cnrms(iv,ik) = 0 | 
| 125 | cnn(iv,ik) = -1 | cnn(iv,ik)   = -1 | 
| 126 | iflag=0 | iflag = 0 | 
| 127 | mask_vk_ev(iv,ik)=1 | mask_vk_ev(iv,ik) = 1 | 
| 128 | call stripmask(iv,ik)      !compute mask(i,j,k), combining VA1-masks | call stripmask(iv,ik)      !compute mask(i,j,k), combining VA1-masks | 
| 129 | c     NBNBNBNBNB mask per la striscia 1 !!!!!!!! | *           -------------------------------------- | 
| 130 | if(mask(iv,ik,1).eq.1)call cncomp(iv,ik,iflag) | *           if chip is not masked ---> evaluate CN | 
| 131 | if(iflag.ne.0)then | *           -------------------------------------- | 
| 132 | ima=ima+1 | if( mask(iv,ik,1).eq.1 ) then !!!NBNB mask per la striscia 1 !!!!!!!! | 
| 133 | mask_vk_ev(iv,ik)=0 | call cncomp(iv,ik,iflag) | 
| 134 | ierror = 220 | if(iflag.ne.0)then | 
| 135 |  | ima=ima+1 | 
| 136 |  | mask_vk_ev(iv,ik)=0 | 
| 137 |  | ierror = 220 | 
| 138 |  | endif | 
| 139 |  | call stripmask(iv,ik) !compute mask(i,j,k), combining VA1-masks | 
| 140 | endif | endif | 
|  | call stripmask(iv,ik)      !compute mask(i,j,k), combining VA1-masks |  | 
|  |  |  | 
| 141 | enddo | enddo | 
| 142 | 100     format(' * WARNING * Event ',i7,' view',i3,': VK MASK ',24i1) | 100     format(' * WARNING * Event ',i7,' view',i3,': VK MASK ',24i1) | 
| 143 | if(ima.ne.0.and.debug)write(*,100)eventn(1),iv | if(ima.ne.0.and.debug)write(*,100)eventn(1),iv | 
| 144 | $        ,(mask_vk_ev(iv,ik),ik=1,nva1_view) | $        ,(mask_vk_ev(iv,ik),ik=1,nva1_view) | 
| 145 |  | c         if(ima.ne.0)write(*,100)eventn(1),iv | 
| 146 |  | c     $        ,(mask_vk_ev(iv,ik),ik=1,nva1_view) | 
| 147 | enddo | enddo | 
| 148 |  |  | 
| 149 | cc      call stripmask !compute mask(i,j,k), combining mask_vk_ev and mask_vk | cc      call stripmask !compute mask(i,j,k), combining mask_vk_ev and mask_vk | 
| 156 | c--------------------------------------------- | c--------------------------------------------- | 
| 157 | ind=1                     !clsignal array index | ind=1                     !clsignal array index | 
| 158 |  |  | 
| 159 |  | if(debug)print*,'-- search clusters' | 
| 160 | do iv=1,nviews            !loop on views | do iv=1,nviews            !loop on views | 
| 161 | do is=1,nstrips_view    !loop on strips (1) | do is=1,nstrips_view    !loop on strips (1) | 
| 162 | if(mod(iv,2).eq.1) then | if(mod(iv,2).eq.1) then | 
| 187 |  |  | 
| 188 | if(.not.flag_shower)then | if(.not.flag_shower)then | 
| 189 | call save_cluster(iv) | call save_cluster(iv) | 
| 190 |  | if(debug)print*,'view ',iv,' #clusters ', nclstr_view | 
| 191 | else | else | 
| 192 | fshower(iv) = 1 | fshower(iv) = 1 | 
| 193 | c           GOOD1(DSPnumber(iv)) = 11 !AHAHAHAHA ORRORE!! | c           GOOD1(DSPnumber(iv)) = 11 !AHAHAHAHA ORRORE!! | 
| 194 | GOOD1(iv) = 11 | GOOD1(iv) = 11 | 
| 195 |  | 101       format(' * WARNING * Event ',i7,' view',i3 | 
| 196 |  | $          ,' #clusters > ',i5,' --> MASKED') | 
| 197 |  | if(debug)write(*,101)eventn(1),iv,nclstrmax_view | 
| 198 | endif | endif | 
| 199 | enddo                     ! end loop on views | enddo                     ! end loop on views | 
| 200 | do iv=1,nviews | do iv=1,nviews | 
| 214 | do iv = 1,nviews | do iv = 1,nviews | 
| 215 | ngood = ngood + good1(iv) | ngood = ngood + good1(iv) | 
| 216 | enddo | enddo | 
| 217 | c$$$      if(ngood.ne.0)print*,'* WARNING * Event ',eventn(1) | if(debug.and.ngood.ne.0)print*,'* WARNING * Event ',eventn(1) | 
| 218 | c$$$     $     ,':LEVEL1 event status: ' | $     ,':LEVEL1 event status: ' | 
| 219 | c$$$     $     ,(good1(i),i=1,nviews) | $     ,(good1(i),i=1,nviews) | 
| 220 | c------------------------------------------------------------------------ | c------------------------------------------------------------------------ | 
| 221 | c | c | 
| 222 | c     closes files and exits | c     closes files and exits | 
| 641 |  |  | 
| 642 | subroutine stripmask(iv,ivk) | subroutine stripmask(iv,ivk) | 
| 643 |  |  | 
| 644 |  | *     ----------------------------------------------- | 
| 645 | *     this routine set va1 and single-strip masks, | *     this routine set va1 and single-strip masks, | 
| 646 | *     on the basis of the VA1 mask saved in the DB | *     on the basis of the VA1 mask saved in the DB | 
| 647 | * | * | 
| 648 | *     mask(nviews,nva1_view,nstrips_va1) !strip mask | *     mask(nviews,nva1_view,nstrips_va1) !strip mask | 
| 649 | *     mask_vk(nviews,nva1_view)          !VA1 mask | *     mask_vk(nviews,nva1_view)          !VA1 mask | 
| 650 | * | *     ----------------------------------------------- | 
| 651 | include 'commontracker.f' | include 'commontracker.f' | 
| 652 | include 'level1.f' | include 'level1.f' | 
| 653 | include 'common_reduction.f' | include 'common_reduction.f' | 
| 655 |  |  | 
| 656 | *     init mask | *     init mask | 
| 657 | do is=1,nstrips_va1 | do is=1,nstrips_va1 | 
| 658 |  | *        -------------------------------------------------------- | 
| 659 |  | *        if VA1-mask from DB is 0 or 1, three masks are combined: | 
| 660 |  | *        - from DB (a-priori mask) | 
| 661 |  | *        - run-based (chip declared bad on the basis of <SIG>) | 
| 662 |  | *        - event-based (failure in CN computation) | 
| 663 |  | *        -------------------------------------------------------- | 
| 664 | if( mask_vk(iv,ivk) .ne. -1)then | if( mask_vk(iv,ivk) .ne. -1)then | 
| 665 | mask(iv,ivk,is) = 1 | mask(iv,ivk,is) = 1 | 
| 666 | $           * mask_vk(iv,ivk) !from DB | $           * mask_vk(iv,ivk)     !from DB | 
| 667 | $           * mask_vk_ev(iv,ivk) !from <SIG> | $           * mask_vk_ev(iv,ivk)  !from <SIG> | 
| 668 | $           * mask_vk_run(iv,ivk) !from CN | $           * mask_vk_run(iv,ivk) !from CN | 
| 669 |  | *        ----------------------------------------------------------- | 
| 670 |  | *        if VA1-mask from DB is -1 only event-based mask is applied | 
| 671 |  | *        ----------------------------------------------------------- | 
| 672 | else | else | 
| 673 | mask(iv,ivk,is) = -1 | mask(iv,ivk,is) = -1 | 
| 674 | $           * mask_vk(iv,ivk) !from DB | $           * mask_vk(iv,ivk)     !from DB | 
| 675 | $           * mask_vk_ev(iv,ivk) !from CN | $           * mask_vk_ev(iv,ivk)  !from CN | 
| 676 | endif | endif | 
| 677 | enddo | enddo | 
| 678 |  |  |