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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6.0 - (hide annotations) (download)
Tue Feb 7 17:11:10 2006 UTC (18 years, 10 months ago) by kusanagi
Branch: MAIN
CVS Tags: yodaPreTermistors2_1/00, YODA6_2/01, YODA6_2/00, YODA6_1/00, YODA6_0/00, YODA6_3/04, YODA6_3/00, YODA6_3/01, YODA6_3/02, YODA6_3/03, yodaPreTermistores2_0/00
Changes since 5.1: +0 -0 lines
Several new features in this revision:
a) all the packets are conform to the Mass Memory Format specifications (http://people.roma2.infn.it/~cpu/Mass_Memory_Format.html)
b) unpacking either using the old files structure OR the new one file unpacking.
c) parametrized root files compression factor
d) deleting of the following packet: TofTest, TrkTest, TrkEvent.
e) the Tracker routines now work without the use of temp files.

The point a) allow Yoda to unpack in the root file all the packets generated by the CPU. According to the MassMemoryFormat; that is three possible data are available:

1) almost explicit structure of the packet (like for Log, Tracker, Mcmd, etc....);
2) dummy data collection structure (InitHeader, InitTrailer, CalibHeader, CalibTrailer);
3) just the data of the packet (almost all Alarm and Init procedures). The class regarding this packets have only one parameters, a TArrayC class, which contain the data-block included in the packet (tat is the data below the packet Header).

The point b) has been implemented as a consequence of an agreement about a more compact structure of the unpacked data. Up to now the structure of each unpacked data consisted of a folder, named after the packet type, and three files: xxx.Header.root, xxx.NamePacket.root, xxx.Registry.root.
Starting from this release YODA, by default will unpack the data in a unique root file. The structure of this file will consist of:
- several TTree(s) named after the packet type;
- into each TTree are foreseen three TBranche(s):
    - 'Header'  (the old xxx.Header.root file)
    - 'NameOfThePacket' (the old xxx.Event.root file or the xxx.Event.DETECTOR.root)
    - 'Registry' (the old xxx.Registry.root file)

Anyway is still possible, but deprecated, to unpack using the old structure, passing to the "yoda" command the optional parameter "-multifile"

The point c) has been implemented because is well know that writing time in a TTree is as much fast as much lower is the compression factor for the root file; anyway for a PAMELA dat file, a compression equal to 0 will generate a root file which will be more than two times the original size. To modify the compression parameter just add the optional parameter "-c [0-9]" to the yoda command line.

