GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> QSEC / V3-3-1 > qsec_wb / linux-gcc


Interface   Data Structures   File List   Data Fields   Globals  

decode.c File Reference

Routines to decode the event data. More...

#include "expand_p.h"
#include "decode.h"
#include "decompress.h"
#include "raw.h"
#include "QSEC_ctx_p.h"
#include "EDS/EBF_ctb.h"
#include "EDS/EBF_gem.h"
#include "EDS/EBF_tem.h"
#include "EDS/EBF_cal.h"
#include "EDS/EBF_tkr.h"
#include "QSE/QSE_ebf.h"
#include "QSE/QSE_aemRepack.h"
#include "QSE/QSE_aem.h"
#include "PBI/Endianness.h"
#include "LCBD/LATP.h"
#include <string.h>

Classes

struct  QSEC_acdRaw
 Private structure holding raw data for an ACD contribution. More...
struct  QSEC_calRaw
 Private structure holding "raw" data for a CAL event. More...

Defines

#define N_INT_BITS   32

Functions

static __inline void fixCtbHdr (EBF_ctbHdr *hdr)
 When the ACD is not included in the output stream (as it is now), the final TEM contribution (if present) must have its response bit removed.
static __inline void genCtbHdr (int twr, unsigned int dMap, const EBF_ctbHdr *gHdr, EBF_ctbHdr *tHdr)
 Generate a TEM contribution header from the GEM header.
static __inline void * roundUpPtr (void *ptr, int r)
 Round the specified pointer up to a specified binary boundary.
static __inline unsigned int roundUpInt (unsigned int ui, int r)
 Round the specified integer up to a binary boundary.
static __inline unsigned short * decodeShorts (unsigned short *us, int cnt, QSEC_decompression *dcmp, APD_dtx *dtx)
 Decode the required number of symbols from the compressed stream and stores them as shorts.
static __inline unsigned int getWord (int leng, const unsigned int **bufp, int *boff)
 Get an arbitrary length word from an integer buffer.
static __inline void setWord (int leng, unsigned int value, unsigned int **bufp, int *boff)
 Set an arbitrary length word into an integer buffer.
static __inline unsigned int getBit (int index, const unsigned int *buff)
 Get a bit from an integer buffer.
static __inline unsigned int getNib (int index, const unsigned int *buff)
 Get a nibble from an integer buffer.
static unsigned int * copyContrib (const unsigned char **ctb, unsigned int *evt)
static unsigned int * decodeAcd (QSEC_expansion *exp, const EBF_ctbHdr *aHdr, const QSEC_acdRaw *raw, unsigned int *evt)
static unsigned int * decodeCal (QSEC_expansion *exp, const EBF_ctbHdr *gHdr, const unsigned char *ibuf, unsigned int *evt)
static unsigned int * decodeCalV3 (QSEC_expansion *exp, const EBF_ctbHdr *tHdr, const QSEC_calRaw *raw, unsigned int *evt)
static unsigned int * decodeCalV2 (QSEC_expansion *exp, const EBF_ctbHdr *tHdr, unsigned int *evt)
static unsigned int * decodeCalV1 (QSEC_expansion *exp, const EBF_ctbHdr *tHdr, unsigned int *evt)
static unsigned int * decodeGem (QSEC_expansion *exp, const EBF_ctbHdr *gHdr, unsigned int *evt)
static unsigned int * decodeTkr (QSEC_expansion *exp, const EBF_ctbHdr *gHdr, const unsigned char *ibuf, unsigned int *evt)
static unsigned int * decodeTkrV1 (QSEC_expansion *exp, const EBF_ctbHdr *tHdr, unsigned int *evt)
static unsigned int * decodeTkrTots (unsigned char *tot, int ntots, QSEC_decompression *tots, APD_dtx *dtx)
static void expandGem (QSEC_expansion *exp, EBF_gem *gem)
void QSEC_update (QSEC_expansion *exp, EBF_gem *gem, unsigned int *seq, const unsigned int *ievt)
 Decode the GEM contribution and extract the 17 bit event sequence.
unsigned int QSEC_decode (QSEC_expansion *exp, QSE_ebfEvt *oevt, const unsigned int *ievt)
 Decode the event held in the expansion structure into the QSE_evt structure.


Detailed Description

Routines to decode the event data.

Author:
James Swain & Owen Saxton
Id
decode.c,v 1.28 2010/08/23 17:43:39 saxton Exp

Function Documentation

static __inline unsigned short* decodeShorts ( unsigned short *  us,
int  cnt,
QSEC_decompression dcmp,
APD_dtx *  dtx 
) [static]

Decode the required number of symbols from the compressed stream and stores them as shorts.

Parameters:
us The pointer to the unsigned short storeage array
cnt The number of symbols to decode and store as short integer
dcmp The decompression context
dtx The compressed bit stream
Returns:
The pointer to the next storage location

