1 |
************************************************************************ |
2 |
* |
3 |
* Program readraw.F |
4 |
* |
5 |
* - creates output files data structure with RUNINFO and LEVEL0 ntuples |
6 |
* - reads raw data input files (FILENAME.DAT, FILENAME.PEDSIG##, |
7 |
* ##=1..12) |
8 |
* - fills ped, sig and bad histograms with online computed (DSP) values |
9 |
* - fills RUNINFO and LEVEL0 ntuples |
10 |
* |
11 |
* needs: |
12 |
* - ./go_readraw go file |
13 |
* - ../data/FILENAME.DAT input data file |
14 |
* - ../data/FILENAME.PEDSIG##, ##=1..12 input pedsig files |
15 |
* - ../common/commontracker.f tracker general common |
16 |
* - ../common/runinfo.f runinfo ntuple common |
17 |
* - ../common/level0.f level0 ntuple common |
18 |
* - ./readevent.c C routine to read input file |
19 |
* |
20 |
* output: |
21 |
* - ../rz/FILENAME.rz ntuples out file |
22 |
* |
23 |
************************************************************************* |
24 |
|
25 |
|
26 |
program readraw |
27 |
|
28 |
include '../common/commontracker.f' |
29 |
include '../common/common_readraw.f' |
30 |
include '../common/level0.f' |
31 |
include '../common/calib.f' |
32 |
|
33 |
include '../tof/common_tof.f' |
34 |
|
35 |
|
36 |
integer trk_DSP_ok(nviews) !mask of found DSP packets |
37 |
common/DSPok/trk_DSP_ok |
38 |
|
39 |
c------------------------------------------------------------------------ |
40 |
c |
41 |
c local variables |
42 |
c |
43 |
c------------------------------------------------------------------------ |
44 |
parameter (nfile_max=20) |
45 |
|
46 |
character*24 processing_date |
47 |
|
48 |
c local variables for input files |
49 |
character*60 name_temp |
50 |
c character*3 aa(nfile_max) |
51 |
character*2 aaa |
52 |
character*40 base_file(nfile_max) !base file name |
53 |
character*40 base_file_runinfo |
54 |
character*40 in_file(nfile_max) !input data file |
55 |
character*40 in_dir !input data dir |
56 |
character*40 out_dir !output dir |
57 |
c character*60 out_file !output rz file |
58 |
character*60 out_file_runinfo !output log file |
59 |
character*60 out_file_level0 !output rz file (level 0) |
60 |
character*60 out_file_calib !output rz file (calibration) |
61 |
character*60 out_file_tof !output rz file (TOF) |
62 |
|
63 |
|
64 |
character*10 input_string(nfile_max) |
65 |
c character*8 date |
66 |
c character*3 particle |
67 |
c integer file_id(nfile_max) |
68 |
|
69 |
c integer file_events(nfile_max) |
70 |
|
71 |
character*200 copystring |
72 |
|
73 |
c integer this_eventn |
74 |
c integer this_calib |
75 |
|
76 |
c local variables for data unpacking |
77 |
logical found_cal_pkt !flag for calibration packets |
78 |
integer ffd !input file descriptor |
79 |
integer runerror !readevent error flag |
80 |
c integer ffd_pkt !pkt file descriptor |
81 |
c !(file temporaneo) |
82 |
parameter (MAXBUFFLEN=z'172c8') |
83 |
integer*4 CPU_pkt_counter |
84 |
c integer pkt_type |
85 |
integer*4 length_buffer |
86 |
integer trk_calib_used |
87 |
integer acq_build_info |
88 |
integer*1 buffer(MAXBUFFLEN) |
89 |
|
90 |
c integer ndummy |
91 |
c data ndummy/1000/ |
92 |
|
93 |
logical DEBUG,ALARMs |
94 |
common/DEBUGflag/DEBUG,ALARMS |
95 |
|
96 |
logical trk_link(2) |
97 |
logical runheader |
98 |
logical skip |
99 |
logical exitflag |
100 |
logical default_calib_written |
101 |
|
102 |
c local parameters |
103 |
parameter (lun_out_file_runinfo=49) !txt log file id number |
104 |
parameter (lun_out_file_calib=50) !output file id number |
105 |
parameter (lun_out_file_level0=51) !output file id number |
106 |
parameter (lun_out_file_tof=52) !output file id number |
107 |
|
108 |
parameter (lun_in_file=53) !input file id number |
109 |
|
110 |
|
111 |
parameter (max_event_number=50000) !maximum number of events |
112 |
|
113 |
integer last_trigger(nviews) |
114 |
common/trigger_counter/last_trigger |
115 |
data last_trigger/12*0./ |
116 |
|
117 |
|
118 |
COMMON/QUEST/IQUEST(100) !permette di ottenere ntuple funzionanti nonostante |
119 |
! il messaggio dei 64K di RZOUT...!??? |
120 |
|
121 |
|
122 |
c------------------------------------------------------------------------ |
123 |
c |
124 |
c HBOOK initialization |
125 |
c |
126 |
c------------------------------------------------------------------------ |
127 |
|
128 |
call HLIMIT(NWPAWC) |
129 |
|
130 |
|
131 |
c------------------------------------------------------------------------ |
132 |
c |
133 |
c reads input informations (through < go_readraw) |
134 |
c |
135 |
c------------------------------------------------------------------------ |
136 |
|
137 |
print*,'______________________________________________' |
138 |
|
139 |
print*,'Number of files to be analysed:' |
140 |
read(*,*)nfile |
141 |
print*,nfile |
142 |
|
143 |
|
144 |
print*,'List of file identifiers: (DATE_NUM)' |
145 |
300 format(A10) |
146 |
read(*,300)(input_string(i),i=1,nfile) |
147 |
write(*,300)(input_string(i),i=1,nfile) |
148 |
|
149 |
|
150 |
in_dir='raw-data/' |
151 |
|
152 |
|
153 |
401 format('DW_',A10) !base file name |
154 |
4401 format(a,'.dat') !input file name |
155 |
|
156 |
|
157 |
do i=1,nfile |
158 |
write(name_temp,401)input_string(i) |
159 |
base_file(i)=name_temp(1:LNBLNK(name_temp)) |
160 |
c print*,base_file(i) |
161 |
write(name_temp,4401) base_file(i)(1:LNBLNK(base_file(i))) |
162 |
in_file(i)=name_temp(1:LNBLNK(name_temp)) |
163 |
print*,in_file(i) |
164 |
c file_events(i)=0 |
165 |
enddo |
166 |
|
167 |
499 format(A40) |
168 |
print*,'output directory:' |
169 |
read(*,499)out_dir |
170 |
print*,out_dir |
171 |
c out_dir='rz/' |
172 |
|
173 |
c$$$ print*,'output files:' !../rz/PART_E_## |
174 |
c$$$ print*,'(name only, without extention)' |
175 |
c$$$ 500 format(A40) |
176 |
c$$$ read(*,500)out_file |
177 |
c$$$ print*,out_file |
178 |
|
179 |
501 format('DW_',A10,'-',A10,'_RUNINFO.txt') |
180 |
base_file_runinfo=name_temp(1:LNBLNK(name_temp)) |
181 |
write(out_file_runinfo,501) input_string(1),input_string(nfile) |
182 |
print*,'RUN INFORMATION:' |
183 |
print*,out_file_runinfo |
184 |
|
185 |
|
186 |
print*,'Total number of events to be analized:' |
187 |
read(*,*)nev_total |
188 |
print*,nev_total |
189 |
print*,'______________________________________________' |
190 |
|
191 |
|
192 |
|
193 |
|
194 |
c------------------------------------------------------------------------ |
195 |
c |
196 |
c Opening log-file RUNINFO |
197 |
c |
198 |
c |
199 |
c------------------------------------------------------------------------ |
200 |
|
201 |
call fdate(processing_date) |
202 |
open(UNIT=lun_out_file_runinfo |
203 |
$ ,FILE=out_dir(1:LNBLNK(out_dir)) |
204 |
$ //out_file_runinfo(1:LNBLNK(out_file_runinfo)) |
205 |
$ ,ACCESS='APPEND' |
206 |
$ ,FORM='FORMATTED' |
207 |
$ ,STATUS='UNKNOWN' |
208 |
$ ) |
209 |
write(lun_out_file_runinfo,101) |
210 |
$ processing_date |
211 |
$ ,nfile |
212 |
c $ ,date |
213 |
$ ,(input_string(i),i=1,nfile) |
214 |
101 format(/ |
215 |
$ ,'*** *** *** *** *** *** *** *** *** *** *** *** ***',/ |
216 |
$ ,'* *',/ |
217 |
$ ,'* READRAW *',/ |
218 |
$ ,'* *',/ |
219 |
$ ,'*** *** *** *** *** *** *** *** *** *** *** *** ***',/ |
220 |
$ ,a24,/ |
221 |
$ ,/ |
222 |
$ ,'Data info',/ |
223 |
$ ,'...................................................',/ |
224 |
$ ,'Number of reduced files ',i6,/ |
225 |
c $ ,'Date ',a6,/ |
226 |
$ ,'List of file identifiers ',/ |
227 |
$ ,A/ |
228 |
$ ) |
229 |
|
230 |
c------------------------------------------------------------------------ |
231 |
c |
232 |
c read run information |
233 |
c |
234 |
c------------------------------------------------------------------------ |
235 |
c level0=.true. !data elaboration level |
236 |
c level1=.false. |
237 |
c level2=.false. |
238 |
c level3=.false. |
239 |
|
240 |
c call read_runinfo !some information about the run is from prompt |
241 |
|
242 |
|
243 |
*------------------------------------------------------------- |
244 |
* |
245 |
* init |
246 |
* |
247 |
*------------------------------------------------------------ |
248 |
* some flags to check the data stream |
249 |
found_cal_pkt=.false. |
250 |
n_cal_pkt_last=0 |
251 |
this_CPU_pkt = 0 |
252 |
|
253 |
|
254 |
iev_total=0 !total number of events |
255 |
nev0_good = 0 |
256 |
n_cal_pkt=0 |
257 |
runheader=.false. |
258 |
|
259 |
trk_link(1)=.false. |
260 |
trk_link(2)=.false. |
261 |
|
262 |
|
263 |
c------------------------------------------------------------------------ |
264 |
c |
265 |
c loop on files |
266 |
c |
267 |
c------------------------------------------------------------------------ |
268 |
|
269 |
do ifile = 1,nfile !files loop |
270 |
|
271 |
c------------------------------------------------------------------------ |
272 |
c init |
273 |
c------------------------------------------------------------------------ |
274 |
default_calib_written=.false. |
275 |
exitflag=.false. |
276 |
nev_file_good = 0 |
277 |
|
278 |
|
279 |
c------------------------------------------------------------------------ |
280 |
c open input file |
281 |
c------------------------------------------------------------------------ |
282 |
|
283 |
write(lun_out_file_runinfo,104) |
284 |
$ ifile |
285 |
$ ,in_file(ifile) |
286 |
104 format(/ |
287 |
$ ,/ |
288 |
$ '+...+...+...+...+...+...+...+...+...+...+...+...+',/ |
289 |
$ ,' Processing file ',i2,/ |
290 |
$ ,' ',a40,/ |
291 |
$ '+...+...+...+...+...+...+...+...+...+...+...+...+' |
292 |
$ ) |
293 |
|
294 |
|
295 |
print*,' ' |
296 |
print*,'OPENING PARTICLE FILE:' |
297 |
print*,in_file(ifile) |
298 |
print*,' ' |
299 |
|
300 |
open(unit=lun_in_file, |
301 |
$ file=in_dir(1:LNBLNK(in_dir)) |
302 |
$ //in_file(ifile)(1:LNBLNK(in_file(ifile))), |
303 |
$ status='old', |
304 |
$ form='unformatted', |
305 |
$ err=22) |
306 |
ffd = FNum(lun_in_file) !reads unix file descriptor |
307 |
|
308 |
c file_events(ifile)=0 !sigle-file event counter |
309 |
c this_eventn=0 |
310 |
|
311 |
c this_CPU_pkt = 0 |
312 |
|
313 |
|
314 |
c------------------------------------------------------------------------ |
315 |
c open output file and book ntuple structure |
316 |
c------------------------------------------------------------------------ |
317 |
502 format(a,'_level0.rz') |
318 |
write(out_file_level0,502) |
319 |
$ base_file(ifile)(1:LNBLNK(base_file(ifile))) |
320 |
c print*,'LEVEL0 EVENT DATA:' |
321 |
c print*,out_file_level0 |
322 |
|
323 |
5022 format(a,'_tof.rz') |
324 |
write(out_file_tof,5022) |
325 |
$ base_file(ifile)(1:LNBLNK(base_file(ifile))) |
326 |
c print*,'TOF EVENT DATA:' |
327 |
c print*,out_file_tof |
328 |
|
329 |
|
330 |
IQUEST(10)=64000 |
331 |
c permette di ottenere ntuple funzionanti nonostante |
332 |
c il messaggio dei 64K di RZOUT... !??? |
333 |
|
334 |
|
335 |
write(lun_out_file_runinfo,103) |
336 |
$ out_file_level0,out_file_tof |
337 |
write(*,103) |
338 |
$ out_file_level0,out_file_tof |
339 |
103 format( |
340 |
$ '*-------------------------------------------------*',/ |
341 |
$ ,' Creating rz files',/ |
342 |
$ ,' ',a40,/ |
343 |
$ ,' ',a40,/ |
344 |
$ '*-------------------------------------------------*',/ |
345 |
c $ ,/ |
346 |
c $ 'Processing events from 1 to ',i6,/ |
347 |
c $ ,/ |
348 |
$ ) |
349 |
|
350 |
|
351 |
* create LEVEL0 tracker file |
352 |
call HROPEN(lun_out_file_level0, |
353 |
$ 'LEVEL0', |
354 |
$ out_dir(1:LNBLNK(out_dir)) |
355 |
$ //out_file_level0(1:LNBLNK(out_file_level0)), |
356 |
$ 'QNP',4096,istat) !opens rz |
357 |
if(istat.ne.0) goto 17 |
358 |
call HCDIR('//LEVEL0',' ') |
359 |
call book_level0 |
360 |
|
361 |
* create TOF tracker file |
362 |
|
363 |
|
364 |
call HROPEN(lun_out_file_tof, |
365 |
$ 'TOF', |
366 |
$ out_dir(1:LNBLNK(out_dir)) |
367 |
$ //out_file_tof(1:LNBLNK(out_file_tof)), |
368 |
$ 'QNP',4096,istat) !opens rz |
369 |
if(istat.ne.0) goto 17 |
370 |
call HCDIR('//TOF',' ') |
371 |
call book_tof |
372 |
|
373 |
c print*,'DONE' |
374 |
print*,' ' |
375 |
|
376 |
|
377 |
|
378 |
|
379 |
c------------------------------------------------------------------------ |
380 |
c |
381 |
c loop on events |
382 |
c |
383 |
c------------------------------------------------------------------------ |
384 |
|
385 |
do iev = 1,min(nev_total,max_event_number) !event loop |
386 |
|
387 |
skip=.false. |
388 |
|
389 |
iev_total=iev_total+1 |
390 |
if(iev_total.eq.nev_total) then |
391 |
exitflag=.true. |
392 |
goto 9900 !stop if nev_total is reached |
393 |
endif |
394 |
|
395 |
**************************************************************** |
396 |
* this routine search for a cpu header pointing to a tracker |
397 |
* packet, and save the content in a temp file |
398 |
* >>>>>> packet.dat <<<<<< |
399 |
|
400 |
c------------------------------------------------------------------------ |
401 |
c look for a cpu packet header |
402 |
c------------------------------------------------------------------------ |
403 |
call findcpuheader(runerror,ffd,pkt_type,CPU_pkt_counter |
404 |
$ ,obt,buffer,length_buffer) |
405 |
|
406 |
|
407 |
c if(runerror.eq.-1) goto 24 |
408 |
if(runerror.eq.-1) then |
409 |
print*,' ' |
410 |
print*,'readraw: ERROR ON READING FILE: ',in_file(ifile) |
411 |
print*,'_____________________________________ ' |
412 |
goto 9900 !next file |
413 |
endif |
414 |
if(runerror.eq.1) then |
415 |
print*,' ' |
416 |
print*,'readraw: FILE: ',in_file(ifile) |
417 |
print*,'readraw: END OF FILE AT EVENT ',iev-1 |
418 |
print*,'_____________________________________ ' |
419 |
goto 9900 !next file |
420 |
endif |
421 |
if(CPU_pkt_counter.le.this_CPU_pkt)then |
422 |
print*,' ' |
423 |
print*,' Non consecutive cpu packet! ' |
424 |
print*,' From ',this_CPU_pkt,' to ',CPU_pkt_counter |
425 |
goto 9900 !next file |
426 |
endif |
427 |
|
428 |
this_CPU_pkt = CPU_pkt_counter |
429 |
name_temp='packet.dat' |
430 |
|
431 |
pkt_num=CPU_pkt_counter |
432 |
|
433 |
****************************************************** |
434 |
****************************************************** |
435 |
****************************************************** |
436 |
****************************************************** |
437 |
****************************************************** |
438 |
****************************************************** |
439 |
****************************************************** |
440 |
****************************************************** |
441 |
|
442 |
|
443 |
|
444 |
c------------------------------------------------------------------------ |
445 |
c read the packet according to packet type as indicated in the header |
446 |
c------------------------------------------------------------------------ |
447 |
|
448 |
if(pkt_type.eq.z'12'.or.pkt_type.eq.z'13')then |
449 |
|
450 |
if(pkt_type.eq.z'12')then |
451 |
trk_link(1)=.true. |
452 |
else |
453 |
trk_link(2)=.true. |
454 |
endif |
455 |
c-- **--**--**--**--**--**--**--**--**--**--**--**--**--**--** |
456 |
c ----------- |
457 |
c CALIBRATION |
458 |
c ----------- |
459 |
c-- **--**--**--**--**--**--**--**--**--**--**--**--**--**--** |
460 |
|
461 |
call trkcalibpkt(runerror,name_temp) |
462 |
|
463 |
elseif(pkt_type.eq.z'10'.or.pkt_type.eq.z'30')then |
464 |
|
465 |
good0=.true. |
466 |
call trkeventpkt(runerror,name_temp) |
467 |
if(runerror.ne.0)then |
468 |
good0=.false. |
469 |
DEBUG = .true. |
470 |
endif |
471 |
|
472 |
call init_tof |
473 |
good=.true. |
474 |
call triggerunpack(buffer,length_buffer,me) |
475 |
if(me.eq.1)good=.false. |
476 |
call tofunpack(buffer,length_buffer,me) |
477 |
if(me.eq.1)good=.false. |
478 |
|
479 |
**** CHECK TRIGGER SEQUENCE **** |
480 |
do idsp=1,nviews |
481 |
if(trk_DSP_ok(idsp).eq.1)then |
482 |
if(eventn(idsp).ne.(last_trigger(idsp)+1) |
483 |
$ .and.eventn(idsp).ne.1) |
484 |
$ write(*,8181) |
485 |
$ idsp,last_trigger(idsp),eventn(idsp) |
486 |
last_trigger(idsp)=eventn(idsp) |
487 |
endif |
488 |
enddo |
489 |
8181 format(i2,' >> JUMP from trigger ',i6,' to ',i6) |
490 |
|
491 |
c$$$ c-- **--**--**--**--**--**--**--**--**--**--**--**--**--**--** |
492 |
c$$$ c ----- |
493 |
c$$$ c EVENT |
494 |
c$$$ c ----- |
495 |
c$$$ c-- **--**--**--**--**--**--**--**--**--**--**--**--**--**--** |
496 |
elseif(pkt_type.eq.z'83')then |
497 |
|
498 |
call trkalarmpkt(buffer,length_buffer,runerror) |
499 |
|
500 |
c$$$ c-- **--**--**--**--**--**--**--**--**--**--**--**--**--**--** |
501 |
c$$$ c ----- |
502 |
c$$$ c ALARM |
503 |
c$$$ c ----- |
504 |
c$$$ c-- **--**--**--**--**--**--**--**--**--**--**--**--**--**--** |
505 |
|
506 |
elseif(pkt_type.eq.z'20')then |
507 |
|
508 |
call runheaderpkt(buffer,length_buffer |
509 |
$ ,trk_calib_used,acq_build_info) |
510 |
c this gives the TRK_CALIB_USED field and the ACQ_BUILD_INFO only |
511 |
c inside the runheader packet |
512 |
c$$$ c-- **--**--**--**--**--**--**--**--**--**--**--**--**--**--** |
513 |
c$$$ c ----- |
514 |
c$$$ c RUNHEADER PACKET |
515 |
c$$$ c ----- |
516 |
c$$$ c-- **--**--**--**--**--**--**--**--**--**--**--**--**--**--** |
517 |
|
518 |
c$$$ 6667 format(z1,' ',z8) |
519 |
c$$$ write(*,6667) trk_calib_used,acq_build_info |
520 |
|
521 |
endif !end pkt type conditions |
522 |
|
523 |
|
524 |
****************************************************** |
525 |
****************************************************** |
526 |
****************************************************** |
527 |
****************************************************** |
528 |
****************************************************** |
529 |
****************************************************** |
530 |
|
531 |
|
532 |
c$$$c---------------------------------------------------------------- |
533 |
c$$$c |
534 |
c$$$c elaborate the packet content |
535 |
c$$$c |
536 |
c$$$c---------------------------------------------------------------- |
537 |
c$$$ |
538 |
c$$$c---------------------------------------------------------------- |
539 |
c$$$c calibration packet: if both 12 and 13 calibration packets |
540 |
c$$$c (corresponding to the X and Y views (in which order?!)) |
541 |
c$$$c have been found, store them |
542 |
c$$$c---------------------------------------------------------------- |
543 |
c$$$ if( |
544 |
c$$$ $ (pkt_type.eq.z'12'.or.pkt_type.eq.z'13').and. |
545 |
c$$$ $ trk_link(1).and. |
546 |
c$$$ $ trk_link(2).and. |
547 |
c$$$ $ .true.) then |
548 |
c$$$c print*,trk_link(1),trk_link(2),pkt_type |
549 |
c$$$c---------------------------------------------------------------- |
550 |
c$$$c a calibration packet has been found |
551 |
c$$$c create a new calibration file: DW_DATE_NUM_NN_calib.rz |
552 |
c$$$c where NN=n_cal_pkt |
553 |
c$$$c --> book and fill histos |
554 |
c$$$c---------------------------------------------------------------- |
555 |
c$$$ |
556 |
c$$$ n_cal_pkt = n_cal_pkt + 1 |
557 |
c$$$ nnnn=n_cal_pkt |
558 |
c$$$ call intstr(nnnn,aaa,2) |
559 |
c$$$ 503 format(a,'_',a2,'_calib.rz') |
560 |
c$$$ write(out_file_calib,503) |
561 |
c$$$ $ base_file(ifile)(1:LNBLNK(base_file(ifile))), |
562 |
c$$$ $ aaa |
563 |
c$$$ |
564 |
c$$$ write(lun_out_file_runinfo,106)out_file_calib |
565 |
c$$$ write(*,106)out_file_calib |
566 |
c$$$ 106 format( |
567 |
c$$$ $ '*----------------------------------------------*',/ |
568 |
c$$$ $ ,' Creating CALIBRATION rz file',/ |
569 |
c$$$ $ ,' ',a40,/ |
570 |
c$$$ $ ,'*---------------------------------------------*' |
571 |
c$$$ $ ) |
572 |
c$$$ |
573 |
c$$$ call HROPEN(lun_out_file_calib, |
574 |
c$$$ $ 'RUNINFO', |
575 |
c$$$ $ out_dir(1:LNBLNK(out_dir)) |
576 |
c$$$ $ //out_file_calib(1:LNBLNK(out_file_calib)), |
577 |
c$$$ $ 'QNP',4096,istat) !opens rz |
578 |
c$$$ if(istat.ne.0) goto 19 |
579 |
c$$$ call HCDIR('//RUNINFO',' ') |
580 |
c$$$ |
581 |
c$$$c print*,out_dir(1:LNBLNK(out_dir)) |
582 |
c$$$c $ //out_file_calib(1:LNBLNK(out_file_calib)) |
583 |
c$$$ |
584 |
c$$$ |
585 |
c$$$ call book_histos |
586 |
c$$$ call fill_histos |
587 |
c$$$ |
588 |
c$$$ call HCDIR('//RUNINFO',' ') |
589 |
c$$$ do iview=1,nviews |
590 |
c$$$c if(trk_DSP_ok(iview).eq.1)then |
591 |
c$$$ call HROUT(id_hi_bad+iview,ICYCLE,'T') |
592 |
c$$$ call HROUT(id_hi_ped+iview,ICYCLE,'T') |
593 |
c$$$ call HROUT(id_hi_sig+iview,ICYCLE,'T') |
594 |
c$$$ call HDELET(id_hi_bad+iview) |
595 |
c$$$ call HDELET(id_hi_ped+iview) |
596 |
c$$$ call HDELET(id_hi_sig+iview) |
597 |
c$$$c endif |
598 |
c$$$ enddo |
599 |
c$$$ call HREND('RUNINFO') |
600 |
c$$$ close(lun_out_file_calib) |
601 |
c$$$ do iview=1,nviews |
602 |
c$$$ trk_DSP_ok(iview)=0 !init DSP flag |
603 |
c$$$ enddo |
604 |
c$$$ trk_link(1)=.false. |
605 |
c$$$ trk_link(2)=.false. |
606 |
c$$$ |
607 |
c$$$c print*,'///////////////////////' |
608 |
c$$$c stop |
609 |
c$$$ |
610 |
c$$$ runheader=.false. !QQQQQQQQQ HA SENSO MESSO QUI?!??? |
611 |
c$$$ |
612 |
c$$$ |
613 |
c$$$ |
614 |
c$$$ |
615 |
c$$$c---------------------------------------------------------------- |
616 |
c$$$c runheader packet: use trk_calib_used and acq_build_info info |
617 |
c$$$c---------------------------------------------------------------- |
618 |
c$$$ elseif( |
619 |
c$$$ $ (pkt_type.eq.z'20') |
620 |
c$$$ $ .and..true.) then |
621 |
c$$$ |
622 |
c$$$ runheader=.true. !a run header has been found |
623 |
c$$$ |
624 |
c$$$ |
625 |
c$$$ if((trk_calib_used.eq.z'1') !use previous calibration |
626 |
c$$$ $ .or.(trk_calib_used.eq.z'2')) then |
627 |
c$$$ |
628 |
c$$$ if(n_cal_pkt.eq.0) then |
629 |
c$$$ print*,'READRAW: WARNING:' |
630 |
c$$$ $ //' Missing calibration for run starting at' |
631 |
c$$$ $ //' event ',iev,'runheader packet' |
632 |
c$$$ $ //' number: ',CPU_pkt_counter,'Using' |
633 |
c$$$ $ //' default one. Readraw should be run on' |
634 |
c$$$ $ //' a complete set of data !' |
635 |
c$$$ goto 777 |
636 |
c$$$ endif |
637 |
c$$$ |
638 |
c$$$ calib=out_file_calib(1:LNBLNK(out_file_calib)) |
639 |
c$$$ |
640 |
c$$$ |
641 |
c$$$c---------------------------------------------------------------- |
642 |
c$$$c if default calibration has been used, create a XXX_00_calib.rz |
643 |
c$$$c with default calibration |
644 |
c$$$c---------------------------------------------------------------- |
645 |
c$$$ elseif((trk_calib_used.eq.z'104') !use default calibration |
646 |
c$$$ $ .and.(.not.default_calib_written)) then |
647 |
c$$$ |
648 |
c$$$ 777 continue |
649 |
c$$$ |
650 |
c$$$ default_calib_written=.true. |
651 |
c$$$ |
652 |
c$$$ 504 format(a,'_00_calib.rz') |
653 |
c$$$ write(out_file_calib,504) |
654 |
c$$$ $ base_file(ifile)(1:LNBLNK(base_file(ifile))) |
655 |
c$$$c write(out_file_calib,503)out_file(1:LNBLNK(out_file)) |
656 |
c$$$c print*,'CREATING DEFAULT CALIBRATION FILE:' |
657 |
c$$$c print*,out_file_calib |
658 |
c$$$ |
659 |
c$$$ write(lun_out_file_runinfo,1033) |
660 |
c$$$ $ out_file_calib |
661 |
c$$$ write(*,1033) |
662 |
c$$$ $ out_file_calib |
663 |
c$$$ 1033 format( |
664 |
c$$$ $ '*-------------------------------------------*',/ |
665 |
c$$$ $ ,' Creating DEFAULT calibration rz file',/ |
666 |
c$$$ $ ,' ',a40,/ |
667 |
c$$$ $ '*-------------------------------------------*',/ |
668 |
c$$$c $ ,/ |
669 |
c$$$c $ 'Processing events from 1 to ',i6,/ |
670 |
c$$$c $ ,/ |
671 |
c$$$ $ ) |
672 |
c$$$ |
673 |
c$$$ copystring='cp ' |
674 |
c$$$ $ //out_dir(1:LNBLNK(out_dir)) |
675 |
c$$$ $ //'default_calib.rz ' |
676 |
c$$$ $ //out_dir(1:LNBLNK(out_dir)) |
677 |
c$$$ $ //out_file_calib(1:LNBLNK(out_file_calib)) |
678 |
c$$$c print*,copystring |
679 |
c$$$ call system(copystring) |
680 |
c$$$ |
681 |
c$$$ calib=out_file_calib(1:LNBLNK(out_file_calib)) |
682 |
c$$$ |
683 |
c$$$ else |
684 |
c$$$ print*,'READRAW: ERROR:' |
685 |
c$$$ $ //' Wrong calibration identifier for run' |
686 |
c$$$ $ //' starting at event ',iev,'(runheader packet' |
687 |
c$$$ $ //' number: ',CPU_pkt_counter,'). Skipping to' |
688 |
c$$$ $ //' next file' |
689 |
c$$$ goto 9900 !next file |
690 |
c$$$ endif |
691 |
c$$$ |
692 |
c$$$ |
693 |
c$$$ |
694 |
c$$$c---------------------------------------------------------------- |
695 |
c$$$c check if the tracker has been included in this run |
696 |
c$$$c---------------------------------------------------------------- |
697 |
c$$$ |
698 |
c$$$ if(iand(acq_build_info,z'00ffff00') |
699 |
c$$$ $ .eq.z'00000000') then |
700 |
c$$$ skip=.true. !skip the event if no DSP has been included in ACQ |
701 |
c$$$ endif |
702 |
c$$$ |
703 |
c$$$ |
704 |
c$$$ |
705 |
c$$$c---------------------------------------------------------------- |
706 |
c$$$c event packet. z'10'=compressed, z'30'=full |
707 |
c$$$c---------------------------------------------------------------- |
708 |
c$$$ |
709 |
c$$$ elseif( |
710 |
c$$$ $ (pkt_type.eq.z'10'.or.pkt_type.eq.z'30') |
711 |
c$$$ $ .and..true.) then |
712 |
c$$$ |
713 |
c$$$ if((pkt_type.eq.z'10').and.(.not.runheader)) then !compressed event have to be inside a run |
714 |
c$$$ print*,'READRAW: ERROR: no runheader for ' |
715 |
c$$$ $ //' event ',iev,'event packet' |
716 |
c$$$ $ //' number: ',CPU_pkt_counter |
717 |
c$$$ endif |
718 |
c$$$ |
719 |
c$$$ if(.not.skip) then |
720 |
c$$$ |
721 |
c$$$C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
722 |
c$$$C then the nt-uple is filled |
723 |
c$$$C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
724 |
c$$$ |
725 |
c$$$ if(good0) nev_file_good = nev_file_good +1 |
726 |
c$$$ |
727 |
c$$$ nev0 = iev |
728 |
c$$$ nev_trk= iev |
729 |
c$$$ |
730 |
c$$$ |
731 |
c$$$ |
732 |
c$$$ call HCDIR('//LEVEL0',' ') |
733 |
c$$$ call HFNT(ntp_level0) !ntuple filling |
734 |
c$$$ |
735 |
c$$$ call HCDIR('//TOF',' ') |
736 |
c$$$ call HFNT(ntp_tof) !ntuple filling |
737 |
c$$$ |
738 |
c$$$ if(mod(iev,100).eq.0)print*,iev |
739 |
c$$$ |
740 |
c$$$ |
741 |
c$$$ dsptot=0 |
742 |
c$$$ do iview=1,nviews |
743 |
c$$$ dsptot=dsptot+trk_DSP_ok(iview) |
744 |
c$$$ trk_DSP_ok(iview)=0 !init DSP flag |
745 |
c$$$ enddo |
746 |
c$$$ |
747 |
c$$$ if(dsptot.lt.nviews)then |
748 |
c$$$ print *,'DSP pkt found: ' |
749 |
c$$$ $ ,(trk_DSP_ok(iview),iview=1,12) |
750 |
c$$$ print *,'---> CPU physics pkt --- ',this_CPU_pkt |
751 |
c$$$ print *,'' |
752 |
c$$$ elseif(DEBUG)then |
753 |
c$$$ print *,'---> CPU physics pkt --- ',this_CPU_pkt |
754 |
c$$$ print *,'' |
755 |
c$$$ DEBUG = .false. |
756 |
c$$$ endif |
757 |
c$$$ |
758 |
c$$$ endif |
759 |
c$$$ |
760 |
c$$$ |
761 |
c$$$ |
762 |
c$$$ |
763 |
c$$$c---------------------------------------------------------------- |
764 |
c$$$c alarm packet |
765 |
c$$$c---------------------------------------------------------------- |
766 |
c$$$ elseif( |
767 |
c$$$ $ pkt_type.eq.z'83'.and. |
768 |
c$$$ $ .true.) then |
769 |
c$$$ |
770 |
c$$$ print*,'' |
771 |
c$$$ print*,'@@@@@@@@@@@@ ALARM @@@@@@@@@@@@@@@' |
772 |
c$$$ print*,'' |
773 |
c$$$ |
774 |
c$$$ |
775 |
c$$$ endif !pkt_type condition |
776 |
|
777 |
9909 continue |
778 |
c close(lun_pkt) |
779 |
|
780 |
enddo !end loop on events |
781 |
|
782 |
9900 continue |
783 |
|
784 |
|
785 |
|
786 |
|
787 |
c------------------------------------------------------------------------ |
788 |
c |
789 |
c closes files and exits |
790 |
c |
791 |
c------------------------------------------------------------------------ |
792 |
close(lun_in_file) |
793 |
|
794 |
nev0_good = nev0_good + nev_file_good |
795 |
write(lun_out_file_runinfo,107) |
796 |
c $ file_events(ifile), |
797 |
$ iev, |
798 |
$ nev_file_good |
799 |
107 format( |
800 |
$ 'Number of events ',i8,/ |
801 |
$ ,'Good events ',i8,/ |
802 |
$ ,'...................................................',/ |
803 |
$ ) |
804 |
|
805 |
|
806 |
print*,' ' |
807 |
print*,'CLOSING FILES:' |
808 |
print*,out_file_level0 |
809 |
print*,out_file_tof |
810 |
print*,' ' |
811 |
|
812 |
call HCDIR('//LEVEL0',' ') |
813 |
call HPRNTU(ntp_level0) !prints ntuple structure |
814 |
c deletes all but the last cycles of all key |
815 |
c from the current working RZ directory |
816 |
call RZPURG(-1) |
817 |
call HROUT(ntp_level0,ICYCLE,'T') |
818 |
call HREND('LEVEL0') |
819 |
close(lun_out_file_level0) |
820 |
|
821 |
call HCDIR('//TOF',' ') |
822 |
call HPRNTU(ntp_tof) !prints ntuple structure |
823 |
c deletes all but the last cycles of all key |
824 |
c from the current working RZ directory |
825 |
call RZPURG(-1) |
826 |
call HROUT(ntp_tof,ICYCLE,'T') |
827 |
call HREND('TOF') |
828 |
close(lun_out_file_tof) |
829 |
|
830 |
|
831 |
close(lun_out_file_runinfo) |
832 |
|
833 |
|
834 |
|
835 |
|
836 |
|
837 |
if(exitflag) goto 9990 !nev_total has been reached --> exit |
838 |
|
839 |
enddo !end loop on files |
840 |
|
841 |
|
842 |
9990 continue |
843 |
write(lun_out_file_runinfo,108) |
844 |
$ iev_total,nev0_good |
845 |
108 format(/ |
846 |
$ ,'|------------------------------------------------|',/ |
847 |
$ ,'| Number of processed events |',/ |
848 |
$ ,'| Total ',i8,' |'/ |
849 |
$ ,'| Good ',i8,' |'/ |
850 |
$ ,'|------------------------------------------------|',/ |
851 |
$ ) |
852 |
|
853 |
|
854 |
goto 9000 !go to end |
855 |
c----------------------------------------- |
856 |
c level0 file creation error |
857 |
c----------------------------------------- |
858 |
17 continue |
859 |
print*,' ' |
860 |
print*,'readraw: ERROR CREATING OUTPUT FILE: ',out_file_level0 |
861 |
print*,istat |
862 |
print*,' ' |
863 |
print*,' ' |
864 |
goto 9000 !the end |
865 |
c----------------------------------------- |
866 |
c tof file creation error |
867 |
c----------------------------------------- |
868 |
18 continue |
869 |
print*,' ' |
870 |
print*,'readraw: ERROR CREATING OUTPUT FILE: ',out_file_tof |
871 |
print*,istat |
872 |
print*,' ' |
873 |
print*,' ' |
874 |
goto 9000 !the end |
875 |
c----------------------------------------- |
876 |
c calibration file creation error |
877 |
c----------------------------------------- |
878 |
19 continue |
879 |
print*,' ' |
880 |
print*,'readraw: ERROR CREATING OUTPUT FILE: ',out_file_calib |
881 |
print*,istat |
882 |
print*,' ' |
883 |
print*,' ' |
884 |
goto 9000 !the end |
885 |
c----------------------------------------- |
886 |
c particle input file opening error |
887 |
c----------------------------------------- |
888 |
22 continue |
889 |
print*,' ' |
890 |
print*,'readraw: ERROR OPENING PARTICLE FILE: ',in_file(ifile) |
891 |
print *,in_dir |
892 |
print *,in_dir(1:LNBLNK(in_dir)) |
893 |
$ //in_file(ifile)(1:LNBLNK(in_file(ifile))) |
894 |
print*,' ' |
895 |
goto 9000 !the end |
896 |
|
897 |
|
898 |
c------------------------------------------------------------------------ |
899 |
c |
900 |
c exit |
901 |
c |
902 |
c------------------------------------------------------------------------ |
903 |
9000 continue |
904 |
|
905 |
|
906 |
stop |
907 |
end |