1 |
kusanagi |
1.3 |
|
2 |
|
|
C------------------------------------------------ |
3 |
kusanagi |
1.5 |
SUBROUTINE CALUNPACK(vectb,lung,me) |
4 |
kusanagi |
1.3 |
c SUBROUTINE CALUNPACK(vect,dexy,dexyc,base, |
5 |
|
|
c & calselftrig,calIItrig, |
6 |
|
|
c & calstripshit,calDSPtaberr,calevnum, |
7 |
|
|
c & merror,contr,e2) |
8 |
|
|
C------------------------------------------------ |
9 |
|
|
|
10 |
|
|
IMPLICIT NONE |
11 |
|
|
C |
12 |
|
|
C Normal variables definition |
13 |
|
|
C |
14 |
|
|
INTEGER SOGLIA |
15 |
|
|
PARAMETER (SOGLIA=27) |
16 |
kusanagi |
1.5 |
c PARAMETER (SOGLIA=24) |
17 |
|
|
integer lung, me, pro, m |
18 |
kusanagi |
1.3 |
c |
19 |
|
|
INTEGER NPLA, NCHA, LENSEV |
20 |
|
|
PARAMETER (NPLA=22,NCHA=96,LENSEV=NPLA*NCHA) |
21 |
|
|
|
22 |
|
|
INTEGER merror(4) |
23 |
|
|
C |
24 |
kusanagi |
1.5 |
INTEGER i, j, iev, min, st2c, bit, bi |
25 |
kusanagi |
1.3 |
C |
26 |
kusanagi |
1.5 |
INTEGER*1 VECTA(40000) |
27 |
|
|
INTEGER*1 VECTB(40000) |
28 |
|
|
c INTEGER*2 VECTD(20000) |
29 |
|
|
INTEGER*2 VECT(20000), test |
30 |
kusanagi |
1.3 |
C |
31 |
kusanagi |
1.5 |
integer*2 check, crc, e2(4), prova, prova2,prova3 |
32 |
kusanagi |
1.3 |
C |
33 |
|
|
INTEGER ic, k,l, ke, ic0, icsave(1000), chi(1000) |
34 |
|
|
INTEGER status, contr, cstatus, co, nta, conte |
35 |
kusanagi |
1.5 |
INTEGER inf, sup, em, esci, icb |
36 |
kusanagi |
1.3 |
INTEGER XO, YO, XE, YE, iev2 |
37 |
|
|
|
38 |
|
|
INTEGER*2 length, length2 |
39 |
|
|
|
40 |
kusanagi |
1.5 |
INTEGER*2 st1, st2, cst1, st4 |
41 |
|
|
|
42 |
|
|
integer st1b, st2b |
43 |
kusanagi |
1.3 |
|
44 |
|
|
INTEGER*2 ival |
45 |
|
|
PARAMETER (ival='FFFF'x) |
46 |
|
|
|
47 |
|
|
real dedx1(11,96),dedx2(11,96),dedx3(11,96),dedx4(11,96) |
48 |
|
|
real dedx1c(11,96),dedx2c(11,96),dedx3c(11,96),dedx4c(11,96) |
49 |
|
|
real base1(11,6),base2(11,6),base3(11,6),base4(11,6) |
50 |
|
|
REAL DEXY(2,NPLA,NCHA), dexyc(2,npla,ncha), base(2,npla,ncha) |
51 |
|
|
|
52 |
|
|
|
53 |
|
|
real auto(7) |
54 |
|
|
real calselftrig(4,7), calIItrig(4), calstripshit(4), |
55 |
|
|
& calDSPtaberr(4), calevnum(4) |
56 |
|
|
|
57 |
|
|
DATA XO/241/ ! CODE_EV_R XO = 111 10001 |
58 |
|
|
DATA YO/237/ ! CODE_EV_R YO = 111 01101 |
59 |
|
|
DATA XE/234/ ! CODE_EV_R XE = 111 01010 |
60 |
|
|
DATA YE/246/ ! CODE_EV_R YE = 111 10110 |
61 |
|
|
|
62 |
|
|
REAL calped(4,11,96), calgood(4,11,96), calthr(4,11,6) |
63 |
|
|
REAL calrms(4,11,96), calbase(4,11,6), calvar(4,11,6) |
64 |
|
|
REAL calpuls(4,11,96) |
65 |
|
|
|
66 |
|
|
COMMON / evento / IEV, |
67 |
|
|
& dexy,dexyc,base, |
68 |
|
|
& calselftrig,calIItrig, |
69 |
|
|
& calstripshit,calDSPtaberr,calevnum |
70 |
|
|
|
71 |
|
|
save / evento / |
72 |
|
|
|
73 |
|
|
COMMON / calib / IEV2, calped, calgood, calthr, calrms, |
74 |
|
|
& calbase, |
75 |
|
|
& calvar, |
76 |
|
|
& calpuls |
77 |
|
|
|
78 |
|
|
save / calib / |
79 |
|
|
|
80 |
|
|
c |
81 |
|
|
COMMON / VARIE / merror, CONTR, E2 |
82 |
|
|
SAVE / VARIE / |
83 |
|
|
|
84 |
|
|
C |
85 |
|
|
C Begin ! |
86 |
|
|
C |
87 |
kusanagi |
1.5 |
cc print *,' INIZIO ' |
88 |
|
|
|
89 |
|
|
min = 0 |
90 |
|
|
m = 0 |
91 |
|
|
do i=1,40000, 2 |
92 |
|
|
vecta(i) = vectb(i+1) |
93 |
|
|
vecta(i+1) = vectb(i) |
94 |
|
|
m = m + 1 |
95 |
|
|
vect(m) = 0 |
96 |
|
|
enddo |
97 |
|
|
c |
98 |
|
|
c do i=1,40 |
99 |
|
|
c write(*,10)i,vecta(i) |
100 |
|
|
c enddo |
101 |
|
|
c m = 2 |
102 |
|
|
c do i = 1, 20000 |
103 |
|
|
c do bit=0, 7 |
104 |
|
|
c bi = ibits(vecta(m+1),bit,1) |
105 |
|
|
c if (bi.eq.1) vectd(i) = ibset(vectd(i),bit) |
106 |
|
|
c bi = ibits(vecta(m),bit,1) |
107 |
|
|
c if (bi.eq.1) vectd(i) = ibset(vectd(i),bit+8) |
108 |
|
|
c enddo |
109 |
|
|
c m = m + 2 |
110 |
|
|
cc write(*,15)i,vectd(i) |
111 |
|
|
c enddo |
112 |
|
|
c |
113 |
|
|
call minerr(ic,icsave,chi,min,co) |
114 |
|
|
call azero(calped,4*11*96) |
115 |
|
|
call azero(calgood,4*11*96) |
116 |
|
|
call azero(calthr,4*11*96) |
117 |
|
|
call azero(calrms,4*11*96) |
118 |
|
|
call azero(calbase,4*11*6) |
119 |
|
|
call azero(calvar,4*11*6) |
120 |
|
|
call azero(calpuls,4*11*96) |
121 |
|
|
call azero(dexy,4*11*96) |
122 |
|
|
call azero(dexyc,4*11*96) |
123 |
|
|
call azero(base,4*11*96) |
124 |
|
|
call azero(calselftrig,4*7) |
125 |
|
|
call azero(calIItrig,4) |
126 |
|
|
call azero(calstripshit,4) |
127 |
|
|
call azero(calDSPtaberr,4) |
128 |
|
|
call azero(calevnum,4) |
129 |
|
|
do l = 1,4 |
130 |
|
|
e2(l) = 0 |
131 |
|
|
enddo |
132 |
|
|
do l = 1,4 |
133 |
|
|
merror(l) = 0 |
134 |
|
|
enddo |
135 |
|
|
c |
136 |
kusanagi |
1.3 |
do l = 1,1000 |
137 |
|
|
icsave(l) = 0 |
138 |
|
|
chi(l) = 0 |
139 |
|
|
enddo |
140 |
|
|
em = 0 |
141 |
|
|
co = 0 |
142 |
|
|
esci = 0 |
143 |
|
|
me = 1 |
144 |
|
|
c |
145 |
|
|
contr = 1 |
146 |
|
|
c |
147 |
|
|
ic = 0 |
148 |
kusanagi |
1.5 |
icb = 0 |
149 |
kusanagi |
1.3 |
nta = 0 |
150 |
|
|
c |
151 |
kusanagi |
1.5 |
length2 = ic - 2 |
152 |
kusanagi |
1.3 |
c |
153 |
|
|
20 continue |
154 |
|
|
nta = nta + 1 |
155 |
kusanagi |
1.5 |
c if (ic.eq.3016) print *,'prima ic = ',ic, length |
156 |
|
|
c ic = ic + length + 1 |
157 |
|
|
if (length2.ge.-2) then |
158 |
|
|
ic = ic + (2 * (length2 + 2)) |
159 |
|
|
else |
160 |
|
|
print *,'WARNING: ',ic,length2,nta |
161 |
|
|
endif |
162 |
|
|
c |
163 |
|
|
32 continue |
164 |
|
|
c |
165 |
|
|
c print *,'dopo ic = ',ic |
166 |
|
|
c |
167 |
kusanagi |
1.3 |
ke = 0 |
168 |
|
|
do while (ke.eq.0) |
169 |
|
|
C |
170 |
|
|
C Check consistency of header. |
171 |
|
|
C it is composed by CODE+D# (8 bits) and by SATUS WORD (8 bits) |
172 |
|
|
c so we must split vect into the two components: |
173 |
|
|
C |
174 |
|
|
C ST1 is CODE + D# |
175 |
kusanagi |
1.5 |
cb status = ISHFT(vect(ic),-8) |
176 |
|
|
cb st1 = IAND(status,'00FF'x) |
177 |
|
|
c print *,'ic ',ic |
178 |
|
|
st1b = 0 |
179 |
|
|
st2b = 0 |
180 |
|
|
do bit = 0, 7 |
181 |
|
|
bi = ibits(vecta(ic),bit,1) |
182 |
|
|
if (bi.eq.1) st1b = ibset(st1b,bit) |
183 |
|
|
bi = ibits(vecta(ic+1),bit,1) |
184 |
|
|
if (bi.eq.1) st2b = ibset(st2b,bit) |
185 |
|
|
enddo |
186 |
|
|
c write(*,15)ic,st1b |
187 |
|
|
c print *,st1b |
188 |
kusanagi |
1.3 |
C ST2 is the STATUS WORD |
189 |
kusanagi |
1.5 |
cb st2 = IAND(vect(ic),'00FF'x) |
190 |
|
|
c st2b = vecta(ic+1) |
191 |
|
|
c if (st1b.gt.200) then |
192 |
|
|
c write(*,15)ic,st1b |
193 |
|
|
c print *,st1b |
194 |
|
|
c write(*,15)ic,st2b |
195 |
|
|
c print *,st2b |
196 |
|
|
c endif |
197 |
|
|
c |
198 |
|
|
length2 = 0 |
199 |
|
|
do bit=0, 7 |
200 |
|
|
bi = ibits(vecta(ic+3),bit,1) |
201 |
|
|
if (bi.eq.1) length2 = ibset(length2,bit) |
202 |
|
|
bi = ibits(vecta(ic+2),bit,1) |
203 |
|
|
if (bi.eq.1) length2 = ibset(length2,bit+8) |
204 |
|
|
enddo |
205 |
|
|
cb length2 = vect(ic+1) |
206 |
kusanagi |
1.3 |
c the crc should be at vect(length) with |
207 |
kusanagi |
1.5 |
length = length2 + 1 |
208 |
|
|
cb length = ic + vect(ic+1) + 1 |
209 |
kusanagi |
1.3 |
C |
210 |
|
|
c some checks to be sure we have found the calorimeter data: |
211 |
|
|
c |
212 |
|
|
c status word is always less then 129 |
213 |
|
|
c |
214 |
kusanagi |
1.5 |
if (st2b.gt.128) then |
215 |
|
|
length = 0 |
216 |
|
|
goto 100 |
217 |
|
|
endif |
218 |
kusanagi |
1.3 |
c |
219 |
|
|
c length of the packet must be less then 20000 if no errors |
220 |
|
|
c are found |
221 |
|
|
c |
222 |
kusanagi |
1.5 |
if (st2b.eq.0.and.length2.gt.20000) then |
223 |
|
|
length = 0 |
224 |
|
|
goto 100 |
225 |
|
|
endif |
226 |
kusanagi |
1.3 |
c |
227 |
kusanagi |
1.5 |
if (length2.lt.0) then |
228 |
|
|
length = 0 |
229 |
|
|
goto 100 |
230 |
|
|
endif |
231 |
|
|
c |
232 |
kusanagi |
1.3 |
e2(contr) = 0 |
233 |
|
|
C |
234 |
|
|
if (contr.eq.1) then |
235 |
|
|
c |
236 |
|
|
c is it the first section? |
237 |
|
|
c |
238 |
kusanagi |
1.5 |
if (st1b.eq.YE) then |
239 |
kusanagi |
1.3 |
c if so go out of this loop and go on recording data |
240 |
|
|
ke = 1 |
241 |
|
|
if (em.eq.0) then |
242 |
|
|
em = 1 |
243 |
|
|
co = co + 1 |
244 |
kusanagi |
1.5 |
c print *,'1 uno',ic, nta |
245 |
kusanagi |
1.3 |
icsave(co) = ic |
246 |
|
|
endif |
247 |
kusanagi |
1.5 |
m = ic |
248 |
|
|
do i = 1, 20000 |
249 |
|
|
vect(i) = 0 |
250 |
|
|
do bit=0, 7 |
251 |
|
|
bi = ibits(vecta(m+1),bit,1) |
252 |
|
|
if (bi.eq.1) vect(i) = ibset(vect(i),bit) |
253 |
|
|
bi = ibits(vecta(m),bit,1) |
254 |
|
|
if (bi.eq.1) vect(i) = ibset(vect(i),bit+8) |
255 |
|
|
enddo |
256 |
|
|
m = m + 2 |
257 |
|
|
c write(*,15)i,vectd(i) |
258 |
|
|
enddo |
259 |
|
|
icb = 1 |
260 |
|
|
if (st2b.ne.0) then |
261 |
|
|
E2(contr) = vect(icb) |
262 |
kusanagi |
1.3 |
call contaer(e2(contr),chi(co)) |
263 |
|
|
endif |
264 |
|
|
else |
265 |
|
|
c if not, is it one of the next sections? did we miss a section? |
266 |
kusanagi |
1.5 |
if (st1b.eq.YO.or.st1b.eq.XE.or.st1b.eq.XO) THEN |
267 |
|
|
c print *,'sono qua',ic |
268 |
kusanagi |
1.3 |
c if so, record an error and go back analizing this section |
269 |
|
|
merror(contr) = 129 |
270 |
|
|
contr = 2 |
271 |
kusanagi |
1.5 |
c length = -1 |
272 |
kusanagi |
1.3 |
if (em.eq.0) then |
273 |
|
|
em = 1 |
274 |
|
|
co = co + 1 |
275 |
kusanagi |
1.5 |
c print *,'2 due',ic, nta |
276 |
kusanagi |
1.3 |
icsave(co) = ic |
277 |
|
|
endif |
278 |
|
|
chi(co) = chi(co) + 8 |
279 |
kusanagi |
1.5 |
goto 32 |
280 |
kusanagi |
1.3 |
ELSE |
281 |
|
|
c if it is not the case, go on with the next value of vect |
282 |
|
|
GOTO 100 |
283 |
|
|
endif |
284 |
|
|
endif |
285 |
|
|
ENDIF |
286 |
|
|
C |
287 |
|
|
c the same for the second section, ... |
288 |
|
|
c |
289 |
|
|
if (CONTR.eq.2) then |
290 |
kusanagi |
1.5 |
if (st1b.eq.YO) then |
291 |
kusanagi |
1.3 |
ke = 1 |
292 |
|
|
if (em.eq.0) then |
293 |
|
|
em = 1 |
294 |
|
|
co = co + 1 |
295 |
kusanagi |
1.5 |
c print *,'2 due ',ic, nta |
296 |
kusanagi |
1.3 |
icsave(co) = ic |
297 |
|
|
endif |
298 |
kusanagi |
1.5 |
c print *,'ic2 ',ic |
299 |
|
|
m = ic |
300 |
|
|
do i = 1, 20000 |
301 |
|
|
vect(i) = 0 |
302 |
|
|
do bit=0, 7 |
303 |
|
|
bi = ibits(vecta(m+1),bit,1) |
304 |
|
|
if (bi.eq.1) vect(i) = ibset(vect(i),bit) |
305 |
|
|
bi = ibits(vecta(m),bit,1) |
306 |
|
|
if (bi.eq.1) vect(i) = ibset(vect(i),bit+8) |
307 |
|
|
enddo |
308 |
|
|
m = m + 2 |
309 |
|
|
c write(*,15)i,vectd(i) |
310 |
|
|
enddo |
311 |
|
|
icb = 1 |
312 |
|
|
if (st2b.ne.0) then |
313 |
|
|
E2(contr) = vect(icb) |
314 |
kusanagi |
1.3 |
call contaer(e2(contr),chi(co)) |
315 |
|
|
endif |
316 |
kusanagi |
1.5 |
c print *,'e ora qui!',ic |
317 |
|
|
goto 9 |
318 |
kusanagi |
1.3 |
else |
319 |
kusanagi |
1.5 |
if (st1b.eq.XE.or.st1b.eq.XO) then |
320 |
kusanagi |
1.3 |
merror(contr) = 129 |
321 |
|
|
contr = 3 |
322 |
kusanagi |
1.5 |
c length = -1 |
323 |
kusanagi |
1.3 |
if (em.eq.0) then |
324 |
|
|
em = 1 |
325 |
|
|
co = co + 1 |
326 |
kusanagi |
1.5 |
c print *,'3 tre ',ic, nta |
327 |
kusanagi |
1.3 |
icsave(co) = ic |
328 |
|
|
endif |
329 |
|
|
chi(co) = chi(co) + 8 |
330 |
kusanagi |
1.5 |
goto 32 |
331 |
kusanagi |
1.3 |
ELSE |
332 |
|
|
GOTO 100 |
333 |
|
|
endif |
334 |
|
|
endif |
335 |
|
|
ENDIF |
336 |
|
|
c |
337 |
|
|
C ... for the third,... |
338 |
|
|
c |
339 |
|
|
if (CONTR.eq.3) then |
340 |
kusanagi |
1.5 |
if (st1b.eq.XE) then |
341 |
kusanagi |
1.3 |
ke = 1 |
342 |
|
|
if (em.eq.0) then |
343 |
|
|
em = 1 |
344 |
|
|
co = co + 1 |
345 |
kusanagi |
1.5 |
c print *,'3 tre', ic, nta |
346 |
kusanagi |
1.3 |
icsave(co) = ic |
347 |
|
|
endif |
348 |
kusanagi |
1.5 |
m = ic |
349 |
|
|
c print *,'ic3 ',ic |
350 |
|
|
do i = 1, 20000 |
351 |
|
|
vect(i) = 0 |
352 |
|
|
do bit=0, 7 |
353 |
|
|
bi = ibits(vecta(m+1),bit,1) |
354 |
|
|
if (bi.eq.1) vect(i) = ibset(vect(i),bit) |
355 |
|
|
bi = ibits(vecta(m),bit,1) |
356 |
|
|
if (bi.eq.1) vect(i) = ibset(vect(i),bit+8) |
357 |
|
|
enddo |
358 |
|
|
m = m + 2 |
359 |
|
|
c write(*,15)i,vectd(i) |
360 |
|
|
enddo |
361 |
|
|
icb = 1 |
362 |
|
|
if (st2b.ne.0) then |
363 |
|
|
E2(contr) = vect(icb) |
364 |
kusanagi |
1.3 |
call contaer(e2(contr),chi(co)) |
365 |
|
|
endif |
366 |
kusanagi |
1.5 |
goto 9 |
367 |
kusanagi |
1.3 |
else |
368 |
kusanagi |
1.5 |
if (st1b.eq.XO) then |
369 |
kusanagi |
1.3 |
merror(contr) = 129 |
370 |
|
|
contr = 4 |
371 |
kusanagi |
1.5 |
c length = -1 |
372 |
kusanagi |
1.3 |
if (em.eq.0) then |
373 |
|
|
em = 1 |
374 |
|
|
co = co + 1 |
375 |
kusanagi |
1.5 |
c print *,'6' |
376 |
kusanagi |
1.3 |
icsave(co) = ic |
377 |
|
|
endif |
378 |
|
|
chi(co) = chi(co) + 8 |
379 |
kusanagi |
1.5 |
goto 32 |
380 |
kusanagi |
1.3 |
ELSE |
381 |
|
|
GOTO 100 |
382 |
|
|
endif |
383 |
|
|
endif |
384 |
|
|
ENDIF |
385 |
|
|
C |
386 |
|
|
c ...and for the last section. |
387 |
|
|
c |
388 |
|
|
if (CONTR.eq.4) then |
389 |
kusanagi |
1.5 |
if (st1b.eq.XO) then |
390 |
kusanagi |
1.3 |
ke = 1 |
391 |
|
|
if (em.eq.0) then |
392 |
|
|
em = 1 |
393 |
|
|
co = co + 1 |
394 |
kusanagi |
1.5 |
c print *,'4 quattro', ic, nta |
395 |
kusanagi |
1.3 |
icsave(co) = ic |
396 |
|
|
endif |
397 |
kusanagi |
1.5 |
m = ic |
398 |
|
|
do i = 1, 20000 |
399 |
|
|
vect(i) = 0 |
400 |
|
|
do bit=0, 7 |
401 |
|
|
bi = ibits(vecta(m+1),bit,1) |
402 |
|
|
if (bi.eq.1) vect(i) = ibset(vect(i),bit) |
403 |
|
|
bi = ibits(vecta(m),bit,1) |
404 |
|
|
if (bi.eq.1) vect(i) = ibset(vect(i),bit+8) |
405 |
|
|
enddo |
406 |
|
|
m = m + 2 |
407 |
|
|
c write(*,15)i,vectd(i) |
408 |
|
|
enddo |
409 |
|
|
icb = 1 |
410 |
|
|
c print *,'qui' |
411 |
|
|
if (st2b.ne.0) then |
412 |
|
|
E2(contr) = vect(icb) |
413 |
kusanagi |
1.3 |
call contaer(e2(contr),chi(co)) |
414 |
|
|
endif |
415 |
kusanagi |
1.5 |
c goto 9 |
416 |
kusanagi |
1.3 |
else |
417 |
kusanagi |
1.5 |
cc we should never arrive here (in case we run out of vector if section |
418 |
|
|
cc four is missing!)... however here it is in case of bugs! |
419 |
|
|
c merror(contr) = 129 |
420 |
|
|
c contr = 5 |
421 |
|
|
c if (em.eq.0) then |
422 |
|
|
c em = 1 |
423 |
|
|
c co = co + 1 |
424 |
|
|
c icsave(co) = ic |
425 |
|
|
c endif |
426 |
|
|
c chi(co) = chi(co) + 8 |
427 |
|
|
c GOTO 200 |
428 |
|
|
goto 100 |
429 |
kusanagi |
1.3 |
endif |
430 |
|
|
endif |
431 |
|
|
C |
432 |
|
|
100 CONTINUE |
433 |
|
|
c |
434 |
|
|
c increment vector of one searching for the next section |
435 |
|
|
c |
436 |
kusanagi |
1.5 |
9 continue |
437 |
kusanagi |
1.3 |
ic = ic + 1 |
438 |
|
|
c |
439 |
|
|
c if we run out of vector give an error and exit the subroutine |
440 |
|
|
c |
441 |
kusanagi |
1.5 |
if (ic.gt.39999) then |
442 |
|
|
if (co.eq.0) co = 1 |
443 |
kusanagi |
1.3 |
chi(co) = chi(co) + 8 * (5 - contr) |
444 |
|
|
merror(contr) = 130 |
445 |
|
|
if (contr.ne.1) contr=5 |
446 |
kusanagi |
1.5 |
c if (em.eq.0) then |
447 |
|
|
c em = 1 |
448 |
|
|
c co = co + 1 |
449 |
|
|
c icsave(co) = ic |
450 |
|
|
c endif |
451 |
|
|
cc print *,'scappa di qua' |
452 |
kusanagi |
1.3 |
goto 200 |
453 |
|
|
endif |
454 |
|
|
enddo |
455 |
|
|
C |
456 |
|
|
c format not used |
457 |
|
|
c |
458 |
|
|
10 FORMAT(2X,'Error for view:',2X,I1,2X,'Status word:',2X,Z4) |
459 |
|
|
11 FORMAT(2X,'View or command not recognized for view:',2X,I1,2X, |
460 |
|
|
& 'Status word:',2X,Z4) |
461 |
|
|
12 FORMAT(2X,'Error - did NOT find view:',2X,I1) |
462 |
|
|
13 FORMAT(2X,'Error - eof reached, exiting') |
463 |
|
|
14 FORMAT(2X,I8,2X,I10) |
464 |
kusanagi |
1.5 |
15 FORMAT(2X,I8,2X,Z8) |
465 |
kusanagi |
1.3 |
C |
466 |
|
|
c go on recording data |
467 |
kusanagi |
1.5 |
ic = ic - 1 |
468 |
kusanagi |
1.3 |
c |
469 |
|
|
K = CONTR |
470 |
kusanagi |
1.5 |
ic0 = icb |
471 |
|
|
icb = icb + 1 |
472 |
|
|
c do pro=-5,15 |
473 |
|
|
length = vect(icb) + 2 !+ 13 |
474 |
|
|
cc print *,'length vect(ic)',length, vect(ic) |
475 |
|
|
length2 = vect(icb) |
476 |
|
|
c write(*,10)nta,vect(icb-1) |
477 |
|
|
c print *,'length ' ,length2, contr |
478 |
kusanagi |
1.3 |
C |
479 |
|
|
C Check consistency of CRC. |
480 |
|
|
C |
481 |
|
|
check = 0. |
482 |
|
|
inf = ic0 |
483 |
|
|
sup = length - 1 |
484 |
|
|
do i = inf,sup |
485 |
|
|
check=crc(check,vect(i)) |
486 |
|
|
enddo |
487 |
kusanagi |
1.5 |
c print *,'check, CRC+1', check, vect(length+3) |
488 |
|
|
c print *,'check, CRC+2', check, vect(length+2) |
489 |
|
|
c print *,'check, CRC+3', check, vect(length+1) |
490 |
|
|
c print *,'check, CRC', check, vect(length), pro |
491 |
|
|
c print *,'check, CRC-1', check, vect(length-1) |
492 |
|
|
c print *,'check, CRC-2', check, vect(length-2) |
493 |
|
|
c print *,'check, CRC-3', check, vect(length-3) |
494 |
|
|
c enddo |
495 |
|
|
c print *,'length2 ',length2 |
496 |
|
|
c if (check.eq.vect(length)) print *,'******ESATTO!*****' |
497 |
|
|
c print *,'ic, contr ',ic, contr |
498 |
kusanagi |
1.3 |
if (check.ne.vect(length)) then |
499 |
|
|
merror(contr) = 132 |
500 |
|
|
chi(co) = chi(co) + 4 |
501 |
kusanagi |
1.5 |
c print *,'hai cannato il CRC',ic,check |
502 |
|
|
cv |
503 |
|
|
ic = ic + 1 |
504 |
|
|
c goto 150 |
505 |
|
|
contr = contr - 1 |
506 |
|
|
goto 32 |
507 |
kusanagi |
1.3 |
endif |
508 |
kusanagi |
1.5 |
C |
509 |
kusanagi |
1.3 |
C Process data. |
510 |
|
|
C |
511 |
kusanagi |
1.5 |
do i = 1, 7 |
512 |
|
|
icb = icb + 1 |
513 |
|
|
auto(i) = vect(icb) |
514 |
kusanagi |
1.3 |
enddo |
515 |
|
|
C |
516 |
kusanagi |
1.5 |
c st4 = 0 |
517 |
|
|
c st4 = IAND(st2b,'00FF'x) |
518 |
|
|
if (st2b.ne.0) then |
519 |
|
|
do bit=0, 6 |
520 |
|
|
bi = ibits(st2b,bit,1) |
521 |
|
|
if (bit.eq.3.and.bi.ne.0) st2c = 8 |
522 |
|
|
enddo |
523 |
|
|
endif |
524 |
|
|
C |
525 |
|
|
if (st2c.eq.8) then |
526 |
kusanagi |
1.3 |
if (length2.ne.1064) then |
527 |
|
|
c print *,'Problems with view:',k,' in Raw mode length:', |
528 |
|
|
c & length2 |
529 |
|
|
merror(contr) = 133 |
530 |
|
|
chi(co) = chi(co) + 4 |
531 |
|
|
goto 150 |
532 |
kusanagi |
1.5 |
else |
533 |
|
|
if (k.eq.1) call CALRAW(vect,icb+1,length-1,dedx1) |
534 |
|
|
if (k.eq.2) call CALRAW(vect,icb+1,length-1,dedx2) |
535 |
|
|
if (k.eq.3) call CALRAW(vect,icb+1,length-1,dedx3) |
536 |
|
|
if (k.eq.4) call CALRAW(vect,icb+1,length-1,dedx4) |
537 |
kusanagi |
1.3 |
endif |
538 |
kusanagi |
1.5 |
c print *,'ciao', ic |
539 |
|
|
goto 50 |
540 |
kusanagi |
1.3 |
endif |
541 |
|
|
C |
542 |
|
|
41 FORMAT(2X,I2,2X,'word :',1x,z4) |
543 |
kusanagi |
1.5 |
c icb = icb - 1 |
544 |
|
|
test = vect(icb+3) |
545 |
|
|
c write(*,10)ic,test |
546 |
|
|
if (test.eq.ival) then |
547 |
kusanagi |
1.3 |
if (length2.gt.1201) then |
548 |
|
|
c print *,'Problems with view:',k, |
549 |
|
|
c & ' in Compress mode length:',length2 |
550 |
|
|
merror(contr) = 134 |
551 |
|
|
chi(co) = chi(co) + 4 |
552 |
|
|
goto 150 |
553 |
|
|
else |
554 |
kusanagi |
1.5 |
icb = icb + 1 |
555 |
|
|
calIItrig(k) = vect(icb) |
556 |
|
|
icb = icb + 1 |
557 |
|
|
calstripshit(k) = vect(icb) |
558 |
|
|
icb = icb + 1 |
559 |
|
|
C qui c'e` test! |
560 |
|
|
icb = icb + 1 |
561 |
|
|
calDSPtaberr(k) = vect(icb) |
562 |
|
|
icb = icb + 1 |
563 |
|
|
calevnum(k) = vect(icb) |
564 |
|
|
c |
565 |
|
|
merror(contr) = 137 |
566 |
|
|
c print *,'compress!' |
567 |
|
|
if (k.eq.1) call CALCOMPRESS(vect,icb+1,length-1,dedx1, |
568 |
kusanagi |
1.3 |
& base1) |
569 |
kusanagi |
1.5 |
if (k.eq.2) call CALCOMPRESS(vect,icb+1,length-1,dedx2, |
570 |
kusanagi |
1.3 |
& base2) |
571 |
kusanagi |
1.5 |
if (k.eq.3) call CALCOMPRESS(vect,icb+1,length-1,dedx3, |
572 |
kusanagi |
1.3 |
& base3) |
573 |
kusanagi |
1.5 |
if (k.eq.4) call CALCOMPRESS(vect,icb+1,length-1,dedx4, |
574 |
kusanagi |
1.3 |
& base4) |
575 |
kusanagi |
1.5 |
goto 50 |
576 |
kusanagi |
1.3 |
endif |
577 |
kusanagi |
1.5 |
else if (test.eq.0) then |
578 |
kusanagi |
1.3 |
if (length2.gt.2257) then |
579 |
|
|
c print *,'Problems with view:',k,' in Full mode length:', |
580 |
|
|
c & length2 |
581 |
|
|
merror(contr) = 135 |
582 |
|
|
chi(co) = chi(co) + 4 |
583 |
|
|
goto 150 |
584 |
|
|
else |
585 |
|
|
c write(*,41) ic,vect(ic) |
586 |
kusanagi |
1.5 |
icb = icb + 1 |
587 |
|
|
calIItrig(k) = vect(icb) |
588 |
|
|
icb = icb + 1 |
589 |
|
|
calstripshit(k) = vect(icb) |
590 |
|
|
icb = icb + 1 |
591 |
|
|
C qui c'e` test |
592 |
|
|
icb = icb + 1 |
593 |
|
|
calDSPtaberr(k) = vect(icb) |
594 |
|
|
icb = icb + 1 |
595 |
|
|
calevnum(k) = vect(icb) |
596 |
|
|
c print *,'full ' |
597 |
|
|
merror(contr) = 138 |
598 |
|
|
c |
599 |
|
|
if (k.eq.1) call CALFULL(vect,icb+1,length-1,dedx1, |
600 |
kusanagi |
1.3 |
& dedx1c,base1) |
601 |
kusanagi |
1.5 |
if (k.eq.2) call CALFULL(vect,icb+1,length-1,dedx2, |
602 |
kusanagi |
1.3 |
& dedx2c,base2) |
603 |
kusanagi |
1.5 |
if (k.eq.3) call CALFULL(vect,icb+1,length-1,dedx3, |
604 |
kusanagi |
1.3 |
& dedx3c,base3) |
605 |
kusanagi |
1.5 |
if (k.eq.4) call CALFULL(vect,icb+1,length-1,dedx4, |
606 |
kusanagi |
1.3 |
& dedx4c,base4) |
607 |
kusanagi |
1.5 |
goto 50 |
608 |
kusanagi |
1.3 |
endif |
609 |
|
|
else |
610 |
|
|
c print *,'Acq mode problems with view:',k |
611 |
kusanagi |
1.5 |
write(*,10)nta,test |
612 |
kusanagi |
1.3 |
merror(contr) = 136 |
613 |
|
|
chi(co) = chi(co) + 4 |
614 |
kusanagi |
1.5 |
goto 150 |
615 |
kusanagi |
1.3 |
endif |
616 |
|
|
C |
617 |
|
|
do i = 1,7 |
618 |
|
|
calselftrig(k,i) = auto(i) |
619 |
|
|
enddo |
620 |
|
|
c |
621 |
|
|
50 continue |
622 |
|
|
c |
623 |
|
|
C |
624 |
|
|
DO I = 1,11 |
625 |
|
|
DO J = 1,96 |
626 |
|
|
DEXY(2,2*I-1,97-J) = DEDX1(I,J) |
627 |
|
|
DEXY(1,2*I-1,J) = DEDX2(I,J) |
628 |
|
|
DEXY(2,2*I,J) = DEDX3(I,J) |
629 |
|
|
DEXY(1,2*I,J) = DEDX4(I,J) |
630 |
|
|
DEXYC(2,2*I-1,97-J) = DEDX1C(I,J) |
631 |
|
|
DEXYC(1,2*I-1,J) = DEDX2C(I,J) |
632 |
|
|
DEXYC(2,2*I,J) = DEDX3C(I,J) |
633 |
|
|
DEXYC(1,2*I,J) = DEDX4C(I,J) |
634 |
|
|
enddo |
635 |
|
|
do j = 1,6 |
636 |
|
|
base(2,2*i-1,7-j) = base1(i,j) |
637 |
|
|
base(1,2*i-1,j) = base2(i,j) |
638 |
|
|
base(2,2*i,j) = base3(i,j) |
639 |
|
|
base(1,2*i,j) = base4(i,j) |
640 |
|
|
enddo |
641 |
|
|
enddo |
642 |
|
|
C |
643 |
|
|
150 continue |
644 |
|
|
C |
645 |
|
|
contr = contr + 1 |
646 |
|
|
C |
647 |
|
|
c go on till we have found all the four sections |
648 |
kusanagi |
1.5 |
cc |
649 |
|
|
c print *,contr, ic, length |
650 |
|
|
c print *,contr, ic |
651 |
kusanagi |
1.3 |
c |
652 |
kusanagi |
1.5 |
if (contr.lt.5) goto 20 |
653 |
kusanagi |
1.3 |
c |
654 |
|
|
c |
655 |
|
|
c |
656 |
|
|
200 continue |
657 |
|
|
C |
658 |
|
|
C if all section are missing clear vectors and go out |
659 |
|
|
C |
660 |
|
|
if (merror(1).eq.129.and.merror(2).eq.129 |
661 |
|
|
& .and.merror(3).eq.129.and.merror(4).eq.130) then |
662 |
|
|
do l = 1,4 |
663 |
|
|
e2(l) = 0 |
664 |
|
|
enddo |
665 |
|
|
do l = 1,4 |
666 |
|
|
merror(l) = 0 |
667 |
|
|
enddo |
668 |
kusanagi |
1.5 |
call azero(calped,4*11*96) |
669 |
|
|
call azero(calgood,4*11*96) |
670 |
|
|
call azero(calthr,4*11*96) |
671 |
|
|
call azero(calrms,4*11*96) |
672 |
|
|
call azero(calbase,4*11*6) |
673 |
|
|
call azero(calvar,4*11*6) |
674 |
|
|
call azero(calpuls,4*11*96) |
675 |
|
|
call azero(dexy,4*11*96) |
676 |
|
|
call azero(dexyc,4*11*96) |
677 |
|
|
call azero(base,4*11*96) |
678 |
|
|
call azero(calselftrig,4*7) |
679 |
|
|
call azero(calIItrig,4) |
680 |
|
|
call azero(calstripshit,4) |
681 |
|
|
call azero(calDSPtaberr,4) |
682 |
|
|
call azero(calevnum,4) |
683 |
kusanagi |
1.3 |
contr=1 |
684 |
|
|
if (esci.eq.0) then |
685 |
kusanagi |
1.5 |
c call minerr(ic,icsave,chi,min,co) |
686 |
|
|
c length = ic - 1 |
687 |
|
|
c print *,'icsave ',icsave(min) |
688 |
|
|
c print *,'ic ',ic |
689 |
|
|
ic = ic + 1 |
690 |
|
|
nta = nta +1 |
691 |
|
|
goto 32 |
692 |
|
|
else |
693 |
|
|
goto 999 |
694 |
kusanagi |
1.3 |
endif |
695 |
|
|
endif |
696 |
|
|
c |
697 |
|
|
|
698 |
|
|
if (esci.eq.0.and.((co.gt.1.and.icsave(co).eq.icsave(co-1)).or. |
699 |
kusanagi |
1.5 |
& co.eq.1000.or.icsave(co).gt.20000.or.nta.gt.20000).or. |
700 |
|
|
& ic.ge.20000) then |
701 |
kusanagi |
1.3 |
esci = 1 |
702 |
|
|
min = 0 |
703 |
|
|
call minerr(ic,icsave,chi,min,co) |
704 |
kusanagi |
1.5 |
call azero(calped,4*11*96) |
705 |
|
|
call azero(calgood,4*11*96) |
706 |
|
|
call azero(calthr,4*11*96) |
707 |
|
|
call azero(calrms,4*11*96) |
708 |
|
|
call azero(calbase,4*11*6) |
709 |
|
|
call azero(calvar,4*11*6) |
710 |
|
|
call azero(calpuls,4*11*96) |
711 |
|
|
call azero(dexy,4*11*96) |
712 |
|
|
call azero(dexyc,4*11*96) |
713 |
|
|
call azero(base,4*11*96) |
714 |
|
|
call azero(calselftrig,4*7) |
715 |
|
|
call azero(calIItrig,4) |
716 |
|
|
call azero(calstripshit,4) |
717 |
|
|
call azero(calDSPtaberr,4) |
718 |
|
|
call azero(calevnum,4) |
719 |
|
|
do l = 1,4 |
720 |
|
|
e2(l) = 0 |
721 |
|
|
enddo |
722 |
|
|
do l = 1,4 |
723 |
|
|
merror(l) = 0 |
724 |
|
|
enddo |
725 |
kusanagi |
1.3 |
contr = 1 |
726 |
|
|
if (chi(min).lt.SOGLIA) then |
727 |
kusanagi |
1.5 |
c length = -1 + (ic - 2)/2 |
728 |
kusanagi |
1.3 |
me = 0 |
729 |
kusanagi |
1.5 |
c print *,'chi min ',chi(min), co |
730 |
|
|
nta = nta + 1 |
731 |
|
|
goto 32 |
732 |
kusanagi |
1.3 |
else |
733 |
|
|
do l = 1,4 |
734 |
|
|
e2(l) = 0 |
735 |
|
|
enddo |
736 |
|
|
do l = 1,4 |
737 |
|
|
merror(l) = 0 |
738 |
|
|
enddo |
739 |
|
|
me = 1 |
740 |
|
|
goto 999 |
741 |
|
|
endif |
742 |
|
|
endif |
743 |
|
|
c |
744 |
|
|
if (esci.eq.0) then |
745 |
kusanagi |
1.5 |
call azero(calped,4*11*96) |
746 |
|
|
call azero(calgood,4*11*96) |
747 |
|
|
call azero(calthr,4*11*96) |
748 |
|
|
call azero(calrms,4*11*96) |
749 |
|
|
call azero(calbase,4*11*6) |
750 |
|
|
call azero(calvar,4*11*6) |
751 |
|
|
call azero(calpuls,4*11*96) |
752 |
|
|
call azero(dexy,4*11*96) |
753 |
|
|
call azero(dexyc,4*11*96) |
754 |
|
|
call azero(base,4*11*96) |
755 |
|
|
call azero(calselftrig,4*7) |
756 |
|
|
call azero(calIItrig,4) |
757 |
|
|
call azero(calstripshit,4) |
758 |
|
|
call azero(calDSPtaberr,4) |
759 |
|
|
call azero(calevnum,4) |
760 |
|
|
length = 0 |
761 |
|
|
ic = ic + 1 |
762 |
|
|
do l = 1,4 |
763 |
|
|
e2(l) = 0 |
764 |
|
|
enddo |
765 |
|
|
do l = 1,4 |
766 |
|
|
merror(l) = 0 |
767 |
|
|
enddo |
768 |
|
|
goto 32 |
769 |
kusanagi |
1.3 |
endif |
770 |
|
|
c |
771 |
|
|
999 continue |
772 |
|
|
c |
773 |
kusanagi |
1.5 |
c print *,' FINE ' |
774 |
kusanagi |
1.3 |
RETURN |
775 |
|
|
END |
776 |
|
|
|
777 |
|
|
|
778 |
|
|
C------------------------------------------------ |
779 |
|
|
SUBROUTINE CALRAW(vect,inf,sup,dedx) |
780 |
|
|
C------------------------------------------------ |
781 |
|
|
|
782 |
|
|
IMPLICIT NONE |
783 |
|
|
|
784 |
|
|
INTEGER*2 VECT(20000) |
785 |
|
|
INTEGER inf, sup |
786 |
|
|
INTEGER i,j,k, iev,iev2 |
787 |
|
|
|
788 |
|
|
C |
789 |
|
|
INTEGER NPLA, NCHA, LENSEV |
790 |
|
|
PARAMETER (NPLA=22,NCHA=96,LENSEV=NPLA*NCHA) |
791 |
|
|
INTEGER merror(4) |
792 |
|
|
integer*2 e2(4) |
793 |
|
|
INTEGER contr |
794 |
|
|
REAL DEXY(2,NPLA,NCHA), dexyc(2,npla,ncha), base(2,npla,ncha) |
795 |
|
|
|
796 |
|
|
|
797 |
|
|
real calselftrig(4,7), calIItrig(4), calstripshit(4), |
798 |
|
|
& calDSPtaberr(4), calevnum(4) |
799 |
|
|
|
800 |
|
|
|
801 |
|
|
REAL calped(4,11,96), calgood(4,11,96), calthr(4,11,6) |
802 |
|
|
REAL calrms(4,11,96), calbase(4,11,6), calvar(4,11,6) |
803 |
|
|
REAL calpuls(4,11,96) |
804 |
|
|
REAL dedx(11,96) |
805 |
|
|
|
806 |
|
|
COMMON / evento / IEV, |
807 |
|
|
& dexy,dexyc,base, |
808 |
|
|
& calselftrig,calIItrig, |
809 |
|
|
& calstripshit,calDSPtaberr,calevnum |
810 |
|
|
|
811 |
|
|
save / evento / |
812 |
|
|
|
813 |
|
|
COMMON / calib / IEV2, calped, calgood, calthr, calrms, |
814 |
|
|
& calbase, |
815 |
|
|
& calvar, |
816 |
|
|
& calpuls |
817 |
|
|
|
818 |
|
|
save / calib / |
819 |
|
|
c |
820 |
|
|
COMMON / VARIE / merror, CONTR, E2 |
821 |
|
|
SAVE / VARIE / |
822 |
|
|
|
823 |
|
|
C |
824 |
|
|
DO I = 1,11 |
825 |
|
|
DO J = 1,96 |
826 |
|
|
DEDX(I,J) = 0. |
827 |
|
|
ENDDO |
828 |
|
|
ENDDO |
829 |
|
|
C |
830 |
|
|
k = inf |
831 |
|
|
do j = 1,96 |
832 |
|
|
do i = 1,11 |
833 |
kusanagi |
1.5 |
c if (vect(k).ne.0) print *,'ciao!' |
834 |
kusanagi |
1.3 |
dedx(i,j) = vect(k) |
835 |
|
|
k = k + 1 |
836 |
|
|
enddo |
837 |
|
|
enddo |
838 |
|
|
c |
839 |
|
|
RETURN |
840 |
|
|
END |
841 |
|
|
|
842 |
|
|
C------------------------------------------------ |
843 |
|
|
SUBROUTINE CALCOMPRESS(vect,inf,sup,dedx,basse) |
844 |
|
|
C------------------------------------------------ |
845 |
|
|
|
846 |
|
|
IMPLICIT NONE |
847 |
|
|
|
848 |
|
|
INTEGER*2 VECT(20000) , st3 |
849 |
|
|
C |
850 |
|
|
INTEGER inf, sup |
851 |
|
|
INTEGER i,j, iev,iev2 |
852 |
|
|
INTEGER*2 st, st1, st2 |
853 |
|
|
C |
854 |
|
|
INTEGER ib |
855 |
|
|
INTEGER ipl, ipr, ist |
856 |
|
|
C |
857 |
|
|
C |
858 |
|
|
INTEGER NPLA, NCHA, LENSEV |
859 |
|
|
PARAMETER (NPLA=22,NCHA=96,LENSEV=NPLA*NCHA) |
860 |
|
|
INTEGER merror(4) |
861 |
|
|
integer*2 e2(4) |
862 |
|
|
INTEGER contr |
863 |
|
|
REAL DEXY(2,NPLA,NCHA), dexyc(2,npla,ncha), base(2,npla,ncha) |
864 |
|
|
|
865 |
|
|
|
866 |
|
|
real calselftrig(4,7), calIItrig(4), calstripshit(4), |
867 |
|
|
& calDSPtaberr(4), calevnum(4) |
868 |
|
|
|
869 |
|
|
|
870 |
|
|
REAL calped(4,11,96), calgood(4,11,96), calthr(4,11,6) |
871 |
|
|
REAL calrms(4,11,96), calbase(4,11,6), calvar(4,11,6) |
872 |
|
|
REAL calpuls(4,11,96) |
873 |
|
|
REAL dedx(11,96), basse(11,6) |
874 |
|
|
C |
875 |
|
|
COMMON / evento / IEV, |
876 |
|
|
& dexy,dexyc,base, |
877 |
|
|
& calselftrig,calIItrig, |
878 |
|
|
& calstripshit,calDSPtaberr,calevnum |
879 |
|
|
|
880 |
|
|
save / evento / |
881 |
|
|
|
882 |
|
|
COMMON / calib / IEV2, calped, calgood, calthr, calrms, |
883 |
|
|
& calbase, |
884 |
|
|
& calvar, |
885 |
|
|
& calpuls |
886 |
|
|
|
887 |
|
|
save / calib / |
888 |
|
|
c |
889 |
|
|
COMMON / VARIE / merror, CONTR, E2 |
890 |
|
|
SAVE / VARIE / |
891 |
|
|
|
892 |
|
|
C |
893 |
|
|
DO I = 1,11 |
894 |
|
|
DO J = 1,96 |
895 |
|
|
DEDX(I,J) = 0. |
896 |
|
|
ENDDO |
897 |
|
|
do j = 1,6 |
898 |
|
|
basse(i,j) = 0. |
899 |
|
|
enddo |
900 |
|
|
ENDDO |
901 |
|
|
C |
902 |
|
|
c do j = inf-1,inf |
903 |
|
|
c write (*,40) j,vect(j) |
904 |
|
|
c enddo |
905 |
|
|
C |
906 |
kusanagi |
1.5 |
i = inf |
907 |
|
|
c |
908 |
kusanagi |
1.3 |
10 continue |
909 |
|
|
if (i.gt.sup) RETURN |
910 |
|
|
C |
911 |
|
|
40 format(2x,i5,2x,'status :',1x,Z4) |
912 |
kusanagi |
1.5 |
C |
913 |
|
|
c |
914 |
|
|
cb print *,'prima',i, inf, sup |
915 |
|
|
st1 = 0 |
916 |
kusanagi |
1.3 |
st1 = IAND(vect(i),'0800'x) |
917 |
kusanagi |
1.5 |
cb write(*,41)st1 |
918 |
kusanagi |
1.3 |
st1 = ISHFT(st1,-11) |
919 |
|
|
cc st2 = IAND(vect(i),'1000'x) !st2 |
920 |
|
|
cc write(*,42)st2 |
921 |
|
|
cc st2 = ISHFT(st1,-12) !st2 |
922 |
kusanagi |
1.5 |
c |
923 |
|
|
cb write(*,43)vect(i) |
924 |
|
|
cb write(*,41)st1 |
925 |
|
|
cb print *,'dopo' |
926 |
|
|
c write(*,42)st2 |
927 |
|
|
c 41 format(2x,'st1 = ',Z8) |
928 |
|
|
c 42 format(2x,'st2 = ',Z8) |
929 |
|
|
c 43 format(2x,'vect(i) = ',Z8) |
930 |
kusanagi |
1.3 |
cc 44 format(2x,'vect(i) dopo = ',Z8) |
931 |
|
|
C end emi |
932 |
|
|
if (st1.eq.1) then |
933 |
|
|
ib = 1 |
934 |
|
|
else |
935 |
|
|
st2 = IAND(vect(i),'1000'x) !st2 |
936 |
|
|
st2 = ISHFT(st1,-12) !st2 |
937 |
kusanagi |
1.5 |
c write(*,43)vect(i) |
938 |
|
|
c write(*,42)st2 |
939 |
kusanagi |
1.3 |
if (st2.eq.1) then !st2 |
940 |
|
|
ib = 0 |
941 |
|
|
else |
942 |
kusanagi |
1.5 |
c print *,'Calorimeter, problems with coding' |
943 |
|
|
merror(contr) = 139 |
944 |
kusanagi |
1.3 |
RETURN |
945 |
|
|
endif |
946 |
|
|
endif |
947 |
|
|
C |
948 |
kusanagi |
1.5 |
cb print *,'ok ',st1, i |
949 |
|
|
c |
950 |
kusanagi |
1.3 |
if (ib.eq.1) then |
951 |
|
|
C |
952 |
|
|
st = IAND(vect(i),'00FF'x) |
953 |
kusanagi |
1.5 |
c |
954 |
|
|
cb write(*,43)vect(i) |
955 |
|
|
cb write(*,41)st |
956 |
|
|
c |
957 |
kusanagi |
1.3 |
ipl = int(st/6) + 1 |
958 |
kusanagi |
1.5 |
ipr = st - (ipl - 1) * 6 + 1 |
959 |
|
|
c if (ipl.gt.11.or.ipr.gt.6.or.ipl.lt.2.or.ipr.lt.2) |
960 |
|
|
c print *,' 1 ipl, ipr ',ipl,ipr |
961 |
kusanagi |
1.3 |
i = i + 1 |
962 |
kusanagi |
1.5 |
c print *,'1i ',i |
963 |
kusanagi |
1.3 |
basse(ipl,ipr) = vect(i) |
964 |
kusanagi |
1.5 |
c 11 6 |
965 |
kusanagi |
1.3 |
C |
966 |
|
|
20 continue |
967 |
|
|
if (i.gt.sup) RETURN |
968 |
|
|
C |
969 |
|
|
i = i + 1 |
970 |
kusanagi |
1.5 |
c print *,'2i ',i |
971 |
kusanagi |
1.3 |
if (vect(i).gt.16) goto 10 |
972 |
|
|
ist = vect(i) |
973 |
|
|
i = i + 1 |
974 |
kusanagi |
1.5 |
c print *,'3i ',i |
975 |
|
|
dedx(ipl,ist) = vect(i) |
976 |
kusanagi |
1.3 |
C |
977 |
|
|
else |
978 |
|
|
C |
979 |
|
|
st = IAND(vect(i),'00FF'x) |
980 |
|
|
ipl = int(st/6) + 1 |
981 |
kusanagi |
1.5 |
ipr = st - (ipl - 1) * 6 + 1 |
982 |
|
|
c if (ipl.gt.11.or.ipr.gt.6.or.ipl.lt.2.or.ipr.lt.2) |
983 |
|
|
c print *,' 2 ipl, ipr ',ipl,ipr |
984 |
kusanagi |
1.3 |
do j = 1,16 |
985 |
|
|
i = i + 1 |
986 |
|
|
dedx(ipl,j) = vect(i) |
987 |
|
|
enddo |
988 |
kusanagi |
1.5 |
c print *,'tre' |
989 |
kusanagi |
1.3 |
goto 10 |
990 |
|
|
C |
991 |
|
|
endif |
992 |
|
|
|
993 |
|
|
|
994 |
|
|
RETURN |
995 |
|
|
END |
996 |
|
|
|
997 |
|
|
|
998 |
kusanagi |
1.5 |
C---------------------------------------------------------- |
999 |
kusanagi |
1.3 |
SUBROUTINE CALFULL(vect,inf,sup,dedx,dedxc,basse) |
1000 |
kusanagi |
1.5 |
C-------------------------------------------------------------- |
1001 |
kusanagi |
1.3 |
|
1002 |
|
|
IMPLICIT NONE |
1003 |
|
|
|
1004 |
|
|
INTEGER*2 VECT(20000) |
1005 |
|
|
C |
1006 |
|
|
INTEGER inf, sup |
1007 |
|
|
INTEGER i,j,k, iev,iev2 |
1008 |
|
|
C |
1009 |
|
|
INTEGER NPLA, NCHA, LENSEV |
1010 |
|
|
PARAMETER (NPLA=22,NCHA=96,LENSEV=NPLA*NCHA) |
1011 |
|
|
INTEGER merror(4) |
1012 |
|
|
integer*2 e2(4) |
1013 |
|
|
INTEGER contr |
1014 |
|
|
REAL DEXY(2,NPLA,NCHA), dexyc(2,npla,ncha), base(2,npla,ncha) |
1015 |
|
|
|
1016 |
|
|
|
1017 |
|
|
real calselftrig(4,7), calIItrig(4), calstripshit(4), |
1018 |
|
|
& calDSPtaberr(4), calevnum(4) |
1019 |
|
|
|
1020 |
|
|
|
1021 |
|
|
REAL calped(4,11,96), calgood(4,11,96), calthr(4,11,6) |
1022 |
|
|
REAL calrms(4,11,96), calbase(4,11,6), calvar(4,11,6) |
1023 |
|
|
REAL calpuls(4,11,96) |
1024 |
|
|
REAL dedx(11,96), basse(11,6), dedxc(11,96) |
1025 |
|
|
|
1026 |
|
|
COMMON / evento / IEV, |
1027 |
|
|
& dexy,dexyc,base, |
1028 |
|
|
& calselftrig,calIItrig, |
1029 |
|
|
& calstripshit,calDSPtaberr,calevnum |
1030 |
|
|
|
1031 |
|
|
save / evento / |
1032 |
|
|
|
1033 |
|
|
COMMON / calib / IEV2, calped, calgood, calthr, calrms, |
1034 |
|
|
& calbase, |
1035 |
|
|
& calvar, |
1036 |
|
|
& calpuls |
1037 |
|
|
|
1038 |
|
|
save / calib / |
1039 |
|
|
|
1040 |
|
|
c |
1041 |
|
|
COMMON / VARIE / merror, CONTR, E2 |
1042 |
|
|
SAVE / VARIE / |
1043 |
|
|
|
1044 |
|
|
C |
1045 |
|
|
C |
1046 |
|
|
C |
1047 |
|
|
DO I = 1,11 |
1048 |
|
|
DO J = 1,96 |
1049 |
|
|
DEDX(I,J) = 0. |
1050 |
|
|
ENDDO |
1051 |
|
|
ENDDO |
1052 |
|
|
C |
1053 |
|
|
k = inf |
1054 |
|
|
do i = 1,11 |
1055 |
|
|
do j = 1,96 |
1056 |
|
|
dedx(i,j) = vect(k) |
1057 |
|
|
k = k + 1 |
1058 |
kusanagi |
1.5 |
c if (vect(k).ne.0) print *,'ciao' |
1059 |
kusanagi |
1.3 |
enddo |
1060 |
|
|
enddo |
1061 |
|
|
C |
1062 |
|
|
c print *,'inf :',inf,' sup :',sup,' k :',k |
1063 |
|
|
call CALCOMPRESS(vect,k,sup,dedxc,basse) |
1064 |
kusanagi |
1.5 |
c print *,'dopo calcompress' |
1065 |
kusanagi |
1.3 |
|
1066 |
|
|
RETURN |
1067 |
|
|
END |
1068 |
|
|
|
1069 |
|
|
|
1070 |
|
|
C------------------------------------------------ |
1071 |
|
|
SUBROUTINE CONTAER(ve,er) |
1072 |
|
|
C------------------------------------------------ |
1073 |
|
|
|
1074 |
|
|
IMPLICIT NONE |
1075 |
|
|
|
1076 |
|
|
INTEGER*2 VE, st4 |
1077 |
|
|
C |
1078 |
|
|
INTEGER*2 VECT(20000) |
1079 |
|
|
C |
1080 |
|
|
INTEGER er, l, bit, bi, iev,iev2 |
1081 |
|
|
C |
1082 |
|
|
INTEGER NPLA, NCHA, LENSEV |
1083 |
|
|
PARAMETER (NPLA=22,NCHA=96,LENSEV=NPLA*NCHA) |
1084 |
|
|
INTEGER merror(4) |
1085 |
|
|
integer*2 e2(4) |
1086 |
|
|
INTEGER contr |
1087 |
|
|
REAL DEXY(2,NPLA,NCHA), dexyc(2,npla,ncha), base(2,npla,ncha) |
1088 |
|
|
|
1089 |
|
|
|
1090 |
|
|
real calselftrig(4,7), calIItrig(4), calstripshit(4), |
1091 |
|
|
& calDSPtaberr(4), calevnum(4) |
1092 |
|
|
|
1093 |
|
|
|
1094 |
|
|
REAL calped(4,11,96), calgood(4,11,96), calthr(4,11,6) |
1095 |
|
|
REAL calrms(4,11,96), calbase(4,11,6), calvar(4,11,6) |
1096 |
|
|
REAL calpuls(4,11,96) |
1097 |
|
|
|
1098 |
|
|
COMMON / evento / IEV, |
1099 |
|
|
& dexy,dexyc,base, |
1100 |
|
|
& calselftrig,calIItrig, |
1101 |
|
|
& calstripshit,calDSPtaberr,calevnum |
1102 |
|
|
|
1103 |
|
|
save / evento / |
1104 |
|
|
|
1105 |
|
|
COMMON / calib / IEV2, calped, calgood, calthr, calrms, |
1106 |
|
|
& calbase, |
1107 |
|
|
& calvar, |
1108 |
|
|
& calpuls |
1109 |
|
|
|
1110 |
|
|
save / calib / |
1111 |
|
|
|
1112 |
|
|
COMMON / VARIE / merror, CONTR, E2 |
1113 |
|
|
SAVE / VARIE / |
1114 |
|
|
|
1115 |
|
|
|
1116 |
|
|
st4 = 0 |
1117 |
|
|
st4 = IAND(ve,'00FF'x) |
1118 |
|
|
if (st4.ne.0) then |
1119 |
|
|
do bit=0, 6 |
1120 |
|
|
bi = ibits(st4,bit,1) |
1121 |
|
|
if (bi.ne.0) then |
1122 |
|
|
er = er + 1 |
1123 |
|
|
endif |
1124 |
|
|
enddo |
1125 |
|
|
endif |
1126 |
|
|
|
1127 |
|
|
10 FORMAT(2X,'Status word:',2X,Z4) |
1128 |
|
|
return |
1129 |
|
|
end |
1130 |
|
|
|
1131 |
|
|
|
1132 |
|
|
C------------------------------------------------ |
1133 |
|
|
SUBROUTINE MINERR(ic,icsave,chi,min,co) |
1134 |
|
|
C------------------------------------------------ |
1135 |
|
|
|
1136 |
|
|
IMPLICIT NONE |
1137 |
|
|
C |
1138 |
|
|
INTEGER ic, icsave(1000), chi(1000) |
1139 |
|
|
integer l, st, min,co |
1140 |
|
|
INTEGER*2 VECT(20000) |
1141 |
|
|
C |
1142 |
|
|
INTEGER iev,iev2 |
1143 |
|
|
C |
1144 |
|
|
INTEGER NPLA, NCHA, LENSEV |
1145 |
|
|
PARAMETER (NPLA=22,NCHA=96,LENSEV=NPLA*NCHA) |
1146 |
|
|
INTEGER merror(4) |
1147 |
|
|
integer*2 e2(4) |
1148 |
|
|
INTEGER contr |
1149 |
|
|
REAL DEXY(2,NPLA,NCHA), dexyc(2,npla,ncha), base(2,npla,ncha) |
1150 |
|
|
|
1151 |
|
|
|
1152 |
|
|
real calselftrig(4,7), calIItrig(4), calstripshit(4), |
1153 |
|
|
& calDSPtaberr(4), calevnum(4) |
1154 |
|
|
|
1155 |
|
|
|
1156 |
|
|
REAL calped(4,11,96), calgood(4,11,96), calthr(4,11,6) |
1157 |
|
|
REAL calrms(4,11,96), calbase(4,11,6), calvar(4,11,6) |
1158 |
|
|
REAL calpuls(4,11,96) |
1159 |
|
|
|
1160 |
|
|
COMMON / evento / IEV, |
1161 |
|
|
& dexy,dexyc,base, |
1162 |
|
|
& calselftrig,calIItrig, |
1163 |
|
|
& calstripshit,calDSPtaberr,calevnum |
1164 |
|
|
|
1165 |
|
|
save / evento / |
1166 |
|
|
|
1167 |
|
|
COMMON / calib / IEV2, calped, calgood, calthr, calrms, |
1168 |
|
|
& calbase, |
1169 |
|
|
& calvar, |
1170 |
|
|
& calpuls |
1171 |
|
|
|
1172 |
|
|
save / calib / |
1173 |
|
|
c |
1174 |
|
|
COMMON / VARIE / merror, CONTR, E2 |
1175 |
|
|
SAVE / VARIE / |
1176 |
|
|
|
1177 |
|
|
st = chi(1) |
1178 |
|
|
min = 1 |
1179 |
|
|
if (co.gt.1) then |
1180 |
|
|
do l = 2, co |
1181 |
|
|
if (chi(l).lt.st) then |
1182 |
|
|
st = chi(l) |
1183 |
|
|
min = l |
1184 |
|
|
endif |
1185 |
|
|
enddo |
1186 |
|
|
endif |
1187 |
|
|
ic = icsave(min) |
1188 |
|
|
|
1189 |
|
|
return |
1190 |
|
|
end |