GLAST/LAT > DAQ and FSW > FSW > Doxygen Index > ASC / V0-0-5

Constituent: asc     Tag: sun-gcc


Interface   Data Structures   File List   Data Fields   Globals  

ASC.c File Reference

ACD Software Rate Counters, implementation file. More...

#include <string.h>
#include "PBS/FFS.ih"
#include "PBI/Endianness.h"
#include "ASC/ASC.h"

Include dependency graph for ASC.c:


Data Structures

struct  _LCB_header
 Layouts out the header for an LCB packet. The header is represented in terms of 32-bit quantities to avoid BIG/ LITTLE endian problems. More...
struct  _EBF_gemAcd
 Lays out the format of the ACD data block from the event builder. More...
struct  _EBF_gem
 Lays out the format of the GEM data block from the event builder. This does not include the LCB header. More...
struct  _EBF_aem
 Lays out the format of the ACD data block from the event builder. This does not include the LCB header. More...
struct  _ASC_acd
 Holds the unpacked ACD information. More...
struct  _ACD_remapBrd
 Structure defining the remapping the ACD data on a single board from electronics space into the standard 4 geographically oriented lists. More...
struct  _ACD_remap
 Defines the information necessary to remap all ACD information laid out in electronics space to a geographical space. More...

Defines

#define EBF_K_CID_GEM   16
 The id of the GEM contribution.
#define EBF_K_CID_ACD   17
 The id of the ACD contribution.
#define LCB_M_PACKET_ALIGN   0xf
 The size of a contributor must be an even multiple of this number. Currently an LCB packet is 128 bits or 16 bytes. This means that the low nibble of each length contributor's field must be zero.
#define LCB_EXTRACT_CID(hdr_clen)   (((hdr_clen) >> 17) & 0x1f)
 Extracts the contributor id from the first word of the LCB header.
#define LCB_EXTRACT_CLEN(hdr_clen)   ((hdr_clen) & 0xffff)
 Extracts the contributor length (in bytes) from the first word of the LCB header.
#define _ADVANCE(_ptr, _nbytes)   (void *)((unsigned char *)(_ptr) + (_nbytes))
 Advances _ptr by _nbytes. The return value is always recast to the type of _ptr.
#define _SKIP_EHDR(_ptr)   (void *)((unsigned char *)(_ptr)+sizeof(LCB_header))
 Skips over the event header (LATp header + summary word) recast to the type of _ptr.
#define EBF_K_ACD_NBRDS   12
 Number of ACD front end boards.
#define EBF_K_ACD_NCHNS_PER_BRD   18
 Number of ACD front end channels serviced by one board.
#define EBF_K_ACD_VETOES_CNT   7
 The number of words in the ACD veto hit map array.
#define EBF_K_ACD_ACCEPTS_CNT   9
 The number of words in the ACD accept map array.

Typedefs

typedef _LCB_header LCB_header
 Typedef for struct _LCB_header.
typedef enum _EBF_K_gem_acd_veto EBF_K_gem_acd_veto
 Typedef for enum _EBF_K_gem_acd_veto.
typedef _EBF_gemAcd EBF_gemAcd
 Typedef for struct _EBF_gemAcd.
typedef _EBF_gem EBF_gem
 Typedef for struct _EBF_gem.
typedef enum _EBF_K_acd_list EBF_K_acd_list
 Typedef for enum _EBF_K_acd_list.
typedef enum _EBF_K_acd_side EBF_K_acd_side
 Typedef for enum _EBF_K_acd_side.
typedef _EBF_aem EBF_aem
 Typedef for struct _EBF_aem.
typedef _ASC_acd ASC_acd
 typedef for struct _ASC_acd
typedef _ACD_remapBrd ACD_remapBrd
 Typedef for struct _ACD_remapBrd.
typedef _ACD_remap ACD_remap
 Typedef for struct _ACD_remap.

Enumerations

