GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> LSE / V2-1-0 > lsew / rhel6-32


Interface   Data Structures   File List   Data Fields   Globals  

CDF_acd_std.c File Reference

Implementation to produce Compressed Data Format for the standard ACD contributor and the ACD portion of the GEM. More...

#include <LSE/CDF_acd_std.h>
#include <LSE/CDF_acd_maps.h>
#include <CDF_acd_def.h>
#include <EDS/ACD_unpack.h>
#include <EDS/ACD_rec.h>
#include <EDS/ACD_map.h>
#include <EDS/EDR_acd.h>
#include <EDS/ECR_acd.h>
#include <EDS/EDA_acd.h>
#include <EDS/EBF_gem.h>
#include <LDT/BFP.h>
#include <PBI/FFS.ih>
#include <string.h>
#include <LSE/cdf_buf_print.h>
#include <dprintf.h>

Classes

struct  _Summary
 Hit summary status. This is the OR of the Ha,Hb,Pa,Pb,V bits. More...

Typedefs

typedef struct _Summary Summary
 Typedef for struct _Summary.

Functions

static __inline unsigned int acd_std_pack_adrs (CDF_acd *cdf, unsigned int *buf, unsigned int pos, const EDR_acd *acd, const EBF_gem *gem, Summary *summary)
 Packs the list of ACD addresses.
static __inline unsigned int acd_std_pack_adr (unsigned int *buf, unsigned int pos, unsigned int summary, unsigned int adr)
 Packs the ACD addressing information. This is an 8 bit value, 7-bits of actual address, 1 bit of stop information.
static __inline unsigned int acd_std_pack_pats (CDF_acd *cdf, unsigned int *buf, unsigned int pos, const EDR_acd *acd, const EBF_gem *gem, const Summary *sum, const unsigned short int *map)
 Packs the list of ACD discriminator patterns.
static __inline unsigned int acd_std_pack_pat32 (unsigned int *buf, unsigned int pos, const unsigned short int *map, unsigned int summary, unsigned int v, unsigned int hb, unsigned int ha, unsigned int pb, unsigned int pa)
 Packs the ACD discriminator pattern information for 32 channels.
static __inline unsigned int acd_std_pack_phas (CDF_acd *cdf, unsigned int *buf, unsigned int pos, const EDR_acd *acd)
 Adds the ACD phas.
static __inline unsigned short int acd_std_assess_phas (const unsigned int paccepts[2][4], const unsigned short int *phas, const unsigned short int *peds)
 Assesses the global properties of the PHAs, by effectively oring all 14 bits together.
static __inline unsigned int acd_std_pack_pha (unsigned int *buf, unsigned int pos, unsigned int pb, unsigned int pa, unsigned int msk, unsigned int chn, const unsigned short int *phas, int shift, int width)
 Packs the ACD Pha values.
unsigned int CDF_acd_std_compress (CDF_acd *cdf, unsigned int *buf, unsigned int pos, const EDR_acd *acd, const EBF_gem *gem)
 Adds the ACD record proper and the ACD portion of the GEM.
static __inline unsigned int prepare (unsigned int w)
 Prepares the initial word of being used in the formation of the pattern word.
static __inline unsigned int form (unsigned int v, unsigned int hb, unsigned int ha, unsigned int pb, unsigned int pa, int bit)
 Creates a 5 bit number with 5 bits representing the pattern of hit discriminators for the selected bit.


Detailed Description

Implementation to produce Compressed Data Format for the standard ACD contributor and the ACD portion of the GEM.

Author:
JJRussell - russell@slac.stanford.edu
    CVS $Id: CDF_acd_std.c,v 1.5 2011/03/26 17:35:23 russell Exp $

This repacks the ACD and the ACD hit list in the GEM using non-statistical methods, effectively just rearranging the bit patterns. This reformatting of the ACD/GEM information can be done in a variety of ways determined by the format definition block. This block begins with a single escape bit, which

This bit provides a path to future expansion. At this time, only the standard encoding has been implemented

At the highest level, the standard encoding consists of 3 major blocks.

  1. List of ACD tile addresses with any discriminator bit struck
  2. List of ACD discriminator patterns =# List of ACD pha values

Tile address list
This is gives the list of tiles that have a non-zero value for any of the 5 discriminators associated with the that tile. It consists of a series of 7-bit tile addresses and preceded by a single stop-bit. The tile address starts with the MSB of the first GEM ACD word and continues through the all 4 32-bits words.
Discriminator Pattern List
This list encodes the 5-bit discriminator pattern associated with each tile address. For future expansion, this list is preceded by a encoding style code.
  • bit 0 = 0, Reserved
  • bit 0,1 = 10, Standard Table
  • bit 0,1 = 11, Reserved
