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


Interface   Data Structures   File List   Data Fields   Globals  

CDF_dgn.c File Reference

Implementation to produce Compressed Data Format for the diagnostic contributions. More...

#include <LSE/CDF_dgn.h>
#include <LSE/CDF_dgn_std.h>
#include <LSE/CDF_dgn_ped.h>
#include <CDF_dgn_def.h>
#include <EDS/EBF_dir.h>
#include <PBI/FFS.ih>
#include <string.h>
#include <dprintf.h>
#include <EDS/EDR_tkrUnpack.h>

Defines

#define unpack_tkr(_tkr, _dir, _map)
#define analyze_tkr_twr(_stats, _tkr, _accept_0, _accept_1, _accept_2)
#define print_tkr_stats(_stats)

Typedefs

typedef struct _EDR_tkrTower EDR_tkrTower

Functions

int CDF_dgnCfg_sizeof (int level)
 Returns the size, in bytes of the DGN compression configuration needed to support the specified level.
int CDF_dgnCfg_construct (CDF_dgnCfg *cfg, int level, void **mem)
 Constructs the CDF_dgnCfg compression configuration.
int CDF_dgn_sizeof (int level, const CDF_dgnCfg *cfg)
 Returns the size, in bytes of the DGN compression structure needed to support the specified level.
int CDF_dgn_construct (CDF_dgn *cdf, int level, const CDF_dgnCfg *cfg, const LSEW_dgmFw *dgmFw, void **mem)
 Constructs the CDF_dgn compression context.
CDF_dgn_stdCDF_dgn_std_locate (CDF_dgn *cdf)
CDF_dgn_pedCDF_dgn_ped_locate (CDF_dgn *cdf)
unsigned int CDF_dgn_gen_header_compress (unsigned int *buf, unsigned int pos, unsigned int xCalHiLo, unsigned int xCtids)
 Encodes the tower summary indicating which
  • CAL LO/CAL HI diagnostic towers do not match the GEM
  • CAL/TKR diagnostic towers with/without data do not match the CAL/TKR contributions.

unsigned long long int CDF_dgn_cal_tkr_nonempty_find (const unsigned int **dgns_p, unsigned int map, const EBF_dirCtbDsc *dscs, const EBF_dirAuxDsc *auxs)
 Compose a list of non-empty CAL and TKR diagnostic blocks.
static __inline unsigned int trg_encode16 (unsigned int *buf, unsigned int pos, unsigned int trg)
static __inline unsigned int trg_encode32 (unsigned int *buf, unsigned int pos, unsigned int trg)
 Encodes the CAL HI/LO trigger word when both the CAL HI and CAL LO are non-zero.
unsigned int CDF_dgn_gen_trg_compress (unsigned int *buf, unsigned int pos, const unsigned int *trgs, int cnt)
 Encodes the CAL log trigger diagnostic trigger data for all towers. This is a generic routine that can be used for both standard physics and pedestal evetns.
static int encode_tkr_10 (unsigned int *buf, unsigned int pos, unsigned int cnt, unsigned int acnt, unsigned int xor, unsigned int tkr)
static int encode_tkr_11 (unsigned int *buf, unsigned int pos, int status, int cnt, int acnt, unsigned int xor, unsigned int tkr)
static __inline unsigned short int reverse9 (const char *rmap, unsigned int w)
 Reverses bit ordering of the lower 9 bits of w.
static __inline int compressDgnTkrTwr (unsigned int *buf, unsigned int pos, int tem, unsigned int tkr_0, unsigned int tkr_1, unsigned int tkr_2, unsigned int dgn_0, unsigned int dgn_1, unsigned int dgn_2)
static __inline unsigned int encodeTkrDgn (CDF_dgn_gen_tkr *cdf, unsigned int *buf, unsigned int pos, const unsigned int *dgn, const EBF_dirCtbDsc *dsc, int tem)
static __inline unsigned int encodeTkrDgnErr (CDF_dgn_gen_tkr *cdf, unsigned int *buf, unsigned int pos, const unsigned int *dgn)
unsigned int CDF_dgn_gen_tkr_compress (CDF_dgn_gen_tkr *cdf, unsigned int *buf, unsigned int pos, unsigned int const **dgns, const EBF_dir *dir, unsigned int map, unsigned int err_ids)

