GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> EDS / V2-12-1 > eds / rhel6-64


Interface   Data Structures   File List   Data Fields   Globals  

EDR_calUnpack.c File Reference

Unpacks the CAL data for the whole LAT. More...

#include <string.h>
#include <EDS/EBF_dir.h>
#include <EDS/EBF_cid.h>
#include <EDS/EBF_cal.h>
#include <EDS/EBF_ctb.h>
#include <EDS/EDR_calUnpack.h>
#include <EDS/EDA_cal.h>
#include <EDS/EDR_cal.h>
#include <EDS/ECR_cal.h>
#include <PBI/FFS.ih>

Defines

#define SATURATION   (7 * (1 << 12)/8)
 This defines the saturation point of an ADC as anything over 7/8 of full range.

Functions

static __inline int convert (int val, const ECR_calLogEnd *cal)
 Converts ADC value into standard units (Log Energy Units). LEUs are the standard unit internally used by the filter code.
static __inline int * unpackTower (EDR_cal *clr, EDR_calTower *ctr, int tower, int *dst, const EBF_dirCtbDsc *contributor, const ECR_calTower *calTower)
 Unpacks the CAL data from 1 tower into a Cal Tower Record (ctr) This routine assumes auto (single) range readout.
static __inline int mapTower (EDR_calTower *ctr, int tower, const EBF_dirCtbDsc *contributor)
 Creates the address map for the specified tower.
static __inline int unpackLayer4 (int *dst, EDR_calColumnMap *colMapP, int nlogs, const unsigned int *data, int increment, const ECR_calTower *calTower, int layer)
 Handles the decoding/autoranging of 1 layer.
static __inline int mapTower4 (EDR_calTower *ctr, int tower, const EBF_dirCtbDsc *contributor)
 Maps the CAL data from 1 tower into a Cal Tower Record (ctr) This routine assumes 4 range readout.
static __inline int * unpackTower4 (EDR_cal *clr, EDR_calTower *ctr, int tower, int *dst, const EBF_dirCtbDsc *contributor, const ECR_calTower *calTower)
 Unpacks the CAL data from 1 tower into a Cal Tower Record (ctr) This routine assumes 4 range readout.
int EDR_calUnpack (EDR_cal *clr, const EBF_dir *dir, const ECR_cal *constants)
 Unpacks the CAL data for the whole LAT.
int EDR_calMapUnpack (EDR_cal *clr, const EBF_dir *dir)
 Unpacks the CAL data for the whole LAT.
int EDR_calUnpackInit (EDR_cal *cal)
 One-time initialization an EDR_cal structure.
void EDR_calUnpackReset (EDR_cal *cal)
 Resets the EDR_cal structure, preparing it for a new event.
int EDR_calUnpackSizeof (void)
 Returns the size, in bytes, of a CAL LAT record.


Detailed Description

Unpacks the CAL data for the whole LAT.

Author:
JJRussell - russell@slac.stanford.edu
  CVS $Id: EDR_calUnpack.c,v 1.6 2011/03/25 22:16:56 russell Exp $

Function Documentation

static __inline int convert ( int  val,
const ECR_calLogEnd cal 
) [static]

Converts ADC value into standard units (Log Energy Units). LEUs are the standard unit internally used by the filter code.

Returns:
The energy, in LEUs.
Parameters:
val The ADC value to convert
cal The calibration values for one log end
A simple linear conversion is used and a scaling factor is applied to convert an ADC value to an energy in LEUs (at one time 1 LEU = 1/4 MEV).

References _ECR_calLogEnd::bf, _ECR_calLogEnd_bf::gain, _ECR_calLogEnd_bf::pedestal, and _ECR_calLogEnd_bf::shift.

int EDR_calMapUnpack ( EDR_cal clr,
const EBF_dir dir 
)

Unpacks the CAL data for the whole LAT.

Parameters:
clr The CAL LAT Record data structure to fill
dir The directory structure for this event; used to locate the CAL data.
The Cal LAT Record contains the control structure to describe a fully unpacked and but non-calibrated CAL data for the entire LAT tower.

References _EBF_dir::ctbs, _EBF_dirRedux::ctids, EBF_CID_K_TEM, EBF_DIR_TEMS_CAL, EDR_CAL_MAP_IS_VALID, EDR_CAL_VALID_M_MAP, _EBF_dirCtbDsc::logcnt, _EDR_cal::logCnt, mapTower(), mapTower4(), _EBF_dir::redux, _EBF_dirRedux::rng_ids, _EDR_cal::twrMap, _EDR_cal::twrs, and _EDR_cal::valid.

