GLAST/LAT > DAQ and FSW > FSW > Doxygen Index > LSEP / V1-0-1

Constituent: lsepw     Tag: linux-gcc


Interface   Data Structures   File List   Data Fields   Globals  

CDF_cal.c File Reference

Implementation to produce Compressed Data Format for the CAL contributors. More...

#include "dprintf.h"
#include "LSEP/CDF.h"
#include "LSEP/CDF_vector.h"
#include "LSEP/CDF_cal.h"
#include "LSEP/BFP.h"
#include "EDS/ECR_cal.h"
#include "EDS/EDR_calUnpack.h"
#include "EDS/EDR_cal.h"
#include "EDS/EBF_cal.h"
#include "EDS/EBF_dir.h"
#include "EDS/EDS_endianness.h"
#include "EDS/FFS.h"
#include "LDT/BTE.h"
#include <string.h>

Include dependency graph for CDF_cal.c:


Data Structures

struct  Lz
 Describes the two log end readings in a leading 0 (pseudo-floating) manner. More...
struct  _Vn
 A structure containing two fields, one with the bit pattern of a packed PHA value and one with the number of bits in the bit pattern. More...
struct  _Lzs
 Structure to hold the minimum of all the maximum ADC values and the minimum of differences. More...

Defines

#define DEBUG_1
#define STYLE_0   0
 Indicates CAL encoding by style 0.
#define STYLE_1   1
 Indicates CAL encoding by style 1.

Typedefs

typedef _Vn Vn
 Typedef for struct _Vn.
typedef _Lzs Lzs
 Typedef for _struct Lzs.

Functions

static unsigned int compress0_raw_adr (unsigned int *buffer, unsigned int position, const EDR_cal *cal)
 Compresses the CAL address data.
static unsigned int compress0_raw_pha (unsigned int *buffer, unsigned int position, const EDR_cal *cal, const ECR_cal *calCal)
 Compresses the CAL pha data.
unsigned int CDF_cal0Compress (CDF_vector *bpv, const EDR_cal *cal, const ECR_cal *calCal)
 Gathers the statistics on the CAL data.
static __inline unsigned int join (unsigned int colMap0, unsigned int colMap1)
 Combines to 12 bit column masks into 1 24 left justified mask.
static unsigned int prepare (unsigned int colMap0, unsigned int colMap1)
 Transforms the the 2 12-bit column masks into 4 groups of 2 rows x 3 columns masks packed into the least significant bits of a 32-bit word One 24-bit mask arranged as 4 groups of 2 rows x 3 columns.
static unsigned int analyze (unsigned int pattern)
 Analyzes the 2 12-bit column masks as 4 groups of 2 rows x 3 columns masks.
static __inline unsigned int pack_adrs_1 (unsigned int *buffer, unsigned int position, unsigned int biase, unsigned int stop, unsigned int colMap)
 Packs the column addresses associated with the specified column mask.
static __inline unsigned int pack_adrs (unsigned int *buffer, unsigned int position, unsigned int colMapx01, unsigned int colMapx23, unsigned int colMapy01, unsigned int colMapy23)
 Packs the addresses associated with the hit columns.
static __inline unsigned int collapse_24x6 (unsigned int pat)
 Collapses the 4 groups of 6 consecutive bits in a 24 bit number to a 4 bit mask.
static __inline unsigned int collapse_4x4 (unsigned int pat)
 Collapses the 4 bits in a 4 bit pattern to a single bit, indicating whether the value is 0 or non-zero.
static __inline unsigned int compose_qmapn (unsigned int r0, unsigned int r1)
 Compose the bit pattern for the negative quadtree encoding.
static __inline unsigned int compose_qmapp (unsigned int r0, unsigned int r1)
 Compose the bit pattern for the positive quadtree encoding.
static __inline unsigned int compose_qmap (unsigned int scheme, unsigned int patternx01, unsigned int patternx23, unsigned int patterny01, unsigned int patterny23)
 Composes a representation of the level 0 and level quad tree map of the 96 bits specified by the 4 24 bit masks.
static __inline unsigned int pack_blks (unsigned int *buffer, unsigned int position, int map, unsigned int pattern)
 Packs the non-zero 6 bit groups in the specified 24-bit pattern.
static __inline unsigned int pack_qtree (unsigned int *buffer, unsigned int position, unsigned int qmap, unsigned int patternx01, unsigned int patternx23, unsigned int patterny01, unsigned int patterny23)
 Packs the complete quad tree representation for the specified patterns.
static void increment (unsigned int stats[64], unsigned int pattern)
 Increments the pattern statistics tables.
