00001 #ifndef _TPX_FCF_H_
00002 #define _TPX_FCF_H_
00003
00004 #include "tpxFCF_flags.h"
00005
00006
00007 #define FCF_ADC_NOISE 4
00008 #define FCF_ADC_MIN 4 // we additionally can kill 1d sequences where the maximum is below this
00009 #define FCF_MIN_WIDTH 1
00010 #define FCF_MIN_ADC_PAD_C 180
00011
00012
00013
00014 #define TPC_GG_OPEN 22
00015 #define TPC_FF_CLOSE 380
00016
00017
00018 #define FCF_MAX_CL 64 // max 1D clusters per pad
00019
00020
00021 #define FCF_V_FY08 0x0000 // used in the FY08 run; has the /32 "bug"
00022 #define FCF_V_FY09 0x0001 // /32 bug fixed
00023
00024
00025
00026
00027
00028
00029
00030 #define FCF_DO_DOUBLE // timebins, pads, averages are double instead of u_int
00031
00032
00033
00034 #ifdef FCF_DO_DOUBLE
00035 typedef float fcf_type;
00036 #else
00037 typedef int fcf_type;
00038 #endif
00039
00040 #ifdef FCF_DO_INT
00041 typedef int fcf_short ;
00042 #else
00043 typedef short fcf_short ;
00044 #endif
00045
00046
00047
00048 class tpxGain ;
00049 struct daq_cld ;
00050 struct daq_sim_cld ;
00051 struct daq_sim_adc_tb ;
00052
00053
00054 struct tpxFCF_cl {
00055 union {
00056 unsigned int charge ;
00057 fcf_type f_charge ;
00058 } ;
00059 union {
00060 unsigned int t_ave ;
00061 fcf_type f_t_ave ;
00062 } ;
00063
00064 fcf_type scharge ;
00065 fcf_type p_ave ;
00066
00067
00068
00069 fcf_short t1, t_min ;
00070 fcf_short t2, t_max ;
00071
00072 fcf_short p1 ;
00073 fcf_short p2 ;
00074
00075 fcf_short flags ;
00076 unsigned short track_id ;
00077
00078 short quality ;
00079 short sim_length ;
00080
00081 daq_sim_adc_tb *sim ;
00082 } ;
00083
00084
00085 struct tpx_altro_struct ;
00086
00087 class tpxFCF {
00088 public:
00089 tpxFCF() ;
00090 ~tpxFCF() ;
00091
00092 void config(unsigned int rb_mask, int modes=0, int rows=0, unsigned char *rowlen=0) ;
00093 int modes ;
00094
00095 void apply_gains(int sector, tpxGain *gains) ;
00096
00097 void start_evt() ;
00098
00099 int do_pad(tpx_altro_struct *a, daq_sim_adc_tb *extra = 0) ;
00100 int stage2(unsigned int *outbuff, int max_bytes) ;
00101
00102
00103
00104 char do_cuts ;
00105 char run_compatibility ;
00106
00107 int ch_min ;
00108
00109 static int fcf_decode(unsigned int *p_buff, daq_cld *dc, unsigned short version=0) ;
00110 static int fcf_decode(unsigned int *p_buff, daq_sim_cld *sdc, unsigned short version=0) ;
00111 static int afterburner(int cou, daq_cld *store[]) ;
00112 static char *fcf_flags(u_char flags) ;
00113
00114 const char *GetCVS() const {
00115 static const char cvs[]="Tag $Name: $: $Id: tpxFCF.h,v 1.14 2012/04/27 09:15:15 tonko Exp $: built "__DATE__" "__TIME__ ; return cvs;
00116 }
00117
00118
00119
00120 private:
00121
00122 unsigned int *loc_buff ;
00123 int cur_row ;
00124 int cur_row_clusters ;
00125
00126 int row_count ;
00127 unsigned char *tpx_rowlen ;
00128 int tpx_padplane ;
00129
00130 int cl_marker ;
00131
00132 struct stage1 {
00133 unsigned short count ;
00134 unsigned short f ;
00135 double g ;
00136 double t0 ;
00137 struct tpxFCF_cl cl[FCF_MAX_CL] ;
00138 } ;
00139
00140
00141 struct stage1 *storage ;
00142
00143 void dump(tpxFCF_cl *cl, int row) ;
00144
00145 inline struct stage1 *get_stage1(int row, int pad)
00146 {
00147 if(row_ix[row] < 0) return 0 ;
00148
00149 return storage + row_ix[row] + (pad-1) ;
00150
00151 }
00152
00153
00154 int row_ix[256] ;
00155
00156 unsigned int rbs ;
00157 int sector ;
00158 tpxGain *gains ;
00159
00160 unsigned int do_version ;
00161 unsigned int read_version ;
00162 } ;
00163
00164 #endif