1 kusanagi 5.1
2 kusanagi 1.8 C
3     C Written by Mirko Boezio and Emiliano Mocchiutti
4     C
5 kusanagi 5.1 C * Version: 3.1.2 *
6     C
7     C 3.1.1 - 3.1.2: (2005-12-02) recognize RAW mode command and exit with error 130.
8 kusanagi 2.5 C
9     C 3.1.0 - 3.1.1: (2004-12-21) changed common varie.
10 kusanagi 2.4 C
11     C 3.0.01 - 3.1.0: (2004-12-10) cleanup of the code and changes in the
12     C sections order.
13 kusanagi 1.8 C
14 kusanagi 2.3 C 3.0.00 - 3.0.01: (2004-11-08) changes in the commons (one more common for
15     C calpulse and from calstripshit to calstriphit).
16     C
17     C previous - 3.0.00: (2004-10-25) cleanup, some small bugs fixed
18 kusanagi 1.10 C
19     C - fixed compilation error
20     C
21 kusanagi 1.3 C------------------------------------------------
22 kusanagi 1.6 SUBROUTINE CALPEDESTAL(vecta,lung,me)
23 kusanagi 1.3 C------------------------------------------------
24    
25     IMPLICIT NONE
26     C
27     C Normal variables definition
28     C
29 kusanagi 2.3 integer lung
30 kusanagi 1.3 INTEGER NPLA, NCHA, LENSEV
31     PARAMETER (NPLA=22,NCHA=96,LENSEV=NPLA*NCHA)
32     C
33 kusanagi 2.3 INTEGER*1 VECTA(lung)
34 kusanagi 1.9 INTEGER*2 VECT(60000)
35 kusanagi 1.3 C
36     integer*2 check, crc, e2(4)
37 kusanagi 2.3 INTEGER*2 length, length2
38     integer*4 chksum, chksum2
39 kusanagi 1.3 C
40 kusanagi 2.3 integer me, lleng
41 kusanagi 2.4 INTEGER i, j
42 kusanagi 2.5 INTEGER ERROR(4), merror(4)
43 kusanagi 2.3 INTEGER ic, k, ke, ic0, l
44     INTEGER contr, m
45 kusanagi 2.4 INTEGER inf, sup,iev
46 kusanagi 1.3 INTEGER XO, YO, XE, YE
47 kusanagi 2.3 integer st1b, st2b, bit, bi, icb
48     INTEGER lunga, pari
49     integer stwerr(4),dump, cstwerr(4)
50     C
51 kusanagi 1.3 REAL calped(4,11,96), calgood(4,11,96), calthr(4,11,6)
52     REAL calrms(4,11,96), calbase(4,11,6), calvar(4,11,6)
53 kusanagi 2.3 real perror(4), cperror(4)
54     C
55     DATA YE/182/ ! CODE_DSP_R YE = 101 10110
56 kusanagi 1.3 DATA YO/173/ ! CODE_DSP_R YO = 101 01101
57     DATA XE/170/ ! CODE_DSP_R XE = 101 01010
58 kusanagi 2.3 DATA XO/177/ ! CODE_DSP_R XO = 101 10001
59 kusanagi 1.3
60 kusanagi 2.4 COMMON / calib / iev, cstwerr, cperror,
61 kusanagi 2.3 & calped, calgood, calthr, calrms,
62     & calbase, calvar
63    
64     save / calib /
65     c
66 kusanagi 2.5 COMMON /VARIE/ dump, contr, merror
67 kusanagi 1.3 SAVE /VARIE/
68    
69     C
70     C Begin !
71     C
72 kusanagi 2.3 if (dump.eq.0) dump = -1
73     C
74     C DEBUG: PRINT OUT THE INPUT VECTOR
75     C
76 kusanagi 2.4 if (iev.eq.dump) then
77 kusanagi 2.3 do l=1,lung
78     write(*,17)l,vecta(l)
79     enddo
80     endif
81     17 FORMAT(2X,'Elemento:',2X,I6,2X,' word:',2X,Z8)
82     C
83 kusanagi 2.4 if (iev.lt.0.or.iev.gt.9000000) iev = 0
84 kusanagi 2.3 C
85     call clearall
86     do i = 1, 4
87     cstwerr(i) = 0
88     cperror(i) = 0.
89     error(i) = 0
90     e2(i) = 0
91     stwerr(i) = 0
92     enddo
93 kusanagi 1.8 contr = 1
94 kusanagi 1.3 me = 0
95 kusanagi 1.7 lleng = 0
96 kusanagi 2.3 ic = 0
97 kusanagi 1.7 pari = 0
98 kusanagi 2.3 length = 0
99     C
100     C input length must be > 0, if not go out with error code 142
101     C
102     if (lung.le.0) then
103     if (dump.eq.iev) print *,'lung = ',lung
104     do i=1,4
105     error(i)=142
106     enddo
107     goto 200
108     endif
109     C
110 kusanagi 5.1 C
111 kusanagi 1.7 IF (MOD(LUNG,2).EQ.0) THEN
112     lunga = lung / 2
113     pari = 1
114     else
115     lunga = int(lung/2) + 1
116     endif
117     c
118 kusanagi 1.9 if (lunga.gt.60000.and.dump.gt.0) then
119 kusanagi 2.1 print *,'Calorimeter WARNING: more than 60000 words!'
120 kusanagi 1.9 lunga = 60000
121 kusanagi 1.7 endif
122 kusanagi 1.3 c
123 kusanagi 5.1 C
124     C the fafede18 packet can also contain the answer to the force RAW mode command
125     C in that case the lenght is 4 and the answer is known.
126     C
127     IF (LUNG.LE.20) THEN
128     if (dump.eq.iev) print *,' RAW MODE COMMAND? '
129     print *,'vecta(1) ',vecta(1),' ',vecta(3)
130     IF ((VECTA(1).EQ.10.AND.VECTA(3).eq.74).or.
131     & (VECTA(1).EQ.17.AND.VECTA(3).eq.81).or.
132     & (VECTA(1).EQ.22.AND.VECTA(3).eq.86).or.
133     & (VECTA(1).EQ.13.AND.VECTA(3).eq.77)) THEN
134     if (dump.eq.iev) print *,' YES! '
135     call fillin(1,lunga,lleng,lung,pari,vect,vecta)
136     if (VECTA(1).EQ.10) contr = 1
137     if (VECTA(1).EQ.17) contr = 2
138     if (VECTA(1).EQ.22) contr = 3
139     if (VECTA(1).EQ.13) contr = 4
140     E2(contr) = vect(2)
141     do i=1,4
142     error(i)=130
143     enddo
144     goto 200
145     ENDIF
146     ENDIF
147     C
148     C
149     C
150     c
151 kusanagi 1.3 20 CONTINUE
152 kusanagi 1.6 ic = ic + length + 1
153 kusanagi 1.5 32 continue
154 kusanagi 1.3 ke = 0
155     do while (ke.eq.0)
156 kusanagi 2.3 C
157     C Check consistency of header.
158     C it is composed by CODE+D# (8 bits) and by SATUS WORD (8 bits)
159     c so we must split vect into the two components:
160     C
161     C ST1 is CODE + D#
162     c
163 kusanagi 1.6 st1b = 0
164     st2b = 0
165     do bit = 0, 7
166     bi = ibits(vecta(ic),bit,1)
167     if (bi.eq.1) st1b = ibset(st1b,bit)
168     bi = ibits(vecta(ic+1),bit,1)
169     if (bi.eq.1) st2b = ibset(st2b,bit)
170     enddo
171     c
172 kusanagi 1.3 C ST2 is the STATUS WORD
173 kusanagi 1.6 c
174     length2 = 0
175     do bit=0, 7
176     bi = ibits(vecta(ic+3),bit,1)
177     if (bi.eq.1) length2 = ibset(length2,bit)
178     bi = ibits(vecta(ic+2),bit,1)
179     if (bi.eq.1) length2 = ibset(length2,bit+8)
180     enddo
181     c the crc should be at vect(length) with
182     length = length2 + 1
183     C
184     c some checks to be sure we have found the calorimeter data:
185     c
186     c status word is always less then 129
187     c
188     if (st2b.gt.128) then
189     length = 0
190     goto 100
191     endif
192     c
193     c length of the packet must be less then 20000 if no errors
194     c are found
195 kusanagi 2.3 c
196 kusanagi 1.7 if (st2b.eq.0.and.length2.gt.lunga) then
197 kusanagi 1.6 length = 0
198     goto 100
199     endif
200     c
201     if (length2.le.0) then
202     length = 0
203     goto 100
204     endif
205 kusanagi 1.3 c
206 kusanagi 1.6 c is it the first section?
207 kusanagi 2.3 c
208 kusanagi 2.4 if (st1b.eq.XE.and.length2.eq.4629) then
209 kusanagi 1.6 c if so go out of this loop and go on recording data
210 kusanagi 2.3 ke = 1
211     m = ic
212     contr = 1
213     call fillin(m,lunga,lleng,lung,pari,vect,vecta)
214     icb = 1
215     E2(contr) = vect(icb)
216     goto 9
217     endif
218 kusanagi 1.3 C
219 kusanagi 1.8 c the same for the second section, ...
220 kusanagi 1.6 c
221 kusanagi 2.4 if (st1b.eq.XO.and.length2.eq.4629) then
222 kusanagi 2.3 ke = 1
223     contr = 2
224     m = ic
225     call fillin(m,lunga,lleng,lung,pari,vect,vecta)
226     icb = 1
227     E2(contr) = vect(icb)
228     goto 9
229     endif
230 kusanagi 1.6 c
231     C ... for the third,...
232     c
233 kusanagi 2.4 if (st1b.eq.YE.and.length2.eq.4629) then
234 kusanagi 2.3 ke = 1
235     m = ic
236     contr = 3
237     call fillin(m,lunga,lleng,lung,pari,vect,vecta)
238     icb = 1
239     E2(contr) = vect(icb)
240     goto 9
241     endif
242 kusanagi 1.3 C
243 kusanagi 1.6 c ...and for the last section.
244     c
245 kusanagi 2.4 if (st1b.eq.YO.and.length2.eq.4629) then
246 kusanagi 2.3 contr = 4
247     ke = 1
248     m = ic
249     call fillin(m,lunga,lleng,lung,pari,vect,vecta)
250     icb = 1
251     E2(contr) = vect(icb)
252     endif
253 kusanagi 1.3 C
254     100 CONTINUE
255 kusanagi 2.3 c
256 kusanagi 1.6 c increment vector of one searching for the next section
257     c
258     9 continue
259 kusanagi 1.3 ic = ic + 1
260 kusanagi 1.6 c
261     c if we run out of vector give an error and exit the subroutine
262     c
263 kusanagi 1.7 if (ic.gt.(lung-1)) then
264 kusanagi 1.3 me = 1
265 kusanagi 2.3 call clearall
266     do i = 1, 4
267     error(i) = 129
268     e2(i) = 0
269     stwerr(i) = 0
270     enddo
271 kusanagi 1.3 goto 200
272     endif
273     enddo
274     C
275     10 FORMAT(2X,'Error for view:',2X,I1,2X,'Status word:',2X,Z4)
276     11 FORMAT(2X,'View or command not recognized for view:',2X,I1,2X,
277     & 'Status word:',2X,Z4)
278     12 FORMAT(2X,'Error - did NOT find view:',2X,I1)
279     13 FORMAT(2X,'Error - eov reached, exiting')
280 kusanagi 1.10 21 FORMAT(2X,'CRC: ',2X,Z8)
281 kusanagi 1.3 101 FORMAT(2X,'Status word 1:',2X,Z8)
282 kusanagi 1.7 102 FORMAT(2X,'CHKSUM: ',2X,Z16)
283 kusanagi 1.3 201 FORMAT(2X,'Status word 2:',2X,Z8)
284     C
285     K = CONTR
286 kusanagi 1.6 ic0 = icb
287     ic = ic - 1
288     icb = icb + 1
289     length = vect(icb) + 2
290     length2 = vect(icb)
291 kusanagi 1.7 lleng = (length * 2) - 1
292 kusanagi 1.3 C
293     C Check consistency of CRC.
294     C
295     check = 0.
296     inf = ic0
297     sup = length - 1
298     do i = inf,sup
299     check=crc(check,vect(i))
300     enddo
301     if (check.ne.vect(length)) then
302     ERROR(contr) = 132
303     goto 200
304     endif
305     C
306 kusanagi 2.4 if (iev.eq.dump) write(*,21)vect(length)
307     if (iev.eq.dump) write(*,21)check
308 kusanagi 1.9 C
309 kusanagi 1.3 C Process data.
310     C
311 kusanagi 1.6 if (k.eq.1) then
312 kusanagi 2.4 k = 1
313 kusanagi 1.6 goto 49
314     endif
315     if (k.eq.2) then
316 kusanagi 2.4 k = 3
317 kusanagi 1.6 goto 49
318     endif
319     if (k.eq.3) then
320 kusanagi 2.4 k = 4
321 kusanagi 1.6 goto 49
322     endif
323 kusanagi 2.4 if (k.eq.4) k = 2
324 kusanagi 1.6 c
325     49 continue
326     c
327 kusanagi 1.7 chksum = 0
328 kusanagi 1.3 do i = 1,11
329     do j = 1,96
330 kusanagi 1.6 icb = icb + 1
331     if (k.eq.1) then
332     calped(k,i,97-j) = vect(icb)
333     calgood(k,i,97-j) = vect(icb+1)
334     else
335     calped(k,i,j) = vect(icb)
336     calgood(k,i,j) = vect(icb+1)
337     endif
338 kusanagi 1.7 chksum = chksum + vect(icb)
339 kusanagi 1.6 icb = icb + 1
340 kusanagi 1.3 enddo
341     enddo
342     C
343 kusanagi 1.7 chksum2 = 0
344     do bit=0, 15
345     bi = ibits(vect(icb+1),bit,1)
346     if (bi.eq.1) chksum2 = ibset(chksum2,bit)
347     bi = ibits(vect(icb+3),bit,1)
348     if (bi.eq.1) chksum2 = ibset(chksum2,bit+16)
349     enddo
350     C
351     if (chksum.ne.chksum2) then
352     error(contr) = 140
353     endif
354     C
355 kusanagi 1.6 icb = icb + 4
356 kusanagi 1.7 chksum = 0
357 kusanagi 1.3 do i = 1,11
358     do j = 1,6
359 kusanagi 1.6 icb = icb + 1
360     if (k.eq.1) then
361     calthr(k,i,7-j) = vect(icb)
362     else
363     calthr(k,i,j) = vect(icb)
364     endif
365 kusanagi 1.7 chksum = chksum + vect(icb)
366 kusanagi 1.6 icb = icb + 1
367 kusanagi 1.3 enddo
368     enddo
369     c
370 kusanagi 1.7 chksum2 = 0
371     do bit=0, 15
372     bi = ibits(vect(icb+1),bit,1)
373     if (bi.eq.1) chksum2 = ibset(chksum2,bit)
374     bi = ibits(vect(icb+3),bit,1)
375     if (bi.eq.1) chksum2 = ibset(chksum2,bit+16)
376     enddo
377     C
378     if (chksum.ne.chksum2) then
379     error(contr) = 141
380     endif
381     C
382 kusanagi 1.6 icb = icb + 4
383 kusanagi 1.3 do i = 1,11
384     do j = 1,96
385 kusanagi 1.6 icb = icb + 1
386     if (k.eq.1) then
387     calrms(k,i,97-j) = vect(icb)
388     else
389     calrms(k,i,j) = vect(icb)
390     endif
391     icb = icb + 1
392 kusanagi 1.3 enddo
393     enddo
394 kusanagi 1.6 c
395 kusanagi 1.3 do i = 1,11
396     do j = 1,6
397 kusanagi 1.6 icb = icb + 1
398     if (k.eq.1) then
399     calbase(k,i,7-j) = vect(icb)
400     icb = icb + 1
401     icb = icb + 1
402     calvar(k,i,7-j) = vect(icb)
403     icb = icb + 1
404     else
405     calbase(k,i,j) = vect(icb)
406     icb = icb + 1
407     icb = icb + 1
408     calvar(k,i,j) = vect(icb)
409     icb = icb + 1
410     endif
411 kusanagi 1.3 enddo
412     enddo
413     me = 0
414     c
415     c
416     50 continue
417     C
418     200 continue
419 kusanagi 1.8 C
420     do l = 1, 4
421     do bit=0, 31
422     if (bit.lt.16) then
423     bi = ibits(E2(L),bit,1)
424     else
425     bi = 0
426     endif
427 kusanagi 2.1 if (bi.eq.1) then
428     stwerr(l) = ibset(stwerr(l),bit)
429     else
430     stwerr(l) = ibclr(stwerr(l),bit)
431     endif
432 kusanagi 1.8 enddo
433 kusanagi 2.3 perror(l) = float(error(l))
434     cstwerr(l) = stwerr(l)
435     cperror(l) = perror(l)
436 kusanagi 1.8 enddo
437 kusanagi 2.3 C
438 kusanagi 2.4 iev = iev + 1
439 kusanagi 1.3 C
440     RETURN
441 kusanagi 5.1 END

  ViewVC Help
Powered by ViewVC 1.1.23