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


Interface   Data Structures   File List   Data Fields   Globals  

CDF_cal_ped.c File Reference

The CAL pedestal event processing and compaction routines. More...

#include <LSE/CDF_cal.h>
#include <LSE/CDF_cal_ped.h>
#include <CDF_cal_def.h>
#include <dprintf.h>
#include <EDS/EBF_dir.h>
#include <EDS/EBF_cid.h>
#include <EDS/EBF_cal.h>
#include <EDS/ECR_cal.h>
#include <LDT/BFP.h>
#include <LDT/APE.h>
#include <LDT/HUFF.h>
#include <LDT/HDE.h>
#include <PBI/FFS.ih>
#include <stdio.h>

Classes

struct  _HistLimits
 Min and Max indices of a histogram. More...

Defines

#define RNGS_COMPOSE(_beg)
 Composes an array of 2 bit range values in the order specified. For example, specifying RNG_COMPOSE(0) means that one expects the four range readout to occur in the order range 0,1,2,3, while specifying RNG_COMPOSE(1) results in an expected order of range 1,2,3,0. This is used to predict the range when processing the layer pairs in the four range readout order.
#define LYR_OFFSETS(_lyr, _rng)
 Computes the offsets to the specified layer and range when all the logs in a tower are struck.
#define RNG_OFFSETS(_rng)
 Creates a comma separated list of the offsets to the 8 layers for the specified range when all the logs in a tower are struck.

Typedefs

typedef struct _HistLimits HistLimits
 Typedef for struct _HistLimits.

Functions

static __inline unsigned int cal_ped1_evaluate (const EBF_dir *dir, int *rngP)
 Evaluates the CAL data to see if it is in a form that the compression routines understand.
static __inline unsigned int cal_ped1_evaluate_layer (const EBF_calLogData *logs, int cnt, int twr, int lyr, int rng)
 Checks that the column numbers are as expected and that all the ranges are 0.
static __inline int cal_ped1_process (short int *cidx, unsigned short int *hist, const EBF_dir *dir, const ECR_cal *clb)
 Creates the histograms and the array of pedestal subtracted indices used to compress the CAL portion of the event that is specific to single-range readout.
static __inline const unsigned
int * 
cal_ped1_process_layer (short int *cidx, unsigned short int *hist, const ECR_calLayer *clyr, const unsigned int *logs, int cnt, int twr, int lyr)
 Accumulates the histograms used in compressing the CAL data for one layer.
static __inline unsigned int cal_ped1_compress (CDF_cal *cdf, unsigned int *buf, unsigned int pos, const EBF_dir *dir, const ECR_cal *clb)
 Makes a compressed copy of the CAL data when it is single range, non-zero suppressed.
static __inline unsigned int cal_ped4_evaluate (const EBF_dir *dir, int *rngP)
 Evaluates the 4-range CAL data to see if it is in a form that the compression routines understand.
static __inline unsigned int cal_ped4_evaluate_layer (const EBF_calLogData *logs, int cnt, int twr, int lyr, int rng)
 Checks 4-range CAL data for
  • column numbers are as expected
  • all the ranges are in the same order.

static __inline unsigned int cal_ped4_compress (CDF_cal *cdf, unsigned int *buf, unsigned int pos, const EBF_dir *dir, const ECR_cal *clb)
 Makes a compressed copy of the CAL data when it is four-range, non-zero suppressed.
static __inline int cal_ped4_process (short int *cidx, unsigned short int *hist, const EBF_dir *dir, const ECR_cal *clb, int rng)
 Creates the histograms and the array of pedestal subtracted indices used to compress the CAL portion of the event that is specific to single-range readout.
static __inline unsigned int cdf_cal_ped_copy (CDF_cal *cdf, unsigned int *buf, unsigned int pos, const EBF_dir *dir)
 Puts out a copy of the CAL data, prefacing it with a style header and tower map.