int EDR_calUnpack ( EDR_cal clr,
const EBF_dir dir,
const ECR_cal constants 
)

Unpacks the CAL data for the whole LAT.

Parameters:
clr The CAL LAT Record data structure to fill
dir The directory structure for this event; used to locate the CAL data.
constants The CAL calibration constants (gains/pedestals) for this tower
Returns:
The number of logs
The Cal LAT Record contains the control structure to describe a fully unpacked and calibrated CAL data for the entire LAT tower.

References _EBF_dir::ctbs, _EBF_dirRedux::ctids, EBF_CID_K_TEM, EBF_DIR_TEMS_CAL, EDR_CAL_MAP_ENERGY_ARE_VALID, EDR_CAL_VALID_M_ENERGY, EDR_CAL_VALID_M_MAP, _EDR_cal::energy, _EDR_cal::layerEnergies, _EDR_cal::logCnt, _EDR_cal::logEnds, _EBF_dir::redux, _EBF_dirRedux::rng_ids, _EDR_cal::twrMap, _ECR_cal::twrs, _EDR_cal::twrs, unpackTower(), unpackTower4(), and _EDR_cal::valid.

int EDR_calUnpackInit ( EDR_cal cal  ) 

One-time initialization an EDR_cal structure.

Returns:
0, always
Parameters:
cal The EDR_cal structure to initialize

References _EDR_cal::valid.

Referenced by initIxbObjTbl().

void EDR_calUnpackReset ( EDR_cal cal  ) 

Resets the EDR_cal structure, preparing it for a new event.

Parameters:
cal The EDR_cal structure to reset

References _EDR_cal::valid.

Referenced by initIxbObjTbl().

int EDR_calUnpackSizeof ( void   ) 

Returns the size, in bytes, of a CAL LAT record.

Returns:
The size, in bytes, of a CAL LAT record.
This function should be called to determine the size of an EDR_cal structure. This allows the calling program to avoid including the structure definition an EDR_cal.

After allocating an EDR_tkr structure, the structure should be initialized using EDR_calUnpackInit().

int mapTower ( EDR_calTower ctr,
int  tower,
const EBF_dirCtbDsc contributor 
) [static]

Creates the address map for the specified tower.

Returns:
The number of logs
Parameters:
ctr The CTR data structure to fill
tower The tower number
contributor The CAL contributor descriptor
The Cal Tower Record contains the control structure to describe a fully unpacked and calibrated CAL tower. However, this version does not convert the ADC/PHA values to energies. This routine is faster than unpackTower and should be used when only the address map and not calibrated energies are needed.
Warning:
This routine can be called if and only if there are struck logs in this tower.

References _EBF_calLogData::bf, _EBF_calLogData_bf::col, _EDR_calTower::colMap, _EBF_dirCtbDsc::ctb, _EBF_ctb::dat, _EDR_calTower::data, EDR_CAL_TOWER_COLMAP, EDR_CAL_TOWER_LAYERMAP_INIT, _EDR_calTower::flags, _EDR_calTower::layerCnts, _EDR_calTower::layerMap, _EBF_dirCtbDsc::logcnt, _EDR_calTower::logCnt, and _EDR_calTower::tower.

Referenced by EDR_calMapUnpack().

int mapTower4 ( EDR_calTower ctr,
int  tower,
const EBF_dirCtbDsc contributor 
) [static]

Maps the CAL data from 1 tower into a Cal Tower Record (ctr) This routine assumes 4 range readout.

Returns:
The next CAL energy location to be stored
Parameters:
ctr The CAL tower data structure to fill
tower The tower number
contributor The CAL contributor descriptor
This routine creates the address map for one tower that is in the 4 range readout mode
Warning:
This routine can be called if and only if there are struck logs in this tower.

References _EDR_calTower::colMap, _EDR_calTower::data, EBF__dirCtbCalLocate(), EDR_CAL_TOWER_COLMAP, EDR_CAL_TOWER_LAYERMAP_INIT, _EDR_calTower::flags, _EDR_calTower::layerCnts, _EDR_calTower::layerMap, _EBF_dirCtbDsc::logcnt, _EDR_calTower::logCnt, and _EDR_calTower::tower.

Referenced by EDR_calMapUnpack().

static __inline int unpackLayer4 ( int *  dst,
EDR_calColumnMap colMapP,
int  nlogs,
const unsigned int *  data,
int  increment,
const ECR_calTower calTower,
int  layer 
) [static]