References QSEC_decompress().

static __inline void fixCtbHdr ( EBF_ctbHdr *  hdr  )  [static]

When the ACD is not included in the output stream (as it is now), the final TEM contribution (if present) must have its response bit removed.

Parameters:
hdr The contribution header to patch

static __inline void genCtbHdr ( int  twr,
unsigned int  dMap,
const EBF_ctbHdr *  gHdr,
EBF_ctbHdr *  tHdr 
) [static]

Generate a TEM contribution header from the GEM header.

Parameters:
twr The tower (TEM) number.
dMap The map of TEMs with diagnostics, TEM 0 = MSB.
gHdr The address of the GEM header.
tHdr The address of the TEM contribution header to generate.

static __inline unsigned int getBit ( int  index,
const unsigned int *  buff 
) [static]

Get a bit from an integer buffer.

The bits are numbered from low to high order within each integer.

Parameters:
index The index of the bit to be obtained.
buff Address of the integer buffer.
Returns:
The value of the specified bit.

static __inline unsigned int getNib ( int  index,
const unsigned int *  buff 
) [static]

Get a nibble from an integer buffer.

The bits are numbered from low to high order within each integer.

Parameters:
index The index of the nibble to be obtained.
buff Address of the integer buffer.
Returns:
The value of the specified nibble.

static __inline unsigned int getWord ( int  leng,
const unsigned int **  bufp,
int *  boff 
) [static]

Get an arbitrary length word from an integer buffer.

Parameters:
leng The length, in bits, of the word to get.
bufp Pointer to a pointer to the current location in the buffer. The latter is updated whenever the requested word reaches or crosses an integer boundary.
boff Pointer to the bit offset, from high order to low within the current (32-bit) integer in the buffer. The offset is updated to just beyond the fetched word.
Returns:
The value obtained from the buffer.

unsigned int QSEC_decode ( QSEC_expansion exp,
QSE_ebfEvt *  oevt,
const unsigned int *  ievt 
)

Decode the event held in the expansion structure into the QSE_evt structure.

Parameters:
exp Pointer to the expansion structure holding the histograms and encoder context
oevt Pointer to the location to output the decoded event
ievt Pointer to the location to input the encoded event
Returns:
Length, in bytes, of the event data

References QSEC_summary::aem, QSEC_expansion_::dtx, QSEC_summary::gem, QSEC_expansion_::gem, QSEC_expansion_::mode, QSEC_CURRENT_VERSION, QSEC_unpackRaw(), QSEC_VERS_FIXED_CAL, QSEC_VERS_NEW_SCHEME, QSEC_VERS_NEWER, QSEC_gemDecompress::raw, QSEC_summary::tem, and QSEC_expansion_::ver.

Referenced by QSEC_expand().

void QSEC_update ( QSEC_expansion exp,
EBF_gem *  gem,
unsigned int *  seq,
const unsigned int *  ievt 
)

Decode the GEM contribution and extract the 17 bit event sequence.

Parameters:
exp Pointer to the expansion structure holding the histograms and encoder context
gem Pointer to the location to place the decoded GEM contribution
seq Pointer to the location to place the 17-bit event sequence number
ievt Pointer to the location to input the encoded event number for use in QSE_ctxUpdateAtEvent

References QSEC_expansion_::dtx, QSEC_expansion_::gem, QSEC_expansion_::mode, QSEC_unpackRaw(), QSEC_VERS_FIXED_CAL, QSEC_VERS_ORIGINAL, QSEC_gemDecompress::raw, and QSEC_expansion_::ver.

Referenced by QSEC_updateAtRecord().

static __inline unsigned int roundUpInt ( unsigned int  ui,
int  r 
) [static]

Round the specified integer up to a binary boundary.

Parameters:
ui The integer to round
r The boundary to round to. This must be a power of 2, i.e. 1, 2, 4, 8 etc
Returns:
The rounded integer

static __inline void* roundUpPtr ( void *  ptr,
int  r 
) [static]

Round the specified pointer up to a specified binary boundary.

Parameters:
ptr The pointer to round
r The boundary to round to. This must be a power of 2, i.e. 1, 2, 4, 8 etc
Returns:
The rounded pointer

static __inline void setWord ( int  leng,
unsigned int  value,
unsigned int **  bufp,
int *  boff 
) [static]

Set an arbitrary length word into an integer buffer.

Parameters:
leng The length, in bits, of the word to set.
value The value of the word to set.
bufp Pointer to a pointer to the current location in the buffer. The latter is updated whenever the set word reaches or crosses an integer boundary.
boff Pointer to the bit offset, from high order to low within the current (32-bit) integer in the buffer. The offset is updated to just beyond the set word.


Generated on Thu Jan 27 12:57:36 2011 by  doxygen 1.5.8