00001 #ifndef _TPX_GAIN_HH_
00002 #define _TPX_GAIN_HH_
00003
00004 #include <stdio.h>
00005
00006 #include "tpxCore.h"
00007
00008
00009 #define TPX_CLOCK_TCU_LOC 9215889 // exactly
00010 #define TPX_CLOCK_TCU_RHIC 9383000 // typical value
00011 #define TPX_CLOCK_TCD_OLD 9434800 // exactly; with the old, pre FY11, TCD
00012 #define TPX_CLOCK_TCD 9370000 // exactly
00013
00014
00015
00016 #define TPX_TCU_LOC_PED_STOP 96
00017 #define TPX_TCU_LOC_START 97
00018 #define TPX_TCU_LOC_STOP 101
00019 #define TPX_TCU_LOC_TIME_0 98.668442 // measured with run 10346005
00020
00021
00022
00023 #define TPX_TCU_RHIC_PED_STOP 97
00024 #define TPX_TCU_RHIC_START 98
00025 #define TPX_TCU_RHIC_STOP 102
00026 #define TPX_TCU_RHIC_TIME_0 99.0 // some number....
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #define TPX_TCD_PED_STOP 173
00043 #define TPX_TCD_START 174
00044 #define TPX_TCD_STOP 177
00045 #define TPX_TCD_TIME_0 175.667713
00046
00047
00048
00049
00050
00051
00052 #define TPX_TCD_OLD_START 100
00053 #define TPX_TCD_OLD_STOP 103
00054 #define TPX_TCD_OLD_TIME_0 100.84 // or perhaps 100.90?
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 #define TPX_PULSER_PED_START 166
00066 #define TPX_PULSER_PED_STOP 182
00067
00068 class tpxGain
00069 {
00070 public:
00071 tpxGain() ;
00072 ~tpxGain() ;
00073
00074
00075 struct gains {
00076 float g ;
00077 float t0 ;
00078 } ;
00079
00080
00081 struct gains *gains[24] ;
00082
00083 void set_gains(int s, int r, int p, float g, float t0) {
00084 struct gains *gs = get_gains(s,r,p) ;
00085
00086 gs->g = g ;
00087 gs->t0 = t0 ;
00088 }
00089
00090 struct gains *get_gains(int s, int r, int p) {
00091 if(gains[s-1]==0) {
00092 return &dummy_gain ;
00093 }
00094
00095 return (gains[s-1] + r*182 + (p-1)) ;
00096 }
00097
00098
00099 u_int bad_fee[25][7][37] ;
00100
00101
00102 u_int bad_rdo_mask[25] ;
00103
00104 void if_file() ;
00105
00106 char *raw_gains_fname ;
00107
00108
00109 struct aux {
00110 short low_pulse ;
00111 short noise ;
00112 short high_pulse ;
00113
00114 short cou ;
00115 short need ;
00116 u_int adc_store[20] ;
00117 } *aux ;
00118
00119 struct aux *get_aux(int s, int r, int p) {
00120 return (aux + (s-1)*46*182 + r*182 + (p-1)) ;
00121 } ;
00122
00123 struct means {
00124 double g ;
00125 double t0 ;
00126 double g_rms ;
00127 double t0_rms ;
00128
00129 } *means ;
00130
00131 struct means *get_means(int s, int r) {
00132 return (means + (s-1)*46 + r) ;
00133 } ;
00134
00135
00136 struct fee_found_t {
00137 u_int got_one ;
00138 int ch_count[256][16] ;
00139 } *fee_found ;
00140
00141 struct fee_found_t *get_fee_found(int s, int rdo) {
00142 return (fee_found + (s-1)*7 + rdo) ;
00143 }
00144
00145 int from_file(char *fname, int sector = 0) ;
00146
00147
00148 int to_file(char *fname) ;
00149
00150 void init(int sec=0) ;
00151 void accum(char *evbuff, int bytes) ;
00152 void ev_done() ;
00153
00154 void calc() ;
00155
00156 void compare(char *fname, int mysec=0) ;
00157 int summarize(char *fname, FILE *log_file=0, int gain_mode=0) ;
00158
00159 void free_store() ;
00160
00161 u_int c_date ;
00162 u_int c_time ;
00163 u_int c_run ;
00164
00165 int pulser_ped ;
00166 int pulser_ped_stop ;
00167 int pulser_start ;
00168 int pulser_stop ;
00169 double pulser_time_0 ;
00170
00171 void set_clock_mode(int mode) ;
00172
00173 private:
00174 void do_default(int sector) ;
00175
00176 time_t load_time ;
00177
00178 int tpx_pulser_peak[25][46] ;
00179
00180 int sector ;
00181 int events ;
00182 int tb_start, tb_stop ;
00183
00184 int clock_mode ;
00185
00186 struct gains dummy_gain ;
00187
00188
00189
00190
00191
00192
00193 } ;
00194
00195 #endif