Currently only the Standard Table method is implemented,
Discriminator Pattern List, Standard Table Encoding Method
For each tile address, the 5-bit disciminator pattern, which is composed
V | HB | HA | PB | PA.

is run through a static Huffman code table that gives a code and code length. Thisis emitted into the output stream. For example, the pattern 0x1f, i.e. all bits set, is very common and given the code 0 with a length of 1 bit. Note that, by definition, the discriminator pattern list must be non-zero.

ACD PHA values
For each struck PB and/or PA bit the PHA value is emitted. The order is the order in the bit pattern, i.e. PB followed by PA. This list of PHA values is preceded by a 2-bit code, the first bit indicating the presence of any PHAs with range 1 and the next bit, indicating the presence of any parity errors. Note that this is an OR over all the PHA values. If these bits indicate that absence of any range 1 or parity error bits, those values are not emitted. For example, in the case where there are no range 1 ADCs nor data parity errors, only the 12-bit ADC value is emitted. Here is the full pattern

Example
Here is a simple example. A simplified pattern lookup table that maps the pattern 0x1f to the code pair of (0, 1 bit in length) and all the others to 0x20 | pattern has been used to simplify this example. Consider the following event.

 GEM Record
 ----------
 Trigger :    ThrTkr 10001100   CalHiLo 00000000 CondCno 0c030000
 Acd     :        XZ 00010000        YZ 00000000      XY 00000000   RU 00000000
 Times   :  Livetime 0075deda     Event 01511659     PPS 7e6704e9
 Counters: Discarded 00476cdc Prescaled 00000000 CondTim 3ffffc1f dWin d117d274

 ACD Record
 ----------
 Missing Start Bit:  0000    Header Parity Errors : 0000
 PHA Unmatched    :  0000    PHA    Parity Summary: 0000
    ACD   hits    :  00010000 00000000 00000000 00000000
                     00010000 00000000 00000000 00000000
    PAccepts      :  00010000 00000020 00000000 00000000
                     00010000 00000060 00000000 00000000
    NAccepts      :  00000000 00000000 00000000 00000000
                     00000000 00000000 00000000 00000000
 Number of PHAs   :         5

  XZ PhaA PhaB   YZ PhaA PhaB   XY PhaA PhaB   RU PhaA PhaB
 --- ---- ----  --- ---- ----  --- ---- ----  --- ---- ----
 400 6b3  7a6   111      10f                                
                110 0d4  130    

This can be restated as the following list
Tile List
Tile AddressPatternPHA BPHA A
0xf0x1f0x7a60x6b3
0x390x010x10f
0x3a0x030x0d40x130

This is encoded as follows
Encoding
Value Binary Description

0 0 No exception, use standard encoding

0 0 Stop address list, no

0x0f 000 1111 Tile address

0 0 Stop address list, no

0x39 011 1001 Tile address

1 1 Stop address list, yes

0x3a 011 1010 Tile address

0x2 10 Use static Pattern Encoding Table

0> 0> Code for pattern 0x1f

0x22 100010 Code for pattern 0x2

0x23 100011 Code for pattern 0x3

0 00 No PHAs with either range 1 or data parity error

0x6b3 0110 1101 0011 PHA value for A side, tile 0xf

0x7a6 0111 1010 0110 PHA value for B side, tile 0xf

0x10f 0001 1000 1111 PHA value for B side, tile 0x39

0xd4 0000 1101 0010 PHA value for A side, tile 0x3a

0x130 0001 0011 0000 PHA value for B side, tile 0x3a

Viewed as a collection of 103 bits this looks like
         00000111100111001101110101100100
         01010001101101001101111010011000
         01100011110000110100100001001100
         0

The original ACD record was 786 bits in length, giving a compaction factor ot ~7.5

Function Documentation

static __inline unsigned short int acd_std_assess_phas ( const unsigned int  paccepts[2][4],
const unsigned short int *  phas,
const unsigned short int *  peds 
) [static]

Assesses the global properties of the PHAs, by effectively oring all 14 bits together.

Parameters:
paccepts The PHA accepts
phas The array of pha values
peds The pedestals, arranged by GEM order
Currently it looks like subtracting the pedestal value does little good in reducing the range. More careful studies are needed.

Referenced by acd_std_pack_phas().

static __inline unsigned int acd_std_pack_adr ( unsigned int *  buf,
unsigned int  pos,
unsigned int  summary,
unsigned int  adr 
) [static]

Packs the ACD addressing information. This is an 8 bit value, 7-bits of actual address, 1 bit of stop information.

Parameters:
buf The output buffer
pos n The current bit offset
summary The summary of any bit set for this base address
adr Starting address

Referenced by acd_std_pack_adrs().

static __inline unsigned int acd_std_pack_adrs ( CDF_acd cdf,
unsigned int *  buf,
unsigned int  pos,
const EDR_acd *  acd,
const EBF_gem *  gem,
Summary sum 
) [static]