static unsigned int cal_ped_hdr_encode (unsigned int *buf, unsigned int pos, unsigned int fmt, unsigned int map)
 Encodes the CAL pedestal header information. This consists of a formatting style (currently 0 = copy, 1 = compress) plus the map of towers that have a CAL contribution.
unsigned int CDF_cal_ped_compress (CDF_cal *cdf, unsigned int *buf, unsigned int pos, const EBF_dir *dir, const ECR_cal *clb, const CDF_err *err)
 Makes a compressed copy of the CAL data if the data is in a form that this routine understands. If not, a straight copy of the data is made.


Detailed Description

The CAL pedestal event processing and compaction routines.

Author:
JJRussell - russell@slac.stanford.edu

   CVS $Id: CDF_cal_ped.c,v 1.6 2011/03/26 17:35:23 russell Exp $

The encoding for the CAL pedestal data is

Object Number of Bits Description Format 2 0 = copy, 1 = standard compress

Format 0
The format style is followed by 16 bits indicating which towers have CAL data, followed by a verbatim copy of the CAL data which begins on the next 32-bit boundary.
Format 1
The format style is followed by
  1. A single bit indicating whether anything unusual is going on. If this is 0, then all logs of the LAT are present. The exception field is yet to be defined. This provides an escape hatch if needed
Each range is then encoded as
  1. 13 bits indicating the offset to the 0 bin of the pedestal subtracted values. This value should be subtracted from each recovered pedestal subtracted value after adding on that logs pedestal, ie
                    ADC = encoded_value - this_offset + pedestal
    
  2. 4 bits giving the number of bits needed to store the run lengths of the valid codes
  3. A list of <nbits> values giving the run lengths of the valid codes. This is terminated by a 0. For example, if the frequency distribution was

1 2 0 3 4 5 0 0 7 6 5

The longest run length is 3. This takes 2 bits to hold so this distribution would be encoded 10b, 01b, 11b, 10b, 11b, 00b.

  1. 5 bits giving the number of bits used to encode the code lengths - 1 (since all valid codes must be at least 1 in length, the 1 is subtracted off).
  2. The list of the code lengths -1, each occupying the number of bits specified by the previous field
  3. The Huffman codes for the logs.

Define Documentation

#define LYR_OFFSETS ( _lyr,
_rng   ) 

Value:

(((_lyr) >>   1) * EDA_CAL_K_LOGS_PER_TOWER +   \
                  ((_lyr) &  0x1) * EDA_CAL_K_LOGS_PER_LAYER +   \
                   (_rng)         * EDA_CAL_K_LOGS_PER_LAYER * 2)
Computes the offsets to the specified layer and range when all the logs in a tower are struck.

Returns:
The offset to the layer of the specified range
Parameters:
_lyr The layer number
_rng The range

#define RNG_OFFSETS ( _rng   ) 

Value:

LYR_OFFSETS(0, _rng), \
        LYR_OFFSETS(1, _rng), \
        LYR_OFFSETS(2, _rng), \
        LYR_OFFSETS(3, _rng), \
        LYR_OFFSETS(4, _rng), \
        LYR_OFFSETS(5, _rng), \
        LYR_OFFSETS(6, _rng), \
        LYR_OFFSETS(7, _rng)
Creates a comma separated list of the offsets to the 8 layers for the specified range when all the logs in a tower are struck.

Returns:
The comma separated list, appropriate to use when defining a data statement of these offsets
Parameters:
_rng The range to compute the offsets for

Referenced by cal_ped4_process().

#define RNGS_COMPOSE ( _beg   ) 

Value:

( ((((_beg) + 3) & 3) << 14) | ((((_beg) + 3) & 3) << 12) | \
          ((((_beg) + 2) & 3) << 10) | ((((_beg) + 2) & 3) <<  8) | \
          ((((_beg) + 1) & 3) <<  6) | ((((_beg) + 1) & 3) <<  4) | \
          ((((_beg) + 0) & 3) <<  2) | ((((_beg) + 0) & 3) <<  0) )
