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