RDF
The RDF format is supposed to be described at https://ribf.riken.jp/~baba/acquisition/system/dataformat.html, but many details are not written there. (This was a problem when I was making RDF Decoder.)
The notes below describe details that were not written on the web page, based on RDF files written by NBBQ. Some of them may be NBBQ-specific, rather than general RDF rules.
Structure
RDF consists of blocks of 16 kB = 16384 bytes. There are three types of blocks:
- Header Block: contains information such as the run number, run start time, and run-start comment.
- Ender Block: contains information such as the run number, run start time, stop time, and run-stop comment.
- Event Block: contains event data.
The first word of a block identifies the block type. Here, one word is 2 bytes.
- Flag of Header Block :
0001 - Flag of Ender Block :
ffff - Flag of Event :
0000
Header Block
| word | |
|---|---|
| 0 | 0001 Flag of Header Block |
| 1-9 | nul 0000 |
| 10-13 | Run Number (ASCII 8char) RUN-0000 |
| 14 | space x2 (ASCII 2char) 2020 = sp sp |
| 15-23 | Start Time (ASCII 18char) START => 12:58:56 |
| 24-32 | Stop Time (ASCII 18char) STOP => XX:XX:XX |
| 33 | space x2 (ASCII 2char) 2020 = sp sp |
| 34-42 | Print Time (ASCII 18char) Print -> XX:XX:XX |
| 43-47 | Print Date (ASCII 10char) 22-Mar-23 |
| 48-49 | nul 0000 |
| 50-89 | run-start comment (ASCII 80char) |
| 90-129 | run-stop comment (ASCII 80char) nul 0000 |
| 130-8191 | nul 0000 |
The Header Block and Ender Block have the same structure. The Header Block therefore has fields such as Stop Time and run-stop comment, but meaningless values are filled in.
- Stop Time is
STOP => XX:XX:XX - Print Time is
Print -> XX:XX:XX - run-stop comment is nul
Ender Block
| word | |
|---|---|
| 0 | ffff Flag of Ender Block |
| 1-9 | nul 0000 |
| 10-13 | Run Number (ASCII 8char) RUN-0000 |
| 14 | space x2 (ASCII 2char) 2020 = sp sp |
| 15-23 | Start Time (ASCII 18char) START => 12:58:56 |
| 24-32 | Stop Time (ASCII 18char) STOP => 09:00:00 |
| 33 | space x2 (ASCII 2char) 2020 = sp sp |
| 34-42 | Print Time (ASCII 18char) Print -> XX:XX:XX |
| 43-47 | Print Date (ASCII 10char) 01-Jan-70 |
| 48-49 | nul 0000 |
| 50-89 | run-start comment (ASCII 80char) |
| 90-129 | run-stop comment (ASCII 80char) |
| 130-8191 | nul 0000 |
Stop Time, Print Time, and Print Date should be written here, but when data are taken with NBBQ, strange values are filled in. Is this because of a 32-bit OS?
- Stop Time is
STOP => 09:00:00 - Print Time is
Print -> XX:XX:XX - Print Date is
01-Jan-70
Event Block
An Event Block contains event data.
Each Event Data contains Segment Data, forming the following nested structure.
Event Block
├── Event Data 1
│ ├── Segment Data 1
│ ├── Segment Data 2
│ : :
│ └── Segment Data M
├── Event Data 2
│ ├── Segment Data 1
│ ├── Segment Data 2
│ : :
│ └── Segment Data M
: :
└── Event Data N
├── Segment Data 1
├── Segment Data 2
: :
└── Segment Data M
Block Header
The first four words of an Event Block are flags indicating that the block is an Event Block.
| word | |
|---|---|
| 0-3 | 0000 Flag of Event Block |
| 4- | Event Data |
Event Data
Event Data is stored from word 4 onward. Event Data consists of several Segment Data entries. Its structure is as follows.
| word | |
|---|---|
| 0 | Event size in words, including this word. The lower 12 bits are the event size, and the upper 4 bits are fixed to 1000. |
| 1 | Fragment ID. Fixed to 0001 |
| 2 | Event ID. The index of this event within the block |
| 3- | Segment Data |
Segment Data
| word | |
|---|---|
| 0 | Segment size in words, including this word. |
| 1 | Segment ID |
| 2- | Segment Data |
The page at https://ribf.riken.jp/~baba/acquisition/system/dataformat.html says that data starts from word 3, but this is probably wrong.
EOB
How can we know how much of an Event Block is filled with Event Data, or where the End Of Block (EOB) is? This is not written anywhere, but when decoding RDF files output by NBBQ, a word sequence
ffff ffff
appears immediately after the last Event Data in an Event Block. According to the rules, this means Segment size = ffff and Segment ID = ffff.
In other words, it seems that Event Data with an impossibly large size (ffff) and an Event ID of ffff is used as the EOB marker.
This is not written anywhere...
Scaler
When scalers are read out for each block, scaler information is written at the end of the block. This information does not have an Event Data-like format; the raw data simply begins there.
When using a V560, the data are written starting at the position obtained by subtracting the number of scaler channels x 2 words (= 32 bits, the scaler data size) from the end of the block. In other words, the end of the scaler data is the end of the Event Block.
This is also not written anywhere.