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


Interface   Data Structures   File List   Data Fields   Globals  

CDF_cal_std.c File Reference

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

#include <LSE/CDF_caldef.h>
#include <LSE/CDF_cal.h>
#include <LSE/CDF_cal_std.h>
#include <CDF_cal_def.h>
#include <LSE/cdf_buf_print.h>
#include <dprintf.h>
#include <EDS/EDA_cal.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/EBF_cid.h>
#include <LDT/BTE.h>
#include <LDT/BFP.h>
#include <LDT/HUFF.h>
#include <LDT/HDE.h>
#include <PBI/FFS.ih>
#include <PBI/Endianness.h>
#include <string.h>

Classes

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...

Typedefs

typedef struct _Vn Vn
 Typedef for struct _Vn.

Functions

static int pha_ctx1_fill (CDF_calPhaCtx *pha_ctx, const EDR_cal *cal, const ECR_cal *clb)
 Transforms the CAL PHA values from EBF format to the leading zero representation. This routine works for CAL data in single range readout mode.
static int pha_ctx4_fill (CDF_calPhaCtx *pha_ctx, const EDR_cal *cal, const ECR_cal *clb, const CDF_cal *cdf, const EBF_dir *dir)
 Transforms the CAL PHA values from EBF format to the leading zero representation. This routine works for CAL data in four range readout mode.
static __inline unsigned int pha_ctx4_fill_layers (CDF_calPhaLz *lz, short int *dif, unsigned int present, unsigned short int hist[2][16], unsigned short int *rhist, const EBF_calLogData *logs, const ECR_calTower *calTwr, const CDF_cal_prd_layer *prdLyr, int twr, int lay, int cnt, int stride)
 Evaluates a CAL layer when in 4-range readout. The checks are
  1. the column numbers of the first range are okay (they increment and do not exceed the maximum column number in a layer)
  2. All layers have the same column number sequence
  3. The 4 ranges go in a circular fashion.

static __inline void pha_predict (unsigned short int *hist, short int *dif, EBF_calLogData log0, EBF_calLogData log1, EBF_calLogData log2, EBF_calLogData log3, const ECR_calTower *calTwr, const CDF_cal_prd_layer *prdLyr, int twr, int lyr)
 Fills in the difference between the actual PHA value and the predicted value.
static unsigned int compress1_raw_adr (unsigned int *buf, unsigned int pos, const EDR_cal *cal)
 Compresses the CAL address data.
static unsigned int compress1_raw1_pha (unsigned int *buf, unsigned int pos, CDF_calPhaCtx *pha_ctx)
 Compresses the CAL pha data when in single range readout mode.
static __inline unsigned int compress1_raw4_pha (unsigned int *buf, unsigned int pos, CDF_calPhaCtx *pha_ctx, HDE *hde)
 Compresses the CAL pha data when in four range readout mode.
static __inline unsigned int compress1_rng4_pha (unsigned int *buf, unsigned int pos, CDF_calPhaCtx *phaCtx, HDE *hde)
 Compresses the CAL pha data for the 'other 4' ranges.
static __inline unsigned int lz_compose (CDF_calPhaLz *lz, unsigned int present, unsigned short int hist[2][16], const EBF_calLogData log, const ECR_calTower *calTwr, int twr, int lay)
 Fills in the LZ structure for the specified log.
unsigned int CDF_cal_std_compress (CDF_cal *cdf, unsigned int *buf, unsigned int pos, const EBF_dir *dir, const EDR_cal *cal, const ECR_cal *clb, const CDF_err *err)
 Compresses the CAL data.
static void pha_compute_dif3 (unsigned short int hist[32], short int *difs, const CDF_cal_prd_log_end_table *ple_tbl, int rng, unsigned short int vals[4])
 Computes the difference between the actual and predicted values for the 'other 3' ranges.
static __inline unsigned int join (unsigned int colMap0, unsigned int colMap1)
 Combines to 12 bit column masks into 1 24 left justified mask.
