Event Builder
Introduction to Event building in MIDAS
MIDAS supports event building through a dedicated mevb application. Similar to the Frontend, the mevb 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 "EQ_EB" flag.
It is possible that in case of multiple Frontends, the same "fragment" code may run in the different hardware frontends. In order to prevent having to build nFragment different Frontend tasks, the "-i index" argument given when starting the Frontend task 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. @ref BO_MIDAS_FRONTEND_INDEX. Environment Variables
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: - \b frontend_name : Name of the frontend application. - \b equipment \b name : Name of the equipment (from the Equipment structure). - \b event \b buffer: Name of the destination buffer (from the Equipment structure).
To allow either synchronized fragment collection or asynchronized gathering of the fragments, the composition of the "event buffer" and "equipment name" require to have the index format part of the equipment definition in the case of the synchronized fragment event builder.
Frontend code for asynchronized fragment collection in the event builder, Event buffer remains the same for all the fragments: @code /* The frontend name (client name) as seen by other MIDAS clients */ char *frontend_name = "ebfe"; ... EQUIPMENT equipment[] = { {"Trigger%02d", /* 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 */ @endcode
Frontend code for synchronized fragment collection in the event buider: @code /* The frontend name (client name) as seen by other MIDAS clients */ char *frontend_name = "ebfe"; ... EQUIPMENT equipment[] = { {"Trigger%02d", /* equipment name */ 1, TRIGGER_ALL, /* event ID, trigger mask */ "BUF%02d", /* event buffer */ EQ_POLLED | EQ_EB, /* equipment type + EQ_EB flag <<<<<< */ LAM_SOURCE(0, 0xFFFFFF), /* event source crate 0, all stations */ "MIDAS", /* format */ @endcode Once the frontend is started with -i 1 , the MIDAS client name, equipment name and buffer name will be modified (case of the synchronized event builder). @code > ebfe -i 1 -D ... odbedit [local:midas:S]/Equipment>ls Trigger01 [local:midas:S]Trigger01>ls -lr Key name Type #Val Size Last Opn Mode Value
Trigger01 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 BUF01 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 ebfe01 Frontend file name STRING 1 256 18h 0 RWD .../eventbuilder/ebfe.c
... @endcode
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.
\anchor idx_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 source ("../Settings/Fragment Required y"), an internal event serial number check is performed prior passing all the fragment to the user code. Content of each fragment can be done within the user code for further consistency check.
*
* \image html eventbuilder.jpg*