GLAST/LAT > DAQ and FSW > FSW > Doxygen Index > EDS / V2-10-0
Constituent: eds     Tag: mv2304
#include "EDS/EDR_tkrUnpack.h"
#include "EDS/EDR_tkr.h"
#include "EDS/EBF_tkr.h"
#include "EDS/EBF_dir.h"
#include "EDS/EBF_ctb.h"
#include "EDS/EDS_endianness.h"
#include "EDS/FFS.h"
#include <string.h>
Classes | |
struct | _TKR_2strips_bf |
Maps out the first word containing strip addresses. More... | |
struct | _TKR_8strips0_bf |
Maps out the first word of the 3 strip address pattern words as bit fields. More... | |
struct | _TKR_8strips1_bf |
Maps out the second word of the 3 strip address pattern words as bit fields. More... | |
struct | _TKR_8strips2_bf |
Maps out the third word of the 3 strip address pattern words as bit fields. More... | |
struct | _TKR_2strips |
Maps out the first word containing strip addresses. More... | |
union | _TKR_8strips0 |
Maps out the first word of the 3 strip address pattern words as bit fields and uninterpretted 32-bit integer. More... | |
union | _TKR_8strips1 |
Maps out the second word of the 3 strip address pattern words as bit fields and uninterpretted 32-bit integer. More... | |
union | _TKR_8strips2 |
Maps out the third word of the 3 strip address pattern words as bit fields and uninterpretted 32-bit integer. More... | |
Defines | |
#define | CONTIGIOUS 1 |
Determines the minimum strip separation for hit strips to be considered contigious. | |
#define | USE_GAPS 1 |
Determines whether the code translates the strip addresses by the ladder gaps. | |
#define | BYTE_ACCESS(_ba, _idx) _ba[_idx]; |
Addresses the TOT oriented byte array in a way that is compatiable with big or little endian machines. | |
#define | TKR__stripToOffset(_s, _x) (_x[((_s) >> 7) & 0xf]) |
Finds the ladder offset associated with the strip in units of a strip width. | |
#define | INIT_LAYERS(_lyrs, _accepts, _mlayers, _map, _layers, _hiLo, _cnt) |
Process the layer bit masks associated with the either X or Y layers. | |
#define | S2(_d0, _d1) ((_d0.bf.s2a << 4) | _d1.bf.s2b) |
Assembles the 2nd strip address from its two pieces. | |
#define | S5(_d1, _d2) ((_d1.bf.s5a << 8) | _d2.bf.s5b) |
Assembles the 5th strip address from its two pieces. | |
#define | NPROCESS(_strip, _beg, _o, _prv, _cur,_lcnt, _layer, _lyrs, _b, _bits) |
Macro to process a strip address when starting a new cluster. | |
#define | CPROCESS(_strip, _beg, _o, _prv, _cur,_lcnt, _layer, _lyrs, _b, _bits) |
Macro to process a strip address when a cluster is being built. | |
#define | PROCESS(_cb, _nb,_strip, _beg, _o, _prv, _cur, _lcnt, _layer, _layers,_bits) |
A convenience macro to drop down a process cluster in progress and a new cluster macro. | |
#define | GAP(_n) ((int)((_n) * ((.974 + .2 + .974) / .228) + 0.5)) |
Calculates the cumulative length due to the gaps between the ladders. | |
Typedefs | |
typedef struct _TKR_2strips_bf | TKR_2strips_bf |
Typedef for struct _TKR_2strips_bf. | |
typedef struct _TKR_8strips0_bf | TKR_8strips0_bf |
Typedef for struct _TKR_8strips0_bf. | |
typedef struct _TKR_8strips1_bf | TKR_8strips1_bf |
Typedef for struct _TKR_8strips1_bf. | |
typedef struct _TKR_8strips2_bf | TKR_8strips2_bf |
Typedef for struct _TKR_8strips2_bf. | |
typedef union _TKR_2strips | TKR_2strips |
Typedef for struct _TKR_2strips_bf. | |
typedef union _TKR_8strips0 | TKR_8strips0 |
Typedef for union _TKR_8strips0. | |
typedef union _TKR_8strips1 | TKR_8strips1 |
Typedef for union _TKR_8strips1. | |
typedef union _TKR_8strips2 | TKR_8strips2 |
Typedef for union _TKR_8strips2. | |
Functions | |
static int | init (EDR_tkrTower *ttr, unsigned int loHiLayerMaps[4], EDR_tkrLayer *layersBuf[72], unsigned int a0, unsigned int a1, unsigned int a2) |
Initializes/extracts the layer information from the accept masks. | |
static __inline void | setSplits (EDR_tkrTower *ttr, const unsigned int *maps) |
Sets the split points. | |
static void | unpackTotsFromAccepts (EDR_tkrTower *ttr, const EBF_tkr *tkr, const unsigned char *map) |
Unpacks the TOTs. | |
int | unpackStrips (EDR_tkrTower *ttr, const EBF_tkr *tkr, int maxwrds) |
Unpacks the data from one tower. | |
int | EDR_tkrUnpack (EDR_tkr *tlr, const EBF_dir *dir, unsigned int stripsTots) |
Driver routine to unpack the specified TKR towers. | |
int | EDR_tkrUnpackInit (EDR_tkr *tlr) |
Performs one time initialization of a Track LAT record. | |
void | EDR_tkrUnpackReset (EDR_tkr *tlr) |
Resets the tlr record, preparing it to receive another unpacked event. | |
int | EDR_tkrUnpackSizeof (void) |
Returns the size, in bytes, of a EDR_tkr. | |
Variables | |
static const unsigned char | Map [18] |
The mapping of the entries in the layer accept list to the physical layer numbers. |
CVS $Id: EDR_tkrUnpack.c,v 1.7 2009/04/29 17:40:31 russell Exp $
#define BYTE_ACCESS | ( | _ba, | |||
_idx | ) | _ba[_idx]; |
Addresses the TOT oriented byte array in a way that is compatiable with big or little endian machines.
_ba | the byte array to access | |
_idx | The value to be transformed |
#define CONTIGIOUS 1 |
Determines the minimum strip separation for hit strips to be considered contigious.
This variable determines when 2 strip addresses are contigious There is really only 1 right answer (1), but by setting this value to anything less than 1, no clusters will be formed, allowing debugging of this code.
#define CPROCESS | ( | _strip, | |||
_beg, | |||||
_o, | |||||
_prv, | |||||
_cur, | |||||
_lcnt, | |||||
_layer, | |||||
_lyrs, | |||||
_b, | |||||
_bits | ) |
Macro to process a strip address when a cluster is being built.
_strip | The strip address to process | |
_beg | Beginning strip address of the cluster. | |
_o | The offset associated with _beg | |
_prv | Ending strip address of the cluster, i.e. the previous strip address. | |
_cur | Current address to store the strip address. | |
_lcnt | Number of layers left to process. | |
_layer | The current EDR_tkrTower layer address | |
_lyrs | A stack of the EDR_tkrTower layer addresses. | |
_b | The number into this batch of 8 strips | |
_bits | Returned as the bits consumed in this batch (12 * _b) |
A check is made to see if the new strip address to be stored is contiguous the current cluster. If so the ending address of the cluster is updated.
If the current cluster is not contiguous, there are two possible reasons. The first is the obvious, they two strip addresses are not contiguous. The second is that the new strip address is actually at the end of a layer. If this is so. the check for being contiguous is remade after stripping the layer end bit. If not, the old cluster centroid is stored and a new one begun.
If a cluster is in the process of being built, the flow of the code is directed to the statement label specified by _Po. If no cluster is currently being built, the flow of the code is directed to the statement label specified by _No.
#define GAP | ( | _n | ) | ((int)((_n) * ((.974 + .2 + .974) / .228) + 0.5)) |
Calculates the cumulative length due to the gaps between the ladders.
_n | The ladder number (0-3) |
#define INIT_LAYERS | ( | _lyrs, | |||
_accepts, | |||||
_mlayers, | |||||
_map, | |||||
_layers, | |||||
_hiLo, | |||||
_cnt | ) |
Process the layer bit masks associated with the either X or Y layers.
_lyrs | An array which receives the address of the layer structure for each of the struck layers. | |
_accepts | The 18 bits representing on end of the layers | |
_mlayers | Bit mask of the struck y layers in layer order, as opposed to readin order of the _accepts. | |
_map | A an array mapping readin bit position order to the canonical layer order. | |
_layers | The array layer structures. | |
_hiLo | 0 is doing the low end, 1 is doing the high end | |
_cnt | Current number of active layers |
#define NPROCESS | ( | _strip, | |||
_beg, | |||||
_o, | |||||
_prv, | |||||
_cur, | |||||
_lcnt, | |||||
_layer, | |||||
_lyrs, | |||||
_b, | |||||
_bits | ) |
Macro to process a strip address when starting a new cluster.
_strip | The strip address to process | |
_beg | Set to the new strip address if this is not the last strip on the layer. | |
_o | Returned as the offset associated with _beg | |
_prv | Set to the new strip address if this is not the last strip on the layer. | |
_cur | Current address to store the strip address. | |
_lcnt | Number of layers left to process. | |
_layer | The current EDR tkrTower layer address | |
_lyrs | A stack of the EDR_tkrtower layer addresses. | |
_b | The number into this batch of 8 strips | |
_bits | Returned as the bits consumed in this batch (12 * _b) |
If this is the last strip on a layer, the strip address is stored along with the ending address of this layer. If there are more layers to process, the address to store the new strip addresses is retrieved and the cluster status is set to no cluster in progress by setting the beginning cluster strip address to -1.
If there are no more layers to process the action indicated by _action is taken. This is generally a break or goto statement.
#define PROCESS | ( | _cb, | |||
_nb, | |||||
_strip, | |||||
_beg, | |||||
_o, | |||||
_prv, | |||||
_cur, | |||||
_lcnt, | |||||
_layer, | |||||
_layers, | |||||
_bits | ) |
Value:
\ _N ## _cb: \ NPROCESS(_strip,_beg,_o, _prv, _cur, _lcnt, _layer, _layers, _nb, _bits); \ _P ## _cb: \ CPROCESS(_strip,_beg,_o, _prv, _cur, _lcnt, _layer, _layers, _nb, _bits);
_cb | Current number of strips processed in this batch of 8 | |
_nb | Next number of strips processed in this batch of 8 | |
_strip | The strip address to process | |
_beg | Beginning strip address of the cluster. | |
_o | Returned as the offset associated with _beg | |
_prv | Ending strip address of the cluster, i.e. the previous strip address. | |
_cur | Current address to store the strip address. | |
_lcnt | Number of layers left to process. | |
_layer | The current EDR_tkrTower layer address | |
_layers | A stack of the EDR_tkrTower layer addresses. | |
_bits | Returned as the number of bits processed in this batch of 8, always 12*_nxt |
#define S2 | ( | _d0, | |||
_d1 | ) | ((_d0.bf.s2a << 4) | _d1.bf.s2b) |
Assembles the 2nd strip address from its two pieces.
_d0 | The 32 bit word holding the upper 8 bits of the strip address | |
_d1 | The 32 bit word holding the lower 4 bits of the strip address |
#define S5 | ( | _d1, | |||
_d2 | ) | ((_d1.bf.s5a << 8) | _d2.bf.s5b) |
Assembles the 5th strip address from its two pieces.
_d1 | The 32 bit word holding the upper 4 bits of the strip address | |
_d2 | The 32 bit word holding the lower 8 bits of the strip address |
#define TKR__stripToOffset | ( | _s, | |||
_x | ) | (_x[((_s) >> 7) & 0xf]) |
Finds the ladder offset associated with the strip in units of a strip width.
_s | The strip address | |
_x | An array of gaps to be applied to each 128 group of strips. |
The transformation is performed using an array (16) of displacements which correspond to each 128 strips. This is number was chosen because it was the largest binary power of 2 number, allowing one to do a shift rather than the more obvious, but much slower, divide by 384. The only burden on the caller is to provide an array of 16 numbers giving the offset for each group of 128 strips. Using a grouping of 128 means that the same offset will be repeated 3 times.
#define USE_GAPS 1 |
Determines whether the code translates the strip addresses by the ladder gaps.
This variable determines whether the code translates the strip addresses by the ladder gaps. It is used exclusively for debugging purposes. The default setting is 1, indicating that the gap correction is to be applied.
Typedef for struct _TKR_2strips_bf.
The first 32-bit word containing strip addresses also contains the last 8 bits of the accept list. This structure maps these fields out as both an uninterpreted 32 bit value and as bit fields for easy access.
Typedef for struct _TKR_2strips_bf.
The first 32-bit word containing strip addresses also contains the last 8 bits of the accept list. This structure maps these fields out for easy access.
Driver routine to unpack the specified TKR towers.
tlr | The TKR LAT record structure to receive the unpacked data | |
dir | The standard directory structure allowing the routine to traverse the LAT event record. | |
stripsTots | A 32-bit word composed of two 16-bit masks. The upper 16-bit mask represents towers to unpack the strip data, the lower towers to unpack the TOT data. In both cases the MSB of the mask = Tower 0. |
status = EDR_tkrUnpack (tlr, tkr, -1);
Will completely unpack both the strip data and the TOT data from all towers that have data. Also note that when examining the structure field member, twrMap, that it will always be a proper subset of those towers that have data.
int EDR_tkrUnpackInit | ( | EDR_tkr * | tlr | ) |
Performs one time initialization of a Track LAT record.
tlr | Pointer to the structure to initialize |
void EDR_tkrUnpackReset | ( | EDR_tkr * | tlr | ) |
Resets the tlr record, preparing it to receive another unpacked event.
tlr | Pointer to the structure to reset. |
EDR_tkrUnpackReset (tkr); EDR_tkrUnpack (tkr, dir, EDR__tkrUnpackTowerNum(1)); EDR_tkrUnpack (tkr, dir, EDR__tkrUnpackTowerNum(4)); EDR_tkrUnpack (tkr, dir, EDR__tkrUnpackTowerNum(8) | EDR__tkrUnpackTowerNum(9));
int EDR_tkrUnpackSizeof | ( | void | ) |
Returns the size, in bytes, of a EDR_tkr.
After allocating an EDR_tkr structure, the structure should be initialized using EDR_tkrUnpackInit().
int init | ( | EDR_tkrTower * | ttr, | |
unsigned int | loHiLayerMaps[4], | |||
EDR_tkrLayer * | layersBuf[72], | |||
unsigned int | a0, | |||
unsigned int | a1, | |||
unsigned int | a2 | |||
) | [static] |
Initializes/extracts the layer information from the accept masks.
ttr | The TKR tower record | |
loHiLayerMaps | Filled with the left-justified version of the xlo, xhi, ylo and yhi layer maps | |
layersBuf | Buffer to hold a pointer to a pointer to the next layer structure to receive the unpacked hits | |
a0 | The first of the 3 accept masks | |
a1 | The second of the 3 accept masks | |
a2 | The last of the 3 accept masks |
static __inline void setSplits | ( | EDR_tkrTower * | ttr, | |
const unsigned int * | maps | |||
) | [static] |
Sets the split points.
ttr | The target tower | |
maps | The map of left justified low and hi layer maps (xLo, xHi, yLo, yHi) |
int unpackStrips | ( | EDR_tkrTower * | ttr, | |
const EBF_tkr * | tkr, | |||
int | maxwrds | |||
) |
Unpacks the data from one tower.
ttr | Pointer to the data structure to receive the unpacked data | |
tkr | The tracker data as received from the hardware | |
maxwrds | The maximum number of words in tkr. |
void unpackTotsFromAccepts | ( | EDR_tkrTower * | ttr, | |
const EBF_tkr * | tkr, | |||
const unsigned char * | map | |||
) | [static] |
Unpacks the TOTs.
ttr | The target tower | |
tkr | The tracker data | |
map | The layer remapping function |
Map [static] |
Initial value:
{ 1, 3, 5, 7, 9, 11, 13, 15, 17, 0, 2, 4, 6, 8, 10, 12, 14, 16 }
The accept list is processed as 4 pairs of cables. The first cable of the pair carries the even layers, the second carries the odd layers. The 4 pairs represent the X lo, X hi and Y lo, Y hi cable pairs. In general one would need to map all 72 layer ends, but because all cable pairs are identical, so the same map can be used for each.
This mapping could have been easily handled in the INIT_LAYERS macro, but the cost would have been some additional arthimetic. The current set bit would have to be translated into a layer number by doubling it and adding 1 iff the current bit was greater than 8. The lookup method seems simpler and faster.