Composes an array of 2 bit range values in the order specified. For example, specifying RNG_COMPOSE(0) means that one expects the four range readout to occur in the order range 0,1,2,3, while specifying RNG_COMPOSE(1) results in an expected order of range 1,2,3,0. This is used to predict the range when processing the layer pairs in the four range readout order.

Referenced by cal_ped4_evaluate().


Function Documentation

static __inline unsigned int cal_ped1_compress ( CDF_cal cdf,
unsigned int *  buf,
unsigned int  pos,
const EBF_dir *  dir,
const ECR_cal *  clb 
) [static]

Makes a compressed copy of the CAL data when it is single range, non-zero suppressed.

Returns:
The updated write bit position
Parameters:
cdf The CAL compression data formatting handle
buf The output buffer
pos The position of the next bit to fill
dir The directory describing the event to be formatted
clb The CAL pedestals and gains

References cal_ped1_process(), _CDF_cal_ped::cidx, _CDF_cal::com, _CDF_cal_com::hde, _CDF_cal_ped_statistics::hist, _CDF_cal::ped, and _CDF_cal_ped::stats.

Referenced by CDF_cal_ped_compress().

static __inline unsigned int cal_ped1_evaluate ( const EBF_dir *  dir,
int *  rngP 
) [static]

Evaluates the CAL data to see if it is in a form that the compression routines understand.

Returns:
A bit mask of the towers that are not understandable
Parameters:
dir The directory of the event to be evaluated
rngP Returned as the range for the event.

References cal_ped1_evaluate_layer().

Referenced by CDF_cal_ped_compress().

static __inline unsigned int cal_ped1_evaluate_layer ( const EBF_calLogData *  logs,
int  cnt,
int  twr,
int  lyr,
int  rng 
) [static]

Checks that the column numbers are as expected and that all the ranges are 0.

Returns:
The tower number as a bit mask
Parameters:
logs The logs for this layer
cnt The number of logs for this layer (likely 12)
twr The tower number for this layer
lyr The layer number for this layer (for debugging only)
rng The 'standard' range. Anything not matching this is considered an exception.

Referenced by cal_ped1_evaluate().

static __inline int cal_ped1_process ( short int *  cidx,
unsigned short int *  hist,
const EBF_dir *  dir,
const ECR_cal *  clb 
) [static]

Creates the histograms and the array of pedestal subtracted indices used to compress the CAL portion of the event that is specific to single-range readout.

Returns:
The number of adcs
Parameters:
cidx The pedestal subtracted ADCs
hist The histogram to fill
dir The directory for this event
clb The calibration constants

References cal_ped1_process_layer().

Referenced by cal_ped1_compress().

static __inline const unsigned int * cal_ped1_process_layer ( short int *  cidx,
unsigned short int *  hist,
const ECR_calLayer *  clyr,
const unsigned int *  logs,
int  cnt,
int  twr,
int  lyr 
) [static]

Accumulates the histograms used in compressing the CAL data for one layer.

Returns:
Pointer to the next CAL log data
Parameters:
cidx The pedestal subtracted ADCs
hist The histogram to fill
clyr The calibration constants for this layer (holds the pedestals)
logs The array of CAL logs for this layer
cnt The number of logs in this layer
twr The tower number of this layer, debugging only
lyr The layer number of this layer, debugging only

Referenced by cal_ped1_process(), and cal_ped4_process().

static __inline unsigned int cal_ped4_compress ( CDF_cal cdf,
unsigned int *  buf,
unsigned int  pos,
const EBF_dir *  dir,
const ECR_cal *  clb 
) [static]

Makes a compressed copy of the CAL data when it is four-range, non-zero suppressed.

Returns:
The updated write bit position
Parameters:
cdf The CAL compression data formatting handle
buf The output buffer
pos The position of the next bit to fill
dir The directory describing the event to be formatted
clb The CAL pedestals and gains