static __inline unsigned int compress0_twr_adr (unsigned int *buffer, unsigned int position, unsigned int nhits, unsigned int colMapx0, unsigned int colMapx1, unsigned int colMapx2, unsigned int colMapx3, unsigned int colMapy0, unsigned int colMapy1, unsigned int colMapy2, unsigned int colMapy3)
 Compresses the addresses for this tower.
static __inline unsigned int gather_twr_adr_stats (CDF_calStatsAdr *stats, unsigned int nhits, unsigned int colMapx0, unsigned int colMapx1, unsigned int colMapx2, unsigned int colMapx3, unsigned int colMapy0, unsigned int colMapy1, unsigned int colMapy2, unsigned int colMapy3)
 Gathers the address statistics for this tower.
static __inline unsigned int pha_exp_compose (const struct Lz *lz, int ndif, unsigned char mappings[2][14])
 Composes the bit pattern to encode the exponents.
static __inline Vn pha_val_compose (const struct Lz *lz, int cutoff_max, int cutoff_dif)
 Composes the packed bit pattern from the leading zero representation of a PHA value.
static unsigned int pha_pack0 (unsigned int *buffer, int position, const struct Lz *lz, int lzcnt, unsigned short int min_max, unsigned short int min_dif)
 Packs each PHA value into the output structure, uses full 8 bit exponent.
static unsigned int pha_pack1 (unsigned int *buffer, int position, const struct Lz *lz, int lzcnt, unsigned short int min_max, unsigned short int min_dif, unsigned short int cutoff_max, unsigned short int cutoff_dif, unsigned int present, unsigned int ntot, unsigned int ndif, unsigned char mappings[2][14])
 Packs each PHA value into the output structure.
static __inline unsigned int lz_limit (unsigned int present, unsigned int cutoff_max, unsigned int cutoff_dif)
 Eliminates the low probability states from the present mask.
static unsigned int lz_reduce (struct Lz *lz, int lz_cnt, unsigned short int min_max, unsigned short int min_dif)
 Reduces the PHA values and transforms the CAL PHA values from EBF format to the leading zero representation.
static Lzs lz_fill (struct Lz *lz, const EDR_cal *cal, const ECR_cal *calCal)
 Transforms the CAL PHA values from EBF format to the leading zero representation.

Detailed Description

Implementation to produce Compressed Data Format for the CAL contributors.

Author:
JJRussell - russell@slac.stanford.edu
    CVS $Id: CDF_cal.c,v 1.4 2005/12/05 18:24:40 russell Exp $


Function Documentation

static unsigned int analyze unsigned int  pattern  )  [static]
 

Analyzes the 2 12-bit column masks as 4 groups of 2 rows x 3 columns masks.

Returns:
A packed 32 bit word
          +----+----+--------+--------+--------+
          | q+ | q- | unused |  size+ |  size- |
          +----+----+--------+--------+--------+
  

where q+/- = quad map of + or - images size +/- = size of the + or - images

Parameters:
pattern 

unsigned int CDF_cal0Compress CDF_vector bpv,
const EDR_cal *  cal,
const ECR_cal *  calCal
 

Gathers the statistics on the CAL data.

Parameters:
bpv The output bit vector
cal The unpacked CAL data
calCal The CAL calibration.

static __inline unsigned int collapse_24x6 unsigned int  pat  )  [static]
 

Collapses the 4 groups of 6 consecutive bits in a 24 bit number to a 4 bit mask.

Returns:
A 4-bit mask indicating which groups of 6 are non-zero.
Parameters:
pat The word to collapse. The 24 bits must be right justified

static __inline unsigned int compose_qmap unsigned int  scheme,
unsigned int  patternx01,
unsigned int  patternx23,
unsigned int  patterny01,
unsigned int  patterny23
[static]
 

Composes a representation of the level 0 and level quad tree map of the 96 bits specified by the 4 24 bit masks.