enum  _EBF_K_gem_acd_veto {
  EBF_K_GEM_ACD_VETO_XZ = 0,
  EBF_K_GEM_ACD_VETO_YZ = 1,
  EBF_K_GEM_ACD_VETO_XY = 2,
  EBF_K_GEM_ACD_VETO_RU = 3,
  EBF_K_GEM_ACD_VETO_CNT = 4
}
 Enumerates the elements of the GEM's ACD veto block.
enum  _EBF_K_acd_list {
  EBF_K_ACD_LIST_XZ = 0,
  EBF_K_ACD_LIST_YZ = 1,
  EBF_K_ACD_LIST_XY = 2,
  EBF_K_ACD_LIST_RU = 3,
  EBF_K_ACD_LIST_CNT = 4
}
 Enumerates the bit lists. More...
enum  _EBF_K_acd_side {
  EBF_K_ACD_SIDE_A = 0,
  EBF_K_ACD_SIDE_B = 1,
  EBF_K_ACD_SIDE_CNT = 2
}
 Enumerates the side A and side B values. More...

Functions

static void clear (void *ptr, int nbytes)
 Zeroes the specified memory.
static void accumulate_cno (ASC_cno *cno, unsigned int cnoReqVec)
 Accumulates the number of CNO triggers from each FREE board.
static void accumulate (ASC_list *list, unsigned int v, unsigned int hb, unsigned int ha, unsigned int pb, unsigned int pa)
 Accumulates the statistics for list (32-bits) of ACD hits.
static int unpack (struct _ASC_acd *acd, const unsigned short int *data)
 Unpacks an ACD record from the AEM into a standard structure.
static __inline unsigned int prepare (unsigned int w)
 Prepares the initial word of being used in the formation of the pattern word.
static __inline const EBF_aemlocate_aem (const unsigned int *evt, int elen)
 Composes the directory of the contributors.
static __inline unsigned int form (unsigned int v, unsigned int hb, unsigned int ha, unsigned int pb, unsigned int pa, int left)
 Forms the 5 bit pattern word from the bits in column left and appropriately shifts the pattern word so that it may be used directly as a byte offset into the correct statistics counters.
void ASC_clear (ASC_counters *counters)
 Clears the specified statistics counters.
void ASC_accumulateU (ASC_counters *counters, const struct _EBF_gem *gem, const struct _ASC_acd *acd)
 Accumulates the proper pattern words for each ACD hit.
const __inline struct _EBF_gemASC_gem_locate (const unsigned int *edata, int esize)
 Locates GEM contribution in an event.
const __inline struct _EBF_aemASC_aem_locate (const unsigned int *edata, int esize)
 Locates ACD contribution in an event.
int ASC_accumulate (ASC_counters *counters, const unsigned int *edata, int esize)
 Accumulate the counters for the specified event.
int ASC_acd_sizeof (void)
 Returns the size, in bytes, of the data structure needed to hold an unpacked ACD event.
int ASC_acd_unpack (struct _ASC_acd *acd, const struct _EBF_aem *aem)
 Unpacks an ACD record from the AEM into a standard structure.

Detailed Description

ACD Software Rate Counters, implementation file.

Author:
JJRussell - russell@slac.stanford.edu
    CVS $Id: ASC.c,v 1.1.1.1 2005/12/01 21:55:31 ebacho Exp $

SYNOPSIS
Defines the the implementation for accumulating the ACD software rate counters

Define Documentation

#define _ADVANCE _ptr,
_nbytes   )     (void *)((unsigned char *)(_ptr) + (_nbytes))
 

Advances _ptr by _nbytes. The return value is always recast to the type of _ptr.

Parameters:
_ptr The pointer to advance
_nbytes The number of nbytes to advance _ptr by.
Returns:
The advanced pointer, the pointer is recast to a void *.

#define _SKIP_EHDR _ptr   )     (void *)((unsigned char *)(_ptr)+sizeof(LCB_header))
 

Skips over the event header (LATp header + summary word) recast to the type of _ptr.

