/[PAMELA software]/DarthVader/TrackerLevel2/src/F77/reductionflight.f
ViewVC logotype

Diff of /DarthVader/TrackerLevel2/src/F77/reductionflight.f

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.9 by pam-fi, Mon Oct 16 12:36:52 2006 UTC revision 1.13 by pam-fi, Thu Nov 23 18:51:45 2006 UTC
# Line 23  Line 23 
23        integer ierror        integer ierror
24        ierror = 0        ierror = 0
25    
 *     -------------------------------------------------------  
 *     STRIP MASK  
 *     -------------------------------------------------------  
   
 c      call stripmask   !called later, after CN computation  
26        call init_level1        call init_level1
27    
28  c      good1 = good0  c      good1 = good0
# Line 99  c     and fill the variable ADC (inverti Line 94  c     and fill the variable ADC (inverti
94  c--------------------------------------------------  c--------------------------------------------------
95        call filladc(iflag)        call filladc(iflag)
96        if(iflag.ne.0)then        if(iflag.ne.0)then
 c        good1=0!<<<<<<<<<<<<<<<  
 c       if(DEBUG)print*,'event ',eventn(1),' >>>>>  decode ERROR'  
97           ierror = 220           ierror = 220
 c        goto 200  
 c         print*,'filladc error'  
98        endif        endif
99    
100  c--------------------------------------------------  c--------------------------------------------------
101  c     computes common noise for each VA1  c     computes common noise for each VA1
102  c     (excluding strips affected by signal,  c     (excluding strips with signal,
103  c     tagged with the flag CLSTR)  c     tagged with the flag CLSTR)
104  c--------------------------------------------------  c--------------------------------------------------
105        do iv=1,nviews        do iv=1,nviews
106           ima=0           ima=0
107           do ik=1,nva1_view           do ik=1,nva1_view
108              cn(iv,ik)  = 0              cn(iv,ik)  = 0
109                cnrms(iv,ik)  = 0
110              cnn(iv,ik) = -1              cnn(iv,ik) = -1
             mask_vk_ev(iv,ik)=1  
111              iflag=0              iflag=0
112              if(mask_vk(iv,ik).eq.1)call cncomp(iv,ik,iflag)              mask_vk_ev(iv,ik)=1
113  c     if(iflag.ne.0)good1=0              call stripmask(iv,ik)      !compute mask(i,j,k), combining VA1-masks
114    c     NBNBNBNBNB mask per la striscia 1 !!!!!!!!
115                if(mask(iv,ik,1).eq.1)call cncomp(iv,ik,iflag)
116              if(iflag.ne.0)then              if(iflag.ne.0)then
117                 ima=ima+1                 ima=ima+1
118                 mask_vk_ev(iv,ik)=0                 mask_vk_ev(iv,ik)=0
119                 ierror = 220                 ierror = 220
 c$$$               if(verbose)  
 c$$$     $              print*,' * WARNING * Event ',eventn(1)  
 c$$$     $              ,': masked vk ',ik,' on view',iv  
120              endif              endif
121                call stripmask(iv,ik)      !compute mask(i,j,k), combining VA1-masks
122                
123           enddo           enddo
124   100     format(' * WARNING * Event ',i7,' view',i3,': VK MASK ',24i1)   100     format(' * WARNING * Event ',i7,' view',i3,': VK MASK ',24i1)
125  c         if(ima.ne.0.and.verbose)print*,' * WARNING * Event ',eventn(1)           if(ima.ne.0.and.debug)write(*,100)eventn(1),iv
 c     $              ,' view',iv,': VK MASK '  
 c     $        ,(mask_vk_ev(iv,ik),ik=1,nva1_view)  
          if(ima.ne.0.and.verbose)write(*,100)eventn(1),iv  
126       $        ,(mask_vk_ev(iv,ik),ik=1,nva1_view)       $        ,(mask_vk_ev(iv,ik),ik=1,nva1_view)
127        enddo        enddo
 c      if(good1.eq.0)then  
 c         ierror = 220  
 c      endif  
128    
129        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
130    
131  c---------------------------------------------  c---------------------------------------------
132  c     loops on views, VA1 and strips,  c     loops on views, VA1 and strips,
133  c     and computes strips signals using  c     and computes strips signals using
134  c     badstrip, pedestals, and  c     badstrip, pedestals, and
135  c     sigma informations from histograms  c     sigma informations from histograms
136  c---------------------------------------------  c---------------------------------------------
       flag_shower = .false.  