Parameters:
scheme A two bit packing scheme. This number must have its MSB set.
patternx01 The first of the 4 24 bit patterns
patternx23 The second of the 4 24 bit patterns
patterny01 The third of the 4 24 bit patterns
patterny23 The fourth of the 4 24 bit patterns
The level 0 quad tree map consists of a 4 bit map indicating which of the four patterns of 24 bits are non-zero.
The level 1 quad tree map consists of 1 4 bit map for each of the set bits in the level 0 map. Each 4 bit map indicates which of the 4 6 bit patterns in the 24 bit pattern are non-zero.
The representation of the output word is described below
         33 2222 2222 2211 1111 1111
         10 9876 5432 1098 7654 3210 9 87654 3210
        +--+----+----+----+----+----+-+-----+----+
        |ss|MapA|Map0|Map1|Map2|Map3|0| Ng6s|NmpA|
        +--+----+----+----+----+----+-+-----+----+

     Where  ss = Scheme 10 for + image, 11 for - image
          Mapa = Bit map of which of pattern words are non-zero
                 Equivalently, it indicates the which of the following maps
                 are present.
          Map0 = Bit map of which groups of 6 from the 1rst hit group are hit
          Map1 = Bit map of which groups of 6 from the 2nd  hit group are hit
          Map2 = Bit map of which groups of 6 from the 3rd  hit group are hit
          Map3 = Bit map of which groups of 6 from the 4rth hit group are hit
             0 = MBZ
          Ng6s = Number of 6 that are hit (ie bit count of Map0-Map3) (0-4)
         Nqmap = Number of bits in the qmap (0-16)

     In the maps, 0 is never a valid number.
  

static unsigned int compress0_raw_adr unsigned int *  buffer,
unsigned int  position,
const EDR_cal *  cal
[static]
 

Compresses the CAL address data.

Returns:
Size, in bits of the compressed CAL address data.
Parameters:
buffer The output buffer
position The current bit position
cal The unpacked CAL data

static unsigned int compress0_raw_pha unsigned int *  buffer,
unsigned int  position,
const EDR_cal *  cal,
const ECR_cal *  calCal
[static]
 

Compresses the CAL pha data.

Returns:
Size, in bits of the compressed CAL pha data.
Parameters:
buffer The output buffer
position The current bit position
cal The unpacked CAL data
calCal The CAL calibration constants

static void increment unsigned int  stats[64],
unsigned int  pattern
[static]
 

Increments the pattern statistics tables.

Parameters:
stats The set of pattern statistics tables to increment
pattern The pattern word

static __inline unsigned int join unsigned int  colMap0,
unsigned int  colMap1
[static]
 

Combines to 12 bit column masks into 1 24 left justified mask.

Returns:
The left justified 24-mask
Parameters:
colMap0 The first column mask
colMap1 The second column mask

static Lzs lz_fill struct Lz lz,
const EDR_cal *  cal,
const ECR_cal *  calCal
[static]
 

Transforms the CAL PHA values from EBF format to the leading zero representation.

Returns:
A bit mask representing which values of the exponents for the maximum and differences are present
Parameters:
lz The output array to receive the leading zero representation
cal The CAL data
calCal The CAL calibration values

static __inline unsigned int lz_limit unsigned int  present,
unsigned int  cutoff_max,
unsigned int  cutoff_dif
[static]
 

Eliminates the low probability states from the present mask.

