If you decode this data by casting pointers to long words to pointers to words (or the other way round), be prepared that some operating systems keep the highest significant bit of a byte/word/longword in a higher point in memory than the lowest significant bit, whereas some other operating systems just do it the other way round. Even though longwords appear always correct, words and bytes will appear swapped. Take a look at the differences between OVMS and UNIX e.g. when decoding the event header starting at line 430 of the C code to scan the lmd files.
All sub events on your tapes should be structured like this (read from top to bottom):
LW means longword, 32 bits numbered 1-32; W means word, 16 bits numbered 1-16; B means byte, 8 bits numbered 1-8.
The array contains a list of data blocks.
Each block looks like this...
back to the online/offline page
!--------------------------------------------------------------------------------
!sub event header
!--------------------------------------------------------------------------------
LW data length in words + 2
W sub event type, should be 32 for fastbus
42 for vme
34 for pattern
10 for camac
otherwise discard event
W sub event subtype,should be 3100 for fastbus
3200 for vme
3100 for pattern
1 for camac
otherwise discard event
LW unused, discard
!--------------------------------------------------------------------------------
!sub event data, (data length) words. The format now depends on the type of sub event
!--------------------------------------------------------------------------------
W
W
W
...
!--------------------------------------------------------------------------------
!end of sub event
!--------------------------------------------------------------------------------
Fastbus
For fastbus sub events, you will get an array of longwords. The first one is always zero.
All other longwords keep the following information:
You may introduce a table mapping pairs of fastbus (geographical addresses / channels) to
detector signals or come up with some other clever way to do the mapping. See the
table for your experiment.
VME
For VME sub events, you will get an array of words. The array contains a list of data blocks.
Each block looks like this...
!--------------------------------------------------------------------------------
!beginning of block
!--------------------------------------------------------------------------------
W the lower byte of this word gives you the VME card identifier.
should be >1 and <7, otherwise discard event
W the lower byte of this word gives you a pattern.
For certain pairs of neighbouring bits you will get data words
Scan this byte from lowest to highest significant bit, taking bitsubstrings
of length 2.
If you get 00, go on scanning the pattern byte.
If you get 01, read one word of data from the block,
read one word to discard from the block (should be 0x7fff,
but don't rely on it),
then go on scanning the pattern byte.
If you get 10, read one word to discard from the block (should be 0x7fff,
but don't rely on it),
read one word of data from the block,
then go on scanning the pattern byte.
If you get 11, read one word of data from the block,
read one word of data from the block,
then go on scanning the pattern byte.
W data words to process while scanning the pattern byte
bits 1-13 of each word (as long as the correspondig bit in the pattern word is set)
contain the data, bits 14-16 should always be 0%111, otherwise discard event.
W
W
W
...
!--------------------------------------------------------------------------------
!end of block
!--------------------------------------------------------------------------------
You may introduce a table mapping pairs of VME (card identifiers / pattern bits) to
detector signals or come up with some other clever way to do the mapping. See the
table for your experiment.
CAMAC
For CAMAC sub events, you will get an array of words. Unfortunately, you have to swap neighbouring words
before you can process the array (of course you may decide to scan through the array in a different way,
e.g. starting at position 2 and then always add an offset of -1 and alternating 3 to your index. In that way
you don't need to swap but of course you need to think about modifying your index).
!--------------------------------------------------------------------------------
!beginning of block
!--------------------------------------------------------------------------------
W a pattern word
bits 1- 8 give you the CAMAC virtual station number
bits 9-12 tell you how many data words will follow
bits 13-16 should always be 0%1000, otherwise discard event
W a word to discard
W data words to process according to bits 9-12 from the pattern word
bits 1-12 of each word contain the data
bits 13-15 tell you the CAMAC sub address
W
W
W
...
!--------------------------------------------------------------------------------
!end of block
!--------------------------------------------------------------------------------
You may introduce a table mapping pairs of CAMAC (virtual station numbers / sub addresses) to
detector signals or come up with some other clever way to do the mapping. See the
table for your experiment.
Pattern sub events
Pattern sub events will always contain 13 longwords, the first is the trigger pattern,
the next 12 are 12 scalers. Note: experiment x70596 will have 14 scalers,
so the sub event length will be 15 longwords.
LW trigger pattern
LW scaler 1
LW scaler 2
LW scaler 3
...
LW scaler 12 (14 in case of x70596)
Bits 2 to 9 of the trigger pattern longword match switches 1 to 8 of the trigger box.
Scalers are all 24 bit, therefore the upper 8 bits of all scaler longwords are to be ignored.
Scaler 14 is 32 bit.