1 |
C-------------------------------------------------------------------- |
C-------------------------------------------------------------------- |
2 |
SUBROUTINE TOFUNPACK(vecta,lung,me) |
SUBROUTINE TOFUNPACK(vecta,lung,me) |
3 |
|
|
4 |
C modified D.Campana, Mar. 06 |
C modified D.Campana, May. 06 |
5 |
C D.Campana, Dec. 04 |
C D.Campana, Dec. 04 |
6 |
C-------------------------------------------------------------------- |
C-------------------------------------------------------------------- |
7 |
|
|
46 |
C |
C |
47 |
ic = start |
ic = start |
48 |
C |
C |
49 |
c print *,'++++++++++ Tof Unpack ++++++++++++++++' |
c print *,'++++++++++ Tof Unpack entro ++++++++++++++++' |
50 |
|
|
51 |
dspcold = 0 |
dspcold = 0 |
52 |
dsphot = 0 |
dsphot = 0 |
71 |
bi = ibits(vecta(ic+1),bit,1) |
bi = ibits(vecta(ic+1),bit,1) |
72 |
if (bi.eq.1) evcount(j) = ibset(evcount(j),bit) |
if (bi.eq.1) evcount(j) = ibset(evcount(j),bit) |
73 |
enddo |
enddo |
|
c print *,'tdcnum(j),boardnum(j)' |
|
|
c print *, tdcnum(j),boardnum(j) |
|
74 |
c |
c |
75 |
ic=ic+2 |
ic=ic+2 |
76 |
|
c print *,'++++++++++ Tof Unpack 2 ++++++++++++++++' |
77 |
tdcmask(j) = 0 |
tdcmask(j) = 0 |
78 |
do bit = 0, 7 |
do bit = 0, 7 |
79 |
bi = ibits(vecta(ic),bit,1) |
bi = ibits(vecta(ic),bit,1) |
84 |
c |
c |
85 |
ic=ic+2 |
ic=ic+2 |
86 |
c |
c |
87 |
|
c print *,'++++++++++ Tof Unpack 3 ++++++++++++++++' |
88 |
c |
c |
89 |
c if the first word RAWADC are equal to 0 |
c if the first word RAWADC are equal to 0 |
90 |
c the data storage is shifted by a word --> ic = ic+1 |
c the data storage is shifted by a word --> ic = ic+1 |
119 |
endif |
endif |
120 |
endif |
endif |
121 |
endif |
endif |
122 |
c |
c |
123 |
|
c print *,'++++++++++ Tof Unpack 4 ++++++++++++++++' |
124 |
|
c |
125 |
|
|
126 |
do i=1,16 |
do i=1,16 |
127 |
do iword=0,17 |
do iword=0,17 |
128 |
vectof(ic+iword,i)=0 |
vectof(ic+iword,i)=0 |
143 |
endif |
endif |
144 |
endif |
endif |
145 |
|
|
146 |
|
c print *,'++++++++++ Tof Unpack 5 ++++++++++++++++' |
147 |
|
|
148 |
c |
c |
149 |
c -----fine cura inversione cavo FE to DSP cold |
c -----fine cura inversione cavo FE to DSP cold |
150 |
c |
c |
177 |
C ----------------- Controllo sulla parola ADC |
C ----------------- Controllo sulla parola ADC |
178 |
C |
C |
179 |
11 continue |
11 continue |
180 |
|
if (ind.lt.15)then |
181 |
tdccodeq = 0 |
tdccodeq = 0 |
182 |
|
c print *,'++++++++++ Tof Unpack 6 (11 continue) ++++++++++++' |
183 |
C |
C |
184 |
do bit = 5,7 |
do bit = 5,7 |
185 |
bi = ibits(vectof(ic,ind),bit,1) |
bi = ibits(vectof(ic,ind),bit,1) |
190 |
c |
c |
191 |
c------------- controllo che la colpa dei 2 zeri non sia di TDC(ch1) |
c------------- controllo che la colpa dei 2 zeri non sia di TDC(ch1) |
192 |
c |
c |
193 |
if ((iadd.eq.3).and.(tdc_ch1.eq.0))then |
if ((iadd.eq.3).and.(tdc_ch1.eq.0))then |
194 |
if (tdccodeq.ne.0) then |
if (tdccodeq.ne.0) then |
195 |
c print *,'2 zeri in ADC, ma la colpa forse e` del TDC' |
c print *,'2 zeri in ADC, ma la colpa forse e` del TDC' |
196 |
ic=ic-4 |
ic=ic-4 |
199 |
adc_ch2=99 |
adc_ch2=99 |
200 |
goto 12 |
goto 12 |
201 |
endif |
endif |
202 |
endif |
endif |
203 |
c--------------- fine controllo |
c--------------- fine controllo |
204 |
c |
c |
205 |
c PRINT *, '---------shift di 2 zeri sui dati ADC ! ' |
c PRINT *, '---------shift di 2 zeri sui dati ADC ! ' |
227 |
c |
c |
228 |
if(iadd.eq.3)adc_ch2=adc_ch2+1 |
if(iadd.eq.3)adc_ch2=adc_ch2+1 |
229 |
ind = (ind + 1) ! aggiorno l' indice |
ind = (ind + 1) ! aggiorno l' indice |
230 |
if (ind.le.14)then |
if (ind.lt.15)then |
231 |
go to 11 ! rifaccio il check |
go to 11 ! rifaccio il check |
232 |
else |
else |
233 |
c print *,'exit ADC senza soluzione',ind |
c print *,'exit ADC senza soluzione',ind |
234 |
|
continue |
235 |
endif |
endif |
236 |
endif |
endif |
237 |
|
|
238 |
c ------- se e' l'ADC channel 2 bisogna ricontrollare il TDC precedente |
c ------- se e' l'ADC channel 2 bisogna ricontrollare il TDC precedente |
239 |
|
|
240 |
if ((iadd.eq.3).and.(adc_ch2.ge.2).and.(tdc_ch1.eq.0))then |
if ((iadd.eq.3).and.(adc_ch2.ge.2).and.(tdc_ch1.eq.0))then |
241 |
c print *,'ci sono!!!!!!!!!!!!!!!!!!' |
c print *,'ci sono!!ADC ch 2 torno al TDC!!!' |
242 |
c print *,'adc_ch2 = ',adc_ch2 |
c print *,'adc_ch2 = ',adc_ch2 |
243 |
c print *,'ind = ',ind |
c print *,'ind = ',ind |
244 |
|
|
245 |
ind=ind-adc_ch2 |
ind=ind-adc_ch2 |
246 |
c print *,'ind - adc_ch2 = ',ind |
c print *,'ind - adc_ch2 = ',ind |
247 |
do ik=1,adc_ch2 |
do ik=1,adc_ch2 |
254 |
ii=1 |
ii=1 |
255 |
goto 12 |
goto 12 |
256 |
endif |
endif |
257 |
|
|
258 |
|
endif ! fine controllo su ind < 15 |
259 |
|
|
260 |
|
c print *,'++++++++++ Tof Unpack 6,5 registro ADC ++++++++++++++' |
261 |
c |
c |
262 |
c --- registro RAWADC |
c --- registro RAWADC |
263 |
c |
c |
273 |
C ----------------- Controllo sulla parola TDC |
C ----------------- Controllo sulla parola TDC |
274 |
C |
C |
275 |
12 continue |
12 continue |
276 |
tdccodet = 0 |
if (ind.lt.16)then |
277 |
|
tdccodet = 0 |
278 |
|
c print *,'++++++++++ Tof Unpack 7 (12 continue) ++++++++++++++++' |
279 |
do bit = 5,7 |
do bit = 5,7 |
280 |
bi = ibits(vectof(ic+2,ind),bit,1) |
bi = ibits(vectof(ic+2,ind),bit,1) |
281 |
if (bi.eq.1) tdccodet = ibset(tdccodet,bit-5) |
if (bi.eq.1) tdccodet = ibset(tdccodet,bit-5) |
311 |
c |
c |
312 |
if(iadd.eq.1)tdc_ch1=tdc_ch1+1 |
if(iadd.eq.1)tdc_ch1=tdc_ch1+1 |
313 |
ind = (ind + 1) ! aggiorno l' indice |
ind = (ind + 1) ! aggiorno l' indice |
314 |
if (ind.le.15) then |
if (ind.lt.16) then |
315 |
go to 12 ! rifaccio il check |
go to 12 ! rifaccio il check |
316 |
else |
else |
317 |
c print *,'exit TDC senza successo ',ind |
c print *,'exit TDC senza successo ',ind |
318 |
|
continue |
319 |
endif |
endif |
320 |
endif |
endif |
321 |
|
|
322 |
|
endif ! fine controllo su ind < 16 |
323 |
|
|
324 |
|
c print *,'++++++++++ Tof Unpack 8 registro TDC +++++++++++++' |
325 |
c |
c |
326 |
c --- registro RAWTDC |
c --- registro RAWTDC |
327 |
c |
c |
335 |
c |
c |
336 |
c |
c |
337 |
c ------- se e' il TDC channel 1 e' il risultato dell'iterazione prodotta |
c ------- se e' il TDC channel 1 e' il risultato dell'iterazione prodotta |
338 |
c dall' ADC channel 2 bisogna ripassare all' ADC successivo |
c dall' ADC channel 2 bisogna ripassare all' ADC successivo |
339 |
|
|
340 |
if ((iadd.eq.1).and.(icorr.eq.1).and.(tdc_ch1.gt.0))then |
if ((iadd.eq.1).and.(icorr.eq.1).and.(tdc_ch1.gt.0))then |
341 |
iadd=3 |
iadd=3 |
351 |
ic=ic+4 |
ic=ic+4 |
352 |
enddo ! fine loop sui 4 TDC channel |
enddo ! fine loop sui 4 TDC channel |
353 |
|
|
354 |
|
c print *,'++++++ Tof Unpack 9 fine primo loop sui ch +++++++++' |
355 |
|
|
356 |
c |
c |
357 |
c adc e tdc data have to be translated from Gray code to binary (bit 0-11) |
c adc e tdc data have to be translated from Gray code to binary (bit 0-11) |
358 |
c bit 12 is added after conversion (control bit) |
c bit 12 is added after conversion (control bit) |
383 |
c |
c |
384 |
enddo |
enddo |
385 |
|
|
386 |
|
c----+---1---------2---------3---------4---------5---------6---------7---------8 |
387 |
|
|
388 |
|
c print *,'+++++++ Tof Unpack 10 fine secondo loop sui ch +++++++' |
389 |
|
|
390 |
c |
c |
391 |
temp1(j) = 0 |
temp1(j) = 0 |
405 |
else |
else |
406 |
temp2(j) = 99 |
temp2(j) = 99 |
407 |
endif |
endif |
408 |
|
c print *,'++++++++++ Tof Unpack 11 fine temperatura ++++++++' |
409 |
c |
c |
410 |
c vecta(ic) is the CRC |
c vecta(ic) is the CRC |
411 |
c Check consistency of CRC. |
c Check consistency of CRC. |
425 |
check=crctof(check,vecta(i)) |
check=crctof(check,vecta(i)) |
426 |
enddo |
enddo |
427 |
c if (check.ne.vecta(ic)) then |
c if (check.ne.vecta(ic)) then |
428 |
|
me = 0 |
429 |
if (check.ne.ibuf) then |
if (check.ne.ibuf) then |
430 |
print *,'crc wrong ',ibuf, check |
print *,'crc wrong ',ibuf, check |
431 |
me = 1 |
me = 1 |
437 |
|
|
438 |
enddo ! j = 1,ntdc |
enddo ! j = 1,ntdc |
439 |
|
|
440 |
|
c print *,'++++++++++ Tof Unpack escooo ! ++++++++++++++++' |
441 |
|
|
442 |
|
|
443 |
RETURN |
RETURN |
444 |
END |
END |