137        ind=1                     !clsignal array index        ind=1                     !clsignal array index
138    
139        do iv=1,nviews            !loop on views        do iv=1,nviews            !loop on views
# Line 161  C===  > Y view Line 147  C===  > Y view
147       $           *mask(iv,nvk(is),nst(is))       $           *mask(iv,nvk(is),nst(is))
148              clinclcut(is)=incuty*sigma(iv,nvk(is),nst(is))              clinclcut(is)=incuty*sigma(iv,nvk(is),nst(is))
149       $           *mask(iv,nvk(is),nst(is))       $           *mask(iv,nvk(is),nst(is))
150  ccc            print*,"value(",is,")(reduction)= ",value(is)              sat(is)=0
151                if( adc(iv,nvk(is),nst(is)).lt.adc_saty )sat(is)=1
152            else                        else            
153  C===  > X view  C===  > X view
154              value(is)= (DBLE(adc(iv,nvk(is),nst(is)))              value(is)= (DBLE(adc(iv,nvk(is),nst(is)))
# Line 171  C===  > X view Line 158  C===  > X view
158       $           *mask(iv,nvk(is),nst(is))       $           *mask(iv,nvk(is),nst(is))
159              clinclcut(is)=incutx*sigma(iv,nvk(is),nst(is))              clinclcut(is)=incutx*sigma(iv,nvk(is),nst(is))
160       $           *mask(iv,nvk(is),nst(is))       $           *mask(iv,nvk(is),nst(is))
161                sat(is)=0
162                if( adc(iv,nvk(is),nst(is)).gt.adc_satx )sat(is)=1
163            endif            endif
 c$$$          print*,iv,is,' --- ',adc(iv,nvk(is),nst(is)),cn(iv,nvk(is))  
 c$$$     $         ,pedestal(iv,nvk(is),nst(is)),value(is)  
 c$$$     $         ,sigma(iv,nvk(is),nst(is))  
 c          if(value(is).gt.clseedcut(is))  
 c     $         print*,iv,is,' --- (ADC_PED_CN) ',value(is),clseedcut(is)  
164          enddo                   !end loop on strips (1)          enddo                   !end loop on strips (1)
165          call search_cluster(iv)          call search_cluster(iv)
166  c$$$        if(flag_shower.eqv..true.)then  
 c$$$          call init_level1                
 c$$$          good1=0  
 c$$$          goto 200              !jump to next event  
 c$$$        endif  
 ccc  
 ccc    modified by Elena (08/2006)  
 ccc  
167          if(.not.flag_shower)then          if(.not.flag_shower)then
168             call save_cluster(iv)             call save_cluster(iv)
169          else          else
170             fshower(iv) = 1             fshower(iv) = 1
171             GOOD1(DSPn) = 11             GOOD1(DSPnumber(iv)) = 11
172          endif          endif
173        enddo                     ! end loop on views        enddo                     ! end loop on views
174        do iv=1,nviews        do iv=1,nviews
175          do ik=1,nva1_view          do ik=1,nva1_view
176            cnev(iv,ik)  = cn(iv,ik) !assigns computed CN to ntuple variables            cnev(iv,ik)    = cn(iv,ik) !assigns computed CN to ntuple variables
177            cnnev(iv,ik) = cnn(iv,ik) !assigns computed CN to ntuple variables            cnrmsev(iv,ik) = cnrms(iv,ik) !assigns computed CN to ntuple variables
178  ccc          print*,"cnev(",iv,",",ik,")(reduction)= ",cnev(iv,ik)            cnnev(iv,ik)   = cnn(iv,ik) !assigns computed CN to ntuple variables
179          enddo          enddo
180        enddo        enddo
181  C---------------------------------------------  C---------------------------------------------
# Line 211  C--------------------------------------- Line 188  C---------------------------------------
188        do iv = 1,nviews        do iv = 1,nviews
189           ngood = ngood + good1(iv)           ngood = ngood + good1(iv)
190        enddo        enddo
191        if(ngood.ne.0)print*,'* WARNING * Event ',eventn(1)  c$$$      if(ngood.ne.0)print*,'* WARNING * Event ',eventn(1)
192       $     ,':LEVEL1 event status: '  c$$$     $     ,':LEVEL1 event status: '
193       $     ,(good1(i),i=1,nviews)  c$$$     $     ,(good1(i),i=1,nviews)
194  c------------------------------------------------------------------------  c------------------------------------------------------------------------
195  c  c
196  c     closes files and exits  c     closes files and exits
# Line 275  c        crc1(iv)=0 Line 252  c        crc1(iv)=0
252                
253        return        return
254        end        end
255    
256  *---***---***---***---***---***---***---***---***  *---***---***---***---***---***---***---***---***
257  *  *
258  *  *
# Line 295  c        crc1(iv)=0 Line 273  c        crc1(iv)=0
273    
274  c     local variables  c     local variables
275        integer rmax,lmax         !estremi del cluster        integer rmax,lmax         !estremi del cluster
276        integer rstop,lstop       !per decidere quali strip includere nel cluster        integer rstop,lstop      
277                                  ! oltre il seed        integer first,last
278        integer first,last,diff   !per includere le strip giuste... !???        integer fsat,lsat
   
       integer multtemp          !temporary multiplicity variable  
279    
280        external nst        external nst
281    
 c------------------------------------------------------------------------  
 c     looks for clusters on each view  
 C     : CERCO STRIP SOPRA CLSEEDCUT, POI SCORRO A DX FINCHE'  
 c     NON TROVO  
 C     STRIP PIU' BASSA (in segnale/rumore)  
 C     => L'ULTIMA DELLA SERIE CRESCENTE  
 C     (LA PIU' ALTA) E' IL  
 C     CLUSTER SEED. POI SCORRO A SX E DX INCLUDENDO TUTTE  
 C     LE STRIP (FINO A 17 AL  
 C     MAX) CHE SUPERANO CLINCLCUT.  
 C     QUANDO CERCO IL CLUSTER SEED SUCCESSIVO SALTO LA STRIP  
 C     ADIACENTE A DESTRA  
 C     DELL'ULTIMO CLUSTER SEED (CHE SARA' NECESSARIAMENTE  
 C     PIU' BASSA) E PRENDO  
 C     COME SEED UNA STRIP SOLO SE IL SUO SEGNALE E'  
 C     MAGGIORE DI QUELLO DELLA STRIP  
 C     PRECEDENTE (PRATICAMENTE PER EVITARE CHE L'ULTIMA  
 C     STRIP DI UN GRUPPO DI STRIP  
 C     TUTTE SOPRA IL CLSEEDCUT VENGA AUTOMATICAMENTE PRESA  
 C     COME SEED... DEVE ESSERE  
 C     PRESA SOLO SE IL CLUSTER E' DOUBLE PEAKED...)  
 c------------------------------------------------------------------------  
 c     6 ottobre 2003  
 c     Elena: CLSEEDCUT = 7 (old value 10)  
 c     Elena: CLINCLCUT = 4 (old value 5)  
   
282        iseed=-999                !cluster seed index initialization        iseed=-999                !cluster seed index initialization
283    
284          inext=-999                !index where to start new cluster search
285    
286          flag_shower = .false.
287        nclstr_view=0        nclstr_view=0
288    
289        do jl=1,nladders_view     !1..3 !loops on ladders        do jl=1,nladders_view              !1..3 !loops on ladders
290           first=1+nstrips_ladder*(jl-1) !1,1025,2049  
291           last=nstrips_ladder*jl !1024,2048,3072           first = 1+nstrips_ladder*(jl-1) !1,1025,2049
292  c     X views have 1018 strips instead of 1024           last  = nstrips_ladder*jl       !1024,2048,3072
293    
294    *        X views have 1018 strips instead of 1024
295           if(mod(iv,2).eq.0) then           if(mod(iv,2).eq.0) then
296              first=first+3              first=first+3
297              last=last-3              last=last-3
# Line 344  c     X views have 1018 strips instead o Line 299  c     X views have 1018 strips instead o
299    
300           do is=first,last       !loop on strips in each ladder           do is=first,last       !loop on strips in each ladder
301    
302              if(is.le.iseed+1) goto 220  c---------------------------------------------
303  *******************************************************  c     new-cluster search starts at index inext
304  *     Elena 08/2006  c---------------------------------------------
305  * QUESTA PARTE NON E` ADEGUATA per cluster con grossi rilasci di carica              if(is.lt.inext) goto 220 ! next strip
 * perche` salva molte volte lo stesso cluster  
 * (salvo il cluster rispetto al primo massimo e basta...)  
 *******************************************************  
 c$$$c-----------------------------------------  
 c$$$c     after a cluster seed as been found,  
 c$$$c     look for next one skipping one strip on the right  
 c$$$c     (i.e. look for double peak cluster)  
 c$$$c-----------------------------------------  
 c$$$            if(is.ne.first) then  
 c$$$               if(value(is).le.value(is-1)) goto 220  
 c$$$            endif  
 c$$$c-----------------------------------------  
 c$$$c     skips cluster seed  
 c$$$c     finding if strips values are descreasing (a strip  
 c$$$c     can be a cluster seed only if previous strip value  
 c$$$c     is lower)  
 c$$$c-----------------------------------------  
 *******************************************************  
 * LA RICERCA PARTE DALL'ULTIMA STRIP SALVATA (***TEMPORANEO****)  
 *******************************************************  
             if(is.le.iseed+rmax+1) goto 220  
 *******************************************************  
306    
307              if(value(is).gt.clseedcut(is)) then              if(value(is).gt.clseedcut(is)) then
 ccc              print*,"value(",is,")=",value(is),  
 ccc     $             " .gt.clseedcut(",is,")=",clseedcut(is)  
308  c-----------------------------------------  c-----------------------------------------
309  c     possible SEED...  c     possible SEED...
310  c-----------------------------------------  c-----------------------------------------
311                 itemp=is                 itemp = is
312                   fsat = 0         ! first saturated strip
313                   lsat = 0         ! last saturated strip
314                 if(itemp.eq.last) goto 230 !estremo...                 if(itemp.eq.last) goto 230 !estremo...
315  ****************************************************  c              ------------------------                
316  *     modificato da Elena (08/2006) per salvare  c              search for first maximum
317  *     il cluster intorno al massimo assoluto  c              ------------------------
 ****************************************************  
 c$$$               do while(value(itemp)  
 c$$$     $              /sigma(iv,nvk(itemp),nst(itemp))  
 c$$$     $              .le.value(itemp+1)  
 c$$$     $              /sigma(iv,nvk(itemp+1),nst(itemp+1))) !BIAS: aggiustare il caso uguale!???  
 c$$$                  itemp=itemp+1  
 c$$$                  if(itemp.eq.last) goto 230 !stops if reaches last strip  
 c$$$               enddo            ! of the ladder  
318                 do while(                 do while(
319       $                   value(itemp).le.value(itemp+1)       $                   value(itemp).le.value(itemp+1)
320       $              .and.value(itemp+1).gt.clseedcut(itemp+1))       $              .and.value(itemp+1).gt.clseedcut(itemp+1))
321                    itemp=itemp+1                    itemp = itemp+1
322                    if(itemp.eq.last) goto 230 !stops if reaches last strip                    if(itemp.eq.last)   goto 230 !stops if reaches last strip
323                      if(sat(itemp).eq.1) goto 230 !stop if reaches a saturated strip
324                 enddo            ! of the ladder                 enddo            ! of the ladder
325   230           continue   230           continue
326  c-----------------------------------------  c              -----------------------------
327    c              check if strips are saturated
328    c              -----------------------------    
329                   if( sat(itemp).eq.1 )then
330                      fsat = itemp
331                      lsat = itemp
332                      if(itemp.eq.last) goto 231 !estremo...
333                      do while( sat(itemp+1).eq.1 )
334                         itemp = itemp+1
335                         lsat = itemp
336                         if(itemp.eq.last)   goto 231 !stops if reaches last strip
337                      enddo                  
338                   endif
339     231           continue
340    c---------------------------------------------------------------------------
341  c     fownd SEED!!!  c     fownd SEED!!!
342  c-----------------------------------------  c     (if there are saturated strips, the cluster is centered in the middle)
343                 iseed=itemp      c---------------------------------------------------------------------------
344  c----------------------------------------------------------                 if(fsat.eq.0.and.lsat.eq.0)then
345                      iseed = itemp ! <<< SEED
346                   else
347                      iseed = int((lsat+fsat)/2) ! <<< SEED
348    c$$$                  print*,'saturated strips ',fsat,lsat,iseed
349    c$$$                  print*,'--> ',(value(ii),ii=fsat,lsat)
350                   endif    
351    c---------------------------------------------------------------
352  c     after finding a cluster seed, checks also adjacent strips,  c     after finding a cluster seed, checks also adjacent strips,
353  C     and marks the ones exceeding clinclcut  C     and tags the ones exceeding clinclcut
354  c----------------------------------------------------------  c---------------------------------------------------------------
355                 ir=iseed         !indici destro                 ir=iseed         !indici destro
356                 il=iseed         ! e sinistro                 il=iseed         ! e sinistro
357                                
# Line 415  c--------------------------------------- Line 362  c---------------------------------------
362                 lstop=0          ! inclusion loop                 lstop=0          ! inclusion loop
363    
364                 do while(lstop.eq.0.or.rstop.eq.0) !shifts left and right from                 do while(lstop.eq.0.or.rstop.eq.0) !shifts left and right from
365                    ir=ir+1       !position index for strips on right side of  
366                                  ! cluster seed  
367                    il=il-1       !and for left side                    ir=ir+1       !index for right side
368                      il=il-1       !index for left side
369  c------------------------------------------------------------------------  c------------------------------------------------------------------------
370  c     checks for last or first strip of the ladder  c     checks for last or first strip of the ladder
371  c------------------------------------------------------------------------  c------------------------------------------------------------------------
372                    if(ir.gt.last) then !when index goes beyond last strip                    if( ir.gt.last  ) rstop = 1                      
373                       rstop=1    ! of the ladder, change rstop flag in order                    if( il.lt.first ) lstop = 1
                                 ! to "help" exiting from loop  
                   endif  
                     
                   if(il.lt.first) then !idem when index goes beyond  
                      lstop=1    ! first strip of the ladder  
                   endif  
374                                        
375  c------------------------------------------------------------------------  c------------------------------------------------------------------------
376  c     check for clusters including more than nclstrp strips  c     add strips exceeding inclusion cut
 c------------------------------------------------------------------------  
                   if((rmax-lmax+1).ge.nclstrp) then  
                      goto 210   !exits inclusion loop:  
                                 ! lmax and rmax maintain last value  
                                 ! NB .ge.!???  
                   endif  
 c------------------------------------------------------------------------  
 c     marks strips exceeding inclusion cut  
377  c------------------------------------------------------------------------  c------------------------------------------------------------------------
378                    if(rstop.eq.0) then !if last strip of the ladder or last                    if( (rmax-lmax+1).ge.nclstrp )goto 210   !exits inclusion loop
379                                  ! over-cut strip has not been reached  
380                       if(value(ir).gt.clinclcut(ir)) then !puts in rmax the                    if(rstop.eq.0) then !if right cluster morder has not been reached
381                          rmax=ir ! last right over-cut strip                       if(value(ir).gt.clinclcut(ir)) then
382                            rmax=ir !include a strip on the right
383                       else                       else
384                          rstop=1 !otherwise cluster ends on right and rstop                          rstop=1 !cluster right end
385                       endif      ! flag=1 signals it                       endif    
386                    endif                    endif
387                    if(lstop.eq.0) then  
388                      if( (rmax-lmax+1).ge.nclstrp )goto 210   !exits inclusion loop
389    
390                      if(lstop.eq.0) then !if left cluster morder has not been reached
391                       if(value(il).gt.clinclcut(il)) then                       if(value(il).gt.clinclcut(il)) then
392                          lmax=il                          lmax=il !include a strip on the left
393                       else                       else
394                          lstop=1                          lstop=1 !cluster left end
395                       endif                       endif
396                    endif                    endif
397    
398                 enddo            !ends strip inclusion loop                 enddo            !ends strip inclusion loop
399                   goto 211
400   210           continue         !jumps here if more than nclstrp have been included   210           continue         !jumps here if more than nclstrp have been included
401                        c               print*,'>>> nclstrp! '
402                 multtemp=rmax-lmax+1 !stores multiplicity in temp   211           continue
403                                  ! variable. NB rmax and lmax can change later in  c-----------------------------------------
404                                  ! order to include enough strips to calculate eta3  c     end of inclusion loop!
405                                  ! and eta4. so mult is not always equal to cllength  c-----------------------------------------
406  c------------------------------------------------------------------------                
407  c     NB per essere sicuro di poter calcolare eta3 e eta4 devo includere  c------------------------------------------------------------------------
408  c     sempre e comunque le 2 strip adiacenti al cluster seed e quella  c     adjust the cluster in order to have at least a strip around the seed
409  c     adiacente ulteriore dalla parte della piu' alta fra queste due  c------------------------------------------------------------------------
410  c     (vedi oltre...)!???                 if(iseed.eq.lmax.and.lmax.ne.first)then
411  c------------------------------------------------------------------------                    lmax = lmax-1
412                      if( (rmax-lmax+1).gt.nclstrp )rmax=rmax-1
413  c     nel caso di estremi del ladder...!???                 endif
414                   if(iseed.eq.rmax.and.rmax.ne.last )then
415  c     ho meno di 4 strip nel cluster --> se sono sui bordi o quasi del ladder                    rmax = rmax+1
416  c     costruisco il cluster ad hoc e poi esco, se non sono sui bordi o quasi                    if( (rmax-lmax+1).gt.nclstrp )lmax=lmax+1
 c     vado oltre (aggiungero' quindi strip a sx e dx in modo da poter calcolare  
 c     eta3e4)  
                if((rmax-lmax+1).lt.4) then  
   
                   if(iseed.eq.first) then !estremi...  
                      rmax=iseed+2 !NB in questo modo puo' anche capitare di  
                      lmax=iseed ! includere strip sotto taglio di inclusione  
                      goto 250   ! che non serviranno per eta3e4!???  
                   endif  
                     
                   if(iseed.eq.last) then !estremi...  
                      rmax=iseed  
                      lmax=iseed-2 !NB 2 e non 3, perche' altrimenti sarei in  
                      goto 250   ! ((rmax-lmax+1).lt.4).eq.false. !???  
                   endif         !NMB questo e' l'unico caso di cllength=3!???  
                     
                   if(iseed.eq.first+1) then !quasi estremi...  
                      rmax=iseed+2  
                      lmax=iseed-1  
                      goto 250  
                   endif  
                   if(iseed.eq.last-1) then  
                      rmax=iseed+1  
                      lmax=iseed-2  
                      goto 250  
                   endif  
 c     se ho 4 o piu' strip --> se sono sui bordi esco, se sono sui quasi bordi  
 c     includo la strip del bordo  
                else  
                     
                   if(iseed.eq.first) goto 250 !estremi... non includo altro                    
                   if(iseed.eq.last) goto 250  
                   if(iseed.eq.first+1) then !quasi estremi... mi assicuro di  
                      lmax=first ! avere le strip adiacenti al seed  
                      if((rmax-lmax+1).gt.nclstrp) rmax=rmax-1 !NB effetto  
                      goto 250   ! coperta: se la lunghezza del cluster era gia'  
                   endif         ! al limite (nclstrp), per poter aggiungere questa  
                                 ! strip a sinistra devo toglierne una a destra...!???  
                   if(iseed.eq.last-1) then  
                      rmax=last  
                      if((rmax-lmax+1).gt.nclstrp) lmax=lmax+1  
                      goto 250  
                   endif                    
417                 endif                 endif
418    
419  c------------------------------------------------------------------------  c------------------------------------------------------------------------
420  c     be sure to include in the cluster the cluster seed with its 2 adjacent  c     adjust the cluster in order to store a minimum number of strips
421  c     strips, and the one adjacent to the greatest between this two strip, as the  c------------------------------------------------------------------------
422  c     fourth one. if the strips have the same value (!) the fourth one is chosen                 do while( (rmax-lmax+1).lt.nclstrpmin )
423  c     as the one having the greatest value between the second neighbors  
424  c------------------------------------------------------------------------                    vl = -99999
425                 if(value(iseed+1).eq.value(iseed-1)) then                    vr = -99999
426                    if(value(iseed+2).ge.value(iseed-2)) then !??? qui cmq c'e'                    if(lmax-1.ge.first) vl = value(lmax-1)
427                       diff=(iseed+2)-rmax                    if(rmax+1.le.last ) vr = value(rmax+1)
428                       if(diff.gt.0) then                    if(vr.ge.vl) then
429                          rmax=rmax+diff                       rmax = rmax+1
430                          if((rmax-lmax+1).gt.nclstrp) then                    else  
431                             lmax=rmax-nclstrp+1                       lmax = lmax-1
                         endif  
                      endif  
                      diff=(iseed-1)-lmax  
                      if(diff.lt.0) then  
                         lmax=lmax+diff  
                         if((rmax-lmax+1).gt.nclstrp) then  
                            rmax=lmax+nclstrp-1  
                         endif  
                      endif  
                   else  
                      diff=(iseed-2)-lmax  
                      if(diff.lt.0) then  
                         lmax=lmax+diff  
                         if((rmax-lmax+1).gt.nclstrp) then  
                            rmax=lmax+nclstrp-1  
                         endif  
                      endif  
                      diff=(iseed+1)-rmax  
                      if(diff.gt.0) then  
                         rmax=rmax+diff  
                         if((rmax-lmax+1).gt.nclstrp) then  
                            lmax=rmax-nclstrp+1  
                         endif  
                      endif  
                   endif  
                elseif(value(iseed+1).gt.value(iseed-1)) then  
 c     !??? sposto il limite del cluster a destra per includere sempre le strip  
 c     necessarie al calcolo di eta-i  
 c     se il cluster diventa  troppo lungo lo accorcio a sinistra per avere non piu'  
 c     di nclstrp (in questo caso sono sicuro di aver gia' incluso le strip  
 c     necessarie al calcolo di eta-i a sinistra, quindi se voglio posso uscire)  
                   diff=(iseed+2)-rmax  
                   if(diff.gt.0) then  
                      rmax=rmax+diff  
                      if((rmax-lmax+1).gt.nclstrp) then  
                         lmax=rmax-nclstrp+1  
 c     goto 250  
                      endif  
                   endif  
                   diff=(iseed-1)-lmax  
                   if(diff.lt.0) then  
                      lmax=lmax+diff  
                      if((rmax-lmax+1).gt.nclstrp) then  
                         rmax=lmax+nclstrp-1  
 c     goto 250 !inutile!???  
                      endif  
                   endif  
                else  
                   diff=(iseed-2)-lmax  
                   if(diff.lt.0) then  
                      lmax=lmax+diff  
                      if((rmax-lmax+1).gt.nclstrp) then  
                         rmax=lmax+nclstrp-1  
 c     goto 250  
                      endif  
                   endif  
                   diff=(iseed+1)-rmax  
                   if(diff.gt.0) then  
                      rmax=rmax+diff  
                      if((rmax-lmax+1).gt.nclstrp) then  
                         lmax=rmax-nclstrp+1  
 c     goto 250 !inutile!???  
                      endif  
432                    endif                    endif
433                 endif                    
434   250           continue                 enddo
435    
436  c--------------------------------------------------------  c--------------------------------------------------------
437  c     fills cluster variables  c     store cluster info
438  c--------------------------------------------------------  c--------------------------------------------------------
 c$$$               nclstr1=nclstr1+1 !cluster number  
 c$$$ccc               print*,nclstr1,multtemp  
 c$$$               if(nclstr1.gt.nclstrmax) then !too many clusters for the event:  
 c$$$                  if(verbose)print*,'Event ',eventn(1),  
 c$$$     $                 ': more than ',nclstrmax,' clusters'  
 c$$$                  good1=0       ! event  
 c$$$                  nclstr1=0  
 c$$$                  totCLlength=0  
 c$$$                  flag_shower = .true.  
 c$$$                  goto 2000  
 c$$$               endif  
 c$$$               view(nclstr1)   = iv !vista del cluster  
 c$$$               ladder(nclstr1) = nld(iseed,iv) !ladder a cui appartiene il cluster seed  
 c$$$               maxs(nclstr1)   = iseed !strip del cluster seed  
 c$$$               mult(nclstr1)   = multtemp !molteplicita'  
 c$$$                
 c$$$               indstart(nclstr1) = ind !posizione dell'inizio del cluster nell'  
 c$$$c                                      ! array clsignal  
 c$$$               indmax(nclstr1)   = indstart(nclstr1)+(iseed-lmax) !posizione del  
 c$$$c                                      ! cluster seed nell'array clsignal  
 c$$$                
 c$$$               CLlength      = rmax-lmax+1 !numero di strip del cluster  
 c$$$               totCLlength   = totCLlength+CLlength  
 c$$$               dedx(nclstr1) = 0  
 c$$$               do j=lmax,rmax   !stores sequentially cluter strip values in  
 c$$$                  clsignal(ind) = value(j) ! clsignal array  
 c$$$                  ind=ind+1  
 c$$$c                  if(value(j).gt.0)  
 c$$$                  if(value(j).gt.clinclcut(j))  
 c$$$     $                 dedx(nclstr1) = dedx(nclstr1) + value(j) !cluster charge  
 c$$$               enddo  
 ccc  
 ccc            *** Modified by Elena (08/2006) ***  
 ccc  
439                 nclstr_view = nclstr_view + 1 !cluster number                 nclstr_view = nclstr_view + 1 !cluster number
440  c               print*,'view ',iv,' -- search_cluster -- nclstr_view: '  
 c     $              ,nclstr_view  
441                 if(nclstr_view.gt.nclstrmax_view) then !too many clusters for the view:                 if(nclstr_view.gt.nclstrmax_view) then !too many clusters for the view:
442                    if(verbose) print*,'Event ',eventn(1),  c$$$                  if(verbose) print*,'Event ',eventn(1),
443       $                 ': more than ',nclstrmax_view  c$$$     $                 ': more than ',nclstrmax_view
444       $                 ,' clusters on view ',iv  c$$$     $                 ,' clusters on view ',iv
 c                  good1=0       ! event  
 c                  nclstr1=0  
 c                  totCLlength=0  
445                    flag_shower = .true.                    flag_shower = .true.
446                    goto 2000                    goto 2000
447                 endif                 endif
448    
449  c               view(nclstr1)   = iv !vista del cluster                 ladder_view(nclstr_view) = nld(iseed,iv)
450                 ladder_view(nclstr_view) = nld(iseed,iv) !ladder a cui appartiene il cluster seed                 maxs_view(nclstr_view)   = iseed
451                 maxs_view(nclstr_view)   = iseed !strip del cluster seed                 mult_view(nclstr_view)   = rmax-lmax+1
                mult_view(nclstr_view)   = multtemp !molteplicita'  
452                 rmax_view(nclstr_view)   = rmax                 rmax_view(nclstr_view)   = rmax
453                 lmax_view(nclstr_view)   = lmax                 lmax_view(nclstr_view)   = lmax
454    
455    c$$$               if(rmax-lmax+1.gt.25)
456    c$$$     $              print*,'view ',iv
457    c$$$     $              ,' cl ',nclstr_view,' mult ',rmax-lmax+1
458    c------------------------------------------------------------------------
459    c     search for a double peak inside the cluster                                                                                                            
460    c------------------------------------------------------------------------
461                   inext = rmax+1   !<< index where to start new-cluster search
462                  
463                   vmax = 0
464                   vmin = value(iseed)
465                   imax = iseed
466                   imin = iseed
467                   do iss = max(iseed+1,lsat+1),rmax
468                      if( value(iss).lt.vmin )then
469                         if( imax.ne.iseed )goto 221 !found dowble peek
470                         imin = iss
471                         vmin = value(iss)
472                      else
473                         delta = value(iss) - value(imin)
474                         cut = sqrt(clinclcut(iss)**2 + clinclcut(imin)**2)
475                         if(
476         $                    delta.gt.cut .and.
477         $                    value(iss).gt.clseedcut(iss).and.
478         $                    .true.)then
479                            if( value(iss).gt.vmax )then                        
480                               imax = iss
481                               vmax = value(iss)
482                            else
483                               goto 221 !found dowble peek
484                            endif
485                         endif
486                      endif
487                   enddo
488     221           continue
489                  
490                   if(imax.gt.iseed)then
491                      inext = imax    !<< index where to start new-cluster search
492    c$$$                  print*,'--- double peek ---'
493    c$$$                  print*,(value(ii),ii=lmax,rmax)
494    c$$$                  print*,'seed ',iseed,' imin ',imin,' imax ',imax
495                   endif
496  c--------------------------------------------------------  c--------------------------------------------------------
497  c  c
498  c--------------------------------------------------------  c--------------------------------------------------------
# Line 741  c     $        ,nclstr1,maxs(nclstr1),mu Line 577  c     $        ,nclstr1,maxs(nclstr1),mu
577  *---***---***---***---***---***---***---***---***  *---***---***---***---***---***---***---***---***
578    
579    
580        subroutine stripmask  c$$$      subroutine stripmask
581    c$$$
582    c$$$*     this routine set va1 and single-strip masks,
583    c$$$*     on the basis of the VA1 mask saved in the DB
584    c$$$*
585    c$$$*     mask(nviews,nva1_view,nstrips_va1) !strip mask
586    c$$$*     mask_vk(nviews,nva1_view)          !VA1 mask
587    c$$$*
588    c$$$      include 'commontracker.f'
589    c$$$      include 'level1.f'
590    c$$$      include 'common_reduction.f'
591    c$$$      include 'calib.f'
592    c$$$
593    c$$$*     init mask
594    c$$$      do iv=1,nviews
595    c$$$         do ivk=1,nva1_view
596    c$$$            do is=1,nstrips_va1
597    c$$$c               mask(iv,ivk,is) = mask_vk(iv,ivk)
598    c$$$               if( mask_vk(iv,ivk) .ne. -1)then
599    c$$$                  mask(iv,ivk,is) = 1
600    c$$$     $                 * mask_vk(iv,ivk)     !from DB
601    c$$$     $                 * mask_vk_ev(iv,ivk)  !from <SIG>
602    c$$$     $                 * mask_vk_run(iv,ivk) !from CN
603    c$$$               else
604    c$$$                  mask(iv,ivk,is) = -1
605    c$$$     $                 * mask_vk(iv,ivk)     !from DB
606    c$$$     $                 * mask_vk_ev(iv,ivk)  !from CN
607    c$$$               endif
608    c$$$            enddo
609    c$$$         enddo
610    c$$$      enddo
611    c$$$
612    c$$$
613    c$$$      return
614    c$$$      end
615    
616          subroutine stripmask(iv,ivk)
617    
618  *     this routine set va1 and single-strip masks,  *     this routine set va1 and single-strip masks,
619  *     on the basis of the VA1 mask saved in the DB  *     on the basis of the VA1 mask saved in the DB
# Line 755  c     $        ,nclstr1,maxs(nclstr1),mu Line 627  c     $        ,nclstr1,maxs(nclstr1),mu
627        include 'calib.f'        include 'calib.f'
628    
629  *     init mask  *     init mask
630        do iv=1,nviews        do is=1,nstrips_va1
631           do ivk=1,nva1_view           if( mask_vk(iv,ivk) .ne. -1)then            
632              do is=1,nstrips_va1              mask(iv,ivk,is) = 1
633  c               mask(iv,ivk,is) = mask_vk(iv,ivk)       $           * mask_vk(iv,ivk) !from DB
634                 mask(iv,ivk,is) = mask_vk(iv,ivk) * mask_vk_ev(iv,ivk)                     $           * mask_vk_ev(iv,ivk) !from <SIG>
635              enddo       $           * mask_vk_run(iv,ivk) !from CN
636           enddo           else
637                mask(iv,ivk,is) = -1
638         $           * mask_vk(iv,ivk) !from DB
639         $           * mask_vk_ev(iv,ivk) !from CN
640             endif
641        enddo        enddo
642          
643          
644        return        return
645        end        end
   

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.13

  ViewVC Help
Powered by ViewVC 1.1.23