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


Interface   Data Structures   File List   Data Fields   Globals  

CDF_acd_ped.c File Reference

Implementation to produce Packed/Compressed Data Format for the ACD/AEM contributor when zero suppression is disabled. More...

#include <LSE/CDF_acd_ped.h>
#include <CDF_acd_def.h>
#include <EDS/ACD_rec.h>
#include <EDS/ECR_acd.h>
#include <EDS/EBF_dir.h>
#include <EDS/EBF_ctb.h>
#include <EDS/EBF_cid.h>
#include <EDS/ACD_unpack.h>
#include <LDT/BFP.h>
#include <LDT/HDE.h>
#include <LDT/BIT.h>
#include <EDS/TMR.h>
#include <PBI/FFS.ih>
#include <dprintf.h>
#include <string.h>

Functions

static __inline unsigned int acd_ped_pack (CDF_acd *cdf, unsigned int *buf, unsigned int pos, const ACD_rec *acd)
 Compresses the ACD data when zero suppression has been disabled.
static __inline unsigned int acd_ped_unpack (CDF_acd_ped_data *evt, const ACD_rec *acd, const ECR_acdPedestals *peds)
 Unpacks ACD_unpack style data to CDF_acd_data style. This is easier to pack.
static __inline unsigned int acd_ped_prepare (CDF_acd_ped_data *evt, const ACD_rec *acd, const ECR_acdPedestals *peds)
 Prepares the ACD for compression. This involves
  • evaluating exceptions (data parity errors, range 1 bit, etc
  • histogramming the pedestal subtracted values
  • finding the 'core' of the histogram.

static unsigned int acd_ped_pack_cables (unsigned int *buf, unsigned int pos, unsigned int cables)
 Packs the any cable masks (missing or timed out).
static __inline unsigned int acd_ped_pack_chnx (unsigned int *buf, unsigned int pos, unsigned int status, const unsigned int *lists)
 Packs cable oriented chnanel exception bit lists as address arrays.
static __inline unsigned int acd_ped_pack_phax (unsigned int *buf, int pos, unsigned int status, const CDF_acd_ped_chn *phaxs, int nphaxs)
 Packs the address and value of any channels with have a PHA value with the parity error or range 1 bit set.
static __inline unsigned int acd_ped_pack_phas (unsigned int *buf, unsigned int pos, HDE *hde, CDF_acd_ped_data *acd)
 Packs the ACD data that falls with the limits of the specified Huffman table.
static __inline unsigned int pack_short (unsigned int *buf, unsigned int pos, short int val)
 Packs the number of bits needed to contain the short integer and its value.
static unsigned int acd_ped_copy (CDF_acd *cdf, unsigned int *buf, unsigned int pos, unsigned int status, const unsigned int *dat, unsigned int nbytes)
 Copies the ACD data when zero suppression has been disabled. This is generally used if and only if the ACD has something seriously wrong with it.
unsigned int CDF_acd_ped_compress (CDF_acd *cdf, unsigned int *buf, unsigned int pos, const EBF_dir *dir)
 Compresses the ACD data when zero suppression has been disabled.


Detailed Description

Implementation to produce Packed/Compressed Data Format for the ACD/AEM contributor when zero suppression is disabled.

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

The format of the compressed ACD pedestal data picks on the following statistical facts

  1. All channels are present with PHA values
  2. There are no data parity errors
  3. The data is from range 0.
  4. The accept discriminator bit is 0
  5. The pedestal subtracted data is biased towards small values

In order to accomodate future improvements to the format, a 2 bit format field introduces the data. The following describes format 0.

ACD Pedestal Data, Format 0
If there are serious decode errors, an 12-bit status mask is placed in data stream, followed by the ACD data which is copied asis to the next 32-bit boundary in the output data stream. The errors are
Fatal Decode Errors
BitDescription
0Decoding overran that available data
1Decoding underan that available data
2Parity error on a cable
3Illegal Cable Number Encountered
4Out of order cable number
5Duplicate Cable Number Encountered
6Cable timeout
7Cable overrun, too much stuff on a cable
8PHA overrun, too few PHA values on a cable
9PHA underrun, too many PHA values on a cable
10Reserved
11Reserved
ACD Pedestal Data, Format 1
To exploit the about characteristics and cover the possible allowed deviations and error scenerios the data layed out in the following major blocks
ACD Pedestal Data Format
Block Presence Description

Header Always Fixed length header describing overall format

Missing Cable List Conditional; Primary Exceptions Present 1-bit exception present flag, followed by, if true a 12-bit mask indicating which cables are missing data

Timeout Cable List Conditional; Primary Exceptions Present 1-bit exception present flag, followed by, if true a 12-bit mask indicating which cables have timeouts

Header Parity Error List Conditional; Primary Exceptions Present 1-bit exception present flag, followed by, if true a 12-bit mask indicating which cables have header parity errors

Channel Exception Lists Conditional, Primary Exceptions Present 1-bit exception present flag, followed by, if true, 8 lists of channel addresses for each of the bit in the possible 8 channel exception states

PHA Exception List Conditional, Primary Exceptions Present List of channels addresses plus values for those PHA value having either a data parity error or its range 1 bit set.

Secondary Exception List Present Conditional; Primary Exception Present List, Secondary Exception List Present This bit provides an escape if more exception fields are needed

PHA, Non-Standard List AlwaysList of channel address for those PHA values that have either their data parity error bit set, their range 1 bit set, or whosepedestal subtracted PHA value falls are outside the encoding table bounds.

PHA Out-of-Range List Always The encoding tables cover only a limited range of the possible pedestal subtracted values. This has a fixed table of contents field, describing the smallest and largest entries, followed by a list of addresses and there associated entries. The address field is 1-stop bit + 8-bit address. This is followed by the pedestal subtract index.

PHA Huffman Encode List Always One Huffman code for each channel not list in the invalid PHA list
Fixed Header
ACD Pedestal Data Format
BitWidthMeaning
02Format Number
31Primary Exceptions Present
Format Number
Since this is format 1, this value must be 1
Primary Exceptions Present Flag
If 0, then no exceptions are present. If non-zero, then the four primary exceptions follow. Each of the primary exceptions is encoded such that it is possible that that particular exception is absent. The five primary exceptions are
Primary Exceptions
ExceptionWidthDescription
01Missing Cable List
11Timeout Cable List
21Header Parity Error List
21Channel Exception List
31PHA exception list
41Secondary Exception List
Missing Cable List
This is a 12 bit mask representing the missing cables. The most significant bit represents cable 0.
Timeout Cable List
This is a 12 bit mask representing the timed out cables. The most significant bit represents cable 0.
Channel Exception Lists
Eight list of 1-stop bit + 8-bit channel addresses. Each list corresponds to on of the 8 possible states that the 3 status bits associated with each channel may assume. That is, if any channel has a particular combination of the 3 status bits set, the corresponding bit in this mask is set. The 3 status bits are
Channel Status Bits
Status Bit NumberDescription
0Accept bit is not 0
1PHA Accept bit is 0
2PHA Valid bit is 0
For example, list 0 means that one or more more channels that have only Status Bit 0, the Accept bit is not 0 and list 5 means that one or more channels has only bits 0 and bits 2 set.

/par PHA, Exceptions List This is an fixed header followed by a 1 stop bit + 8 channel bit address + a value field. The fixed header describes the contents of the value field which is composed of (optionally)

The table of contents is

PHA Exceptions List, Table of Contents
BitWidthMeaning
01Range Bit Present
14Number of bits in PHA field
51Data Parity Error Bit Present

For example, if the are no channels with data parity errors, but one channel with a range 1 bit set and the maximum range of the PHA index of 0x21, then this value will be

          Range Present      = 1
          Number of Bits     = 6
          Data Parity Error  = 0
       -> Table of contents  = 1 0110 0 = 0x4c
     

PHA Out-of-Range List
This list describes ADC values which are perfectly normal except that they fall outside the range of the encoding table. The typical address list is followed by a value describing the pedestal subtract ADC. The format of the table of contents is
PHA, Out-of-Range List Table Of Contents
Bit
0-3Number of bits needed to hold the minimum ADC index
4-7Number of bits needed to hold the maximum ADC index

The encode ADC index takes the number of bits needed to encode the range from min to max.

PHA, Encoded Values
This is an Huffman encoded representation of the ADCs for those channels that do not appear in the either invalid list or the PHA Exceptions List. The Huffman table is described referenced by some other means, typically appearing in the datagram's private context.

Function Documentation

static unsigned int acd_ped_copy ( CDF_acd cdf,
unsigned int *  buf,
unsigned int  pos,
unsigned int  status,
const unsigned int *  dat,
unsigned int  nbytes 
) [static]

Copies the ACD data when zero suppression has been disabled. This is generally used if and only if the ACD has something seriously wrong with it.

Returns:
The updated bit write position
Parameters:
cdf The ACD's Compressed Data Format context
buf The output buffer
pos The current bit offset into the output buffer buf
status The ACD_unpack status
dat The raw ACD data
nbytes The size, in bytes, of the ACD data

Referenced by CDF_acd_ped_compress().

static __inline unsigned int acd_ped_pack ( CDF_acd cdf,
unsigned int *  buf,
unsigned int  pos,
const ACD_rec *  acd 
) [static]

Compresses the ACD data when zero suppression has been disabled.

Returns:
The updated bit write position
Parameters:
cdf The ACD's Compressed Data Format context
buf The output buffer
pos The current bit offset into the output buffer buf
acd The unpacked ACD contribution

References acd_ped_pack_cables(), acd_ped_pack_chnx(), acd_ped_pack_phas(), acd_ped_pack_phax(), acd_ped_unpack(), _CDF_acd::calib, CDF_ACD_PED_DATA_STATUS_M_CBLX, CDF_ACD_PED_DATA_STATUS_M_CHNX, CDF_ACD_PED_DATA_STATUS_M_PHA, CDF_ACD_PED_DATA_STATUS_M_PHAX, _CDF_acd_ped_lists::chnx, _CDF_acd::evt, _CDF_acd::hde, _CDF_acd_ped_data::hdr_parity, _CDF_acd_ped_data::lists, _CDF_acd_ped_data::missing, _CDF_acd_ped_data::nphaxs, _CDF_acd_ped_data::phaxs, and _CDF_acd_ped_data::timeout.

Referenced by CDF_acd_ped_compress().

static unsigned int acd_ped_pack_cables ( unsigned int *  buf,
unsigned int  pos,
unsigned int  cables 
) [static]

Packs the any cable masks (missing or timed out).

Returns:
The updated bit write position
Parameters:
buf The output buffer
pos The current bit offset into the output buffer buf
cables The right justified 12-bit mask of missing cables

Referenced by acd_ped_pack().

static __inline unsigned int acd_ped_pack_chnx ( unsigned int *  buf,
unsigned int  pos,
unsigned int  status,
const unsigned int *  lists 
) [static]

Packs cable oriented chnanel exception bit lists as address arrays.

Returns:
The updated bit write position
Parameters:
buf The output buffer
pos The current bit offset into the output buffer buf
status Left justified mask of which lists to pack
lists The arrary 8 x 12 cable lists to pack

References CDF_ACD_PED_DATA_STATUS_V_CHNX.

Referenced by acd_ped_pack().

static __inline unsigned int acd_ped_pack_phas ( unsigned int *  buf,
unsigned int  pos,
HDE *  hde,
CDF_acd_ped_data evt 
) [static]

Packs the ACD data that falls with the limits of the specified Huffman table.

Returns:
The updated bit write position
Parameters:
buf The output buffer
pos The current bit offset into the output buffer buf
hde The Huffman Distribution Encoding handle
evt The ACD evemt data to encode

References _CDF_acd_ped_data::dadcs, _CDF_acd_ped_data::hist, and _CDF_acd_ped_data::ndadcs.

Referenced by acd_ped_pack().

static __inline unsigned int acd_ped_pack_phax ( unsigned int *  buf,
int  pos,
unsigned int  status,
const CDF_acd_ped_chn *  phaxs,
int  nphaxs 
) [static]

Packs the address and value of any channels with have a PHA value with the parity error or range 1 bit set.

Returns:
The updated bit write position
Parameters:
buf The output buffer
pos The current bit offset into the output buffer buf
status The status from acd_ped_unpack. This is used to determine the number of bits to devote the PHA value and whether the packed value include the RNG 1 bit and/or the DATA PARITY BIT
phaxs The list of channel exceptions (high 16 bits = address, low 16 bits the PHAVEC)
nphaxs The count of such exceptions (must be non-zero)
This packed data structure begins with a fixed 6-bit table of contents

Bit 5 - Rng 1 bit present flag Bits 1-4 - Size of the ADC value Bit 0 - Data Parity Error present flag

For each entry, the following value is packed

[ADR] - 8 bits [RNG] - 1 bit, present iff flag bit indicates as such [ADC] - 0-12 bits [PE] - 1 bit, present iff flag bit indicates as such [STOP] - 1 bit, if 1, no more values present

References CDF_ACD_PED_DATA_STATUS_M_PE, CDF_ACD_PED_DATA_STATUS_M_PHAX, CDF_ACD_PED_DATA_STATUS_M_RNG, and CDF_ACD_PED_DATA_STATUS_M_VAL.

Referenced by acd_ped_pack().

static unsigned int acd_ped_prepare ( CDF_acd_ped_data evt,
const ACD_rec *  acd,
const ECR_acdPedestals *  peds 
) [static]

Prepares the ACD for compression. This involves

  • evaluating exceptions (data parity errors, range 1 bit, etc
  • histogramming the pedestal subtracted values
  • finding the 'core' of the histogram.

Parameters:
evt The output event data
acd The previously unpacked input data
peds The AEM/ACD pedestals

References CDF_ACD_PED_DATA_STATUS_V_CHNX, CDF_ACD_PED_DATA_STATUS_V_PHA, _CDF_acd_ped_lists::chnx, _CDF_acd_ped_data::dadcs, _CDF_acd_ped_data::hist, _CDF_acd_ped_data::lists, _CDF_acd_ped_data::ndadcs, _CDF_acd_ped_data::nphaxs, and _CDF_acd_ped_data::phaxs.

Referenced by acd_ped_unpack().

static unsigned int acd_ped_unpack ( CDF_acd_ped_data evt,
const ACD_rec *  acd,
const ECR_acdPedestals *  peds 
) [static]

Unpacks ACD_unpack style data to CDF_acd_data style. This is easier to pack.

Parameters:
evt The output event data
acd The previously unpacked input data
peds The AEM/ACD pedestals

References acd_ped_prepare(), CDF_ACD_PED_DATA_STATUS_M_CBLX, _CDF_acd_ped_lists::chnx, _CDF_acd_ped_data::hdr_parity, _CDF_acd_ped_data::lists, _CDF_acd_ped_data::missing, and _CDF_acd_ped_data::timeout.

Referenced by acd_ped_pack().

unsigned int CDF_acd_ped_compress ( CDF_acd cdf,
unsigned int *  buf,
unsigned int  pos,
const EBF_dir *  dir 
)

Compresses the ACD data when zero suppression has been disabled.

Returns:
The updated bit write position
Parameters:
cdf The ACD's Compressed Data Format context
buf The output buffer
pos The current bit offset into the output buffer buf
dir The event directory.

References acd_ped_copy(), acd_ped_pack(), and _CDF_acd::aem.

static __inline unsigned int pack_short ( unsigned int *  buf,
unsigned int  pos,
short int  val 
) [static]

Packs the number of bits needed to contain the short integer and its value.

Returns:
The update bit write position
Parameters:
buf The output buffer
pos The position of the next bit to fill
val The value to pack


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