Parameters:
_ptr The pointer to advance
Returns:
The advanced pointer, the pointer is recast to a void *.

#define EBF_K_ACD_ACCEPTS_CNT   9
 

The number of words in the ACD accept map array.

The ACD data structure consists of the standard header word followed by 3 major blocks. The first two blocks, the veto hit map and the accept block are fixed length. The final block is a variable length block containing the ADC pulse values. The number of ADC values is determined by the count field in the accept block.

Header Word Event sequence number and contributor id Veto Hit Map One 18 bit vector for each of the 12 ACD FREE boards Accept Block One 24 bit vector for each of the 12 ACD FREE boards ACD ADCs The ACD ADC pulse values, variable length.

Veto Hit Map
The Veto Hit Map is packed densely into 7 32 bit words. There is one unused byte at the end. Picturally this block looks like

        11111111 11111111
        fedcba98 76543210 fedcba98 76543210                 
       +--------+--------+--------+--------+
     0 |11111111 11111100 00000000 00000000| 
     1 |33333333 33222222 22222222 22221111| 
     2 |55555544 44444444 44444444 333333331
     3 |77666666 66666666 66665555 55555555|
     4 |88888888 88888888 77777777 77777777|
     5 |AAAAAAAA AAAA9999 99999999 99999988|
     6 |-------- BBBBBBBB BBBBBBBB BBAAAAAA|
       +--------+--------+--------+--------+
  

