GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> LSE / V2-0-1 > lsew / sun-gcc
#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 "EDS/EDS_endianness.h"
#include "EDS/FFS.h"
#include "LDT/BTE.h"
#include "LDT/BFP.h"
#include "LDT/HUFF.h"
#include "LDT/HDE.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
| |
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], unsigned 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. |
CVS $Id: CDF_cal_std.c,v 1.6 2009/04/30 18:38:19 russell Exp $
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.
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 |
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.
0,if | scheme A is cheaper | |
1,if | scheme B is cheaper |
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. |
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.
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.
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 |
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 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.
buf | The output buffer | |
pos | The current bit position | |
pha_ctx | The structure to receive the processed PHA values |
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.
buf | The output buffer | |
pos | The current bit position | |
pha_ctx | The PHA context to pack | |
hde | The Huffman distribution encoding handle |
static unsigned int compress1_raw_adr | ( | unsigned int * | buf, | |
unsigned int | pos, | |||
const EDR_cal * | cal | |||
) | [static] |
Compresses the CAL address data.
buf | The output buffer | |
pos | The current bit position | |
cal | The unpacked CAL data |
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.
buf | The output buffer | |
pos | The current bit position | |
phaCtx | The PHA context to pack | |
hde | The Huffman distribution encoding handle |
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.
map | The map to fill | |
msk | The mask of bits (only the upper 16 bits most be set). |
static __inline unsigned int join | ( | unsigned int | colMap0, | |
unsigned int | colMap1 | |||
) | [static] |
Combines to 12 bit column masks into 1 24 left justified mask.
colMap0 | The first column mask | |
colMap1 | The second column mask |
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.
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 |
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.
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 |
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.
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 |
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.
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 |
static __inline Vn pack_present | ( | unsigned int | present | ) | [static] |
Constructs the packed version of the present mask.
present | The presence mask to pack |
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.
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 |
static void pha_compute_dif3 | ( | unsigned short int | hist[32], | |
unsigned 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.
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 |
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.
pha_ctx | The PHA context to fill | |
cal | The CAL data | |
clb | The CAL calibration values |
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.
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 |
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
printf ("Logs %8.8x %8.8x %8.8x %8.8x\n", log_0.ui, log_1.ui, log_2.ui, log_3.ui);
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.
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 |
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.
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 |
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.
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. |
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.
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 |
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.
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 |
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
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
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).
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.
lz | The leading zero representation of the PHA value |
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
colMap0 | One of the two 12-bit masks | |
colMap1 | The other of the two 12-bit masks |