Returns:
The present mask with these states eliminated
Parameters:
present The target present mask (upper 16 bits = max mask, lower 16 bits = dif mask of exponents that are present
cutoff_max The cutoff value for the maximum mask
cutoff_dif The cutoff value for the difference mask

static unsigned int lz_reduce struct Lz lz,
int  lz_cnt,
unsigned short int  min_max,
unsigned short int  min_dif
[static]
 

Reduces the PHA values and transforms the CAL PHA values from EBF format to the leading zero representation.

Returns:
A bit mask representing which values of the exponents for the maximum and differences are present
Parameters:
lz The output array to receive the leading zero representation
lz_cnt The number of elements in the lz array
min_max The minimum PHA value of the maximum PHA values
min_dif The minimum PHA value of the difference PHA values

static __inline unsigned int pack_adrs unsigned int *  buffer,
unsigned int  position,
unsigned int  colMapx01,
unsigned int  colMapx23,
unsigned int  colMapy01,
unsigned int  colMapy23
[static]
 

Packs the addresses associated with the hit columns.

Returns:
The new output bit offset
Parameters:
buffer The output buffer
position The current bit position in the output buffer
colMapx01 24-bit column mask associated with x-rows 0 and 1
colMapx23 24-bit column mask associated with x-rows 2 and 3
colMapy01 24-bit column mask associated with y-rows 0 and 1
colMapy23 24-bit column mask associated with y-rows 2 and 3

static __inline unsigned int pack_adrs_1 unsigned int *  buffer,
unsigned int  position,
unsigned int  biase,
unsigned int  stop,
unsigned int  colMap
[static]
 

Packs the column addresses associated with the specified column mask.

Parameters:
buffer The output buffer
position The current bit position in the output buffer
biase The column biase/offset (0, 32, 64)
stop The flag to apply to the last hit column (either 0 or 0x80)
colMap The column map

static __inline unsigned int pack_blks unsigned int *  buffer,
unsigned int  position,
int  map,
unsigned int  pattern
[static]
 

Packs the non-zero 6 bit groups in the specified 24-bit pattern.

Returns:
The next bit position
Parameters:
buffer The output buffer
position The next bit position to fill
map A 4-bit number indicating which groups of 6 are non-zero. Technically the routine needs only the pattern argument, but having map makes for a more efficient implentation.
pattern The pattern word to pack

static __inline unsigned int pack_qtree unsigned int *  buffer,
unsigned int  position,
unsigned int  qmap,
unsigned int  patternx01,
unsigned int  patternx23,
unsigned int  patterny01,
unsigned int  patterny23
[static]
 

Packs the complete quad tree representation for the specified patterns.

Returns:
The next bit position to fill
Parameters:
buffer The output buffer
position The position of the next bit to fill
qmap A combination of the level 0 and level 1 quad tree map and bit counts of level 0 and level 1 quad tree maps. This value was composed by pack_qmap.
patternx01 The 24 bit x01 pattern
patternx23 The 24 bit x23 pattern
patterny01 The 24 bit y01 pattern
patterny23 The 24 bit y23 pattern

static __inline unsigned int pha_exp_compose const struct Lz lz,
int  ndif,
unsigned char  mappings[2][14]
[static]
 

Composes the bit pattern to encode the exponents.

Returns:
The encoded bit pattern
Parameters:
lz The leading zero representation of the CAL PHA value
ndif The number of bits in exp_dif
mappings Maps an exponent value into a dense value
The mapping algorithm is straight-forward
  1. Get the value of the exponents for the maximum and difference PHA values
  2. Use the mappings array to map these values to a dense state
  3. Encode as mapped_maximum * ndif + mapped_difference

static unsigned int pha_pack0 unsigned int *  buffer,
int  position,
const struct Lz lz,
int  lzcnt,
unsigned short int  min_max,
unsigned short int  min_dif
[static]
 

Packs each PHA value into the output structure, uses full 8 bit exponent.

Returns:
Where to place the next bit to be output
Parameters:
buffer The output buffer
position The bit position in the output buffer
lz The array of PHA values in leading zero representation
lzcnt The number of elements in lz
min_max The minimum value of all the maximums
min_dif The minimum value of all differences

static unsigned int pha_pack1 unsigned int *  buffer,
int  position,
const struct Lz lz,
int  lzcnt,
unsigned short int  min_max,
unsigned short int  min_dif,
unsigned short int  cutoff_max,
unsigned short int  cutoff_dif,
unsigned int  present,
unsigned int  ntot,
unsigned int  ndif,
unsigned char  mappings[2][14]
[static]
 

Packs each PHA value into the output structure.

Returns:
Where to place the next bit to be output
Parameters:
buffer The output buffer
position The bit position in the output buffer
lz The array of PHA values in leading zero representation
lzcnt The number of elements in lz
min_max The minimum value of all the maximums
min_dif The minimum value of all differences
cutoff_max The cut off used when constructing the exponent for the maximum value
cutoff_dif The cut off used when constructing the exponent for the difference value
present ?? !!! KLUDGE
ntot The total number of bits to hold the encoded exponents
ndif The count of difference exponent values. This is used when encoding the exponents
mappings A mapping array to convert a sparse exponent value to a dense number; one each for the maximum PHA exponent and the difference of the PHA values.

static __inline Vn pha_val_compose const struct Lz lz,
int  cutoff_max,
int  cutoff_dif
[static]
 

Composes the packed bit pattern from the leading zero representation of a PHA value.

Returns:
A 64 bit value, with one 32-bit word containing the bit pattern and one 32-bit word containing the number of bits in the bit pattern
Parameters:
lz The leading zero representation of the PHA value
cutoff_max The cut off used constructing the maximum exponent Must be between 0-7
cutoff_dif The cut off used constructing the difference exponent Must be between 0-7
The constructed word looks like
  • Sign Bit 1 bit
  • Mantissa of maximum PHA value, Mm bits
  • Mantissa of differences of the PHA values, Md bits;

static unsigned int prepare unsigned int  colMap0,
unsigned int  colMap1
[static]
 

Transforms the the 2 12-bit column masks into 4 groups of 2 rows x 3 columns masks packed into the least significant bits of a 32-bit word One 24-bit mask arranged as 4 groups of 2 rows x 3 columns.

Parameters:
colMap0 One of the two 12-bit masks
colMap1 The other of the two 12-bit masks


Generated on Tue Dec 6 20:25:36 2005 by  doxygen 1.4.4