| 1 |
************************************************************************* |
| 2 |
* |
| 3 |
* Subroutine cutcn.f!DA COMMENTARE!??? |
| 4 |
* |
| 5 |
* excludes strips with particle signals and/or noisy strips from common |
| 6 |
* noise calculation, marking their clstr(nviews,nva1_view,nstrips_va1) |
| 7 |
* flag: |
| 8 |
* clstr=0 ---> not to be used in CN computation |
| 9 |
* clstr=1 ---> to be used in CN computation |
| 10 |
* |
| 11 |
* needs: |
| 12 |
* - ./common_calib.f |
| 13 |
* |
| 14 |
* to be called inside ./cncomp.f |
| 15 |
* |
| 16 |
************************************************************************* |
| 17 |
|
| 18 |
subroutine cutcn(i,j) !(view, VA1) |
| 19 |
|
| 20 |
include '../common/commontracker.f' |
| 21 |
include '../common/common_reduction.f' |
| 22 |
include '../common/calib.f' |
| 23 |
|
| 24 |
|
| 25 |
integer skip !used to skip strips (see later...) |
| 26 |
|
| 27 |
integer kr, kl !position indexes to check signal affected |
| 28 |
! strips on right and left side of cluster |
| 29 |
! seed |
| 30 |
integer ir, il !flags to exit loop on reaching VA1 extremes |
| 31 |
|
| 32 |
real value !cluster seed signal |
| 33 |
real cut,stripcut !cluster seed cut |
| 34 |
|
| 35 |
real valuel, valuer !left and right strips signal |
| 36 |
real stripcnincut !strip include cut |
| 37 |
|
| 38 |
skip = 0 !initializes skip |
| 39 |
|
| 40 |
do k=1,nstrips_va1 !loops on strips searching for cluster seeds |
| 41 |
|
| 42 |
if(k.le.skip) goto 20 !continues only if k strip has not been |
| 43 |
! checked yet |
| 44 |
|
| 45 |
clstr(i,j,k)=1 !reinitializes strip to be used in CN!??? |
| 46 |
! computation, in order to be able to exclude |
| 47 |
! different strips at every CN computation loop |
| 48 |
|
| 49 |
c------------------------------------------------------------------------ |
| 50 |
c |
| 51 |
c selects cut according to view |
| 52 |
c |
| 53 |
c------------------------------------------------------------------------ |
| 54 |
if(mod(i,2).eq.1) then !odd strip ---> Y view |
| 55 |
value= - (DBLE(adc(i,j,k))-cn(i,j)-pedestal(i,j,k)) !negative signal |
| 56 |
cut=clcuty !sets Y cut to find cluster seeds |
| 57 |
else !even strip ---> X view |
| 58 |
value= DBLE(adc(i,j,k))-cn(i,j)-pedestal(i,j,k) !positive signal |
| 59 |
cut=clcutx !sets X cut to find cluster seeds |
| 60 |
endif |
| 61 |
|
| 62 |
|
| 63 |
c------------------------------------------------------------------------ |
| 64 |
c |
| 65 |
c seeks clusters |
| 66 |
c |
| 67 |
c------------------------------------------------------------------------ |
| 68 |
stripcut=cut*sigma(i,j,k) !cluster seed cut |
| 69 |
|
| 70 |
c if(ABS(value).gt.stripcut) then !checks if signal exceeds threshold!??? |
| 71 |
if(value.gt.stripcut) then !checks if signal exceeds threshold |
| 72 |
|
| 73 |
c$$$ print*,'cut',i,j,k,value,stripcut,adc(i,j,k),cn(i,j) |
| 74 |
c$$$ $ ,pedestal(i,j,k) !??? |
| 75 |
|
| 76 |
clstr(i,j,k)=0 !if so, marks this strip as part of a |
| 77 |
! cluster |
| 78 |
|
| 79 |
c------------------------------------------------------------------------ |
| 80 |
c after finding a cluster seed, checks also adiacent strips, and marks |
| 81 |
c the ones exceeding cnincut |
| 82 |
c------------------------------------------------------------------------ |
| 83 |
kr=k !initializes position indexes to be equal to |
| 84 |
kl=k ! cluster seed position |
| 85 |
|
| 86 |
ir=0 !initialize flags used to exit from |
| 87 |
il=0 ! inclusion loop |
| 88 |
|
| 89 |
do while (il.eq.0.or.ir.eq.0) !shifts left and right from |
| 90 |
! cluster seed till it finds a strip below |
| 91 |
! the threshold, or till it reaches first or |
| 92 |
! last VA1 strip |
| 93 |
kr=kr+1 !position index for strips on right side of |
| 94 |
! cluster seed |
| 95 |
kl=kl-1 !and for left side |
| 96 |
|
| 97 |
c------------------------------------------------------------------------ |
| 98 |
c checks for last or first strip |
| 99 |
c------------------------------------------------------------------------ |
| 100 |
if(kr.gt.nstrips_va1.and.ir.eq.0) then !when index goes |
| 101 |
ir=1 ! beyond last VA1 strip, change ir flag in |
| 102 |
! order to "help" exiting from loop |
| 103 |
skip=nstrips_va1+1 !sets skip beyond last strip: all |
| 104 |
! strips on the right have been included in |
| 105 |
! the cluster, so skips all next strips |
| 106 |
! (goto 20 condition is now always true) |
| 107 |
endif |
| 108 |
|
| 109 |
if(kl.lt.1.and.il.eq.0) then !idem when index goes beyond |
| 110 |
il=1 ! first strip |
| 111 |
endif |
| 112 |
|
| 113 |
c P.S.: the "....and.i#.eq.0" term in above conditions is needed. In |
| 114 |
c fact, even if I reach a under-cut strip on the right (so I get ir=1), |
| 115 |
c the "do while loop" continues till such strip will be found on the |
| 116 |
c left too. |
| 117 |
c Thus kl and kr (! too) keep increasing, and it can happen kr gets |
| 118 |
c greater than nstrips_va1 before kl reaches a under-cut strip. In this |
| 119 |
c case it would pass this "if condition", so setting skip=nstrips_va1+1 |
| 120 |
c and skipping right strips never checked, if the "....and.i#.eq.0" term |
| 121 |
c weren't the: instead, including this part it won't pass it |
| 122 |
c because when I found reach the last VA1 strip on the right I set ir=1. |
| 123 |
c (AAAAAAHHHHHHHHH!!!!!!!!!!!) |
| 124 |
|
| 125 |
c------------------------------------------------------------------------ |
| 126 |
c marks strips exceeding inclusion cut |
| 127 |
c------------------------------------------------------------------------ |
| 128 |
c for right strips (kr index) |
| 129 |
if(ir.eq.0) then !if last strip or last over-cut strip has |
| 130 |
! not been reached |
| 131 |
|
| 132 |
if(mod(i,2).eq.1) then !Y view |
| 133 |
valuer= - (DBLE(adc(i,j,kr))-cn(i,j) !puts in valuer |
| 134 |
$ -pedestal(i,j,kr)) ! right strip value |
| 135 |
else !X view |
| 136 |
valuer=DBLE(adc(i,j,kr))-cn(i,j)-pedestal(i,j,kr) |
| 137 |
endif |
| 138 |
|
| 139 |
stripcnincut=cnincut*sigma(i,j,kr) !defines include cut |
| 140 |
c if(ABS(valuer).gt.stripcnincut) then !marks right strip if it !??? |
| 141 |
if(valuer.gt.stripcnincut) then !marks right strip if it |
| 142 |
clstr(i,j,kr)=0 !exceedes include cut |
| 143 |
c$$$ print*,'inclcut_r',i,j,kr,valuer,stripcnincut |
| 144 |
c$$$ $ ,adc(i,j,kr),cn(i,j),pedestal(i,j,kr) !??? |
| 145 |
else |
| 146 |
ir=1 !otherwise cluster ends and ir flag =1 |
| 147 |
! signals it |
| 148 |
skip=kr !putting skip=kr, next k to be checked is |
| 149 |
! k=kr |
| 150 |
endif |
| 151 |
|
| 152 |
endif |
| 153 |
|
| 154 |
c for left strips (kl index) |
| 155 |
if(il.eq.0) then !if first strip or last over-cut strip has |
| 156 |
! not been reached |
| 157 |
|
| 158 |
if (mod(i,2).eq.1) then !Y view |
| 159 |
valuel= - (DBLE(adc(i,j,kl))-cn(i,j) !puts in valuel |
| 160 |
$ -pedestal(i,j,kl)) ! left strip value |
| 161 |
else !X view |
| 162 |
valuel=DBLE(adc(i,j,kl))-cn(i,j)-pedestal(i,j,kl) |
| 163 |
endif |
| 164 |
|
| 165 |
stripcnincut=cnincut*sigma(i,j,kl) !defines include cut |
| 166 |
c if(ABS(valuel).gt.stripcnincut) then !marks left strip if it!??? |
| 167 |
if(valuel.gt.stripcnincut) then !marks left strip if it |
| 168 |
clstr(i,j,kl)=0 !exceedes include cut |
| 169 |
c$$$ print*,'inclcut_l',i,j,kl,valuel,stripcnincut |
| 170 |
c$$$ $ ,adc(i,j,kl),cn(i,j),pedestal(i,j,kl) !??? |
| 171 |
else |
| 172 |
il=1 !otherwise cluster ends and il flag =1 |
| 173 |
! signals it |
| 174 |
endif |
| 175 |
|
| 176 |
endif |
| 177 |
|
| 178 |
enddo !ends lateral strips loop |
| 179 |
|
| 180 |
endif !ends cluster seed condition |
| 181 |
|
| 182 |
20 continue !comes here if next strip on the right has |
| 183 |
! already been included in a cluster |
| 184 |
|
| 185 |
enddo !ends principal strip loop |
| 186 |
|
| 187 |
return |
| 188 |
end |