;+ ; NAME: ; E4US4B01 ; ; PURPOSE: ; Extracts the PCU module number and PCU energy channel number from ; XTE Event words with the TTDES2 keyword: ; ; (M[1]{1},D[0:4]{3},C[0~13,14~23,24~35,36~249]{2}, ; T[0.0:0.00390625;3.814697265625e-06]{10}) ; (DLL String) ; ; (i.e. configuration E_4us_4B_0_1s) ; ; CATEGORY: ; XTE. ; ; CALLING SEQUENCE: ; ; E4US4B01, Event_bytes, M_token, Detector, Channel ; ; INPUTS: ; Event_bytes: Array of Event bytes, BYTARR(2,nevents) or ; BYTARR(nevents). Specify the former array type to ; calculate Time output. ; ; OUTPUTS: ; M_token: Byte array with elements set to 1 for all words with a ; valid M[1] token, 0 for all others. (Namely, all array ; elements set to one have valid corresponding detector and ; energy channel numbers.) ; ; Detector: Byte array of PCU detector module numbers, [0,1,2,3, or 4] ; ; Channel: Byte array of PCU energy channel numbers, [0,1,2 or 3]. ; These are the channel assignments: ; ; Channel: 0 Energy channels: [ 0-13 ] ; 1 [ 14-23 ] ; 2 [ 24-35 ] ; 3 [ 36-249 ] ; Time: Short integer array of photon times MOD 1024. The units ; of time are 3.814697265625e-6 sec. This output is filled only ; if Event_bytes is a BYTARR(2,nevents) ; ; MODIFICATION HISTORY: ; Written by: Han Wen, July 1996. ;- pro E4US4B01, Event_bytes, M_token, Detector, Channel, Time ndim = (SIZE(Event_bytes))(0) if (ndim gt 2) then message, $ 'Event_bytes parameter has wrong dimensions.' ; Convention ; Byte(0) Byte(1) ; | ; |-> first bit, MSB. ; Byte(0) Byte(1) M_token = 128 & M_shift = -7 ; 10000000 00000000 D_mask = 112 & D_shift = -4 ; 01110000 00000000 C_mask = 12 & C_shift = -2 ; 00001100 00000000 T_mask = 3 & T_shift = 8 ; 00000011 11111111 Byte0 = (REFORM(TRANSPOSE(Event_bytes)))(*,0) M_token = ISHFT(Byte0 and M_token,M_shift) ; M[1]{1} key Detector = ISHFT(Byte0 and D_mask ,D_shift) ; detector bits Channel = ISHFT(Byte0 and C_mask ,C_shift) ; energy channel bits if (ndim eq 2) then begin Byte0 = FIX(TEMPORARY(Byte0)) Time = ISHFT(Byte0 and T_mask ,T_shift) $ ; time bins + REFORM( Event_bytes(1,*) ) endif end