Technical details on CSCFileReader:

To build FED buffers CSCFileReader merges DDU data streams and constructs fake DCC Headers and DCC Trailers for FED buffers.

For every RUI stream module instantiates FileReaderDDU class inherited from our on-line software (in TriDAS).

FileReaderDDU reads file with DDU data, searches for DDU Headers and DDU Trailers, and finally returns event buffer. It also handles data corruptions.

FileReaderDDU continuously reads DDU data in blocks of definite length. Each time it passes through block, it searches for DDU Header or DDU Trailer. In same time it composes event buffer. Once it find DDU Trailer it sets an ``end mark'' in current data block and returns event buffer with event status flag, which tells that we have DDU Trailer in this event. On next call it continues passing through data block starting from ``end mark''. If it finds DDU Header pattern in first two DDU words it sets status flag accordingly and goes further until it finds DDU Trailer or another DDU Header. If DDU Header appeared in a place anywhere after first two DDU words, program sets Unknown bit in status flag and returns buffer composed with data in front of this DDU Header. If program finds DDU Header in a right place and encounters second DDU Header it returns data between these DDU Headers, sets DDU Header bit in status flag, and starts from second DDU Header on next call. If buffer size reaches value of 50000 DDU words, status flag contains DDUoversize bit set.

Described scheme can be presented by following diagrams of buffer structure:

1)[H-T]// Normal event
2)[H-?]H// More likely event with corrupted trailer
3)[H-max]// DDUoversize condition
4)[?-T]// Could be anything
5)[?-?]H// Could be anything (depends on previous event)
6)[?-max]// Could be anything
7)[FFFF]// Some standard sequence to complete ethernet package


One remark to be made here is that DDU Header (as well as DDU Trailer) consists of three words with identifying pattern in second word. If two consecutive DDU Headers were found, first word of second Header goes to both events.

In FileReaderDDU for user convenience additional to read function next was implemented. Together with select, accept, and reject functions it allows user to get events of specified type. Function reject helps to filter out events with any of status flag bits matches defined criteria. Function accept forces next to return events with any of status flag bits matches its criteria. Function select requires events exactly match its criteria. In CSCFileReader module selection/rejection criteria are set to default (safe) values and cannot be changed.