MIDAS Event Header Macros: Difference between revisions

From MidasWiki
Jump to navigation Jump to search
No edit summary
(The midas documentation has moved to https://midas.triumf.ca/docs/)
 
Line 1: Line 1:
{{Pagelinks}}
The midas documentation has moved. See [https://midas.triumf.ca/docs/develop/api/cpp/definitions/#event-header-macros Event header macros] on the Midas C++ API - constants and generic macros page for the new documentation about the event header macros, and [https://midas.triumf.ca/docs/develop/features/acquiring_data/data_format/#event-header Event header] on the Event data format page for the fields of the event header.
 
Every event travelling through the Midas system has a  [[MIDAS Event Structure#Event Header|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 Operation#Frontend|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 Operation#Frontend|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--;
    ...
  }
  ...
 
 
[[Category:Event]] [[Category:Frontend]] [[Category:Appendices]] [[Category:Macros]]

Latest revision as of 22:00, 30 October 2026

The midas documentation has moved. See Event header macros on the Midas C++ API - constants and generic macros page for the new documentation about the event header macros, and Event header on the Event data format page for the fields of the event header.