References cal_ped4_process(), _CDF_cal_ped::cidx, _CDF_cal::com, _CDF_cal_com::hde, _CDF_cal_ped_statistics::hist, _CDF_cal::ped, and _CDF_cal_ped::stats.

Referenced by CDF_cal_ped_compress().

static __inline unsigned int cal_ped4_evaluate ( const EBF_dir *  dir,
int *  rngP 
) [static]

Evaluates the 4-range CAL data to see if it is in a form that the compression routines understand.

Returns:
A bit mask of the towers that are not understandable
Parameters:
dir The directory of the event to be evaluated
rngP Returned as the range for the event.

References cal_ped4_evaluate_layer(), and RNGS_COMPOSE.

Referenced by CDF_cal_ped_compress().

static __inline unsigned int cal_ped4_evaluate_layer ( const EBF_calLogData *  logs,
int  cnt,
int  twr,
int  lyr,
int  rng 
) [static]

Checks 4-range CAL data for

  • column numbers are as expected
  • all the ranges are in the same order.

Returns:
If in error, tower number as a bit mask, else 0
Parameters:
logs The logs for this layer
cnt The number of logs for this layer (likely 12)
twr The tower number for this layer
lyr The layer number for this layer (for debugging only)
rng The expected range

Referenced by cal_ped4_evaluate().

static __inline int cal_ped4_process ( short int *  cidx,
unsigned short int *  hist,
const EBF_dir *  dir,
const ECR_cal *  clb,
int  rng 
) [static]

Creates the histograms and the array of pedestal subtracted indices used to compress the CAL portion of the event that is specific to single-range readout.

Returns:
The number of adcs
Parameters:
cidx The pedestal subtracted ADCs
hist The histogram to fill
dir The directory for this event
clb The calibration constants
rng The range to process

const unsigned short int off_buf[8];

References cal_ped1_process_layer(), and RNG_OFFSETS.

Referenced by cal_ped4_compress().

static unsigned int cal_ped_hdr_encode ( unsigned int *  buf,
unsigned int  pos,
unsigned int  fmt,
unsigned int  map 
) [static]

Encodes the CAL pedestal header information. This consists of a formatting style (currently 0 = copy, 1 = compress) plus the map of towers that have a CAL contribution.

Returns:
The updated write bit position
Parameters:
buf The output buffer
pos The position of the next bit to fill
fmt The format style
map The map of towers with CAL data

Referenced by cdf_cal_ped_copy().

unsigned int CDF_cal_ped_compress ( CDF_cal cdf,
unsigned int *  buf,
unsigned int  pos,
const EBF_dir *  dir,
const ECR_cal *  clb,
const CDF_err err 
)

Makes a compressed copy of the CAL data if the data is in a form that this routine understands. If not, a straight copy of the data is made.

Returns:
The updated write bit position
Parameters:
cdf The CAL compression data formatting handle
buf The output buffer
pos The position of the next bit to fill
dir The directory describing the event to be formatted
clb The CAL pedestals and gains
err The error context block
This routine is merely a dispatch routine, vectoring control to either single range or four range compression.

References cal_ped1_compress(), cal_ped1_evaluate(), cal_ped4_compress(), cal_ped4_evaluate(), and cdf_cal_ped_copy().

static __inline unsigned int cdf_cal_ped_copy ( CDF_cal cdf,
unsigned int *  buf,
unsigned int  pos,
const EBF_dir *  dir 
) [static]

Puts out a copy of the CAL data, prefacing it with a style header and tower map.

Returns:
The updated write bit position
Parameters:
cdf The CAL compression data formatting handle
buf The output buffer
pos The position of the next bit to fill
dir The directory describing the event to be formatted
This routine is called when the CAL data does not meet the expectations of the fancier compression encoding. This is either due to a variation that has not be specifically handled or due to an error in the data itself.

References cal_ped_hdr_encode(), and CDF_cal_copy().

Referenced by CDF_cal_ped_compress().


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