- Timestamp:
- 05/26/13 21:18:21 (12 years ago)
- Location:
- trunk/FACT++/src
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/Description.cc
r10429 r16282 93 93 94 94 vector<Description> vec; 95 vec. push_back(Description(svc, d));95 vec.emplace_back(svc, d); 96 96 97 97 if (p==string::npos) … … 119 119 const string name = hasunit ? buf.substr(0, p2) : buf; 120 120 121 vec. push_back(Description(name, comment, unit));121 vec.emplace_back(name, comment, unit); 122 122 } 123 123 -
trunk/FACT++/src/DimState.h
r15039 r16282 150 150 { 151 151 states = State::SplitStates(evt.GetString()); 152 states. push_back(State(kOffline, "Offline"));152 states.emplace_back(kOffline, "Offline"); 153 153 154 154 CallbackStates(); -
trunk/FACT++/src/State.cc
r14541 r16282 78 78 const string comment = p2==string::npos ? "" : buf.substr(p2+1); 79 79 80 vec. push_back(State(index, name, comment));80 vec.emplace_back(index, name, comment); 81 81 } 82 82 -
trunk/FACT++/src/StateMachineDimControl.cc
r15430 r16282 476 476 continue; 477 477 478 rc. push_back(State(it->first.second, it->second.first, it->second.second));478 rc.emplace_back(it->first.second, it->second.first, it->second.second); 479 479 } 480 480 -
trunk/FACT++/src/StateMachineImp.cc
r16089 r16282 166 166 { 167 167 const lock_guard<mutex> guard(fMutex); 168 fEventQueue. push_back(shared_ptr<Event>(cmd));168 fEventQueue.emplace_back(cmd); 169 169 } 170 170 -
trunk/FACT++/src/datalogger.cc
r16088 r16282 2004 2004 vector<string> names; 2005 2005 vector<string> dataTypes; 2006 names. push_back("MEMBER_XTENSION");2007 dataTypes. push_back("8A");2008 names. push_back("MEMBER_URI_TYPE");2009 dataTypes. push_back("3A");2010 names. push_back("MEMBER_LOCATION");2006 names.emplace_back("MEMBER_XTENSION"); 2007 dataTypes.emplace_back("8A"); 2008 names.emplace_back("MEMBER_URI_TYPE"); 2009 dataTypes.emplace_back("3A"); 2010 names.emplace_back("MEMBER_LOCATION"); 2011 2011 dataTypes.push_back(pathTypeName.str()); 2012 names. push_back("MEMBER_NAME");2012 names.emplace_back("MEMBER_NAME"); 2013 2013 dataTypes.push_back(pathTypeName.str()); 2014 names. push_back("MEMBER_VERSION");2015 dataTypes. push_back("1J");2016 names. push_back("MEMBER_POSITION");2017 dataTypes. push_back("1J");2014 names.emplace_back("MEMBER_VERSION"); 2015 dataTypes.emplace_back("1J"); 2016 names.emplace_back("MEMBER_POSITION"); 2017 dataTypes.emplace_back("1J"); 2018 2018 2019 2019 groupTable = groupFile->addTable("GROUPING", numFilesToGroup, names, dataTypes); -
trunk/FACT++/src/feedback.cc
r15493 r16282 37 37 kFeedbackGlobal, 38 38 kCurrents, 39 kCurrentsNew, 39 40 }; 40 41 … … 94 95 int HandleCameraTemp(const EventImp &evt) 95 96 { 96 if (fControlType!=kTemp && fControlType!=kCurrents )97 if (fControlType!=kTemp && fControlType!=kCurrents && fControlType!=kCurrentsNew) 97 98 return GetCurrentState(); 98 99 … … 123 124 fCursorTemp++; 124 125 125 return HandleCurrentControl(); 126 return fControlType==kCurrentsNew ? HandleCurrentControlNew() : HandleCurrentControl(); 127 } 128 129 int HandleCurrentControlNew() 130 { 131 if (GetCurrentState()==Feedback::State::kCalibrating && fBiasOffset>fTempOffset-1.2) 132 { 133 fCursorTemp = 0; 134 135 ostringstream msg; 136 msg << " (applied calibration offset " << fBiasOffset << "V exceeds temperature correction " << fTempOffset << "V - 1.2V."; 137 Warn("Trying to calibrate above G-APD breakdown volatge!"); 138 Warn(msg); 139 return GetCurrentState(); 140 } 141 142 double avg[2] = { 0, 0 }; 143 double min[2] = { 90, 90 }; 144 double max[2] = { -90, -90 }; 145 int num[2] = { 0, 0 }; 146 147 vector<double> med[2]; 148 med[0].resize(416); 149 med[1].resize(416); 150 151 const float *Ravg = fCalibration.data()+BIAS::kNumChannels*2; // Measured resistance 152 153 vector<float> vec(2*BIAS::kNumChannels+2); 154 155 vec[BIAS::kNumChannels*2] = fTempOffset; 156 vec[BIAS::kNumChannels*2+1] = fBiasOffset; 157 158 float *Uoff = vec.data()+BIAS::kNumChannels; 159 160 if (GetCurrentState()==Feedback::State::kCalibrating) 161 for (int i=0; i<BIAS::kNumChannels; i++) 162 Uoff[i] = fBiasOffset; 163 else 164 for (int i=0; i<BIAS::kNumChannels; i++) 165 Uoff[i] = fTempOffset+fBiasOffset; 166 167 if (fControlType==kCurrentsNew) 168 { 169 // Would be a devision by zero. We need informations first. 170 if (fCursorCur==0) 171 return GetCurrentState(); 172 173 for (int i=0; i<BIAS::kNumChannels; i++) 174 { 175 const PixelMapEntry &hv = fMap.hv(i); 176 if (!hv) 177 continue; 178 179 // Nominal breakdown voltage (includes overvoltage already) 180 double Ubd = fVoltGapd[i]; 181 182 // Nominal breakdown voltage excluding overvoltage of 1.1V 183 Ubd -= 1.1; 184 185 // Correct breakdown voltage for temperature dependence 186 Ubd += fTempOffset; 187 188 // Number of G-APDs in this patch 189 const int N = hv.group() ? 5 : 4; 190 191 // 100 Ohm measurement resistor for current measurement 192 const double R2 = 100; 193 194 // Serial resistors (one 1kOhm at the output of the bias crate, one 1kOhm in the camera) 195 const double R4 = 2000; 196 197 // Serial resistor of the individual G-APDs 198 double R5 = 3900/N; 199 200 // This is assuming that the broken pixels have a 390 Ohm instead of 3900 Ohm serial resistor 201 if (i==66) // Pixel 830(66) 202 R5 = 300; // 2400 = 1/(3/3900 + 1/390) 203 if (i==191 || i==193) // Pixel 583(191) / Pixel 1401(193) 204 R5 = 390/1.4; // 379 = 1/(4/3900 + 1/390) 205 206 // Total resistance of branch with diode 207 const double R3 = R4+R5; 208 209 // Measured calibration resistor 210 const double R1 = Ravg[i] - R2; 211 212 // Voltage output of bias crate 213 const double Uout = fBiasVolt[i]; 214 215 // Average current measured for this channel 216 const double Imes = double(fCurrentsAvg[i])/fCursorCur * (5000/4096.); // [uA] 217 218 // Voltage drop at measurement resistor R2 is define 219 // bythe measured current and the resistor 220 const double U2 = R2*Imes; 221 222 // The voltage seen by the calibration resistor R1 is defined by the 223 // bias crate output voltage minus the drop at the measurement resistor R2 224 const double U1 = Uout - U2; 225 226 // The current through the resistor R1 is defined 227 // by the applied voltage and the resistor 228 const double I1 = U1/R1; 229 230 // The current through the diode branch is the measured current 231 // minus the current through the calibration resistor R1 232 const double I3 = Imes - I1; 233 234 // The voltage drop in the diode branch (without the diode) is defined by the 235 // resistor and the current. It is 0 below the breakdown voltage of the G-APD 236 // is reached at the G-APD. This is the case when the output voltage minus 237 // the voltage drop at the calibration resistor reaches the breakdown voltage. 238 const double U3 = Uout-U2<Ubd ? 0 : R3*I3; 239 240 // Voltage drop at measurement resistor R2 and 241 // the total serial resistor R3 in the diode branch 242 const double Udrp = U2 + U3; 243 244 // Voltage finally at each G-APD (bias crate output voltage minus voltage drop) 245 const double Uapd = Uout - Udrp; 246 247 // The over-voltage seen by the G-APD (the voltage above the breakdown voltage) is 248 const double Uov = Uapd<Ubd ? 0 : Uapd - Ubd; 249 250 // The current through one G-APD is the sum divided by the number of G-APDs 251 // (assuming identical serial resistors) 252 double Iapd = I3/N; 253 254 // This is assuming that the broken pixels have a 390 Ohm instead of 3900 Ohm serial resistor 255 // In this and the previosu case we neglect the resistance of the G-APDs, but we can make an 256 // assumption: The differential resistance depends more on the NSB than on the PDE, 257 // thus it is at least comparable for all G-APDs in the patch. In addition, although the 258 // G-APD with the 390Ohm serial resistor has the wrong voltage applied, this does not 259 // significantly influences the ohmic resistor or the G-APD because the differential 260 // resistor is large enough that the increase of the overvoltage does not dramatically 261 // increase the current flow as compared to the total current flow. 262 if (i==66) 263 Iapd *= 1.3; 264 if (i==191 || i==193) 265 Iapd *= 1.4; 266 267 // If the G-APD voltage is above the breakdown voltage we have the current through the 268 // G-APD and the over-voltage applied to the G-APD to calculate its differential resistor. 269 if (Uapd>Ubd) 270 { 271 // The differential resistance of the G-APD, i.e. the dependence of the 272 // current above the breakdown voltage, is given by 273 const double Rapd = Uov/Iapd; 274 275 // This allows us to estimate the current Iov at the overvoltage we want to apply 276 const double Iov = (1.1+fBiasOffset)/Rapd; 277 278 // This gives us an ohmic resistance Rov of the G-APD at the set-point 279 const double Rest = (Ubd+1.1+fBiasOffset)/Iov; 280 281 // This lets us estimate the total resistance Rtot of the circuit at the set-point 282 const double R3b = R4 + (R5+Rest)/N; 283 const double Rtot = R2 + 1/(1/R1 + 1/R3b); 284 285 // From this we can estimate the output voltage we need to get the 286 // over-voltage at the G-APD as anticipated 287 const double r = 1 + R3/R1 - (R2 + R3 + R3*R2/R1)/Rtot; 288 const double Uset = (Ubd+1.1+fBiasOffset)/r; 289 290 Uoff[i] = Uset - fVoltGapd[i]; 291 } 292 293 // Calculate statistics only for channels with a valid calibration 294 if (Uov>0) 295 { 296 const int g = hv.group(); 297 298 med[g][num[g]] = Uov; 299 avg[g] += Uov; 300 num[g]++; 301 302 if (Uov<min[g]) 303 min[g] = Uov; 304 if (Uov>max[g]) 305 max[g] = Uov; 306 } 307 } 308 309 sort(med[0].begin(), med[0].begin()+num[0]); 310 sort(med[1].begin(), med[1].begin()+num[1]); 311 312 fCurrentsAvg.assign(BIAS::kNumChannels, 0); 313 fCursorCur = 0; 314 } 315 316 fDimDeviation.setQuality(fControlType); 317 fDimDeviation.Update(vec); 318 319 // Warning: Here it is assumed that the ramp up and down is done properly 320 // within the time between two new temperatures and that the calibration 321 // is finished within that time. 322 if (GetCurrentState()!=Feedback::State::kCalibrating || 323 fDimBias.state()!=BIAS::State::kVoltageOff || 324 fCursorTemp!=1 || !fOutputEnabled) 325 { 326 if (!fOutputEnabled || fDimBias.state()!=BIAS::State::kVoltageOn) 327 return GetCurrentState(); 328 329 // Trigger calibration 330 if (GetCurrentState()==Feedback::State::kCalibrating && fCursorTemp==2) 331 { 332 DimClient::sendCommandNB("BIAS_CONTROL/REQUEST_STATUS", NULL, 0); 333 return GetCurrentState(); 334 } 335 } 336 337 ostringstream msg; 338 msg << setprecision(4) << "Sending new absolute offset (" << fAppliedOffset << "V+" << (num[0]+num[1]>0?(avg[0]+avg[1])/(num[0]+num[1]):0) << "V) to biasctrl."; 339 Info(msg); 340 341 if (fControlType==kCurrents && num[0]>0 && num[1]>0) 342 { 343 msg.str(""); 344 msg << " Avg0=" << setw(7) << avg[0]/num[0] << " | Avg1=" << setw(7) << avg[1]/num[1]; 345 Debug(msg); 346 347 msg.str(""); 348 msg << " Med0=" << setw(7) << med[0][num[0]/2] << " | Med1=" << setw(7) << med[1][num[1]/2]; 349 Debug(msg); 350 351 msg.str(""); 352 msg << " Min0=" << setw(7) << min[0] << " | Min1=" << setw(7) << min[1]; 353 Debug(msg); 354 355 msg.str(""); 356 msg << " Max0=" << setw(7) << max[0] << " | Max1=" << setw(7) << max[1]; 357 Debug(msg); 358 } 359 360 DimClient::sendCommandNB("BIAS_CONTROL/SET_ALL_CHANNELS_OFFSET", 361 vec.data()+BIAS::kNumChannels, BIAS::kNumChannels*sizeof(float)); 362 363 return GetCurrentState(); 126 364 } 127 365 … … 727 965 void HandleCalibrateCurrents(const EventImp &evt) 728 966 { 729 if (fBiasVolt. size()==0 || fCalibration.size()==0|| evt.GetSize()<416*sizeof(int16_t))967 if (fBiasVolt.empty() || fCalibration.empty() || evt.GetSize()<416*sizeof(int16_t)) 730 968 return; 731 969 … … 806 1044 HandleCalibration(evt); 807 1045 808 if (fControlType==kFeedbackGlobal || fControlType==kCurrents )1046 if (fControlType==kFeedbackGlobal || fControlType==kCurrents || fControlType==kCurrentsNew) 809 1047 AverageCurrents(evt); 810 1048 … … 875 1113 int PrintCalibration() 876 1114 { 877 if (fCalibration. size()==0)1115 if (fCalibration.empty()) 878 1116 { 879 1117 Out() << "No calibration performed so far." << endl; … … 953 1191 fOutputEnabled = evt.GetBool(); 954 1192 955 if (fControlType==kCurrents )1193 if (fControlType==kCurrents || fControlType==kCurrentsNew) 956 1194 if (fCursorTemp>1) 957 1195 fCursorTemp = 1; … … 1043 1281 return kSM_FatalError; 1044 1282 1045 if (fCalibration. size()==0)1283 if (fCalibration.empty()) 1046 1284 { 1047 1285 Warn("Current control needs a bias crate calibration first... command ignored."); … … 1063 1301 } 1064 1302 1303 int StartNewCurrentCtrl(const EventImp &evt) 1304 { 1305 if (!CheckEventSize(evt.GetSize(), "StartNewCurrentCtrl", 4)) 1306 return kSM_FatalError; 1307 1308 if (fCalibration.empty()) 1309 { 1310 Warn("Current control needs a bias crate calibration first... command ignored."); 1311 return GetCurrentState(); 1312 } 1313 1314 WarnState(true, false); 1315 1316 fBiasOffset = evt.GetFloat(); 1317 fTempOffset = -3; 1318 ResetData(0); 1319 fControlType = kCurrentsNew; 1320 1321 ostringstream out; 1322 out << "Starting new current/temp feedback with an offset of " << fBiasOffset << "V"; 1323 Message(out); 1324 1325 return GetCurrentState(); 1326 } 1327 1065 1328 int StopFeedback() 1066 1329 { … … 1130 1393 } 1131 1394 1132 if (fVoltGapd. size()==0)1395 if (fVoltGapd.empty()) 1133 1396 { 1134 1397 Error("No G-APD reference voltages received yet (BIAS_CONTROL/NOMINAL)."); … … 1248 1511 return fOutputEnabled ? Feedback::State::kTempCtrlRunning : Feedback::State::kTempCtrlIdle; 1249 1512 } 1250 if (fControlType==kCurrents )1513 if (fControlType==kCurrents || fControlType==kCurrentsNew) 1251 1514 { 1252 1515 static Time past; -
trunk/FACT++/src/makedata.cc
r15366 r16282 141 141 const double disk = ln_get_lunar_disk(jd+h); 142 142 143 fMoonCoords. push_back(make_pair(moon, disk));143 fMoonCoords.emplace_back(moon, disk); 144 144 } 145 145 -
trunk/FACT++/src/makeplots.cc
r15209 r16282 157 157 const double disk = Nova::GetLunarDisk(jd+h); 158 158 159 fMoonCoords. push_back(make_pair(moon, disk));159 fMoonCoords.emplace_back(moon, disk); 160 160 } 161 161 -
trunk/FACT++/src/ratecontrol.cc
r16088 r16282 410 410 411 411 // Keep all median currents of the past 10 seconds 412 fCurrentsMed. push_back(make_pair(time, med));413 fCurrentsDev. push_back(make_pair(time, dev));414 fCurrentsVec. push_back(make_pair(time, vector<float>(cur, cur+320)));412 fCurrentsMed.emplace_back(time, med); 413 fCurrentsDev.emplace_back(time, dev); 414 fCurrentsVec.emplace_back(time, vector<float>(cur, cur+320)); 415 415 while (!fCurrentsMed.empty()) 416 416 { -
trunk/FACT++/src/smartfact.cc
r16087 r16282 368 368 pop_front(); 369 369 370 push_back(EventElement(t, s));370 emplace_back(t, s); 371 371 } 372 372 … … 1912 1912 const double disk = Nova::GetLunarDisk(jd+h); 1913 1913 1914 fMoonCoords. push_back(make_pair(moon, disk));1914 fMoonCoords.emplace_back(moon, disk); 1915 1915 } 1916 1916 }
Note:
See TracChangeset
for help on using the changeset viewer.