Packs the list of ACD addresses.

Returns:
The next available bit position in the output buffer
Parameters:
cdf The ACD compression data formatting handle
buf The output buffer
pos The current bit offset
acd The input EDR_acd record
gem The input EBF_gem record
sum Returned as the 'or' of any action in the discriminator bits

References acd_std_pack_adr(), _Summary::global, and _Summary::lists.

Referenced by CDF_acd_std_compress().

static __inline unsigned int acd_std_pack_pat32 ( unsigned int *  buf,
unsigned int  pos,
const unsigned short int *  map,
unsigned int  summary,
unsigned int  v,
unsigned int  hb,
unsigned int  ha,
unsigned int  pb,
unsigned int  pa 
) [static]

Packs the ACD discriminator pattern information for 32 channels.

Returns:
The next available bit position in the output buffer
Parameters:
buf The output buffer
pos The current bit offset
map Mapping array translating a hit pattern into a variable length bit pattern (lower 4 bits are the length, upper 12 bits are the pattern.
summary The OR of v, hb, ha, pb and pa
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

References _CDF_ACD_PAT_MAP_N, _CDF_ACD_PAT_MAP_P, form(), and prepare().

Referenced by acd_std_pack_pats().

static __inline unsigned int acd_std_pack_pats ( CDF_acd cdf,
unsigned int *  buf,
unsigned int  pos,
const EDR_acd *  acd,
const EBF_gem *  gem,
const Summary sum,
const unsigned short int *  map 
) [static]

Packs the list of ACD discriminator patterns.

Returns:
The next available bit position in the output buffer
Parameters:
cdf The ACD compression data formatting handle
buf The output buffer
pos The current bit offset
acd The input EDR_acd record
gem The input EBF_gem record
sum The 'or' of any action in the discriminator bits
map The map used to pack the patterns

References acd_std_pack_pat32(), and _Summary::lists.

Referenced by CDF_acd_std_compress().

static __inline unsigned int acd_std_pack_pha ( unsigned int *  buf,
unsigned int  pos,
unsigned int  pb,
unsigned int  pa,
unsigned int  msk,
unsigned int  chn,
const unsigned short int *  phas,
int  shift,
int  width 
) [static]

Packs the ACD Pha values.

Returns:
The updated bit write position
Parameters:
buf The output buffer
pos The bit index into the output buffer
pb The PHA B accept pattern
pa The PHA A accept pattern
msk Mask of the target channel
chn The GEM ACD channel number
phas The array of pha values
shift The number of bits to shift the PHA value
width The number of bits per PHA to store

Referenced by acd_std_pack_phas().

static __inline unsigned int acd_std_pack_phas ( CDF_acd cdf,
unsigned int *  buf,
unsigned int  pos,
const EDR_acd *  acd 
) [static]

Adds the ACD phas.

Returns:
The next available bit position in the output buffer
Parameters:
cdf The ACD compression data formatting handle
buf The output buffer
pos The current bit offset
acd The input EDR_acd record
The only error condition that this routine can deal with is PHA parity errors.

References acd_std_assess_phas(), acd_std_pack_pha(), _CDF_acd_pedestals::chns, and _CDF_acd::peds.

Referenced by CDF_acd_std_compress().

unsigned int CDF_acd_std_compress ( CDF_acd cdf,
unsigned int *  buf,
unsigned int  pos,
const EDR_acd *  acd,
const EBF_gem *  gem 
)

Adds the ACD record proper and the ACD portion of the GEM.

Returns:
The next available bit position in the output buffer
Parameters:
cdf The ACD compression data formatting handle
buf The output buffer
pos The current bit offset
acd The input EDR_acd record
gem The input EBF_gem record
The only error condition that this routine can deal with is PHA parity errors.

References _CDF_ACD_PAT_MAP_STD, acd_std_pack_adrs(), acd_std_pack_pats(), acd_std_pack_phas(), and _Summary::global.

static __inline unsigned int form ( unsigned int  v,
unsigned int  hb,
unsigned int  ha,
unsigned int  pb,
unsigned int  pa,
int  bit 
) [static]

Creates a 5 bit number with 5 bits representing the pattern of hit discriminators for the selected bit.

Returns:
The created pattern
Parameters:
v The GEM veto word
hb The ACD hit map b word
ha The ACD hit map a word
pb The ACD pulse height accept b word
pa The ACD pulse height accept a word
bit The bit number (MSB = 0) to strobe out of the above 32-bit words
The pattern is
          V Hb Ha Pb Pa Bit#(5)

Referenced by acd_std_pack_pat32().

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.

Referenced by acd_std_pack_pat32(), and compress1_twr_adr().


Generated on Thu Aug 4 13:00:08 2011 by  doxygen 1.5.8