Changeset 13235 for trunk/FACT++/src/feedback.cc
- Timestamp:
- 03/26/12 16:10:34 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/feedback.cc
r13224 r13235 148 148 const float *ptr = static_cast<float*>(fCameraTemp.getData()); 149 149 150 double avg = 0;151 int num = 0;150 double avgt = 0; 151 int numt = 0; 152 152 for (int i=1; i<32; i++) 153 153 if (ptr[i]!=0) 154 154 { 155 avg += ptr[i];156 num ++;155 avgt += ptr[i]; 156 numt++; 157 157 } 158 158 159 if (num ==0)160 return; 161 162 avg /= num;163 164 165 const float diff = (avg -25)*4./70 + fBiasOffset;159 if (numt==0) 160 return; 161 162 avgt /= numt; 163 164 165 const float diff = (avgt-25)*4./70 + fBiasOffset; 166 166 167 167 vector<float> vec(2*BIAS::kNumChannels); … … 169 169 vec[i+BIAS::kNumChannels] = diff; 170 170 171 avg = 0; 172 num = 0; 171 double avg[2] = { 0, 0 }; 172 double min[2] = { 90, 90 }; 173 double max[2] = { -90, -90 }; 174 int num[2] = { 0, 0 }; 175 176 vector<double> med[2]; 177 med[0].resize(416); 178 med[1].resize(416); 179 173 180 if (fControlType==kCurrents) 174 181 { … … 179 186 } 180 187 188 // Pixel 583: 5 31 == 191 (5) 189 // Pixel 830: 2 2 == 66 (4) 190 // Pixel 1401: 6 1 == 193 (4) 191 181 192 // Convert from DAC counts to uA 182 193 const double conv = 5000e-6/4096; 194 195 // 3900 Ohm/n + 1000 Ohm + 1100 Ohm (with n=4 or n=5) 196 const double R[2] = { 3075, 2870 }; 197 183 198 for (int i=0; i<BIAS::kNumChannels; i++) 184 199 { 185 // 3900 Ohm/n + 1000 Ohm + 1150 Ohm 186 const double R = fMap.hv(i).group()==0 ? 3125 : 2930; 200 const PixelMapEntry &hv = fMap.hv(i); 201 if (!hv) 202 continue; 203 204 const int g = hv.group(); 205 187 206 const double Im = double(fCurrentsAvg[i])/fCursorCur; 188 207 const double I = Im>fCalibration[i] ? Im-fCalibration[i] : 0; 189 vec[i+BIAS::kNumChannels] += R * I*conv; 208 209 double U = R[g] * I*conv; 210 211 // 510 / 390 1.30 ^1.66 = 1.55 212 // 470 / 380 1.23 = 1.41 213 // 450 / 360 1.25 = 1.45 214 215 // This is assuming that the broken pixels 216 // have a 1kOhm instead of 390 Ohm serial resistor 217 if (i==66 || i==193) 218 U /= 2665./R[0]; // (1k)2665 / (390)2400 / (~0)2110 219 if (i==191) 220 U /= 2594./R[1]; // (1k)2794 / (390)2320 / (~0)2110 221 222 vec[i+BIAS::kNumChannels] += U; 223 190 224 if (fCalibration[i]>0) 191 225 { 192 avg += R * I*conv; 193 num++; 226 med[g][num[g]] = U; 227 avg[g] += U; 228 num[g]++; 229 230 if (U<min[g]) 231 min[g] = U; 232 if (U>max[g]) 233 max[g] = U; 194 234 } 195 235 } 196 avg /= num; 236 237 sort(med[0].begin(), med[0].begin()+num[0]); 238 sort(med[1].begin(), med[1].begin()+num[1]); 197 239 198 240 fCurrentsAvg.assign(BIAS::kNumChannels, 0); … … 214 256 215 257 ostringstream msg; 216 msg << setprecision(4) << "Sending new absolute offset (" << diff << "V+" << avg<< "V) to biasctrl.";258 msg << setprecision(4) << "Sending new absolute offset (" << diff << "V+" << (avg[0]+avg[1])/(num[0]+num[1]) << "V) to biasctrl."; 217 259 Info(msg); 260 261 if (fControlType==kCurrents) 262 { 263 msg.str(""); 264 msg << " Avg0=" << setw(5) << avg[0]/num[0] << " | Avg1=" << setw(5) << avg[1]/num[1] << endl; 265 Debug(msg); 266 267 msg.str(""); 268 msg << " Med0=" << setw(5) << med[0][num[0]/2] << " | Med1=" << setw(5) << med[1][num[1]/2] << endl; 269 Debug(msg); 270 271 msg.str(""); 272 msg << " Min0=" << setw(5) << min[0] << " | Min1=" << setw(5) << min[1] << endl; 273 Debug(msg); 274 275 msg.str(""); 276 msg << " Max0=" << setw(5) << max[0] << " | Max1=" << setw(5) << max[1] << endl; 277 Debug(msg); 278 } 218 279 219 280 DimClient::sendCommandNB("BIAS_CONTROL/SET_ALL_CHANNELS_OFFSET", … … 1237 1298 1238 1299 fCurrentRequestInterval = conf.Get<uint16_t>("current-request-interval"); 1239 fNumCalibIgnore = conf.Get<uint16_t>("num-calib-ignore");1240 fNumCalibRequest = conf.Get<uint16_t>("num-calib-average");1300 fNumCalibIgnore = conf.Get<uint16_t>("num-calib-ignore"); 1301 fNumCalibRequests = conf.Get<uint16_t>("num-calib-average"); 1241 1302 1242 1303 return -1;
Note:
See TracChangeset
for help on using the changeset viewer.