Handles the decoding/autoranging of 1 layer.

Returns:
The total energy, in units of LEUs, in this layer
Parameters:
dst The energy destination array. This is where the energy of each log end is stored
colMapP Pointer to the column map for this layer
nlogs The number logs in this layer
data Pointer to the first data word
increment The number of 32-words needed to advance from 1 range to the next
calTower The calibration constants for this tower
layer The target

References _EBF_calLogData::bf, _EBF_calLogData_bf::col, _ECR_calLayer::columns, convert(), EDR_CAL_TOWER_COLMAP, _ECR_calRange::layers, _ECR_calLog::n, _ECR_calLog::p, _ECR_calTower::ranges, _EBF_calLogData_bf::rngN, _EBF_calLogData_bf::rngP, _EBF_calLogData::ui, _EBF_calLogData_bf::valN, and _EBF_calLogData_bf::valP.

Referenced by unpackTower4().

int * unpackTower ( EDR_cal clr,
EDR_calTower ctr,
int  tower,
int *  dst,
const EBF_dirCtbDsc contributor,
const ECR_calTower calTower 
) [static]

Unpacks the CAL data from 1 tower into a Cal Tower Record (ctr) This routine assumes auto (single) range readout.

Returns:
The next CAL energy location to be stored
Parameters:
clr The CAL LAT data structure to fill
ctr The CAL tower data structure to fill
tower The tower number
dst The destination array for the CAL energies
contributor The CAL contributor descriptor
calTower The CAL calibration constants for this tower
The Cal Tower Record contains the control structure to describe a fully unpacked and calibrated CAL tower. The calibrated energies are stored in a separate array. This allows the control structure to be relatively compact and the CAL energies to be contigious.
Warning:
This routine can be called if and only if there are struck logs in this tower.

References _EBF_calLogData::bf, _EBF_calLogData_bf::col, _EDR_calTower::colMap, convert(), _EDR_calTower::data, EBF__dirCtbCalLocate(), EDA_CAL_K_LOGS_PER_LAYER, EDR_CAL_TOWER_COLMAP, EDR_CAL_TOWER_LAYERMAP, _EDR_cal::energy, _EDR_calTower::energy, _EDR_calTower::flags, _EDR_calTower::layerCnts, _EDR_cal::layerEnergies, _EDR_calTower::layerEnergies, _EDR_calTower::layerMap, _EBF_dirCtbDsc::logcnt, _EDR_calTower::logCnt, _EDR_calTower::logEnergies, _ECR_calRange::logs, _ECR_calLog::n, _ECR_calLog::p, _ECR_calTower::ranges, _EBF_calLogData_bf::rngN, _EBF_calLogData_bf::rngP, _EDR_calTower::tower, _EBF_calLogData::ui, _EBF_calLogData_bf::valN, and _EBF_calLogData_bf::valP.

Referenced by EDR_calUnpack().

int * unpackTower4 ( EDR_cal clr,
EDR_calTower ctr,
int  tower,
int *  dst,
const EBF_dirCtbDsc contributor,
const ECR_calTower constants 
) [static]

Unpacks the CAL data from 1 tower into a Cal Tower Record (ctr) This routine assumes 4 range readout.

Returns:
The next CAL energy location to be stored
Parameters:
clr The CAL LAT data structure to fill
ctr The CAL tower data structure to fill
tower The tower number
dst The destination array for the CAL energies
contributor The CAL contributor descriptor
constants The CAL calibration constants for this tower
The Cal Tower Record contains the control structure to describe a fully unpacked and calibrated CAL tower. The calibrated energies are stored in a separate array. This allows the control structure to be relatively compact and the CAL energies to be contigious.
Warning:
This routine can be called if and only if there are struck logs in this tower.

References _EDR_calTower::colMap, _EDR_calTower::data, EBF__dirCtbCalLocate(), EDR_CAL_TOWER_LAYERMAP, _EDR_cal::energy, _EDR_calTower::energy, _EDR_calTower::flags, _EDR_calTower::layerCnts, _EDR_cal::layerEnergies, _EDR_calTower::layerEnergies, _EDR_calTower::layerMap, _EBF_dirCtbDsc::logcnt, _EDR_calTower::logCnt, _EDR_calTower::logEnergies, _EDR_calTower::tower, and unpackLayer4().

Referenced by EDR_calUnpack().


Generated on Thu Sep 27 13:52:20 2012 by  doxygen 1.5.8