Where the numbers represent the 12 ADC FREE boards. (Note that each string of numbers has 18 bits.

ADC Accept Block
The Accept block is a densely packed array of words 24 bits in length. Each 24 bit word is formatted as follows

        11111111
        76543210 fedcba98 76543210    
       +--------+--------+--------+   
       |aaaaaaaa aaaaaaaa aaCccccc|           
       +--------+--------+--------+
   

Where

       c( 5 bits)
       Count of number of ADC accepted for this board. Because the
       number of ADCs from the ACD can be limited, this count must be
       less than or equal to the number of bits set in accept mask.

       C( 1 bit )
       The CNO bit for this board.

       a(18 bits)
       A bit map of the number of pulse heights over threshold on
       this board. If the number of bits exceeds the count (c) then
       only the first 'count' are present in the ADC array.
   

These 12 Accept vectors are packed densely into 9 32 bit words.

           11111111 11111111
           fedcba98 76543210 fedcba98 76543210                 
       +--------+--------+--------+--------+
     0 |11111111 00000000 00000000 00000000| 
     1 |22222222 22222222 11111111 11111111| 
     2 |33333333 33333333 33333333 222222221
     3 |55555555 44444444 44444444 44444444|
     4 |66666666 66666666 55555555 55555555|
     5 |77777777 77777777 77777777 66666666|
     6 |99999999 88888888 88888888 88888888|
     7 |aaaaaaaa aaaaaaaa 99999999 99999999|
     8 |bbbbbbbb bbbbbbbb bbbbbbbb aaaaaaaa|
       +--------+--------+--------+--------+
   

Again the numbers represent the accept words for each of the 12 ACD FREE boards.

ACD ADC Pulse Heights
Each ACD ADC pulse height is 16 bits in length. The total number of ADC values is determined by the count field in the accept word. The mapping is determined by accept map in each accept word. Only the first count bits of ADC values are used. That is, if there are more bits set in the accept map, there will be only count number of ADC pulse heights from this board.

#define LCB_EXTRACT_CID hdr_clen   )     (((hdr_clen) >> 17) & 0x1f)
 

Extracts the contributor id from the first word of the LCB header.

Parameters:
hdr_clen The first word of the LCB header
Returns:
The contributor id

#define LCB_EXTRACT_CLEN hdr_clen   )     ((hdr_clen) & 0xffff)
 

Extracts the contributor length (in bytes) from the first word of the LCB header.

Parameters:
hdr_clen The first word of the LCB header
Returns:
The contributor's length (in bytes)


Typedef Documentation

ACD_remap
 

Typedef for struct _ACD_remap.

This is basically just an array of the remap structures AFF_remapBrd for each of the 12 FREE boards.

ACD_remapBrd
 

Typedef for struct _ACD_remapBrd.

This is a fairly complicated structure whose layout is driven by the code. These arrays define the mapping from electronics space, i.e. channels on a particular FREE boards, to geometric space, i.e. tiles on the 5 faces, top (XY) and the 4 side planes (XZ-,XZ+,YZ-,YZ+). There are 3 remapping arrays.

The first array is a series of masks, one for each of the geometrically oriented lists. For a given list of 18 channels on a FREE board, each mask projects out only those channels of the corresponding geometrical list.

The next array is indexed by electronics channel and yields the corresponding channel within the context of its geographical list. This array may contain the same geometrical channel more than once, but, by virtue of using the first array to project out only those channels belonging to a particular geometrical list, the duplicate channels will never direct more than one electronics channel to a single geometrical channel. In fact, the first mask is just a bit list of the channels in this array belonging to a single geometrical list.

The final array remaps a PHA value in electronics space into an array indexed by geometrical index. This array is differs from the previous array only by having the geometrical list index as part of the output index. That is, the output index is in a flat space from 0 to the number of actual tiles/ribbons. The other two arrays are merely rearrangements of the information in this array.

EBF_K_acd_list
 

Typedef for enum _EBF_K_acd_list.

These definitions should be used to access the elements of the ACD hit and accept lists by name.

EBF_K_acd_side
 

Typedef for enum _EBF_K_acd_side.

These definitions should be used to access the elements of the ACD hit and accept sides by name.

EBF_K_gem_acd_veto
 

Typedef for enum _EBF_K_gem_acd_veto.

These definitions should be used to access the elements of the ACD veto block by name.


Enumeration Type Documentation

enum _EBF_K_acd_list
 

Enumerates the bit lists.

Enumerator:
EBF_K_ACD_LIST_XZ  Bit mask of tiles in the XZ plane
EBF_K_ACD_LIST_YZ  Bit mask of tiles in the YZ plane
EBF_K_ACD_LIST_XY  Bit mask of tiles in the XY plane
EBF_K_ACD_LIST_RU  Bit mask of ribbons and unused
EBF_K_ACD_LIST_CNT  Number of bit masks

enum _EBF_K_acd_side
 

Enumerates the side A and side B values.

Enumerator:
EBF_K_ACD_SIDE_A  The side A block
EBF_K_ACD_SIDE_B  The side B block
EBF_K_ACD_SIDE_CNT  Count of the number of sides


Function Documentation

static void accumulate ASC_list list,
unsigned int  v,
unsigned int  hb,
unsigned int  ha,
unsigned int  pb,
unsigned int  pa
[static]
 

Accumulates the statistics for list (32-bits) of ACD hits.

Parameters:
list Pointer to the statistics for this list of ACD hits
v The GEM list of veto bits
hb The ACD hit bits for side b
ha The ACD hit bits for side a
pb The ACD pulse height accept bits for side b
pa The ACD pulse height accept bits for side a

static void accumulate_cno ASC_cno cno,
unsigned int  cnoReqvec
[static]
 

Accumulates the number of CNO triggers from each FREE board.

Parameters:
cno The CNO statistics block
cnoReqvec The CNO and trigger request vector. The CNO trigger information occupies the lower 12 of the upper 16 bits.

int ASC_accumulate ASC_counters counters,
const unsigned int *  edata,
int  esize
 

Accumulate the counters for the specified event.

Returns:
Status indicating the event was successfully processed (0) or a non-zero number indicating the event was not successfully processed.
Parameters:
counters Pointer to the counters to increment
edata Pointer to the event data
esize The event size, in units of bytes. This is used as a consistency check in the unpacking.

void ASC_accumulateU ASC_counters counters,
const struct _EBF_gem gem,
const struct _ASC_acd acd
 

Accumulates the proper pattern words for each ACD hit.

Parameters:
counters The statistics counters
gem Pointer to the GEM record
acd Pointer to an unpacked ACD record
This function is called on the assumption that the GEM record has been located and the ACD data has been both located and successfully unpacked.

int ASC_acd_sizeof void   ) 
 

