Midas Bank Functions (bk_xxx)
[The midas.h & midas.c]


Functions

void bk_init (void *event)
void bk_init32 (void *event)
INT bk_size (void *event)
void bk_create (void *event, const char *name, WORD type, void *pdata)
INT bk_close (void *event, void *pdata)
INT bk_list (void *event, char *bklist)
INT bk_locate (void *event, const char *name, void *pdata)
INT bk_find (BANK_HEADER *pbkh, const char *name, DWORD *bklen, DWORD *bktype, void **pdata)
INT bk_iterate (void *event, BANK **pbk, void *pdata)
INT bk_swap (void *event, BOOL force)


Function Documentation

INT bk_close void *  event,
void *  pdata
 

Close the Midas bank priviously created by bk_create(). The data pointer pdata must be obtained by bk_create() and used as an address to fill a bank. It is incremented with every value written to the bank and finally points to a location just after the last byte of the bank. It is then passed to bk_close() to finish the bank creation

Parameters:
event pointer to current composed event
pdata pointer to the data
Returns:
number of bytes contained in bank

Definition at line 12255 of file midas.c.

Referenced by adc_calib(), adc_summing(), eb_user(), read_scaler_event(), read_trigger_event(), and scaler_accum().

void bk_create void *  event,
const char *  name,
WORD  type,
void *  pdata
 

Create a Midas bank. The data pointer pdata must be used as an address to fill a bank. It is incremented with every value written to the bank and finally points to a location just after the last byte of the bank. It is then passed to the function bk_close() to finish the bank creation.

INT *pdata;
bk_init(pevent);
bk_create(pevent, "ADC0", TID_INT, &pdata);
*pdata++ = 123
*pdata++ = 456
bk_close(pevent, pdata);
Parameters:
event pointer to the data area
name of the bank, must be exactly 4 charaters
type type of bank, one of the Midas Data Types values defined in midas.h
pdata pointer to the data area of the newly created bank
Returns:
void

Definition at line 12136 of file midas.c.

Referenced by adc_calib(), adc_summing(), eb_user(), read_scaler_event(), read_trigger_event(), and scaler_accum().

INT bk_find BANK_HEADER pbkh,
const char *  name,
DWORD *  bklen,
DWORD *  bktype,
void **  pdata
 

Finds a MIDAS bank of given name inside an event.

Parameters:
pbkh pointer to current composed event
name bank name to look for
bklen number of elemtents in bank
bktype bank type, one of TID_xxx
pdata pointer to data area of bank, NULL if bank not found
Returns:
1 if bank found, 0 otherwise

Definition at line 12403 of file midas.c.

void bk_init void *  event  ) 
 

Initializes an event for Midas banks structure. Before banks can be created in an event, bk_init() has to be called first.

Parameters:
event pointer to the area of event

Definition at line 12054 of file midas.c.

Referenced by eb_user(), read_scaler_event(), and read_trigger_event().

void bk_init32 void *  event  ) 
 

Initializes an event for Midas banks structure for large bank size (> 32KBytes) Before banks can be created in an event, bk_init32() has to be called first.

Parameters:
event pointer to the area of event
Returns:
void

Definition at line 12095 of file midas.c.

INT bk_iterate void *  event,
BANK **  pbk,
void *  pdata
 

Iterates through banks inside an event. The function can be used to enumerate all banks of an event. The returned pointer to the bank header has following structure:

typedef struct {
char   name[4];
WORD   type;
WORD   data_size;
} BANK;
where type is a TID_xxx value and data_size the size of the bank in bytes.
BANK *pbk;
INT  size;
void *pdata;
char name[5];
pbk = NULL;
do
{
 size = bk_iterate(event, &pbk, &pdata);
 if (pbk == NULL)
  break;
 *((DWORD *)name) = *((DWORD *)(pbk)->name);
 name[4] = 0;
 printf("bank %s found\n", name);
} while(TRUE);
Parameters:
event Pointer to data area of event.
pbk pointer to the bank header, must be NULL for the first call to this function.
pdata Pointer to the bank header, must be NULL for the first call to this function
Returns:
Size of bank in bytes

Definition at line 12487 of file midas.c.

Referenced by bk_list(), and update_odb().

INT bk_list void *  event,
char *  bklist
 

Extract the MIDAS bank name listing of an event. The bklist should be dimensioned with STRING_BANKLIST_MAX which corresponds to a max of BANKLIST_MAX banks (midas.h: 32 banks max).

INT adc_calib(EVENT_HEADER *pheader, void *pevent)
{
  INT    n_adc, nbanks;
  WORD   *pdata;
  char   banklist[STRING_BANKLIST_MAX];

  // Display # of banks and list of banks in the event
  nbanks = bk_list(pevent, banklist);
  printf("#banks:%d List:%s\n", nbanks, banklist);

  // look for ADC0 bank, return if not present
  n_adc = bk_locate(pevent, "ADC0", &pdata);
  ...
}
Parameters:
event pointer to current composed event
bklist returned ASCII string, has to be booked with STRING_BANKLIST_MAX.
Returns:
number of bank found in this event.

Definition at line 12309 of file midas.c.

INT bk_locate void *  event,
const char *  name,
void *  pdata
 

Locates a MIDAS bank of given name inside an event.

Parameters:
event pointer to current composed event
name bank name to look for
pdata pointer to data area of bank, NULL if bank not found
Returns:
number of values inside the bank

Definition at line 12353 of file midas.c.

Referenced by adc_calib(), adc_summing(), and scaler_accum().

INT bk_size void *  event  ) 
 

Returns the size of an event containing banks. The total size of an event is the value returned by bk_size() plus the size of the event header (sizeof(EVENT_HEADER)).

Parameters:
event pointer to the area of event
Returns:
number of bytes contained in data area of event

Definition at line 12109 of file midas.c.

Referenced by read_scaler_event().

INT bk_swap void *  event,
BOOL  force
 

Swaps bytes from little endian to big endian or vice versa for a whole event.

An event contains a flag which is set by bk_init() to identify the endian format of an event. If force is FALSE, this flag is evaluated and the event is only swapped if it is in the "wrong" format for this system. An event can be swapped to the "wrong" format on purpose for example by a front-end which wants to produce events in a "right" format for a back-end analyzer which has different byte ordering.

Parameters:
event pointer to data area of event
force If TRUE, the event is always swapped, if FALSE, the event is only swapped if it is in the wrong format.
Returns:
1==event has been swap, 0==event has not been swapped.

Definition at line 12564 of file midas.c.

Referenced by eb_mfragment_add(), and source_scan().


Midas DOC Version 1.9.5 ---- PSI Stefan Ritt ----
Contributions: Pierre-Andre Amaudruz - Sergio Ballestrero - Suzannah Daviel - Doxygen - Peter Green - Qing Gu - Greg Hackman - Gertjan Hofman - Paul Knowles - Rudi Meier - Glenn Moloney - Dave Morris - John M O'Donnell - Konstantin Olchanski - Renee Poutissou - Tamsen Schurman - Andreas Suter - Jan M.Wouters - Piotr Adam Zolnierczuk