/*:>-------------------------------------------------------------------- **: FILE: mMvdCalib.c **: HISTORY: **: 00jan93-v000a-hpl- Created by stic Version **: Id: idl.y,v 1.17 1997/03/25 19:22:52 ward Exp **:<------------------------------------------------------------------*/ #include "mMvdCalib.h" extern int bDbase_Table ( DMVDGEO_ST *Geo, DMVBPAR_ST *bPar, DMVCPAR_ST *cPar, short shell, short row, short panel, short strip ); void MvdMess_(char *name_of_function, short ierror, short level, char *message, ...); #define NO_ERROR 0 /* used for mesage output with no error */ #define LOUD 2 /* messages which are usually output */ #define QUIET 1 /* used for messages which are output at default setting */ #define SILENT 0 /* for messages which are usually not output */ long mMvdCalib_( TABLE_HEAD_ST *bCal_h, DMVBCAL_ST *bCal , TABLE_HEAD_ST *dPar_h, DMVDPAR_ST *dPar , TABLE_HEAD_ST *bPar_h, DMVBPAR_ST *bPar , TABLE_HEAD_ST *cPar_h, DMVCPAR_ST *cPar , TABLE_HEAD_ST *Geo_h, DMVDGEO_ST *Geo , TABLE_HEAD_ST *bRaw_h, DMVBRAW_ST *bRaw , TABLE_HEAD_ST *bSkev_h, DMVBSKEV_ST *bSkev ) { /*:>-------------------------------------------------------------------- **: ROUTINE: mMvdCalib_ **: DESCRIPTION: Sort and calibrate raw ADC data **: temporarily only for PISA and will be updated **: to meet real raw data calibration format **: **: AUTHOR: J.H.Park, S.S.Ryu (YonSei Univ.) (Feb 03 98) **: Change sorting algorithm for raw ADC table **: J.H.Park, S.S.Ryu (YonSei Univ.) (Nov 10 97) **: based on J.P.Sullivan's pisorp codes **: ARGUMENTS: **: IN: **: bCal - barrel detector calibration data **: bCal_h - header Structure for bCal **: dPar - mvd uncalibration parameters **: dPar_h - header Structure for dPar **: bPar - barrel detector geometry parameters **: bPar_h - header Structure for bPar **: cPar - endcap detector geometry parameters **: cPar_h - header Structure for cPar **: Geo - Geant MVD geometry **: Geo_h - header Structure for Geo **: bRaw - barrel detector digitized raw data **: bRaw_h - header Structure for bRaw **: INOUT: **: OUT: **: bSkev - barrel detector calibrated data **: bSkev_h - header Structure for Skev **: RETURNS: STAF Condition Value **: **: HISTORY: JPSullivan 14-Apr-98 replaced printf calls with calls to **: MvdMess_ **: JPSullivan 21-Jul-98 minor output fixes **: S.S.Ryu 09-JUL-1999 replaces declarations like **: "struct dMvdGeo_st *geo" **: with STAF standard "DMVDGEO_ST *geo" **:>------------------------------------------------------------------*/ int i; /* for Barrel */ DMVBRAW_ST barrel[28672]; short STRIP=(short)Geo->nstrip; short PANEL=(short)bPar->NCHDIM; short ROW =(short)bPar->NPHDIM; short SHELL=(short)bPar->NSHELL; short HOLE =(short)Geo->nwhole; short SEGMENT=(short)bPar->NSEGMENT; short shell,row,panel,strip; int index,total; MvdMess_("mMvdCalib",NO_ERROR,LOUD,"\nmMvdCalib{"); total=SHELL*ROW*PANEL*STRIP-HOLE*SEGMENT*STRIP; /* initialize barrel array */ for (i=0;i < total;++i) barrel[i].shell=-1; /* sort raw barrel tables */ for ( i=0;i < bRaw_h->nok ; ++i) { shell=bRaw[i].shell; row =bRaw[i].row; panel=bRaw[i].cell; strip=bRaw[i].strip; index=bDbase_Table(Geo,bPar,cPar,shell,row,panel,strip); barrel[index]=bRaw[i]; } index=-1; for ( i=0;i < total ; ++i) if ( barrel[i].shell != -1) bRaw[++index]=barrel[i]; if ( bCal_h->nok ==0 ){ bCal->gain=dPar->smax_kev/dPar->full_scale; bCal_h->nok=1; } ds2ReallocTable(&bSkev_h,&bSkev,bRaw_h->nok); MvdMess_("mMvdCalib",NO_ERROR,QUIET,"\tbRaw_h->nok=%d",bRaw_h->nok); for (i=0;inok;i++){ bSkev[i].shell=bRaw[i].shell; bSkev[i].row =bRaw[i].row; bSkev[i].cell =bRaw[i].cell; bSkev[i].strip=bRaw[i].strip; bSkev[i].skev =bRaw[i].adc*bCal->gain; } bSkev_h->nok=bRaw_h->nok; MvdMess_("mMvdCalib",NO_ERROR,QUIET,"\tbSkev_h->nok=%d",bSkev_h->nok); MvdMess_("mMvdCalib",NO_ERROR,LOUD,"}"); return STAFCV_OK; }