Returns the size, in bytes, of the data structure needed to hold an unpacked ACD event.

Returns:
The size, in bytes, of the data structure needed to hold an unpacked ACD event

int ASC_acd_unpack struct _ASC_acd acd,
const struct _EBF_aem aem
 

Unpacks an ACD record from the AEM into a standard structure.

Returns:
Status. The only failure is if more than 18 PHAs are found to be present on an given FREE board.
Parameters:
acd Pointer to the data structure to receive the unpacked ACD data
aem Pointer to the AEM ACD data

const struct _EBF_aem * ASC_aem_locate const unsigned int *  edata,
int  esize
 

Locates ACD contribution in an event.

Return values:
A pointer to the GEM contribution.
NULL is return if the GEM contribution cannnot be found
Parameters:
edata Pointer to the event data structure
esize Size, in bytes, of the event

ASC_clear ASC_counters counters  ) 
 

Clears the specified statistics counters.

Parameters:
counters The statistics counters to be cleared
Warning:
Currently this is a NON-interlocked operation.

const struct _EBF_gem * ASC_gem_locate const unsigned int *  edata,
int  esize
 

Locates GEM contribution in an event.

Return values:
A pointer to the GEM contribution.
NULL is return if the GEM contribution cannnot be found
Parameters:
edata Pointer to the event data structure
esize Size, in bytes, of the event

void clear void *  ptr,
int  nbytes
[static]
 

Zeroes the specified memory.

Parameters:
ptr Pointer to the memory to zero
nbytes The number of bytes to zero
This provides a fast way of zeroing large chunks of memory on PPC platforms using the dcbz instruction. This instruction zeroes a cache line at a time. The savings in speed various by processor, but factors of 5 or more are in the ballpark. For example, on the mv2304, zeroing 32K of memory

On other platforms, the generic memset routine is used.

unsigned int form unsigned int  v,
unsigned int  hb,
unsigned int  ha,
unsigned int  pb,
unsigned int  pa,
int  left
[static]
 

Forms the 5 bit pattern word from the bits in column left and appropriately shifts the pattern word so that it may be used directly as a byte offset into the correct statistics counters.

Returns:
A word that can be used to increment the statistics pattern counter.
Parameters:
v The GEM list of veto bits
hb The ACD hit bits for side b
ha The ACD hit bits for side a
pb The ACD pulse height accept bits for side b
pa The ACD pulse height accept bits for side a
left The bit number of the channel (counting from the left or MSB)

static __inline const EBF_aem * locate_aem const unsigned int *  evt,
int  elen
[static]
 

Composes the directory of the contributors.

Parameters:
evt The source event.
elen The size of the event in bytes
Returns:
Pointer to the ACD data or NULL if it cannot be located.

static __inline unsigned int prepare unsigned int  w  )  [static]
 

Prepares the initial word of being used in the formation of the pattern word.

Returns:
The prepared word
Parameters:
w The word to prepare
On the PowerPC, 1 instruction in the accumulation loop is saved by preshifting the intial word used in the formation of the pattern word. All other platforms do the straightforward thing of shifting and oring each bit and this routine is a NOOP. By doing defining this routine, the bulk of the code is portable across platforms.

static int unpack struct _ASC_acd acd,
const unsigned short int *  data
[static]
 

Unpacks an ACD record from the AEM into a standard structure.

Returns:
Status. The only failure is if more than 18 PHAs are found to be present on an given FREE board.
Parameters:
acd Pointer to the data structure to receive the unpacked data
data Pointer to the AEM data


Generated on Tue Dec 6 21:26:20 2005 by  doxygen 1.4.4