Skip to content

Event building: overview

If your data is read out by several frontends (e.g. one per digitizer or detector subsystem), each trigger may produce several separate events - one from each frontend. Event building combines these "fragments" into a single event, so that all the data from one trigger is stored together.

This can make data analysis simpler, and can also help you catch some synchronisation errors in real time during a run.

Key definitions

  • A fragment is the event sent by one frontend for a given trigger.
  • The event builder is the program that collects one fragment from each frontend and combines them into a built event.
  • By default, fragments are matched using the serial number in the event header. Each frontend numbers its events from 0 at the start of each run, so the Nth event from every frontend should belong to the same trigger.

How event building works

However the event builder is written, the data flows in the same way:

flowchart LR
    FE1(["Frontend 1"]) --> B1[("BUF01")]
    FE2(["Frontend 2"]) --> B2[("BUF02")]
    FEn(["Frontend n"]) --> Bn[("BUFnn")]
    B1 --> EB(["Event builder"])
    B2 --> EB
    Bn --> EB
    EB --> SYS[("SYSTEM")]
    SYS --> LOG(["mlogger"])
  • Each fragment frontend writes its events to its own event buffer, rather than to the SYSTEM buffer.
  • The event builder reads one fragment from each buffer, checks that they belong to the same trigger, and merges them into a single event.
  • It writes the built event to the SYSTEM buffer, where mlogger records it in the normal way.

The event builder appears on the midas status page as an equipment, with its own event and data rates.

Synchronisation is your responsibility

The event builder can only check that the fragments it receives belong together. It is up to you (usually via a hardware trigger distribution system) to ensure that every frontend produces exactly one event per trigger, in the same order.

Options for writing an event builder

There are two common approaches:

  • use the mevb framework
  • write your own

These options are explained in more detail on the programming page.