Event Builder: 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/)
Tag: Replaced
 
Line 1: Line 1:
{{Pagelinks}}
The midas documentation has moved. See [https://midas.triumf.ca/docs/develop/features/acquiring_data/event_building/ Event building: overview] and [https://midas.triumf.ca/docs/develop/features/acquiring_data/event_building/programming/ Event building: programming] for the new documentation about the event builder.
== Introduction to Event building in MIDAS ==
 
MIDAS supports event building through a dedicated <span style=" font-style:bold; font-size: 110%;">[[mevb]]</span>
application. Similar to the [[Frontend Operation#Frontend|Frontend]], the <span style="color:darkcyan;">''mevb''</span> application
requires the definition of an equipment structure which describes its mode of operation.
 
The set of parameters for this equipment is limited to:
* Equipment name (appears in the Equipment list).
* Equipment type  (should be 0).
* Destination buffer name (SYSTEM if destination event goes to logger).
* Event ID and Trigger mask for the build event (destination event ID).
* Data format (should match the source data format).
 
Based on the given buffer name provided at the start-up time through the " ''-b <buffer_name>'' " argument supplied, the [[mevb]] utility will scan all the equipments and  handle the building of an event based on the identical buffer name found in the equipment list if the frontend equipment type includes the  "[[Equipment List Parameters#EQ_EB|EQ_EB]]" flag.
 
== Example ==
An example eventbuilder can be found in [[Environment Variables#MIDASSYS|$MIDASSYS]]/examples/eventbuilder/.
 
<div id="EventFragment"></div>
== Event Builder and related frontend fragment ==
 
It is possible that in the case of multiple [[Frontend Operation#Frontend|Frontends]], the same "fragment" code may run in the different hardware frontends. In order to prevent having to build nFragment different [[Frontend Application |Frontend tasks]], the  [[Frontend Application |Frontend task]]
argument  ''-i <index>'' will replicate the same application image with the necessary dynamic modification required for the proper Event Building operation.
 
The index can be passed to the frontend application either by this argument, or by environment variable  [[Environment Variables#MIDAS_FRONTEND_INDEX|MIDAS_FRONTEND_INDEX]]
 
The ''-i <index>'' argument will provide the index to be appended to the minimal set of
parameters to distinguish the different frontends. These parameters are:
; frontend_name : Name of the frontend application.
; equipment name : Name of the equipment (from the Equipment structure).
; event buffer: Name of the destination buffer (from the Equipment structure).
 
Asynchronized and synchronized data collection can be envisaged (see [[Mevb]]).
- For '''asynchronized''' fragment collection, the composition of the "equipment name" in the Equipment definition requires the index format to be present (see  [[#1.Asynchronized|example 1]]).
- For '''synchronized''' gathering of the fragments, the composition of the "equipment name" and "event buffer" both require the index format to be present (see  [[#2.Synchronized|example 2]]).
 
 
== Examples of Frontend Code for fragment collection in the event builder ==
=== 1.Asynchronized ===
 
Event buffer  remains the same for all the fragments:
 
 
  char *frontend_name = "ebfe";    /* The frontend name (client name) as seen by other MIDAS clients */
  ... 
  EQUIPMENT equipment[] = {
      {"Trigger<span style="color:red">%02d</span>",              /* equipment name */
      1, TRIGGER_ALL,        /* event ID, trigger mask */
      "BUFFER",                  /* event buffer */
      EQ_POLLED | EQ_EB,      /* equipment type + EQ_EB flag <<<<<< */
      LAM_SOURCE(0, 0xFFFFFF), /* event source crate 0, all stations */
      "MIDAS",                /* format */
 
 
 
=== 2.Synchronized === 
 
  char *frontend_name = "ebfe";  /* The frontend name (client name) as seen by other MIDAS clients */
  ...
  EQUIPMENT equipment[] = {
      {"Trigger<span style="color:red">%02d</span>",              /* equipment name */
      1, TRIGGER_ALL,        /* event ID, trigger mask */
      "BUF<span style="color:red">%02d</span>",                  /* event buffer */
      EQ_POLLED | EQ_EB,      /* equipment type + EQ_EB flag <<<<<< */
      LAM_SOURCE(0, 0xFFFFFF), /* event source crate 0, all stations */
      "MIDAS",                /* format */
 
 
 
Once the frontend is started with e.g. ''' -i  <span style="color:red">1</span> ''', the MIDAS client name, equipment name and, in the  case of the synchronized event builder,
buffer name will be modified by adding the index number (1 in this case).
 
 
> ebfe -i 1 -D
...
odbedit
[local:midas:S]/Equipment>ls
Trigger<span style="color:red">01</span>
[local:midas:S]Trigger01>ls -lr
Key name                        Type    #Val  Size  Last Opn Mode Value
---------------------------------------------------------------------------
Trigger<span style="color:red">01</span>                      DIR
    Common                      DIR
        Event ID                WORD    1    2    18h  0  RWD  1
        Trigger mask            WORD    1    2    18h  0  RWD  65535
        Buffer                  STRING  1    32    18h  0  RWD  BUF<span style="color:red">01</span>
        Type                    INT    1    4    18h  0  RWD  66
        Source                  INT    1    4    18h  0  RWD  16777215
        Format                  STRING  1    8    18h  0  RWD  MIDAS
        Enabled                BOOL    1    4    18h  0  RWD  y
        Read on                INT    1    4    18h  0  RWD  257
        Period                  INT    1    4    18h  0  RWD  500
        Event limit            DOUBLE  1    8    18h  0  RWD  0
        Num subevents          DWORD  1    4    18h  0  RWD  0
        Log history            INT    1    4    18h  0  RWD  0
        Frontend host          STRING  1    32    18h  0  RWD  hostname
        Frontend name          STRING  1    32    18h  0  RWD  ebfe<span style="color:red">01</span>
        Frontend file name      STRING  1    256  18h  0  RWD  .../eventbuilder/ebfe.c
...
 
 
Independently of the event ID, each fragment frontend will send its data to the composed  event buffer (BUFxx). The event builder task will make up a list of all the equipment belonging to the same event buffer name (BUFxx). If multiple equipments exists in the same  frontend, the equipment type (EQ_EB) and the event buffer name will distinguish them.
 
 
 
== Event Builder Flowchart ==
The Event Builder flowchart below shows a general picture of the event process cycle of the task. The Event Builder runs in polling mode over all the source buffers collected at the
begin of run procedure. Once a fragment has been received from all enabled sources (i.e. those with <span style="color: purple; font-style:italic;">/Equipment/<equipment-name>/Settings/Fragment Required</span> set to y"), an internal event serial number check is performed prior to passing all the fragments to the user code. A check on the content of each fragment can be done within the user code for further consistency check.
 
[[File:Eventbuilder.jpg| Event Builder Flowchart]]
 
 
[[Category:Event]]  [[Category:Appendices]]

Latest revision as of 22:00, 30 October 2026

The midas documentation has moved. See Event building: overview and Event building: programming for the new documentation about the event builder.