GLAST/LAT > DAQ and FSW > FSW > Doxygen Index > LSEP / V1-0-2
Constituent: lsepw     Tag: linux-gcc
#include "LSEP/CDF.h"
#include "LSEP/CDF_vector.h"
#include "LSEP/CDF_tkr.h"
#include "LSEP/BFP.h"
#include "EDS/EDR_tkr.h"
#include "EDS/FFS.h"
#include "LDT/BTE.h"
Include dependency graph for CDF_tkr.c:
Data Structures | |
struct | _TowerMaps |
Captures the map of the tower classification and the XY layers for all 16 towers. More... | |
struct | _Tree18Result |
The result of encoding an 18-bit layer map. This consists of the right justified encoded bit pattern and the number of bits in the bit pattern. More... | |
struct | _TotsRep |
The tots represented as a count of the significant bits + the significant bits. More... | |
struct | _TotsRet |
Return value from the tots_acquire, captures the next write location plus a bit mask of those TOTs having each particular value of the number of significant digits. More... | |
Typedefs | |
typedef _TowerMaps | TowerMaps |
Typedef for struct _TowerMaps. | |
typedef _Tree18Result | Tree18Result |
Typedef for struct _Tree18Result. | |
typedef _TotsRep | TotsRep |
Typedef for struct _TotsRep. | |
typedef _TotsRet | TotsRet |
Typedef for struct _TotsRet. | |
typedef int(* | StripsPacker )(unsigned int *buffer, int position, const EDR_tkrLayer *lyrs, unsigned int layerMap) |
Call signature for the 4 tower level strip packing routines. | |
Functions | |
static Tree18Result | tree18_encode (unsigned int w) |
Does a binary-like tree encode of an 18-bit number. | |
static __inline int | layer_map_pack (unsigned int *buffer, int position, unsigned int map) |
Packs the specified layer map. | |
static TotsRet | tots_acquire (TotsRep *tots, unsigned int present, const EDR_tkrLayer *lyrs, unsigned int layerMap) |
Packs the TOTs for the specified layers. | |
static unsigned int | tots_map_compress (unsigned int *buffer, unsigned int position, unsigned int *map, unsigned int mapcnt, unsigned int lzeroes) |
Compresses what is essentially the exponent map of the TOTs. | |
static unsigned int | tots_exp_pack (unsigned int *buffer, unsigned int position, TotsRep *tots, int ntots, unsigned int present) |
Compresses what is essentially the exponent map of the TOTs. | |
static unsigned int | tots_man_pack (unsigned int *buffer, unsigned int position, TotsRep *tots, int ntots) |
Compresses what is essentially the exponent map of the TOTs. | |
static __inline int | tots_pack (unsigned int *buffer, int position, const EDR_tkrTower *twrs, unsigned int twrMap) |
Driver routine to pack the strips from each non-empty layer. | |
static __inline int | layer_maps_pack (unsigned int *buffer, int position, const EDR_tkrTower *twrs, unsigned int twrMap) |
Driver routine to pack the layer masks. | |
static int | strips_pack_0 (unsigned int *buffer, int position, const EDR_tkrLayer *lyrs, unsigned int layerMap) |
Packs the strips for a Class 0 tower (only one hit strip/layer), no clusters. | |
static int | strips_pack_1 (unsigned int *buffer, int position, const EDR_tkrLayer *lyrs, unsigned int layerMap) |
Packs the strips for a Class 1 tower (only one hit strip or one cluster/layer). This needs the address + cluster width + stop. | |
static int | strips_pack_2 (unsigned int *buffer, int position, const EDR_tkrLayer *lyrs, unsigned int layerMap) |
Packs the strips for a Class 2 tower (multiple hits, clusters will be expanded. | |
static int | strips_pack_3 (unsigned int *buffer, int position, const EDR_tkrLayer *lyrs, unsigned int layerMap) |
Packs the strips for a Class 3 tower (multiple hits, clusters will not be expanded. | |
static __inline int | strips_pack (unsigned int *buffer, int position, const EDR_tkrTower *twrs, unsigned int twrMap, unsigned int classMap) |
Driver routine to pack the strips from each non-empty layer. | |
static __inline unsigned int | layer_map_size (unsigned int map) |
Computes the number of bits to encode the specified layer map. | |
static TowerMaps | tower_classify (const EDR_tkrTower *twrs, unsigned int twrMap) |
Picks the optimal encoding method for all towers. | |
unsigned int | CDF_tkrCompress (CDF_vector *bpv, const EDR_tkr *tkr) |
Compresses the TKR data. |
CVS $Id: CDF_tkr.c,v 1.4 2005/12/05 18:24:40 russell Exp $
|
Call signature for the 4 tower level strip packing routines.
|
|
Typedef for struct _TotsRet. The pointer to the next TOTs location to write is absolutely necessary. The present mask is an optimization to avoid scanning NS values that are not populated. Perhaps even better would be a histogram of the values, That way the scan loop could abort when the number reached 0. We will try this simple approach until it is found that something more sophisiticated is warranted. |
|
Typedef for struct _TowerMaps. Each map contains 2 bits of information per tower. For the layer maps the 2 bits represent whether the X and/or Y layers have any hits. The order is X0 = Bit 0 (MSb) Y0 = bit 1, X1 = bit2, etc For the class maps, the two bits give the tower encoding scheme to use. The order is Tower 0 class = Bits 0,1 (MSb = bit 0), Tower 1 class = Bits 2,3 etc. |
|
Compresses the TKR data.
|
|
Packs the specified layer map.
|
|
Computes the number of bits to encode the specified layer map.
|
|
Driver routine to pack the layer masks.
|
|
Driver routine to pack the strips from each non-empty layer.
|
|
Packs the strips for a Class 0 tower (only one hit strip/layer), no clusters.
|
|
Packs the strips for a Class 1 tower (only one hit strip or one cluster/layer). This needs the address + cluster width + stop.
|
|
Packs the strips for a Class 2 tower (multiple hits, clusters will be expanded.
|
|
Packs the strips for a Class 3 tower (multiple hits, clusters will not be expanded.
|
|
Packs the TOTs for the specified layers.
|
|
Compresses what is essentially the exponent map of the TOTs.
|
|
Compresses what is essentially the exponent map of the TOTs.
|
|
Compresses what is essentially the exponent map of the TOTs.
|
|
Driver routine to pack the strips from each non-empty layer.
At first glance the algorthm used by the CAL would be seem attractive. In that algorithm the PHA value number of leading is decomposed into two values, an exponent-like value that counts the number of leading zeros and a manitissa-like value that captures the significant bits (less the first leading 1, since it is implied). However, the method for encoding the exponent does not work here. In the CAL, the number of leading zeros is around 7, here it is only 2-4. With this smaller number of bits, the scheme does not work. The algorithm used here can be visualize by the following example. Suppose one has the following 4 TOTS, 0x61, 0x73, 0x00, 0x4, 0x18, 0x2c, 0x3d, 0x7d. Now write the bits patterns representing these values vertically (rather than the usual horizontal). Then peel off each row. For each column, only consider entries where no 1 has yet been encountered. Mark down a 0 if, on such entries, the value is 0 and a 1 if the value is 1. Once a value of 1 has been encountered, that column is no longer considered. Now turn this pattern into a string of bits
Original Decimated Bit String 00000000 00000000 00000000 11000001 00011 001 00 00 1 0 11000001 11000001 11000111 00011 01001011 001 00001111 00 00010111 00 01000000 1 11100011 0 If the values are all small, then this is quite representative of what one will encounter. The leading bits will be sparsely populated, making this a canidate of a Binary Tree Encoding. Latter in the bit string the number of 0's and 1's become more or less equal. At that time, the Binary Tree Encoding method no longer will compress, but will inflate. To compensate for this, the rule is that as soon as the Binary Tree Encoding ceases to compress, a flag is set, and the remaining bits are emitted as is. (This is perfectly decodable, since the decoder will notice the same thing, i.e. it took more bits to encode than the actual value it represents.) Once the above process is done, the 'manitissa-like' piece is emitted as is, but only outputting the significant bits. Continuing with the above example, but this time writing the significant digits
Original Decimated Bit String 7 00000000 11 111 01 1011 00 1111 00 11111 01 00000 6 11000001 1110001 5 11000111 11 111 4 01001011 01 1011 3 00001111 00 1111 2 00010111 00 11111 1 01000000 01 00000 0 11100011 11100011 Note two things in the above
On Monte Carlo events, typical compress sizes are on the order of 2. Almost all this comes from compressing the leading zeros in the exponent-like piece. There are some tricks played to achieve performance. The main one is keeping track of the pattern of significant bits seen. By doing this one can avoid turning all the leading zeros into a bit array that will be binary tree encoded. Instead, a count is made of these leading zeros, using this pattern array to skip entire rows. For example, in the above, the pattern array would be 00111111, indicating that except for rows 6 and 7 never have the first significant bit. A representation of these leading zeros is trivial to compose without going to the usual expense of the Binary Tree Algorithm. As a final trick, one notices there is no reason to encode the values in order. It is in fact, advantageous to order the rows from the sparest to the densest. This improves the compression of the exponent-like piece (at the expense of picking out the appropriate bits in the manitissa and reassembling them later. But wait, there is more, one does not need to encode the final row. Because one already ones, apriori, how many TOTs there are, so, at the final row, one knows exactly which ones are left.
|
|
Picks the optimal encoding method for all towers.
For the layer map, bit position 0, i.e. the MSb, contains X0, bit position 1 contains Y0. |
|
Does a binary-like tree encode of an 18-bit number.
|