Variables

static const char Reverse4 [16]
 Lookup table to reverse a 4-bit field.


Detailed Description

Implementation to produce Compressed Data Format for the diagnostic contributions.

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


Function Documentation

int CDF_dgn_construct ( CDF_dgn cdf,
int  level,
const CDF_dgnCfg *  cfg,
const LSEW_dgmFw dgmFw,
void **  mem 
)

Constructs the CDF_dgn compression context.

Return values:
Status 
Parameters:
cdf The CDF_dgn compress context structure to fill
level The maximum compression level that needs to be supported
cfg Target specific configuration parameter
dgmFw The datagram framework handle
mem Pointer to free memory pointer, return as the the updated pointer. If cdf is equal to the current contents of mem, then mem will be advanced by the size of CDF_dgn, else this routine will believe that the only the variable allocation of cdf needs to be allocated.

References CDF_dgn_ped_construct(), CDF_dgn_std_construct(), _CDF_dgn::ped, and _CDF_dgn::std.

unsigned int CDF_dgn_gen_header_compress ( unsigned int *  buf,
unsigned int  pos,
unsigned int  xCalHiLo,
unsigned int  xCtids 
)

Encodes the tower summary indicating which

  • CAL LO/CAL HI diagnostic towers do not match the GEM
  • CAL/TKR diagnostic towers with/without data do not match the CAL/TKR contributions.

Returns:
The new bit index
Parameters:
buf The output buffer
pos The bit index
xCalHiLo Bit mask of the non-matching CAL HI and CAL LO towers
xCtids Bit mask of the non-matching CAL and TKR towers
Logically one expects that these two values are 0, but in given that the signal paths and timing strobes are different for the diagnostic data, the values in the diagnostics and there logical equivalents in the data stream occassionally do not match.

The number of the mismatches depends on the quantity

  • CAL towers with and without data very rarely (have not seen a case) does not match the towers with diagnostic data that is empty and nonempty. That is because it is precisely these values that determine which CAL logs get committed to the data stream. In fact, if the data stream recorded which end was above threshold, this data would not only match at the summary level, but at the log end level. As it is, the diagnostic data does match at the log level, just not the log-end level. This is because a log is accepted if eiher end is above threshold.

  • TKR towers with and without data mismatch quite frequently. This is because the diagnostic data indicating which layers have or do not data are taken with a one time and the data in the TKR stream is taken at another time. This is because the former signals are used in the trigger, while the latter are captured only after the trigger. (2/3)

  • The CAL HI/CAL LO triggers rarely mismatch. These mismatches must be due to the CAL and GEM latching these signals slightly differently. This mismatch perhaps indicates a mistiming of latching strobes. (< 1/100)

The encoding attempts to take advantage of these statistics. It treats the incoming data as three values

  • xCalHiLo (32-bits)
  • CAL ids (16-bits)
  • TKR ids (16-bits)

0 - all zero 10 - CAL ids zero, xCaLHiLo zero, TKR ids non-zero 110 - CAL ids zero, xCalHiLo nonzero, TKR_ids zero 1110 - CAL ids zero, xCalHiLo nonzero, TKR_ids nonzero 1111xx - CAL ids nonzero, xx gives non zero status

Referenced by CDF_dgn_ped_compress(), and CDF_dgn_std_compress().

unsigned int CDF_dgn_gen_trg_compress ( unsigned int *  buf,
unsigned int  pos,
const unsigned int *  trgs,
int  cnt 
)

Encodes the CAL log trigger diagnostic trigger data for all towers. This is a generic routine that can be used for both standard physics and pedestal evetns.

Returns:
The updated bit index
Parameters:
buf The output bit buffer
pos The output bit index
trgs The array of prepared trigger data for the list of towers with non-empty trigger data.
cnt The count of dgn

References trg_encode32().

