1 |
pam-fi |
1.1 |
************************************************************************* |
2 |
|
|
* |
3 |
|
|
* Subroutine cncomp.f |
4 |
|
|
* |
5 |
|
|
* iterates common noise computation subroutine (./cnoise.f) and cluster |
6 |
|
|
* cutting subroutine (./cutcn.f) till no more clusters are found |
7 |
|
|
* |
8 |
|
|
************************************************************************* |
9 |
|
|
|
10 |
|
|
subroutine cncomp(i,j) !(view, VA1) |
11 |
|
|
|
12 |
|
|
include '../common/commontracker.f' |
13 |
|
|
include '../common/common_reduction.f' |
14 |
|
|
include '../common/calib.f' |
15 |
|
|
|
16 |
|
|
integer errflag !error flag to mark no signal free VA1 |
17 |
|
|
|
18 |
|
|
integer clstr_old(nstrips_va1) !flag storage vector |
19 |
|
|
|
20 |
|
|
real signal(nstrips_va1) !"signal" (=adc-ped) value storage vector |
21 |
|
|
|
22 |
|
|
real smean, ssigma !"signal" mean and sigma |
23 |
|
|
real cut !"strange" strip exclusion cut |
24 |
|
|
|
25 |
|
|
integer newclstr !flag to warn about new found clusters to be |
26 |
|
|
! excluded from common noise computation |
27 |
|
|
|
28 |
|
|
|
29 |
|
|
c call HBOOK1(20000+100*i+j,' ',30,0.,30.,0.) !??? |
30 |
|
|
|
31 |
|
|
c------------------------------------------------------------------------ |
32 |
|
|
c |
33 |
|
|
c variables initialization |
34 |
|
|
c |
35 |
|
|
c------------------------------------------------------------------------ |
36 |
|
|
do k=1,nstrips_va1 !loops on strips |
37 |
|
|
clstr(i,j,k)=1 !initializes signal affected strips flag |
38 |
|
|
clstr_old(k)=1 !initializes signal affected strips storage |
39 |
|
|
strange(i,j,k)=1 !initializes unusually high or low signal |
40 |
|
|
enddo ! affected strips flag |
41 |
|
|
|
42 |
|
|
newclstr=1 !flag to warn about new found signal |
43 |
|
|
! affected strips |
44 |
|
|
|
45 |
|
|
|
46 |
|
|
|
47 |
|
|
c------------------------------------------------------------------------ |
48 |
|
|
c |
49 |
|
|
c high or low signal affected strips exclusion: computes "signal" (=adc-ped) |
50 |
|
|
c mean value and sigma, and cuts from common noise computation strips |
51 |
|
|
c whose ABS(signal) exceeds scut*sigma |
52 |
|
|
c |
53 |
|
|
c------------------------------------------------------------------------ |
54 |
|
|
countme=0 !??? |
55 |
|
|
666 continue !??? |
56 |
|
|
|
57 |
|
|
smean=0. !initialization |
58 |
|
|
ssigma=0. |
59 |
|
|
nstr=0 |
60 |
|
|
|
61 |
|
|
do k=1,nstrips_va1 |
62 |
|
|
nstr=nstr+strange(i,j,k) !uses only |
63 |
|
|
if(mod(i,2).eq.1) then !odd strip ---> Y view |
64 |
|
|
signal(k)= - (DBLE(adc(i,j,k))-pedestal(i,j,k)) !negative signal |
65 |
|
|
else !even strip ---> X view |
66 |
|
|
signal(k)= DBLE(adc(i,j,k))-pedestal(i,j,k) !positive signal |
67 |
|
|
endif |
68 |
|
|
|
69 |
|
|
smean=smean+signal(k)*strange(i,j,k) |
70 |
|
|
ssigma=ssigma+(signal(k)**2)*strange(i,j,k) |
71 |
|
|
|
72 |
|
|
c call HFILL(10000+100*i+j,signal(k),0.,1.) !??? |
73 |
|
|
enddo |
74 |
|
|
|
75 |
|
|
smean=smean/nstr !strips value distribution mean |
76 |
|
|
|
77 |
|
|
ssigma=SQRT((ssigma/nstr)-smean**2) !strips value distribution sigma |
78 |
|
|
|
79 |
|
|
cut=scut*ssigma !exclusion cut |
80 |
|
|
|
81 |
|
|
do k=1,nstrips_va1 |
82 |
|
|
c call HFILL(20000+100*i+j,ABS(signal(k)-smean)/ssigma,0.,1.) !??? |
83 |
|
|
if(ABS(signal(k)-smean).gt.cut) then |
84 |
|
|
c print*,i,j,k,signal(k),abs(signal(k)),cut,strange(i,j,k) !??? |
85 |
|
|
strange(i,j,k)=0 !marks strips exceeding cut |
86 |
|
|
endif |
87 |
|
|
enddo ! in order not to use them in CN computation |
88 |
|
|
|
89 |
|
|
|
90 |
|
|
countme=countme+1 !??? |
91 |
|
|
if (countme.le.3) goto 666 !??? |
92 |
|
|
|
93 |
|
|
|
94 |
|
|
c------------------------------------------------------------------------ |
95 |
|
|
c |
96 |
|
|
c common noise computation |
97 |
|
|
c |
98 |
|
|
c------------------------------------------------------------------------ |
99 |
|
|
do while(newclstr.eq.1) !loops on this VA1 till no new signal |
100 |
|
|
! affected strips are found |
101 |
|
|
|
102 |
|
|
newclstr=0 !to exit from loop if no new cluster is |
103 |
|
|
! found |
104 |
|
|
|
105 |
|
|
errflag=0 |
106 |
|
|
|
107 |
|
|
call cnoise(i,j,errflag) !(view, VA1, error flag) computes common |
108 |
|
|
! noise |
109 |
|
|
|
110 |
|
|
c print*,cn(i,j) !??? |
111 |
|
|
|
112 |
|
|
if(errflag.eq.1) goto 10 !goes to next VA1: this one has no signal |
113 |
|
|
! free strips... |
114 |
|
|
|
115 |
|
|
call cutcn(i,j) !(view, VA1) excludes clusters from |
116 |
|
|
! common noise calculation |
117 |
|
|
|
118 |
|
|
ncs=0 !initializes number of strips not excluded by cncut |
119 |
|
|
|
120 |
|
|
do k=1,nstrips_va1 !loops on strips |
121 |
|
|
if(clstr(i,j,k).ne.clstr_old(k)) then !checks if there are |
122 |
|
|
! new found clusters, and if so sets |
123 |
|
|
newclstr=1 ! newclstr flag = 1 |
124 |
|
|
|
125 |
|
|
clstr_old(k)=clstr(i,j,k) !stores cluster flags in |
126 |
|
|
endif ! clstr_old variable |
127 |
|
|
|
128 |
|
|
iok=strange(i,j,k)*bad(i,j,k)*clstr(i,j,k) |
129 |
|
|
|
130 |
|
|
ncs=ncs+iok !counts number of good strips for cn computation |
131 |
|
|
|
132 |
|
|
enddo |
133 |
|
|
|
134 |
|
|
enddo !ends do while loop when there are no new |
135 |
|
|
! clusters |
136 |
|
|
|
137 |
|
|
c call HFILL(666,FLOAT(ncs),0.,1.) !??? |
138 |
|
|
|
139 |
|
|
|
140 |
|
|
c$$$ if(ncs.lt.20) then !warns if too many strips have been excluded from CN |
141 |
|
|
c$$$ ! computation |
142 |
|
|
c$$$ print*,'cncomp: WARNING, LESS THAN 20 STRIPS PASSED CN CUT' |
143 |
|
|
c$$$ $ //' ON VA1 ',j,', VIEW ',i !NB questo errore e' "un po'" in conflitto |
144 |
|
|
c$$$ ! con quello che setta errflag (vedi cnoise.f)... |
145 |
|
|
c$$$ |
146 |
|
|
c$$$ endif |
147 |
|
|
|
148 |
|
|
10 continue |
149 |
|
|
|
150 |
|
|
return |
151 |
|
|
end |