Super Event

From MidasWiki
Revision as of 14:59, 14 July 2015 by Suz (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


Links

Introduction

The Super-Event is an option implemented in the Frontend code in order to reduce the amount of data to be transferred to the back-end computer(s) by removing the bank header for each event constructed. It is not applicable to FIXED Format events.

In other words, when an equipment readout in MIDAS Format is complete, the event is composed of the bank header followed by the data section.

The overhead in bytes of the bank structure is 16 bytes for bk_init(), 20 bytes for bk_init32(). If the data section size is close to the number above, the data transfer as well as the data storage has an non-negligible overhead. To address this problem, the equipment can be set up to generate a so called Super-Event which is an event composed of the initial standard bank header for the first event of the super-event, and up to the number of sub-events maximum successive data sections before the closing of the bank.

Example frontend code

To demonstrate the use of the super-event, consider the following example of the Equipment Declaration in the frontend code:

 // Define equipment to be able to generate the Super-Event 
                                      //
 { "GE",                 // equipment name 
     2, 0x0002,            // event ID, trigger mask 
     "SYSTEM",             // event buffer 
 #ifdef USE_INT
     EQ_INTERRUPT,         // equipment type 
 #else
     EQ_POLLED,            // equipment type 
 #endif
     LAM_SOURCE(GE_C, LAM_STATION(GE_N)), // interrupt source 
     "MIDAS",              // format 
     TRUE,                 // enabled 
     RO_RUNNING,           // read only when running 
     200,                  // poll for 200ms 
     0,                    // stop run after this event limit 
     1000,                 // number of sub events > 0 ... enables Super-event
     0,                    // don't log history 
     "", "", "",
     read_ge_event,        // readout routine 
      ,
     ...

Example Readout code

Set up the readout function for Super-Event collection, e.g.

 //-- Event readout
 // Global and fixed -- Expect NWORDS 16bits data readout per sub-event
 #define NWORDS 3
 //
 INT read_ge_event(char *pevent, INT offset)
 {
   static WORD *pdata;
                                      //
   // Super-event structure 
   if (offset == 0)
   {
     // FIRST event of the Super-event 
     bk_init(pevent);
     bk_create(pevent, "GERM", TID_WORD, &pdata);
                                      //
   else if (offset == -1)
   {
     // close the Super-event if offset is -1
     bk_close(pevent, pdata);
                                      //
     // End of Super-Event
     return bk_size(pevent);
                                     //
                                     //
   // read GE sub-event (ADC) 
   cam16i(GE_C, GE_N, 0, GE_READ, pdata++);
   cam16i(GE_C, GE_N, 1, GE_READ, pdata++);
   cam16i(GE_C, GE_N, 2, GE_READ, pdata++);
                                     //
   // clear hardware 
   re_arm_ge(); 
                                     //
   if (offset == 0)
   {
     // Compute the proper event length on the FIRST event in the Super-Event
     // NWORDS correspond to the !! NWORDS WORD above !!
     // sizeof(BANK_HEADER) + sizeof(BANK) will make the 16 bytes header
     // sizeof(WORD) is defined by the TID_WORD in bk_create()
                                     //
     return NWORDS * sizeof(WORD) + sizeof(BANK_HEADER) + sizeof(BANK);
                                     //
   else
     // Return the data section size only
     // sizeof(WORD) is defined by the TID_WORD in bk_create()
                                     //
     return NWORDS * sizeof(WORD);

Discussion

As shown in the example above:

  • For the first event, the correct size of the event, including the header, must be calculated and returned
  • Subsequent events return the size of the data only, excluding the header.


The input parameter "offset" is used to indicate whether the event is the first, last or intermediate. After the last event, the bank is closed.

The encoding of the data section is left to the user. If the number of words per sub-event is fixed (i.e. NWORDS in the above example), the sub-event extraction by an analyzer is simple. In the case of variable sub-event length, it is necessary to tag the first or the last word of each sub-event.The contents of the sub-event is the choice of the user.

Note
  • Since no particular tagging is applied to the Super-Event by the Midas transfer mechanism, the user must provide code in the backend analyzer to interpret the contents of the Super-Event bank(s).
  • If the Super-Event is composed by an equipment on a remote processor running a different Endian mode than the backend processor, it would be necessary to ensure the data type consistency throughout the Super-Event in order to guarantee the proper byte-swapping of the data content. Byte Swap Macros are available for this purpose.
  • It may be convenient to change the time-stamp of the super-event using the TIME_STAMP Macro.
  • The ODB key /Equipment/<equipment name>/statistics/event rate event rate will indicate the rate of sub-events.