Referenced by CDF_dgn_ped_cal_compress(), and CDF_dgn_std_cal_compress().

int CDF_dgn_sizeof ( int  level,
const CDF_dgnCfg *  cfg 
)

Returns the size, in bytes of the DGN compression structure needed to support the specified level.

Parameters:
level The maximum compression level to support
cfg Target specific configuration

References CDF_dgn_ped_sizeof(), and CDF_dgn_std_sizeof().

int CDF_dgnCfg_construct ( CDF_dgnCfg *  cfg,
int  level,
void **  mem 
)

Constructs the CDF_dgnCfg compression configuration.

Return values:
Status 
Parameters:
cfg Target specific configuration
level The maximum compression level that needs to be supported
mem Pointer to free memory pointer, return as the the updated pointer. If cfg is equal to the current contents of mem, then mem will be advanced by the size of CDF_dgnCfg else this routine will believe that the only the variable allocation of cdf needs to be allocated.

References CDF_dgn_ped_cfg_construct(), and CDF_dgn_std_cfg_construct().

int CDF_dgnCfg_sizeof ( int  level  ) 

Returns the size, in bytes of the DGN compression configuration needed to support the specified level.

Parameters:
level The maximum compression level to support

References CDF_dgn_ped_cfg_sizeof(), and CDF_dgn_std_cfg_sizeof().

static __inline unsigned short int reverse9 ( const char *  rmap,
unsigned int  w 
) [static]

Reverses bit ordering of the lower 9 bits of w.

Returns:
The bit reversed value
Parameters:
rmap The reversal map. This is purely a bow to efficiency so that the address does not have to keep getting reloaded each call.
w The 9-bit value to bit-reverse.

static __inline unsigned int trg_encode32 ( unsigned int *  buf,
unsigned int  pos,
unsigned int  trg 
) [static]

Encodes the CAL HI/LO trigger word when both the CAL HI and CAL LO are non-zero.

Returns:
The updated bit write position
Parameters:
buf The output buffer
pos The current bit position
trg The 32-bit CAL HI/LO trigger word to encode. This word must be encoded as 4 x 1 byte quantities. The 4 bytes, from MSB to LSB are
  • CAL HI negative end for the 8 layers of a tower
  • CAL HI plus end for the 8 layers of a tower
  • CAL LO negative end for the 8 layers of a tower
  • CAL LO plus end for the 8 layers of a tower
Many things where tried, but the best compress that could be achieved was an reduction of the 32-bits to an average of ~28.5 bits. When the CAL HI and CAL LO are both non-zero, this trigger word, on average has many bits set, with the CAL LO bits being over 50% set on the average.
There are many correlation one might thing could be taken advantage of, but, while the help, there are always exceptions to the rule. If, one was doing a true statistically based compression, then these correlelations would make a bigger difference.
The information content that is exploited is
  • Many CAL LO bits set, so one encodes the clear bits
  • The plus and minus patterns are nearly equal, so one encodes one end (arbitrarily the minus end) asis and the XOR of the plus and minus ends
  • The x and y layers are roughly equal, so one encodes encodes one end (arbitrarily the x end) asis and the XOR of the x and y ends.
  • Finally, to take advantage that the run length encoding is more efficient the more leading 0s there are, the various pieces are rearranged from the most probable 0s to the least probable 0s. This ordering is (from MSB to LSB)
    • The XOR of the CAL LO plus and minus patterns, 8 bits
    • The XOR of the CAL LO x and y patterns, 4 bits
    • The XOR of the CAL HI plus and minus patterns, 8 bits
    • The XOR of the CAL HI x and y patterns, 4 bits
    • The CAL HI x pattern, 4 bits
    • The CAL LO x pattern, 4 bits

Referenced by CDF_dgn_gen_trg_compress().


Variable Documentation

static const char Reverse4[16] [static]

Initial value:

 { 0x0, 0x8, 0x4, 0xc, 0x2, 0xa, 0x6, 0xe,
                                   0x1, 0x9, 0x5, 0xd, 0x3, 0xb, 0x7, 0xf }
Lookup table to reverse a 4-bit field.


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