MIDAS Event Header Macros: Difference between revisions
No edit summary |
mNo edit summary |
||
Line 52: | Line 52: | ||
[[Category:Event]] [[Category:Frontend]] | [[Category:Event]] [[Category:Frontend]] [[Category:Appendices]] |
Revision as of 14:20, 14 July 2015
Every event travelling through the Midas system has a Event Header containing the minimum information required to identify its contents. The size of the header has been kept as small as possible in order to minimize its impact on the data rate as well as on the data storage requirement. The following Macros (defined in midas.h in the MIDAS package) are available for manipulating Midas event headers. They permit reading or overriding the content of the event header, as long as the argument of the macro refers to the top of the Midas event (pevent). This argument (pevent) is available in the Frontend code in any of the user readout functions.
The Macros are also available to the user analyzer code, which retrieves the event and provide direct access to the event header (pheader) and to the user part of the event (pevent). Sub-functions using pevent would then be able to get back the header through the use of the macros.
- TRIGGER_MASK
- Extract or set the trigger mask field
- EVENT_ID
- Extract or set the event ID field
- SERIAL_NUMBER
- Extract or set/reset the serial number field
- TIME_STAMP
- Extract or set/reset the time stamp field
- DATA_SIZE
- Extract or set/reset the data size field
The following Frontend C-code fragments from a running experiment demonstrate the use of these Macros :
- Example 1
INT read_ge_event(char *pevent, INT offset) { static WORD *pdata; INT i, x, q; WORD temp; // // Change the time stamp in millisecond for the Super event TIME_STAMP(pevent) = ss_millitime(); // bk_init(pevent); bk_create(pevent, "GERM", TID_WORD, &pdata); ... }
- Example 2
... lam = *((DWORD *)pevent); // if (lam & LAM_STATION(JW_N)) // { ... // compose event header TRIGGER_MASK(pevent) = JW_MASK; EVENT_ID(pevent) = JW_ID; SERIAL_NUMBER(pevent)= eq->serial_number++; // read MCS event size = read_mcs_event(pevent); // Correct serial in case event is empty if (size == 0) SERIAL_NUMBER(pevent) = eq->serial_number--; ... } ...