MIDAS Event Header Macros: Difference between revisions

From MidasWiki
Jump to navigation Jump to search
(Created page with "Every event travelling through the Midas system has a Event Header containing the minimum information required to identify its contents...")
 
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Pagelinks}}
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.
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.
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
; TRIGGER_MASK : Extract or set the trigger mask field
* EVENT_ID
; EVENT_ID : Extract or set the event ID field
* SERIAL_NUMBER
; SERIAL_NUMBER : Extract or set/reset the serial number field
* TIME_STAMP
; 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 :
The following [[Frontend Operation#Frontend|Frontend]] C-code fragments from a running experiment demonstrate the use of these Macros :
Line 47: Line 50:
   }
   }
   ...
   ...
[[Category:Event]] [[Category:Frontend]] [[Category:Appendices]] [[Category:Macros]]

Latest revision as of 15:06, 4 August 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--;
    ...
  }
  ...