static __inline 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.
static __inline unsigned int pack_adrs_1 (unsigned int *buf, unsigned int pos, 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 *buf, unsigned int pos, 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 *buf, unsigned int pos, 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 *buf, unsigned int pos, 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 __inline unsigned int compress1_twr_adr (unsigned int *buf, unsigned int pos, 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 Vn pack_present (unsigned int present)
 Constructs the packed version of the present mask.
static __inline unsigned int pha_exp_compose (const CDF_calPhaLz *lz, int ndif, unsigned char mappings[2][16])
 Composes the bit pattern to encode the exponents.
static __inline Vn pha_val_compose (const CDF_calPhaLz *lz)
 Composes the packed bit pattern from the leading zero representation of a PHA value.
static unsigned int pha_max_dif_pack (unsigned int *buf, int pos, const CDF_calPhaLz *lz, int lzcnt, unsigned int cnts)
 Packs each PHA value into the output structure, using a fixed number of bits (specified by the cnts) for the maximum and difference values.
static unsigned int pha_exp_man_pack (unsigned int *buf, int pos, const CDF_calPhaLz *lz, int lzcnt)
 Packs each PHA value into the output structure, uses full 8 bit exponent. This version represents the exponents using two fixed 4 bit fields.
static unsigned int pha_exp_man_s_pack (unsigned int *buf, int pos, const CDF_calPhaLz *lz, int lzcnt, Vn present, unsigned int ntot, unsigned int ndif, unsigned char mappings[2][16])
 Packs each PHA value into the output structure, using a pseudo- floating point scheme.
static __inline unsigned int create_mapping (unsigned char map[16], unsigned int msk)
 Creates a crossing mapping array, yielding, for a given set bit, the number of that set bit.
static __inline int chose (unsigned short int hist[2][16], unsigned int novr_a, unsigned int novr_b, unsigned int nexp_b, unsigned int npha, unsigned int *a)
 Evaluates the cost to encode the PHAs values as an exponent and manitissa in for two encoding methods.


Detailed Description

Implementation to produce Compressed Data Format for the CAL contributors.

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


Function Documentation

unsigned int CDF_cal_std_compress ( CDF_cal cdf,
unsigned int *  buf,
unsigned int  pos,
const EBF_dir *  dir,
const EDR_cal *  cal,
const ECR_cal *  clb,
const CDF_err err 
)

Compresses the CAL data.

Returns:
The updated write bit position
Parameters:
cdf The CAL compression data formatting handle
buf The output buffer
pos The position of the next bit to fill
dir The directory describing the event to be formatted
cal The unpacked CAL data
clb The CAL calibration.
err The error context block

References CDF_cal_copy(), _CDF_cal::com, compress1_raw1_pha(), compress1_raw4_pha(), compress1_raw_adr(), _CDF_cal_com::hde, pha_ctx1_fill(), pha_ctx4_fill(), _CDF_cal_std::phaCtx, and _CDF_cal::std.

static __inline int chose ( unsigned short int  hist[2][16],
unsigned int  novr_a,
unsigned int  novr_b,
unsigned int  nexp_b,
unsigned int  npha,
unsigned int *  a 
) [static]

Evaluates the cost to encode the PHAs values as an exponent and manitissa in for two encoding methods.

Return values:
0,if scheme A is cheaper
1,if scheme B is cheaper
Returns:
The cost in bits of using this encoding scheme
Parameters:
hist The histogram of the number of PHAs with the specified count of leading zeros
novr_a The overhead associated with scheme A
novr_b The overhead associated with scheme B
nexp_b The number of bits used to encode the exponent in scheme b.
npha The number of PHA values to be encoded
a If scheme A is cheaper, this value is returned as an 2 nibbles, the lower nibble giving the number of bits used to encode the difference PHA value and the upper nibble giving the numbe of tibs used to encode the maximum PHA value.
This cost is only based on encoding the exponent. Scheme A uses two 2 fixed field widths to encode the exponent (one for the maximum PHA value and one for the difference. Scheme uses a variable encoding table to encode the exponents. The cost of encoding table is expressed as novr_b.

Referenced by compress1_raw1_pha().

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

Referenced by compose_qmap().

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.
  

References collapse_24x6(), and collapse_4x4().

Referenced by compress1_twr_adr().

static unsigned int compress1_raw1_pha ( unsigned int *  buf,
unsigned int  pos,
CDF_calPhaCtx pha_ctx 
) [static]

Compresses the CAL pha data when in single range readout mode.

Returns:
The updated write bit position
Parameters:
buf The output buffer
pos The current bit position
pha_ctx The structure to receive the processed PHA values

References _Vn::bits, chose(), create_mapping(), _Vn::nbits, pack_present(), pha_exp_man_pack(), pha_exp_man_s_pack(), and pha_max_dif_pack().

Referenced by CDF_cal_std_compress(), and compress1_raw4_pha().

static __inline unsigned int compress1_raw4_pha ( unsigned int *  buf,
unsigned int  pos,
CDF_calPhaCtx pha_ctx,
HDE *  hde 
) [static]

Compresses the CAL pha data when in four range readout mode.

Returns:
The updated write bit positino
Parameters:
buf The output buffer
pos The current bit position
pha_ctx The PHA context to pack
hde The Huffman distribution encoding handle

References compress1_raw1_pha(), and compress1_rng4_pha().

Referenced by CDF_cal_std_compress().

static unsigned int compress1_raw_adr ( unsigned int *  buf,
unsigned int  pos,
const EDR_cal *  cal 
) [static]

Compresses the CAL address data.

Returns:
The updated write bit position
Parameters:
buf The output buffer
pos The current bit position
cal The unpacked CAL data

References compress1_twr_adr().

Referenced by CDF_cal_std_compress().

static __inline unsigned int compress1_rng4_pha ( unsigned int *  buf,
unsigned int  pos,
CDF_calPhaCtx phaCtx,
HDE *  hde 
) [static]

Compresses the CAL pha data for the 'other 4' ranges.

Returns:
The updated write bit position
Parameters:
buf The output buffer
pos The current bit position
phaCtx The PHA context to pack
hde The Huffman distribution encoding handle

Referenced by compress1_raw4_pha().

static __inline unsigned int create_mapping ( unsigned char  map[16],
unsigned int  msk 
) [static]

Creates a crossing mapping array, yielding, for a given set bit, the number of that set bit.

Parameters:
map The map to fill
msk The mask of bits (only the upper 16 bits most be set).
Example

Referenced by compress1_raw1_pha().

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

Referenced by compress1_twr_adr().

static __inline unsigned int lz_compose ( CDF_calPhaLz lz,
unsigned int  present,
unsigned short int  hist[2][16],
const EBF_calLogData  log,
const ECR_calTower *  calTwr,
int  twr,
int  lay 
) [static]

Fills in the LZ structure for the specified log.

Returns:
Update presence mask
Parameters:
lz The LZ structure to fill in
present Bit mask of which values of the max and dif exponents are present
hist Histogram of the number of leading zeros for the maximum and differences PHA values
log The target log
calTwr The calibration constants for this tower
twr The targer tower (debugging only)
lay The target layer number

References _CDF_calPhaLz::exp_dif, _CDF_calPhaLz::exp_max, _CDF_calPhaLz::n_is_max, _CDF_calPhaLz::pha_dif, and _CDF_calPhaLz::pha_max.

Referenced by pha_ctx1_fill(), and pha_ctx4_fill_layers().

static __inline unsigned int pack_adrs ( unsigned int *  buf,
unsigned int  pos,
unsigned int  colMapx01,
unsigned int  colMapx23,
unsigned int  colMapy01,
unsigned int  colMapy23 
) [static]

Packs the addresses associated with the hit columns.

Returns:
The updated write position
Parameters:
buf The output buffer
pos 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

References pack_adrs_1().

Referenced by compress1_twr_adr().

static __inline unsigned int pack_adrs_1 ( unsigned int *  buf,
unsigned int  pos,
unsigned int  biase,
unsigned int  stop,
unsigned int  colMap 
) [static]

Packs the column addresses associated with the specified column mask.

Returns:
The updated write position
Parameters:
buf The output buffer
pos 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

Referenced by pack_adrs().

static __inline unsigned int pack_blks ( unsigned int *  buf,
unsigned int  pos,
int  map,
unsigned int  pattern 
) [static]

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

Returns:
The updated write bit position
Parameters:
buf The output buffer
pos 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

Referenced by pack_qtree().

static __inline Vn pack_present ( unsigned int  present  )  [static]

Constructs the packed version of the present mask.

Returns:
The value and number of bits in the packed present mask
Parameters:
present The presence mask to pack
This scheme takes advantage of the fact that there cannot be more bits in the difference part of the presence mask than in the maximum part of the acceptance mask. This takes a little thinking. The low portion of the is really exp_max - exp_dif. Since exp_dif can be as only as large as exp_max (that sets the minimum at 0, not interesting) or as small as 0, that sets the maximum at exp_max.

Note:
I blew this. The constraint is not on exp_max but exp_min. This is too hard to recover from and it only saves ~3-5 bits, so I am punting and encoding the full 32 bits. To fix this I would have to redefine the present mask to be exp_min | exp_dif....

References _Vn::bits, and _Vn::nbits.

Referenced by compress1_raw1_pha().

static __inline unsigned int pack_qtree ( unsigned int *  buf,
unsigned int  pos,
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 updated write bit position
Parameters:
buf The output buffer
pos 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

References pack_blks().

Referenced by compress1_twr_adr().

static void pha_compute_dif3 ( unsigned short int  hist[32],
short int *  difs,
const CDF_cal_prd_log_end_table ple_tbl,
int  rng,
unsigned short int  vals[4] 
) [static]

Computes the difference between the actual and predicted values for the 'other 3' ranges.

Parameters:
hist The histogram of the residuals
difs Every 2nd entry is filled in this the computed difference
ple_tbl The prediction constants for one log end
rng The 'best' range
vals The 4-ranges

References _CDF_cal_prd_log_end::bf, CDF__cal_prd_predict(), _CDF_cal_prd_log_end_bf::gain, _CDF_cal_prd_log_end_bf::pedestal, _CDF_cal_prd_log_end_bf::shift, and _CDF_cal_prd_log_end_table::tbls.

Referenced by pha_predict().

static int pha_ctx1_fill ( CDF_calPhaCtx pha_ctx,
const EDR_cal *  cal,
const ECR_cal *  clb 
) [static]

Transforms the CAL PHA values from EBF format to the leading zero representation. This routine works for CAL data in single range readout mode.

Returns:
0, if successful
Parameters:
pha_ctx The PHA context to fill
cal The CAL data
clb The CAL calibration values

References lz_compose().

Referenced by CDF_cal_std_compress().

static int pha_ctx4_fill ( CDF_calPhaCtx pha_ctx,
const EDR_cal *  cal,
const ECR_cal *  clb,
const CDF_cal cdf,
const EBF_dir *  dir 
) [static]

Transforms the CAL PHA values from EBF format to the leading zero representation. This routine works for CAL data in four range readout mode.

Returns:
0, if successful
Parameters:
pha_ctx The PHA context to fill
cal The CAL data
clb The CAL calibration values
cdf THE CAL compression context
dir The event directory

References _CDF_cal::com, _CDF_cal_prd_tower::layers, pha_ctx4_fill_layers(), _CDF_cal_com::prd, and _CDF_cal_prd::twrs.

Referenced by CDF_cal_std_compress().

static __inline unsigned int pha_ctx4_fill_layers ( CDF_calPhaLz lz,
short int *  dif,
unsigned int  present,
unsigned short int  hist[2][16],
unsigned short int *  rhist,
const EBF_calLogData *  logs,
const ECR_calTower *  calTwr,
const CDF_cal_prd_layer prdLyr,
int  twr,
int  lyr,
int  cnt,
int  stride 
) [static]

Evaluates a CAL layer when in 4-range readout. The checks are

  1. the column numbers of the first range are okay (they increment and do not exceed the maximum column number in a layer)
  2. All layers have the same column number sequence
  3. The 4 ranges go in a circular fashion.

Returns:
0, if okay, else -1

printf ("Logs %8.8x %8.8x %8.8x %8.8x\n", log_0.ui, log_1.ui, log_2.ui, log_3.ui);

References lz_compose(), and pha_predict().

Referenced by pha_ctx4_fill().

static __inline unsigned int pha_exp_compose ( const CDF_calPhaLz lz,
int  ndif,
unsigned char  mappings[2][16] 
) [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

References _CDF_calPhaLz::exp_dif, and _CDF_calPhaLz::exp_max.

Referenced by pha_exp_man_s_pack().

static unsigned int pha_exp_man_pack ( unsigned int *  buf,
int  pos,
const CDF_calPhaLz lz,
int  lzcnt 
) [static]

Packs each PHA value into the output structure, uses full 8 bit exponent. This version represents the exponents using two fixed 4 bit fields.

Returns:
Where to place the next bit to be output
Parameters:
buf The output buffer
pos The bit position in the output buffer
lz The array of PHA values in leading zero representation
lzcnt The number of elements in lz

References _Vn::bits, _CDF_calPhaLz::exp_dif, _CDF_calPhaLz::exp_max, _Vn::nbits, and pha_val_compose().

Referenced by compress1_raw1_pha().

static unsigned int pha_exp_man_s_pack ( unsigned int *  buf,
int  pos,
const CDF_calPhaLz lz,
int  lzcnt,
Vn  present,
unsigned int  ntot,
unsigned int  ndif,
unsigned char  mappings[2][16] 
) [static]

Packs each PHA value into the output structure, using a pseudo- floating point scheme.

Returns:
Where to place the next bit to be output
Parameters:
buf The output buffer
pos The bit position in the output buffer
lz The array of PHA values in leading zero representation
lzcnt The number of elements in lz
present The packed presence mask
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.

References _Vn::bits, _Vn::nbits, pha_exp_compose(), and pha_val_compose().

Referenced by compress1_raw1_pha().

static unsigned int pha_max_dif_pack ( unsigned int *  buf,
int  pos,
const CDF_calPhaLz lz,
int  lzcnt,
unsigned int  cnts 
) [static]

Packs each PHA value into the output structure, using a fixed number of bits (specified by the cnts) for the maximum and difference values.

Returns:
The updated write bit position
Parameters:
buf The output buffer
pos The bit position in the output buffer
lz The array of PHA values in leading zero representation
lzcnt The number of elements in lz
cnts The packed number of nbits to store max and differences

References _CDF_calPhaLz::n_is_max, _CDF_calPhaLz::pha_dif, and _CDF_calPhaLz::pha_max.

Referenced by compress1_raw1_pha().

static __inline void pha_predict ( unsigned short int *  hist,
short int *  dif,
EBF_calLogData  log0,
EBF_calLogData  log1,
EBF_calLogData  log2,
EBF_calLogData  log3,
const ECR_calTower *  calTwr,
const CDF_cal_prd_layer prdLyr,
int  twr,
int  lyr 
) [static]

Fills in the difference between the actual PHA value and the predicted value.

Parameters:
hist Histogram of the residuals
dif Filled in with the 6 prediction differences
log0 The first range read out
log1 The second range read out
log2 The third range read out
log3 The fourth range read out
calTwr The calibration constants
prdLyr The prediction constants
twr The tower
lyr The layer
The prediction scheme is


    Best    Use Range # to Predict
    Range     0   1   2   3
    ------+----+---+---+---+
        0 |  NA   0   0   2
        1 |   1  NA   1   2
        2 |   1   2  NA   2
        3 |   1   2   3  NA

Looking at the above table, there are 7 unique predictor combinations. The predictor constants are stored in a table in the following order

  • 0) 0 -> 1
  • 1) 0 -> 2
  • 2) 2 -> 3
  • 3) 1 -> 2
  • 4) 1 -> 0
  • 5) 2 -> 1
  • 6) 3 -> 2

Thus given a best value, one can arrange a lookup table to give the prediction constants for the 3 ranges (i.e. the ones following the best. This table is

  • Best Range 0, 0,1,2
  • Best Range 1 4,3,2
  • Best Range 2 4,5,2
  • Best Range 3 4,5,6

Note that predictors with indices 4,5 and 6 are used when using a base range to predict a value with a larger value. In this case saturation may and presumably does occur (that's why a lower gain range was selected in the first place).

References _CDF_cal_prd_layer::logs, _CDF_cal_prd_log::n, _CDF_cal_prd_log::p, and pha_compute_dif3().

Referenced by pha_ctx4_fill_layers().

static __inline Vn pha_val_compose ( const CDF_calPhaLz lz  )  [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
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;

References _Vn::bits, _CDF_calPhaLz::exp_dif, _CDF_calPhaLz::exp_max, _CDF_calPhaLz::n_is_max, _Vn::nbits, _CDF_calPhaLz::pha_dif, and _CDF_calPhaLz::pha_max.

Referenced by pha_exp_man_pack(), and pha_exp_man_s_pack().

static __inline 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 Thu Aug 4 13:00:08 2011 by  doxygen 1.5.8