/[PAMELA software]/yoda/techmodel/forroutines/calorimeter/calunpack.for
ViewVC logotype

Annotation of /yoda/techmodel/forroutines/calorimeter/calunpack.for

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (hide annotations) (download)
Sat Jul 17 20:03:44 2004 UTC (20 years, 5 months ago) by kusanagi
Branch: MAIN
Changes since 1.5: +160 -221 lines
*** empty log message ***

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

  ViewVC Help
Powered by ViewVC 1.1.23