00001
00002
00003
00004
00005
00006
00007 #ifndef _FCF_CLASS_HH_
00008 #define _FCF_CLASS_HH_
00009
00010
00011
00012
00013
00014
00015
00016
00017 #define FCF_ONEPAD 1
00018 #define FCF_DOUBLE_PAD 2
00019 #define FCF_DOUBLE_T 4
00020 #define FCF_FALLING 8
00021 #define FCF_ROW_EDGE 16 // touched end of row
00022 #define FCF_BROKEN_EDGE 32 // touches one of the mezzanine edges
00023 #define FCF_DEAD_EDGE 64 // touches a dead pad
00024 #define FCF_IGNORE 128
00025
00026
00027 #define FCF_PARAM1 2 // was 2
00028 #define FCF_MIN_ADC_T 3 // was 3
00029 #define FCF_MIN_ADC_PAD 12 // was 12
00030
00031
00032 #define FCF_GAIN_SHIFT 6 // shift left/righ
00033 #define FCF_GAIN_FACTOR (1<<FCF_GAIN_SHIFT) // 64!!!
00034
00035
00036 #define FCF_WORDS_PER_CLUSTER 2
00037
00038
00039 #if defined(__unix) || defined(__ROOT__)
00040
00041 typedef unsigned int u_int;
00042 typedef unsigned short u_short;
00043 typedef unsigned char u_char;
00044
00045 #define FCF_SIM_ON
00046
00047 #else
00048
00049 #ifdef FCF_ANNOTATE_CLUSTERS
00050 #undef FCF_ANNOTATE_CLUSTERS
00051 #endif
00052
00053 #ifdef FCF_DEBUG_OUTPUT
00054 #undef FCF_DEBUG_OUTPUT
00055 #endif
00056
00057 #ifdef FCF_SIM_ON
00058 #undef FCF_SIM_ON
00059 #endif
00060
00061 #endif
00062
00063
00064
00065 struct fcfPixAnnotate {
00066 u_short adc ;
00067 u_short cl_id ;
00068 u_short id_simtrk ;
00069 u_short res ;
00070 } ;
00071
00072
00073
00074 struct FcfSimOutput {
00075 short id_simtrk;
00076 short id_quality;
00077 short cl_id ;
00078 short reserved;
00079 };
00080
00081
00082 #ifdef FCF_ANNOTATE_CLUSTERS
00083 #ifndef FCF_SIM_ON
00084 #define FCF_SIM_ON
00085 #endif
00086
00087 #ifndef __ROOT__
00088
00089 extern struct fcfPixAnnotate fcfPixA[45][182][512] ;
00090
00091 #else
00092 extern struct fcfPixAnnotate pixStruct[183][512] ;
00093
00094 #endif
00095
00096 #endif
00097
00098
00099 class fcfClass {
00100 public:
00101
00102 fcfClass(int det, u_short *table = NULL) ;
00103
00104
00105
00106
00107
00108 u_int cvs_revision ;
00109
00110 int detector ;
00111 u_int maxTimebin ;
00112 u_int maxCPP ;
00113
00114
00115 u_int svtPedestal ;
00116 u_int timebinLo ;
00117 u_int timebinHi ;
00118 u_int chargeMin ;
00119
00120
00121 u_int deconTime ;
00122 u_int deconPad ;
00123
00124 u_int doCuts ;
00125
00126 int param1 ;
00127 int minAdcT ;
00128 int minAdcPad ;
00129
00130
00131 int row ;
00132 int padStart ;
00133 int padStop ;
00134 int padMax ;
00135
00136 u_int *adcOff ;
00137 u_short *cppOff ;
00138 u_int maxClusters ;
00139
00140 short *simIn;
00141 u_int *simOut;
00142
00143
00144 int *t0Corr ;
00145
00146
00147 u_int *gainCorr ;
00148
00149 u_short *startFlags ;
00150
00151
00152 int sb ;
00153 int rb ;
00154 int mz ;
00155
00156
00157
00158 int finder(u_char *adcin, u_short *cppin, u_int *outres) ;
00159
00160
00161 inline int saveRes(struct fcfResx *res_p[], int cou, u_int *output) ;
00162 void set8to10(u_short *extTable) ;
00163
00164 private:
00165 struct fcfResx *resx[2][512] ;
00166
00167 u_short *a8to10 ;
00168 int noADCconversion ;
00169
00170
00171 u_short adc8to10_storage[256] ;
00172
00173 u_int chargeMinCorrect ;
00174 } ;
00175
00176
00177
00178
00179 struct fcfHit {
00180 u_short pad ;
00181 u_short tm ;
00182 u_short f ;
00183 u_short c ;
00184 u_short p1,p2,t1,t2 ;
00185 short id_simtrk;
00186 short id_quality;
00187 short cl_id ;
00188 } ;
00189
00190
00191 class fcfAfterburner {
00192 enum {kMax_fcfHit = 200};
00193 public:
00194 fcfAfterburner();
00195 ~fcfAfterburner() { ; } ;
00196
00197 int burn(u_int *ptr_res[3], u_int *ptr_simu_res[3] = NULL) ;
00198 int next(fcfHit *out) ;
00199 int compare(u_int *p1[3], u_int *p2[3]) ;
00200
00201 void decode(u_int *data, fcfHit *h, u_int *sim = 0) ;
00202 void print_hit(char *, fcfHit *hit) ;
00203
00204 u_int do_swap ;
00205 u_int do_merge ;
00206 u_int do_cuts ;
00207 u_int row ;
00208
00209 void setVerbose(bool v) { verbose = v; };
00210 private :
00211 bool verbose;
00212
00213 u_int last_n, last_i, last_count, last_stage ;
00214 u_int **ptr ;
00215 u_int **ptr_simu ;
00216
00217 u_int edge[4] ;
00218 struct fcfHit broken[4][kMax_fcfHit] ;
00219 u_int cou_broken[4] ;
00220
00221 int output(fcfHit *l) ;
00222 int check_merge(fcfHit *l, fcfHit *r) ;
00223 } ;
00224
00225
00226
00227 #endif