1 |
C |
2 |
C Written by Emiliano Mocchiutti and Mirko Boezio |
3 |
C |
4 |
C * Version: 3.4.08 * |
5 |
C |
6 |
C Changelog: |
7 |
C |
8 |
C 3.4.07 - 3.4.08: (2006-06-29) XO is rotated, not XE!! fixed. |
9 |
C |
10 |
C 3.4.06 - 3.4.07: (2006-06-29) save CRC values in calselftrig(section,1) and calselftrig(section,2) in case of CRC errors |
11 |
C |
12 |
C 3.4.05 - 3.4.06: (2005-01-12) section order wrong in CLEARSEC, fixed. |
13 |
C |
14 |
C 3.4.04 - 3.4.05: (2005-01-05) XE is section y odd not even, fixed. |
15 |
C |
16 |
C 3.4.03 - 3.4.04: (2004-12-21) bug in recognising decoding errors, fixed. |
17 |
C |
18 |
C 3.4.02 - 3.4.03: (2004-12-17) forget to clear esci/stwerr and vector vect |
19 |
C plus problems with lleng (truncated vect!). Fixed the |
20 |
C clearing, workaround for lleng (to be further investigated) |
21 |
C |
22 |
C 3.4.01 - 3.4.02: (2004-12-10) cleanup of the code and changed sections order. |
23 |
C |
24 |
C 3.4.00 - 3.4.01: (2004-11-26) CA50 comes after Strips Hit, fixed. |
25 |
C |
26 |
C 3.3.03 - 3.4.00: (2004-11-08) changed the DSP program hence changed calunpack |
27 |
C to better find the calorimeter sections. |
28 |
C |
29 |
C 3.3.02 - 3.3.03: (2004-11-08) changes in the commons (one more common for |
30 |
C calpulse and from calstripshit to calstriphit). |
31 |
C |
32 |
C 3.3.01 - 3.3.02: (2004-10-19) italian name of subroutines translated to |
33 |
C english. Forgot to clear vector in case of CRC errors, |
34 |
C fixed. stwerr is integer not real! fixed |
35 |
C |
36 |
C 3.3.00 - 3.3.01: (2004-10-18) forgot to clear stwerr if no sections are found |
37 |
C fixed. |
38 |
C |
39 |
C 3.2.00 - 3.3.00: (2004-10-15) enanched search of sections in case of one or |
40 |
C more missing sections. |
41 |
C Switched to c function "fillin" to create calorimeter words |
42 |
C instead of fortran function "riempi": great improvement in |
43 |
C time processing!! |
44 |
C |
45 |
C 3.1.00 - 3.2.00: (2004-10-13) forget to clean some variables, fixed. |
46 |
C Reprocess event in the case we have CRC errors and a high |
47 |
C number of error trying to understand the kind of event |
48 |
C we are processing (raw, compress, full mode) in order to |
49 |
C distinguish better the four section.The reprocessing happens |
50 |
C on about the 30% of events with CRC errors (in the case of |
51 |
C file 040827_005 the reprocessing is done on about 2% of all |
52 |
C the events). |
53 |
C |
54 |
C 3.0.00 - 3.1.00: (2004-10-12) cleanup and speedup of the code, less loops |
55 |
C same strength in finding the calorimeter sections. |
56 |
C |
57 |
C 2.18.4 - 3.0.00: (2004-10-07) major changes in the procedure to find the |
58 |
C calorimeter sections and enhanced search in the case of |
59 |
c CRC errors (to fix a bug which made the misunderstanding |
60 |
C some kind of CRC errors with missing sections). |
61 |
C Clean up unused variables, speeded up some loops. |
62 |
C Zero length input vector error added. |
63 |
C Enhanced search of the first section recorded since the |
64 |
C starting point is very important to correctly find and |
65 |
C interpret all the other sections. |
66 |
C If section length is absurd and the CRC header bit = 0 |
67 |
C then search again for that section (needed to make a |
68 |
C better search of section when in presence of CRC errors) |
69 |
C Search all the sections and if you reach the end of vector |
70 |
C (EOV) continue searching if you haven't find all the four |
71 |
C section (and go out without looping if no section is |
72 |
C present). |
73 |
C |
74 |
C 2.18.3 - 2.18.4: consider a bad thing if you find a section in the wrong |
75 |
C position of the vector and try again to |
76 |
C find the real data (if they exist). |
77 |
C |
78 |
C 2.18.2 - 2.18.3: vectors belonging to common must be cleared if the calo |
79 |
C isn't found. Fixed. |
80 |
C |
81 |
C 2.18.1 - 2.18.2: fixed unclearing error codes if the program doesn't find |
82 |
C the calorimeter where it should be but shifted somewhere |
83 |
C else forgotten to clear st2c variable: fixed |
84 |
C exit error code wrong in some cases: fixed |
85 |
C self trigger data not saved: fixed. |
86 |
C |
87 |
C 2.18.0 - 2.18.1: small changes in the common varie to fix a memory leak; |
88 |
C fixed an error in reporting error codes (stwerr,pwerror). |
89 |
C |
90 |
C 2.17.0 - 2.18.0: corrected bug which made unable the program to find CRC |
91 |
C errors in the last section of the calorimeter; |
92 |
C added a "debugging" option to dump to standard output |
93 |
C the whole packet in hexadecimal format and other |
94 |
C useful informations. To activate it the dump variable |
95 |
C in the common varie must be passed with the value |
96 |
C of iev you want to check. Do nothing if you don't want |
97 |
C any output. |
98 |
C |
99 |
C------------------------------------------------ |
100 |
SUBROUTINE CALUNPACK(vecta,lung,me) |
101 |
C------------------------------------------------ |
102 |
|
103 |
IMPLICIT NONE |
104 |
C |
105 |
C PARAMETERS DEFINITION |
106 |
C |
107 |
C START = WHERE TO START TO LOOK FOR THE CALORIMETER, IN WORDS |
108 |
C 1STSEC = MAXIMUM POSITION, IN BYTES, WHERE WE SUPPOSE TO FIND THE |
109 |
C HEADER OF THE FIRST SECTION |
110 |
C |
111 |
INTEGER START, SEC1ST |
112 |
INTEGER NPLA, NCHA, LENSEV |
113 |
INTEGER*2 ival |
114 |
C |
115 |
PARAMETER (START=50,SEC1ST=1200) |
116 |
PARAMETER (NPLA=22,NCHA=96,LENSEV=NPLA*NCHA) |
117 |
PARAMETER (ival='FFFF'x) |
118 |
C |
119 |
C Normal variables definition |
120 |
C |
121 |
integer lung, SOGLIA0, SEC2ND |
122 |
INTEGER*1 VECTA(lung) |
123 |
INTEGER*2 vect(60000), test |
124 |
integer*2 check, crc, e2(4) |
125 |
INTEGER*2 length, length2 |
126 |
integer me, m, dumpo, finoa |
127 |
INTEGER merror(4), headcor, ichc, coco |
128 |
INTEGER i, j, iev, min, st2c, bit, bi, lleng |
129 |
INTEGER ic, k,l, ke, ic0, icsave, chi |
130 |
INTEGER hcchi(1000), hcic(1000),hcco |
131 |
INTEGER contr, isfull, israw, iscomp |
132 |
INTEGER inf, sup, em, icb |
133 |
INTEGER XO, YO, XE, YE, icold |
134 |
integer st1b, st2b, lunga, pari |
135 |
integer stwerr(4),yescbra, chis, esci, icprima |
136 |
integer seemcomp, seemfull, cberaw, yesisco, yesisfu,yesisra |
137 |
integer ca50, ca50a, ca50b |
138 |
C |
139 |
real dedx1(11,96),dedx2(11,96),dedx3(11,96),dedx4(11,96) |
140 |
real dedx1c(11,96),dedx2c(11,96),dedx3c(11,96),dedx4c(11,96) |
141 |
real base1(11,6),base2(11,6),base3(11,6),base4(11,6) |
142 |
REAL DEXY(2,NPLA,NCHA), dexyc(2,npla,ncha), base(2,npla,6) |
143 |
real auto(7) |
144 |
real calselftrig(4,7), calIItrig(4), calstriphit(4), |
145 |
& calDSPtaberr(4), calevnum(4) |
146 |
real perror(4) |
147 |
C |
148 |
DATA YE/246/ ! CODE_EV_R YE = 111 10110 |
149 |
DATA YO/237/ ! CODE_EV_R YO = 111 01101 |
150 |
DATA XE/234/ ! CODE_EV_R XE = 111 01010 |
151 |
DATA XO/241/ ! CODE_EV_R XO = 111 10001 |
152 |
C |
153 |
COMMON / evento / iev, stwerr, perror, |
154 |
& dexy,dexyc,base, |
155 |
& calselftrig,calIItrig, |
156 |
& calstriphit,calDSPtaberr,calevnum |
157 |
save / evento / |
158 |
C |
159 |
COMMON / VARIE / dumpo, CONTR, merror |
160 |
SAVE / VARIE / |
161 |
C |
162 |
C Begin ! |
163 |
C |
164 |
SOGLIA0 = 70 |
165 |
C |
166 |
C input length must be > 0, if not go out with error code 142 |
167 |
C |
168 |
if (lung.le.0) then |
169 |
if (dumpo.eq.iev) print *,'lung = ',lung |
170 |
do i=1,4 |
171 |
merror(i)=142 |
172 |
enddo |
173 |
goto 999 |
174 |
endif |
175 |
C |
176 |
C no debug informations |
177 |
C |
178 |
if (dumpo.eq.0) dumpo=-1 |
179 |
C |
180 |
C DEBUG: PRINT OUT THE INPUT VECTOR |
181 |
C |
182 |
if (iev.eq.dumpo) then |
183 |
do l=1,lung |
184 |
write(*,17)l,vecta(l) |
185 |
enddo |
186 |
endif |
187 |
C |
188 |
C DETERMINE LENGTH IN WORDS FROM LENGTH IN BYTES |
189 |
C |
190 |
IF (MOD(LUNG,2).EQ.0) THEN |
191 |
lunga = lung / 2 |
192 |
pari = 1 |
193 |
else |
194 |
lunga = int(lung/2) + 1 |
195 |
endif |
196 |
SEC2ND = LUNGA |
197 |
C |
198 |
C IS LENGTH IS TOO LONG? |
199 |
C |
200 |
if (lunga.gt.60000.and.dumpo.gt.0) then |
201 |
print *,'Calorimeter WARNING: more than 60000 words!' |
202 |
lunga = 60000 |
203 |
endif |
204 |
C |
205 |
C PRE-CLEAR VARIABLES |
206 |
C |
207 |
yesisco = 0 |
208 |
yesisfu = 0 |
209 |
yesisra = 0 |
210 |
yescbra = 0 |
211 |
C |
212 |
1 CONTINUE |
213 |
c |
214 |
C CLEAR VARIABLES |
215 |
C |
216 |
if (iev.lt.0.or.iev.gt.90000000) iev = 0 |
217 |
esci = 0 |
218 |
chi = 0 |
219 |
chis = 0 |
220 |
min = 0 |
221 |
lleng = 0 |
222 |
m = 0 |
223 |
pari = 0 |
224 |
icb = 0 |
225 |
em = 0 |
226 |
coco = 0 |
227 |
me = 1 |
228 |
contr = 1 |
229 |
ic = 1 |
230 |
icsave = 0 |
231 |
C |
232 |
call clearall |
233 |
call azero(dedx1,11*96) |
234 |
call azero(dedx2,11*96) |
235 |
call azero(dedx3,11*96) |
236 |
call azero(dedx4,11*96) |
237 |
call azero(dedx1c,11*96) |
238 |
call azero(dedx2c,11*96) |
239 |
call azero(dedx3c,11*96) |
240 |
call azero(dedx4c,11*96) |
241 |
call azero(base1,11*6) |
242 |
call azero(base2,11*6) |
243 |
call azero(base3,11*6) |
244 |
call azero(base4,11*6) |
245 |
C |
246 |
do l = 1,4 |
247 |
e2(l) = 0 |
248 |
perror(l) = 0. |
249 |
stwerr(l) = 0 |
250 |
merror(l) = 0 |
251 |
enddo |
252 |
C |
253 |
C DETERMINE WHERE TO START TO FIND THE CALORIMETER IN THE INBUT BUFFER |
254 |
C |
255 |
length2 = start |
256 |
c |
257 |
20 continue |
258 |
C |
259 |
if (length2.ge.-2) then |
260 |
ic = ic + (2 * (length2 + 2)) |
261 |
else |
262 |
if (dumpo.gt.0) |
263 |
& print *,'Calorimeter WARNING: length errors ',ic,length2 |
264 |
endif |
265 |
C |
266 |
headcor = 0 |
267 |
ichc = ic |
268 |
icprima = ic |
269 |
hcco = 0 |
270 |
do i=1,1000 |
271 |
hcchi(i) = 0 |
272 |
hcic(i) = 0 |
273 |
enddo |
274 |
c |
275 |
32 continue |
276 |
C |
277 |
ke = 0 |
278 |
chis = chi |
279 |
icold = ic |
280 |
DO i = 1, 60000 |
281 |
vect(i) = 0 |
282 |
enddo |
283 |
do while (ke.eq.0) |
284 |
C |
285 |
C if (iev.eq.dumpo) print *,'parto da ',ic,contr |
286 |
C |
287 |
C Check consistency of header. |
288 |
C it is composed by CODE+D# (8 bits) and by SATUS WORD (8 bits) |
289 |
c so we must split vect into the two components: |
290 |
C |
291 |
st1b = 0 |
292 |
st2b = 0 |
293 |
C |
294 |
C A CALORIMETER SECTION IS MADE OF AT LEAST 4 BYTES |
295 |
C IF WE HAVE NO ROOM FOR A SECTION GO OUT |
296 |
C |
297 |
if ((ic+4).gt.lung.or.esci.eq.1) then |
298 |
if (headcor.eq.1.and.contr.lt.5) then |
299 |
headcor=-1 |
300 |
ic=ichc |
301 |
goto 32 |
302 |
else |
303 |
if (headcor.eq.0.or.headcor.eq.2) then |
304 |
chi = chi + 8 * (5 - contr) |
305 |
endif |
306 |
merror(contr) = 129 |
307 |
stwerr(contr) = 0 |
308 |
if (iev.eq.dumpo) print *,'put to zero here ',headcor |
309 |
if (esci.eq.0) then |
310 |
ic = icsave |
311 |
else |
312 |
ic = icprima |
313 |
endif |
314 |
if (headcor.eq.2) then |
315 |
chi = chis |
316 |
endif |
317 |
esci = 0 |
318 |
headcor = 0 |
319 |
hcco = 0 |
320 |
ichc = 0 |
321 |
do i=1,1000 |
322 |
hcchi(i) = 0 |
323 |
hcic(i) = 0 |
324 |
enddo |
325 |
length2 = -2 |
326 |
lleng = 0 |
327 |
length = 0 |
328 |
goto 150 |
329 |
endif |
330 |
endif |
331 |
C |
332 |
C ST1B IS "CODE", ST2B IS "D#" |
333 |
C |
334 |
do bit = 0, 7 |
335 |
bi = ibits(vecta(ic),bit,1) |
336 |
if (bi.eq.1) st1b = ibset(st1b,bit) |
337 |
bi = ibits(vecta(ic+1),bit,1) |
338 |
if (bi.eq.1) st2b = ibset(st2b,bit) |
339 |
enddo |
340 |
c |
341 |
C IC+2 AND IC+3 CONTAINS THE LENGTH OF THE CALORIMETER SECTION |
342 |
c |
343 |
length2 = 0 |
344 |
do bit=0, 7 |
345 |
bi = ibits(vecta(ic+3),bit,1) |
346 |
if (bi.eq.1) length2 = ibset(length2,bit) |
347 |
bi = ibits(vecta(ic+2),bit,1) |
348 |
if (bi.eq.1) length2 = ibset(length2,bit+8) |
349 |
enddo |
350 |
C |
351 |
C calorimeter signature in DSP mode (CA50 CA50): |
352 |
C |
353 |
ca50 = 0 |
354 |
if (ic+24.lt.lung) then |
355 |
ca50a = 0 |
356 |
do bit=0, 7 |
357 |
bi = ibits(vecta(ic+23),bit,1) |
358 |
if (bi.eq.1) ca50a = ibset(ca50a,bit) |
359 |
bi = ibits(vecta(ic+22),bit,1) |
360 |
if (bi.eq.1) ca50a = ibset(ca50a,bit+8) |
361 |
enddo |
362 |
ca50b = 0 |
363 |
do bit=0, 7 |
364 |
bi = ibits(vecta(ic+25),bit,1) |
365 |
if (bi.eq.1) ca50b = ibset(ca50b,bit) |
366 |
bi = ibits(vecta(ic+24),bit,1) |
367 |
if (bi.eq.1) ca50b = ibset(ca50b,bit+8) |
368 |
enddo |
369 |
if (ca50a.eq.ca50b.and.ca50a.eq.51792) ca50 = 1 |
370 |
endif |
371 |
|
372 |
C |
373 |
c the crc should be at vect(length) with |
374 |
C |
375 |
length = length2 + 1 |
376 |
C |
377 |
c some checks to be sure we have found the calorimeter data: |
378 |
c status word is always less then 129 |
379 |
c |
380 |
if (st2b.gt.128) then |
381 |
length = 0 |
382 |
length2 = 0 |
383 |
goto 100 |
384 |
endif |
385 |
c |
386 |
c length of the packet IN WORDS must be less then HALF OF THE |
387 |
C LENGTH IN BYTES if noT THERE ARE SOME errors |
388 |
c |
389 |
bi = ibits(st2b,0,1) |
390 |
if (length2.gt.lunga.OR.LENGTH2.LE.0) then |
391 |
if (headcor.eq.2) then |
392 |
chi = chi + 4 |
393 |
endif |
394 |
length = 0 |
395 |
length2 = 0 |
396 |
goto 100 |
397 |
endif |
398 |
c |
399 |
e2(contr) = 0 |
400 |
C |
401 |
if (CONTR.eq.1) then |
402 |
c |
403 |
c is it the first section? |
404 |
c |
405 |
if (st1b.eq.XE.and.(ca50.eq.1.or.length2.eq.1064)) then |
406 |
c if so go out of this loop and go on recording data |
407 |
ke = 1 |
408 |
icsave = ic |
409 |
m = ic |
410 |
if (iev.eq.dumpo) then |
411 |
print *,'1m,lunga,lleng,lung,pari',m,lunga,lleng,lung, |
412 |
& pari |
413 |
endif |
414 |
call fillin(m,lunga,lleng,lung,pari,vect,vecta) |
415 |
C |
416 |
icb = 1 |
417 |
E2(contr) = vect(icb) |
418 |
if (iev.eq.dumpo) then |
419 |
print *,'headcor ',headcor |
420 |
write(*,22)vect(icb) |
421 |
print *,'1m,lunga,lleng,lung,pari',m,lunga,lleng,lung, |
422 |
& pari |
423 |
endif |
424 |
if (headcor.eq.2) then |
425 |
if (coco.ne.1) then |
426 |
coco = 1 |
427 |
else |
428 |
coco = -1 |
429 |
endif |
430 |
if (st2b.ne.0) then |
431 |
call counter(e2(contr),chi) |
432 |
endif |
433 |
endif |
434 |
goto 100 |
435 |
endif |
436 |
ENDIF |
437 |
C |
438 |
c the same for the second section, ... |
439 |
c |
440 |
if (CONTR.eq.2) then |
441 |
if (st1b.eq.XO.and.(ca50.eq.1.or.length2.eq.1064)) then |
442 |
ke = 2 |
443 |
icsave = ic |
444 |
m = ic |
445 |
if (iev.eq.dumpo) then |
446 |
print *,'2m,lunga,lleng,lung,pari',m,lunga,lleng,lung, |
447 |
& pari |
448 |
endif |
449 |
call fillin(m,lunga,lleng,lung,pari,vect,vecta) |
450 |
icb = 1 |
451 |
E2(contr) = vect(icb) |
452 |
if (iev.eq.dumpo) then |
453 |
print *,'headcor ',headcor |
454 |
write(*,22)vect(icb) |
455 |
print *,'2m,lunga,lleng,lung,pari',m,lunga,lleng,lung, |
456 |
& pari |
457 |
endif |
458 |
if (headcor.eq.2) then |
459 |
if (coco.ne.2) then |
460 |
coco = 2 |
461 |
else |
462 |
coco = -1 |
463 |
endif |
464 |
if ((ic-icold).ne.0) chi=chi+abs(ic-icold) |
465 |
if (st2b.ne.0) then |
466 |
call counter(e2(contr),chi) |
467 |
endif |
468 |
endif |
469 |
goto 100 |
470 |
endif |
471 |
ENDIF |
472 |
c |
473 |
C ... for the third,... |
474 |
c |
475 |
if (CONTR.eq.3) then |
476 |
if (st1b.eq.YE.and.(ca50.eq.1.or.length2.eq.1064)) then |
477 |
ke = 3 |
478 |
icsave = ic |
479 |
m = ic |
480 |
if (iev.eq.dumpo) then |
481 |
print *,'3m,lunga,lleng,lung,pari',m,lunga,lleng,lung, |
482 |
& pari |
483 |
endif |
484 |
call fillin(m,lunga,lleng,lung,pari,vect,vecta) |
485 |
icb = 1 |
486 |
E2(contr) = vect(icb) |
487 |
if (iev.eq.dumpo) then |
488 |
print *,'headcor ',headcor |
489 |
write(*,22)vect(icb) |
490 |
print *,'3m,lunga,lleng,lung,pari',m,lunga,lleng,lung, |
491 |
& pari |
492 |
endif |
493 |
if (headcor.eq.2) then |
494 |
if (coco.eq.3) then |
495 |
coco = 3 |
496 |
else |
497 |
coco = -1 |
498 |
endif |
499 |
if (ic-icold.ne.0) chi = chi + abs(ic-icold) |
500 |
if (st2b.ne.0) then |
501 |
call counter(e2(contr),chi) |
502 |
endif |
503 |
endif |
504 |
goto 100 |
505 |
endif |
506 |
ENDIF |
507 |
C |
508 |
c ...and for the last section. |
509 |
c |
510 |
if (CONTR.eq.4) then |
511 |
if (st1b.eq.YO.and.(ca50.eq.1.or.length2.eq.1064)) then |
512 |
ke = 4 |
513 |
icsave = ic |
514 |
m = ic |
515 |
call fillin(m,lunga,lleng,lung,pari,vect,vecta) |
516 |
icb = 1 |
517 |
E2(contr) = vect(icb) |
518 |
if (headcor.eq.2) then |
519 |
if (coco.eq.4) then |
520 |
coco = 4 |
521 |
else |
522 |
coco = -1 |
523 |
endif |
524 |
if ((ic-icold).ne.0) chi = chi + abs(ic-icold) |
525 |
if (st2b.ne.0) then |
526 |
call counter(e2(contr),chi) |
527 |
endif |
528 |
endif |
529 |
goto 100 |
530 |
endif |
531 |
endif |
532 |
C |
533 |
if (contr.gt.4) then |
534 |
if (iev.eq.dumpo) print *,'go out here' |
535 |
headcor = 0 |
536 |
hcco = 0 |
537 |
ichc = 0 |
538 |
do i=1,1000 |
539 |
hcchi(i) = 0 |
540 |
hcic(i) = 0 |
541 |
enddo |
542 |
goto 200 |
543 |
endif |
544 |
C |
545 |
100 CONTINUE |
546 |
c |
547 |
c increment vector of one searching for the next section |
548 |
c |
549 |
ic = ic + 1 |
550 |
c |
551 |
enddo |
552 |
C |
553 |
c format not used |
554 |
c |
555 |
10 FORMAT(2X,'Error for view:',2X,I1,2X,'Status word:',2X,Z4) |
556 |
11 FORMAT(2X,'View or command not recognized for view:',2X,I1,2X, |
557 |
& 'Status word:',2X,Z4) |
558 |
12 FORMAT(2X,'Error - did NOT find view:',2X,I1) |
559 |
13 FORMAT(2X,'Error - eof reached, exiting') |
560 |
14 FORMAT(2X,I8,2X,I10) |
561 |
15 FORMAT(2X,I8,2X,Z8) |
562 |
17 FORMAT(2X,'Element:',2X,I6,2X,' word:',2X,Z8) |
563 |
18 FORMAT(2X,'Element:',2X,I6,2X,' word:',2X,Z2,Z2) |
564 |
21 FORMAT(2X,'CRC: ',2X,Z8) |
565 |
22 FORMAT(2X,'vect(icb): ',2X,Z8) |
566 |
C |
567 |
c go on recording data |
568 |
ic = ic - 1 |
569 |
c |
570 |
c |
571 |
K = CONTR |
572 |
ic0 = icb |
573 |
icb = icb + 1 |
574 |
length = vect(icb) + 2 |
575 |
length2 = vect(icb) |
576 |
lleng = (length*2) - 1 |
577 |
C |
578 |
C Check consistency of CRCs. |
579 |
C |
580 |
C |
581 |
C IF THE STATUS WORD HAS THE CRC BIT ON AND WE ARE NOT IN THE |
582 |
C HEADCOR CASE 0 (WE WERE BELIEVING THE SECTION FOUND WAS FINE) |
583 |
C |
584 |
if ((ibits(e2(contr),0,1).ne.0.or. |
585 |
& (ibits(e2(contr),3,1).eq.1.and.length2.ne.1064)) |
586 |
& .and.headcor.EQ.0) then |
587 |
headcor = 1 |
588 |
ichc = ic - 1 |
589 |
if (iev.eq.dumpo) print *,'crc st word wrong',ic,ichc,headcor |
590 |
endif |
591 |
C |
592 |
C HEADOCR = 1 MEANS SEARCH AGAIN FOR THAT SECTION |
593 |
C |
594 |
if (headcor.eq.1) then |
595 |
hcco = hcco + 1 |
596 |
if (st2b.ne.0) then |
597 |
call counter(e2(contr),hcchi(hcco)) |
598 |
endif |
599 |
C |
600 |
if (contr.gt.1.or.yesisco.ne.0.or.yesisfu.ne.0 |
601 |
& .or.yesisra.ne.0.or.yescbra.ne.0) then |
602 |
iscomp = 0 |
603 |
isfull = 0 |
604 |
israw = 0 |
605 |
if (yesisco.ne.0.or.yesisfu.ne.0 |
606 |
& .or.yesisra.ne.0.or.yescbra.ne.0) then |
607 |
if (yesisra.ne.0.or.yescbra.ne.0) israw = 2 |
608 |
if (yesisco.ne.0) iscomp = 2 |
609 |
if (yesisfu.ne.0) isfull = 2 |
610 |
else |
611 |
i = 1 |
612 |
do while(iscomp.eq.0.and.isfull.eq.0.and.israw.eq.0.and. |
613 |
& i.lt.(contr-1)) |
614 |
if (ibits(stwerr(i),16,1).eq.1) iscomp = iscomp + 1 |
615 |
if (ibits(stwerr(i),17,1).eq.1) isfull = isfull + 1 |
616 |
if (ibits(e2(i),3,1).eq.1.and.merror(i).eq.0) |
617 |
& israw = israw + 1 |
618 |
i = i + 1 |
619 |
enddo |
620 |
endif |
621 |
c |
622 |
c how does this section look like? (note that in case of crc errors |
623 |
c this test has no value...) |
624 |
c |
625 |
test = vect(icb+12) |
626 |
seemcomp = 0 |
627 |
seemfull = 0 |
628 |
if (test.eq.ival) then |
629 |
seemcomp = 1 |
630 |
elseif (test.eq.0) then |
631 |
seemfull = 1 |
632 |
endif |
633 |
c |
634 |
c if a previous good section was raw and this header we are analyzing |
635 |
c is not raw something strange is happening, add a weight. |
636 |
c |
637 |
if ((israw.ne.0.and.ibits(e2(contr),3,1).ne.1) |
638 |
& .or.(israw.ne.0.and.length2.ne.1064)) then |
639 |
hcco = hcco - 1 |
640 |
length=0 |
641 |
length2=0 |
642 |
lleng=0 |
643 |
ic = ic + 1 |
644 |
if (iev.eq.dumpo) |
645 |
& print *,'not raw, search again ',ic,ichc,headcor |
646 |
goto 32 |
647 |
endif |
648 |
c |
649 |
c the same with compress and full mode |
650 |
c |
651 |
if ((iscomp.ne.0.or.isfull.ne.0) |
652 |
& .and.ibits(e2(contr),3,1).eq.1) then |
653 |
hcco = hcco - 1 |
654 |
length=0 |
655 |
length2=0 |
656 |
lleng=0 |
657 |
ic = ic + 1 |
658 |
if (iev.eq.dumpo) |
659 |
& print *,'raw in full or compress mode, search again ',ic,ichc, |
660 |
& headcor |
661 |
goto 32 |
662 |
endif |
663 |
|
664 |
if (iscomp.ne.0.and.(ibits(e2(contr),3,1).eq.1.or. |
665 |
& seemcomp.eq.0)) hcchi(hcco) = hcchi(hcco) + 2 |
666 |
if (isfull.ne.0.and.(ibits(e2(contr),3,1).eq.1.or. |
667 |
& seemfull.eq.0)) hcchi(hcco) = hcchi(hcco) + 2 |
668 |
endif |
669 |
C |
670 |
if (ibits(e2(contr),3,1).eq.1.and.length2.eq.1064) then |
671 |
hcchi(hcco) = hcchi(hcco) - 2 |
672 |
elseif ((ibits(e2(contr),3,1).eq.1.or.israw.ne.0) |
673 |
& .and.length2.ne.1064) then |
674 |
hcco = hcco - 1 |
675 |
length=0 |
676 |
length2=0 |
677 |
lleng=0 |
678 |
ic = ic + 1 |
679 |
if (iev.eq.dumpo) |
680 |
& print *,'raw bit not raw length, search again ',ic,ichc,headcor |
681 |
goto 32 |
682 |
endif |
683 |
C |
684 |
hcic(hcco) = ic |
685 |
ic = ic + 1 |
686 |
length=0 |
687 |
length2=0 |
688 |
lleng=0 |
689 |
if (iev.eq.dumpo) print *,'search again ',ic,ichc,headcor |
690 |
goto 32 |
691 |
endif |
692 |
C |
693 |
C HEADCOR = - 1 MEANS STOP SEARCHING FOR THAT SECTION, SELECT |
694 |
C THE CASE WITH LESS ERRORS, FOUND THAT SECTION AND GIVE |
695 |
C HEADCOR = 2 (I.E. GO OUT OF THE LOOP) |
696 |
C |
697 |
if (headcor.eq.-1) then |
698 |
if (iev.eq.dumpo) print *,'enter -1, ',hcco,ke |
699 |
headcor = 2 |
700 |
if (ke.le.2.and.hcco.ge.1) then |
701 |
finoa = 0 |
702 |
do i = 1, hcco |
703 |
if (ke.eq.1.and.hcic(i).lt.SEC1ST) finoa = i |
704 |
if (ke.eq.2.and.hcic(i).lt.SEC2ND) finoa = i |
705 |
enddo |
706 |
if (finoa.eq.0) then |
707 |
esci = 1 |
708 |
if (iev.eq.dumpo) |
709 |
& print *,'finoa=0! no possible solutions ' |
710 |
else |
711 |
if (iev.eq.dumpo) print *,'ke = ',ke,' and hcco>1 ',finoa |
712 |
call minerr(ic,hcic,hcchi,min,finoa) |
713 |
endif |
714 |
else |
715 |
if (hcco.eq.0) then |
716 |
esci = 1 |
717 |
if (iev.eq.dumpo) |
718 |
& print *,'hcco=0! no possible solutions' |
719 |
else |
720 |
call minerr(ic,hcic,hcchi,min,hcco) |
721 |
endif |
722 |
endif |
723 |
e2(contr) = 0 |
724 |
if (iev.eq.dumpo) then |
725 |
print *,'stop searching' |
726 |
print *,'ic,hcic(min),min,... ',ic,hcic(min),min, |
727 |
& hcchi(min),hcco,coco |
728 |
do i=1,hcco |
729 |
print *,'i, hcchi ',i,hcchi(i) |
730 |
enddo |
731 |
endif |
732 |
c |
733 |
length=0 |
734 |
length2=0 |
735 |
lleng=0 |
736 |
esci = 0 |
737 |
MERROR(contr) = 0 |
738 |
goto 32 |
739 |
endif |
740 |
C |
741 |
C determine the type of data if not raw (compress or full) |
742 |
C |
743 |
if (headcor.eq.0.or.headcor.eq.2 |
744 |
& .and.ibits(e2(contr),3,1).ne.1) then |
745 |
test = vect(icb+12) |
746 |
seemcomp = 0 |
747 |
seemfull = 0 |
748 |
if (test.eq.ival) then |
749 |
C |
750 |
C compress mode |
751 |
C |
752 |
stwerr(contr) = ibset(stwerr(contr),16) |
753 |
elseif (test.eq.0) then |
754 |
C |
755 |
C full mode |
756 |
C |
757 |
stwerr(contr) = ibset(stwerr(contr),17) |
758 |
endif |
759 |
endif |
760 |
C |
761 |
hcco = 0 |
762 |
ichc = 0 |
763 |
check = 0 |
764 |
do i=1,1000 |
765 |
hcchi(i) = 0 |
766 |
hcic(i) = 0 |
767 |
enddo |
768 |
inf = ic0 |
769 |
sup = length - 1 |
770 |
do i = inf,sup |
771 |
check=crc(check,vect(i)) |
772 |
enddo |
773 |
C |
774 |
if (iev.eq.dumpo) then |
775 |
write(*,21)vect(length) |
776 |
print *,' CRC position ',length |
777 |
write(*,21)check |
778 |
endif |
779 |
C |
780 |
if (check.ne.vect(length)) then |
781 |
C |
782 |
C clear vectors of that section in the common |
783 |
C |
784 |
call clearsec |
785 |
C |
786 |
calselftrig(k,1) = check |
787 |
calselftrig(k,2) = vect(length) |
788 |
c |
789 |
merror(contr) = 132 |
790 |
chi = chi + 4 |
791 |
lleng = 0 |
792 |
length2 = 0 |
793 |
length = 0 |
794 |
c |
795 |
if (ke.eq.1.and.headcor.ne.2) then |
796 |
ic = 10 |
797 |
elseif (headcor.eq.2) then |
798 |
contr = contr + 1 |
799 |
endif |
800 |
headcor = 1 |
801 |
ichc = ic - 1 |
802 |
if (iev.eq.dumpo) |
803 |
& print *,'crc is wrong ',ic, |
804 |
& ' search section ',contr,' coco = ',coco |
805 |
goto 32 |
806 |
else |
807 |
chi = chi - 4 |
808 |
if (chi.lt.0) chi = 0 |
809 |
endif |
810 |
C |
811 |
headcor = 0 |
812 |
C |
813 |
19 CONTINUE |
814 |
C |
815 |
C Process data. |
816 |
C |
817 |
call clearsec |
818 |
do i = 1, 7 |
819 |
icb = icb + 1 |
820 |
auto(i) = vect(icb) |
821 |
enddo |
822 |
C |
823 |
st2c = 0 |
824 |
if (st2b.ne.0) then |
825 |
do bit=0, 6 |
826 |
bi = ibits(st2b,bit,1) |
827 |
if (bit.eq.3.and.bi.ne.0) st2c = 8 |
828 |
enddo |
829 |
endif |
830 |
C |
831 |
if (st2c.eq.8) then |
832 |
if (length2.ne.1064) then |
833 |
merror(contr) = 133 |
834 |
chi = chi + 4 |
835 |
if (iev.eq.dumpo) |
836 |
& print *,'raw lung 4' |
837 |
lleng = 0 |
838 |
goto 150 |
839 |
else |
840 |
if (k.eq.1) call CALRAW(vect,icb+1,length-1,dedx1) |
841 |
if (k.eq.2) call CALRAW(vect,icb+1,length-1,dedx2) |
842 |
if (k.eq.3) call CALRAW(vect,icb+1,length-1,dedx3) |
843 |
if (k.eq.4) call CALRAW(vect,icb+1,length-1,dedx4) |
844 |
endif |
845 |
goto 50 |
846 |
endif |
847 |
C |
848 |
41 FORMAT(2X,I2,2X,'word :',1x,z4) |
849 |
test = vect(icb+5) |
850 |
c |
851 |
if (test.eq.ival) then |
852 |
if (length2.gt.1201) then |
853 |
merror(contr) = 134 |
854 |
chi = chi + 4 |
855 |
if (iev.eq.dumpo) |
856 |
& print *,'compr lung 4' |
857 |
lleng = 0 |
858 |
goto 150 |
859 |
else |
860 |
icb = icb + 1 |
861 |
calIItrig(k) = vect(icb) |
862 |
icb = icb + 1 |
863 |
calstriphit(k) = vect(icb) |
864 |
icb = icb + 1 |
865 |
C FIRST CALORIMETER SIGNATURE: CA50 |
866 |
icb = icb + 1 |
867 |
C SECOND CALORIMETER SIGNATURE: CA50 |
868 |
icb = icb + 1 |
869 |
C test is here! |
870 |
icb = icb + 1 |
871 |
calDSPtaberr(k) = vect(icb) |
872 |
icb = icb + 1 |
873 |
calevnum(k) = vect(icb) |
874 |
if (k.eq.1) call CALCOMPRESS(vect,icb+1,length-1,dedx1c, |
875 |
& base1) |
876 |
if (k.eq.2) call CALCOMPRESS(vect,icb+1,length-1,dedx2c, |
877 |
& base2) |
878 |
if (k.eq.3) call CALCOMPRESS(vect,icb+1,length-1,dedx3c, |
879 |
& base3) |
880 |
if (k.eq.4) call CALCOMPRESS(vect,icb+1,length-1,dedx4c, |
881 |
& base4) |
882 |
goto 50 |
883 |
endif |
884 |
else if (test.eq.0) then |
885 |
if (length2.gt.2257) then |
886 |
merror(contr) = 135 |
887 |
chi = chi + 4 |
888 |
if (iev.eq.dumpo) |
889 |
& print *,'full lung 4' |
890 |
lleng = 0 |
891 |
goto 150 |
892 |
else |
893 |
icb = icb + 1 |
894 |
calIItrig(k) = vect(icb) |
895 |
icb = icb + 1 |
896 |
calstriphit(k) = vect(icb) |
897 |
icb = icb + 1 |
898 |
C FIRST CALORIMETER SIGNATURE: CA50 |
899 |
icb = icb + 1 |
900 |
C SECOND CALORIMETER SIGNATURE: CA50 |
901 |
icb = icb + 1 |
902 |
C test is here! |
903 |
icb = icb + 1 |
904 |
calDSPtaberr(k) = vect(icb) |
905 |
icb = icb + 1 |
906 |
calevnum(k) = vect(icb) |
907 |
if (k.eq.1) call CALFULL(vect,icb+1,length-1,dedx1, |
908 |
& dedx1c,base1) |
909 |
if (k.eq.2) call CALFULL(vect,icb+1,length-1,dedx2, |
910 |
& dedx2c,base2) |
911 |
if (k.eq.3) call CALFULL(vect,icb+1,length-1,dedx3, |
912 |
& dedx3c,base3) |
913 |
if (k.eq.4) call CALFULL(vect,icb+1,length-1,dedx4, |
914 |
& dedx4c,base4) |
915 |
goto 50 |
916 |
endif |
917 |
else |
918 |
merror(contr) = 136 |
919 |
chi = chi + 4 |
920 |
if (iev.eq.dumpo) |
921 |
& print *,'decoding problems 4' |
922 |
lleng = 0 |
923 |
goto 150 |
924 |
endif |
925 |
c |
926 |
50 continue |
927 |
c |
928 |
C |
929 |
do i = 1,7 |
930 |
calselftrig(k,i) = auto(i) |
931 |
enddo |
932 |
C |
933 |
DO I = 1,11 |
934 |
DO J = 1,96 |
935 |
DEXY(2,2*I,97-J) = DEDX2(I,J) |
936 |
DEXY(1,2*I-1,J) = DEDX4(I,J) |
937 |
DEXY(2,2*I-1,J) = DEDX1(I,J) |
938 |
DEXY(1,2*I,J) = DEDX3(I,J) |
939 |
DEXYC(2,2*I,97-J) = DEDX2C(I,J) |
940 |
DEXYC(1,2*I-1,J) = DEDX4C(I,J) |
941 |
DEXYC(2,2*I-1,J) = DEDX1C(I,J) |
942 |
DEXYC(1,2*I,J) = DEDX3C(I,J) |
943 |
enddo |
944 |
do j = 1,6 |
945 |
base(2,2*i,7-j) = base2(i,j) |
946 |
base(1,2*i-1,j) = base4(i,j) |
947 |
base(2,2*i-1,j) = base1(i,j) |
948 |
base(1,2*i,j) = base3(i,j) |
949 |
enddo |
950 |
enddo |
951 |
C |
952 |
150 continue |
953 |
C |
954 |
contr = contr + 1 |
955 |
C |
956 |
c go on till we have found all the four sections |
957 |
c |
958 |
if (contr.lt.5) goto 20 |
959 |
c |
960 |
200 continue |
961 |
C |
962 |
iscomp = 0 |
963 |
isfull = 0 |
964 |
israw = 0 |
965 |
do i = 1, 4 |
966 |
if (ibits(stwerr(i),16,1).eq.1) iscomp = iscomp + 1 |
967 |
if (ibits(stwerr(i),17,1).eq.1) isfull = isfull + 1 |
968 |
if (ibits(e2(i),3,1).eq.1) israw = israw + 1 |
969 |
enddo |
970 |
if (iscomp.ne.0) chi = chi + 8 * (4 - iscomp) |
971 |
if (israw.ne.0) chi = chi + 8 * (4 - israw) |
972 |
if (isfull.ne.0) chi = chi + 8 * (4 - isfull) |
973 |
C |
974 |
C if chi>10 and we have information enough to understand the physic event |
975 |
C was acquired in a certain mode (RAW, FULL or COMPRESS) then reprocess |
976 |
C the event using this information, sometimes we miss a section due to |
977 |
C CRC errors in the previous one but if we know what we are looking for |
978 |
C then it is possible to save this kind of events. |
979 |
C |
980 |
if (chi.gt.5.and.yesisco.eq.0.and.yesisfu.eq.0 |
981 |
& .and.yesisra.eq.0.and.yescbra.eq.0) then |
982 |
israw = 0 |
983 |
cberaw = 0 |
984 |
do i = 1, 4 |
985 |
if (ibits(e2(i),3,1).eq.1.and.merror(i).eq.0) |
986 |
& israw = israw + 1 |
987 |
if (ibits(e2(i),3,1).eq.1.and.merror(i).eq.132) |
988 |
& cberaw = cberaw + 1 |
989 |
enddo |
990 |
yesisco = 0 |
991 |
yesisfu = 0 |
992 |
yesisra = 0 |
993 |
yescbra = 0 |
994 |
if (iscomp.ne.0) yesisco = 1 |
995 |
if (isfull.ne.0) yesisfu = 1 |
996 |
if (israw.ne.0) yesisra = 1 |
997 |
if (cberaw.ne.0) yescbra = 1 |
998 |
if ((yesisco+yesisfu+yesisra).eq.1.or. |
999 |
& ((yesisco+yesisfu+yesisra).eq.0.and.yescbra.eq.1)) then |
1000 |
if (iev.eq.dumpo) then |
1001 |
print *,'************************' |
1002 |
if (iscomp.ne.0) print *,'is a compress acq.' |
1003 |
if (isfull.ne.0) print *,'is a full acq.' |
1004 |
if (israw.ne.0) print *,'is a raw acq.' |
1005 |
if (israw.eq.0.and.cberaw.ne.0) |
1006 |
& print *,'could be a raw acq.' |
1007 |
print *,'so, SGARBUF, do it again! ',chi |
1008 |
print *,'************************' |
1009 |
endif |
1010 |
SOGLIA0 = SOGLIA0 - ISCOMP - ISFULL - ISRAW |
1011 |
goto 1 |
1012 |
endif |
1013 |
if ((yesisco+yesisfu+yesisra+yescbra).eq.0) chi = 1000 |
1014 |
endif |
1015 |
C |
1016 |
if (iev.eq.dumpo) |
1017 |
& print *,'chi <= soglia0 ?',chi,soglia0 |
1018 |
if (chi.lt.soglia0) then |
1019 |
me = 0 |
1020 |
else |
1021 |
me = 1 |
1022 |
do i = 1, 4 |
1023 |
merror(i) = 129 |
1024 |
e2(i) = 0 |
1025 |
stwerr(i) = 0 |
1026 |
enddo |
1027 |
call clearall |
1028 |
goto 999 |
1029 |
endif |
1030 |
C |
1031 |
C if all section are missing clear vectors and go out |
1032 |
C |
1033 |
if (merror(1).eq.129.and.merror(2).eq.129 |
1034 |
& .and.merror(3).eq.129.and.merror(4).eq.129) then |
1035 |
do l = 1,4 |
1036 |
e2(l) = 0 |
1037 |
stwerr(l) = 0 |
1038 |
enddo |
1039 |
call clearall |
1040 |
endif |
1041 |
c |
1042 |
999 continue |
1043 |
c |
1044 |
do l = 1, 4 |
1045 |
do bit=0, 31 |
1046 |
if (bit.lt.16) then |
1047 |
bi = ibits(E2(L),bit,1) |
1048 |
elseif (bit.gt.17) then |
1049 |
bi = 0 |
1050 |
elseif (bit.ge.16.and.bit.le.17) then |
1051 |
bi = 2 |
1052 |
endif |
1053 |
if (bi.eq.1) then |
1054 |
stwerr(l) = ibset(stwerr(l),bit) |
1055 |
elseif (bi.eq.0) then |
1056 |
stwerr(l) = ibclr(stwerr(l),bit) |
1057 |
endif |
1058 |
enddo |
1059 |
perror(l) = float(merror(l)) |
1060 |
enddo |
1061 |
c |
1062 |
if ( iev.eq.dumpo ) then |
1063 |
if (perror(3).eq.132.and.perror(4).eq.129) then |
1064 |
do i = 1, 2 |
1065 |
do j = 1, 22 |
1066 |
do l = 1, 96 |
1067 |
print *,'Evento ',i,j,l,dexy(i,j,l) |
1068 |
enddo |
1069 |
enddo |
1070 |
enddo |
1071 |
do l=1,lung |
1072 |
write(*,17)l,vecta(l) |
1073 |
enddo |
1074 |
endif |
1075 |
endif |
1076 |
iev = iev + 1 |
1077 |
RETURN |
1078 |
END |
1079 |
|
1080 |
|
1081 |
C------------------------------------------------ |
1082 |
SUBROUTINE CALRAW(vect,inf,sup,dedx) |
1083 |
C------------------------------------------------ |
1084 |
|
1085 |
IMPLICIT NONE |
1086 |
C |
1087 |
INTEGER NPLA, NCHA, LENSEV |
1088 |
PARAMETER (NPLA=22,NCHA=96,LENSEV=NPLA*NCHA) |
1089 |
C |
1090 |
INTEGER*2 VECT(30000) |
1091 |
INTEGER inf, sup |
1092 |
INTEGER i,j,k, iev |
1093 |
INTEGER contr |
1094 |
integer stwerr(4), dumpo, merror(4) |
1095 |
C |
1096 |
REAL DEXY(2,NPLA,NCHA), dexyc(2,npla,ncha), base(2,npla,6) |
1097 |
real calselftrig(4,7), calIItrig(4), calstriphit(4), |
1098 |
& calDSPtaberr(4), calevnum(4) |
1099 |
REAL dedx(11,96) |
1100 |
real perror(4) |
1101 |
C |
1102 |
COMMON / evento / iev, stwerr, perror, |
1103 |
& dexy,dexyc,base, |
1104 |
& calselftrig,calIItrig, |
1105 |
& calstriphit,calDSPtaberr,calevnum |
1106 |
|
1107 |
save / evento / |
1108 |
c |
1109 |
COMMON / VARIE / dumpo, CONTR, merror |
1110 |
SAVE / VARIE / |
1111 |
c |
1112 |
k = inf |
1113 |
do j = 1,96 |
1114 |
do i = 1,11 |
1115 |
DEDX(I,J) = 0. |
1116 |
dedx(i,j) = vect(k) |
1117 |
k = k + 1 |
1118 |
enddo |
1119 |
enddo |
1120 |
c |
1121 |
RETURN |
1122 |
END |
1123 |
|
1124 |
C------------------------------------------------ |
1125 |
SUBROUTINE CALCOMPRESS(vect,inf,sup,dedx,basse) |
1126 |
C------------------------------------------------ |
1127 |
|
1128 |
IMPLICIT NONE |
1129 |
|
1130 |
INTEGER NPLA, NCHA, LENSEV |
1131 |
PARAMETER (NPLA=22,NCHA=96,LENSEV=NPLA*NCHA) |
1132 |
C |
1133 |
INTEGER*2 VECT(30000) |
1134 |
INTEGER*2 st, st1 |
1135 |
INTEGER inf, sup |
1136 |
INTEGER i,j, iev |
1137 |
INTEGER ib |
1138 |
INTEGER ipl, ipr, ist |
1139 |
INTEGER merror(4) |
1140 |
INTEGER contr |
1141 |
integer stwerr(4),dumpo |
1142 |
integer bit,bi |
1143 |
C |
1144 |
REAL DEXY(2,NPLA,NCHA), dexyc(2,npla,ncha), base(2,npla,6) |
1145 |
real calselftrig(4,7), calIItrig(4), calstriphit(4), |
1146 |
& calDSPtaberr(4), calevnum(4) |
1147 |
REAL dedx(11,96), basse(11,6) |
1148 |
real perror(4) |
1149 |
C |
1150 |
COMMON / evento / IEV, stwerr,perror, |
1151 |
& dexy,dexyc,base, |
1152 |
& calselftrig,calIItrig, |
1153 |
& calstriphit,calDSPtaberr,calevnum |
1154 |
|
1155 |
save / evento / |
1156 |
c |
1157 |
COMMON / VARIE / dumpo, CONTR, merror |
1158 |
SAVE / VARIE / |
1159 |
|
1160 |
C |
1161 |
DO I = 1,11 |
1162 |
DO J = 1,96 |
1163 |
if (j.le.6) basse(i,j) = 0. |
1164 |
DEDX(I,J) = 0. |
1165 |
ENDDO |
1166 |
ENDDO |
1167 |
C |
1168 |
i = inf |
1169 |
c |
1170 |
10 continue |
1171 |
if (i.gt.sup) then |
1172 |
RETURN |
1173 |
endif |
1174 |
C |
1175 |
40 format(2x,i5,2x,'status :',1x,Z4) |
1176 |
C |
1177 |
c |
1178 |
st1 = 0 |
1179 |
do bit=0, 7 |
1180 |
bi = ibits(vect(i),bit+8,1) |
1181 |
if (bi.eq.1) st1 = ibset(st1,bit) |
1182 |
enddo |
1183 |
43 format(2x,'vect(i) = ',Z8) |
1184 |
if (st1.eq.8) then |
1185 |
ib = 1 |
1186 |
else |
1187 |
if (st1.eq.16) then |
1188 |
ib = 0 |
1189 |
else |
1190 |
if (iev.eq.dumpo) then |
1191 |
print *,'i ',i |
1192 |
write(*,43)vect(i) |
1193 |
endif |
1194 |
merror(contr) = 139 |
1195 |
RETURN |
1196 |
endif |
1197 |
endif |
1198 |
C |
1199 |
if (ib.eq.1) then |
1200 |
C |
1201 |
st = IAND(vect(i),'00FF'x) |
1202 |
c |
1203 |
ipl = int(st/6) + 1 |
1204 |
ipr = st - (ipl - 1) * 6 + 1 |
1205 |
i = i + 1 |
1206 |
if (i.gt.sup) RETURN |
1207 |
basse(ipl,ipr) = vect(i) |
1208 |
c |
1209 |
20 continue |
1210 |
if (i.gt.sup) RETURN |
1211 |
C |
1212 |
i = i + 1 |
1213 |
if (i.gt.sup) RETURN |
1214 |
if ((vect(i)+1).gt.16.or.(vect(i)+1).lt.1) then |
1215 |
|
1216 |
goto 10 |
1217 |
endif |
1218 |
ist = vect(i) + 1 + 16 * (ipr - 1) |
1219 |
i = i + 1 |
1220 |
if (i.gt.sup) RETURN |
1221 |
dedx(ipl,ist) = vect(i) |
1222 |
goto 20 |
1223 |
else |
1224 |
C |
1225 |
st = IAND(vect(i),'00FF'x) |
1226 |
ipl = int(st/6) + 1 |
1227 |
ipr = st - (ipl - 1) * 6 + 1 |
1228 |
do j = 1,16 |
1229 |
i = i + 1 |
1230 |
if (i.gt.sup) RETURN |
1231 |
ist = j + 16 * (ipr - 1) |
1232 |
dedx(ipl,ist) = vect(i) |
1233 |
enddo |
1234 |
i = i + 1 |
1235 |
if (i.gt.sup) RETURN |
1236 |
goto 10 |
1237 |
C |
1238 |
endif |
1239 |
|
1240 |
|
1241 |
RETURN |
1242 |
END |
1243 |
|
1244 |
|
1245 |
C---------------------------------------------------------- |
1246 |
SUBROUTINE CALFULL(vect,inf,sup,dedx,dedxc,basse) |
1247 |
C-------------------------------------------------------------- |
1248 |
|
1249 |
IMPLICIT NONE |
1250 |
|
1251 |
INTEGER NPLA, NCHA, LENSEV |
1252 |
PARAMETER (NPLA=22,NCHA=96,LENSEV=NPLA*NCHA) |
1253 |
C |
1254 |
INTEGER*2 VECT(30000) |
1255 |
INTEGER inf, sup |
1256 |
INTEGER i,j,k, iev |
1257 |
INTEGER contr |
1258 |
integer stwerr(4),dumpo,merror(4) |
1259 |
C |
1260 |
REAL DEXY(2,NPLA,NCHA), dexyc(2,npla,ncha), base(2,npla,6) |
1261 |
real calselftrig(4,7), calIItrig(4), calstriphit(4), |
1262 |
& calDSPtaberr(4), calevnum(4) |
1263 |
REAL dedx(11,96), basse(11,6), dedxc(11,96) |
1264 |
real perror(4) |
1265 |
C |
1266 |
COMMON / evento / iev, stwerr,perror, |
1267 |
& dexy,dexyc,base, |
1268 |
& calselftrig,calIItrig, |
1269 |
& calstriphit,calDSPtaberr,calevnum |
1270 |
|
1271 |
save / evento / |
1272 |
c |
1273 |
COMMON / VARIE / dumpo, CONTR, merror |
1274 |
SAVE / VARIE / |
1275 |
C |
1276 |
k = inf |
1277 |
do i = 1,11 |
1278 |
do j = 1,96 |
1279 |
DEDX(I,J) = 0. |
1280 |
dedx(i,j) = vect(k) |
1281 |
k = k + 1 |
1282 |
enddo |
1283 |
enddo |
1284 |
C |
1285 |
call CALCOMPRESS(vect,k,sup,dedxc,basse) |
1286 |
C |
1287 |
10 FORMAT(2X,'Status word:',2X,Z8) |
1288 |
|
1289 |
RETURN |
1290 |
END |
1291 |
|
1292 |
|
1293 |
C------------------------------------------------ |
1294 |
SUBROUTINE COUNTER(ve,er) |
1295 |
C------------------------------------------------ |
1296 |
|
1297 |
IMPLICIT NONE |
1298 |
|
1299 |
INTEGER NPLA, NCHA, LENSEV |
1300 |
PARAMETER (NPLA=22,NCHA=96,LENSEV=NPLA*NCHA) |
1301 |
C |
1302 |
INTEGER*2 VE, st4 |
1303 |
INTEGER er, bit, bi, iev |
1304 |
INTEGER contr |
1305 |
integer stwerr(4),dumpo, merror(4) |
1306 |
C |
1307 |
REAL DEXY(2,NPLA,NCHA), dexyc(2,npla,ncha), base(2,npla,6) |
1308 |
real calselftrig(4,7), calIItrig(4), calstriphit(4), |
1309 |
& calDSPtaberr(4), calevnum(4) |
1310 |
real perror(4) |
1311 |
C |
1312 |
COMMON / evento / IEV, stwerr,perror, |
1313 |
& dexy,dexyc,base, |
1314 |
& calselftrig,calIItrig, |
1315 |
& calstriphit,calDSPtaberr,calevnum |
1316 |
|
1317 |
save / evento / |
1318 |
|
1319 |
COMMON / VARIE / dumpo, CONTR, merror |
1320 |
SAVE / VARIE / |
1321 |
|
1322 |
|
1323 |
st4 = 0 |
1324 |
st4 = IAND(ve,'00FF'x) |
1325 |
if (st4.ne.0) then |
1326 |
do bit=0, 6 |
1327 |
bi = ibits(st4,bit,1) |
1328 |
if (bi.ne.0) then |
1329 |
er = er + 2 |
1330 |
endif |
1331 |
enddo |
1332 |
endif |
1333 |
|
1334 |
10 FORMAT(2X,'Status word:',2X,Z4) |
1335 |
return |
1336 |
end |
1337 |
|
1338 |
|
1339 |
C------------------------------------------------ |
1340 |
SUBROUTINE MINERR(ic,icsave,chi,min,co) |
1341 |
C------------------------------------------------ |
1342 |
|
1343 |
IMPLICIT NONE |
1344 |
C |
1345 |
INTEGER NPLA, NCHA, LENSEV |
1346 |
PARAMETER (NPLA=22,NCHA=96,LENSEV=NPLA*NCHA) |
1347 |
C |
1348 |
INTEGER ic, icsave(1000), chi(1000) |
1349 |
integer l, st, min,co |
1350 |
INTEGER iev |
1351 |
INTEGER contr |
1352 |
integer stwerr(4),dumpo, merror(4) |
1353 |
C |
1354 |
REAL DEXY(2,NPLA,NCHA), dexyc(2,npla,ncha), base(2,npla,6) |
1355 |
real calselftrig(4,7), calIItrig(4), calstriphit(4), |
1356 |
& calDSPtaberr(4), calevnum(4) |
1357 |
real perror(4) |
1358 |
C |
1359 |
COMMON / evento / iev, stwerr,perror, |
1360 |
& dexy,dexyc,base, |
1361 |
& calselftrig,calIItrig, |
1362 |
& calstriphit,calDSPtaberr,calevnum |
1363 |
|
1364 |
save / evento / |
1365 |
C |
1366 |
COMMON / VARIE / dumpo, CONTR, merror |
1367 |
SAVE / VARIE / |
1368 |
|
1369 |
st = chi(1) |
1370 |
min = 1 |
1371 |
if (co.gt.1) then |
1372 |
do l = 2, co |
1373 |
if (chi(l).lt.st) then |
1374 |
st = chi(l) |
1375 |
min = l |
1376 |
endif |
1377 |
enddo |
1378 |
endif |
1379 |
ic = icsave(min) |
1380 |
|
1381 |
return |
1382 |
end |
1383 |
|
1384 |
C----------------------------------------------------- |
1385 |
SUBROUTINE CLEARSEC |
1386 |
C----------------------------------------------------- |
1387 |
|
1388 |
IMPLICIT NONE |
1389 |
C |
1390 |
INTEGER NPLA, NCHA, LENSEV |
1391 |
PARAMETER (NPLA=22,NCHA=96,LENSEV=NPLA*NCHA) |
1392 |
C |
1393 |
INTEGER iev |
1394 |
INTEGER contr, i,j |
1395 |
integer stwerr(4),dumpo, merror(4) |
1396 |
C |
1397 |
REAL DEXY(2,NPLA,NCHA), dexyc(2,npla,ncha), base(2,npla,6) |
1398 |
real calselftrig(4,7), calIItrig(4), calstriphit(4), |
1399 |
& calDSPtaberr(4), calevnum(4) |
1400 |
real perror(4) |
1401 |
C |
1402 |
COMMON / evento / iev, stwerr,perror, |
1403 |
& dexy,dexyc,base, |
1404 |
& calselftrig,calIItrig, |
1405 |
& calstriphit,calDSPtaberr,calevnum |
1406 |
|
1407 |
save / evento / |
1408 |
c |
1409 |
COMMON / VARIE / dumpo, CONTR, merror |
1410 |
SAVE / VARIE / |
1411 |
C |
1412 |
DO I = 1,11 |
1413 |
DO J = 1,96 |
1414 |
if (contr.eq.3) then |
1415 |
DEXY(1,2*I,J) = 0. |
1416 |
DEXYC(1,2*I,J) = 0. |
1417 |
endif |
1418 |
if (contr.eq.4) then |
1419 |
DEXY(1,2*I-1,J) = 0. |
1420 |
DEXYC(1,2*I-1,J) = 0. |
1421 |
endif |
1422 |
if (contr.eq.1) then |
1423 |
DEXY(2,2*I-1,J) = 0. |
1424 |
DEXYC(2,2*I-1,J) = 0. |
1425 |
endif |
1426 |
if (contr.eq.2) then |
1427 |
DEXY(2,2*I,97-J) = 0. |
1428 |
DEXYC(2,2*I,97-J) = 0. |
1429 |
endif |
1430 |
enddo |
1431 |
do j = 1,6 |
1432 |
if (contr.eq.1) base(2,2*i-1,7-j) = 0. |
1433 |
if (contr.eq.4) base(1,2*i-1,j) = 0. |
1434 |
if (contr.eq.2) base(2,2*i,j) = 0. |
1435 |
if (contr.eq.3) base(1,2*i,j) = 0. |
1436 |
enddo |
1437 |
if (i.le.7) calselftrig(contr,i) = 0. |
1438 |
enddo |
1439 |
calIItrig(contr) = 0. |
1440 |
calstriphit(contr) = 0. |
1441 |
calDSPtaberr(contr) = 0. |
1442 |
calevnum(contr) = 0. |
1443 |
return |
1444 |
end |
1445 |
C |