FACT++  1.0
int StateMachineSmartFACT::HandleBiasCurrent ( const EventImp d)
inlineprivate

Definition at line 1336 of file smartfact.cc.

References StateMachineSmartFACT::Statistics::avg, EventImp::GetJavaDate(), PixelMapEntry::group(), PixelMap::hv(), PixelMapEntry::hw(), i, Feedback::State::kCalibrated, HTML::kWhite, StateMachineSmartFACT::Statistics::max, StateMachineSmartFACT::Statistics::med, StateMachineSmartFACT::Statistics::min, EventImp::Ptr(), and DimState::state().

Referenced by StateMachineSmartFACT().

1337  {
1339  return GetCurrentState();
1340 
1341  if (!CheckDataSize(d, "BiasControl:Current", 832))
1342  return GetCurrentState();
1343 
1344  // Convert dac counts to uA
1345  vector<float> v(320);
1346  for (int i=0; i<320; i++)
1347  v[i] = d.Ptr<uint16_t>()[i] * 5000./4096;
1348 
1350 
1351  // Get the maximum of each patch
1352  vector<float> val(320, 0);
1353  for (int i=0; i<320; i++)
1354  {
1355  const PixelMapEntry &hv = fPixelMap.hv(i);
1356  if (!hv)
1357  continue;
1358 
1359  const int idx = (hv.hw()/9)*2+hv.group();
1360  val[idx] = v[i];
1361  }
1362 
1363  // Write the 160 patch values to a file
1364  WriteCam(d, "cam-biascontrol-current", val, 1000);
1365 
1366  const Statistics stat(v, 0, 3);
1367 
1368  // Exclude the three crazy channels
1369  fBiasControlCurrentMed = stat.med;
1370  fBiasControlCurrentMax = stat.max;
1371 
1372  // Store a history of the last 60 entries
1374  if (fBiasControlCurrentHist.size()>360)
1375  fBiasControlCurrentHist.pop_front();
1376 
1377  // write the history to a file
1378  WriteHist(d, "hist-biascontrol-current", fBiasControlCurrentHist, 1000);
1379 
1380  ostringstream out;
1381  out << setprecision(3);
1382  out << d.GetJavaDate() << '\n';
1383  out << HTML::kWhite<< '\t' << "no" << '\n';
1384  out << HTML::kWhite << '\t' << stat.min << '\n';
1385  out << HTML::kWhite << '\t' << stat.med << '\n';
1386  out << HTML::kWhite << '\t' << stat.avg << '\n';
1387  out << HTML::kWhite << '\t' << stat.max << '\n';
1388  out << HTML::kWhite << '\t' << "---\n";
1389  ofstream(fPath+"/current.data") << out.str();
1390 
1391  return GetCurrentState();
1392  }
int GetCurrentState() const
return the current state of the machine
bool CheckDataSize(const EventImp &d, const char *name, size_t size, bool min=false)
Definition: smartfact.cc:669
int i
Definition: db_dim_client.c:21
int group() const
Definition: PixelMap.h:40
deque< float > fBiasControlCurrentHist
Definition: smartfact.cc:552
void WriteHist(const EventImp &d, const string &fname, const T &t, double scale, double offset=0)
Definition: smartfact.cc:752
const int32_t & state() const
Definition: DimState.h:80
DimDescribedState fDimFeedback
Definition: smartfact.cc:633
static const string kWhite
Definition: smartfact.cc:74
uint64_t GetJavaDate() const
Definition: EventImp.cc:303
int hw() const
Definition: PixelMap.h:39
void WriteCam(const EventImp &d, const string &fname, const T &t, double scale, double offset=0)
Definition: smartfact.cc:758
const T * Ptr(size_t offset=0) const
Definition: EventImp.h:74
const PixelMapEntry & hv(int board, int channel) const
Definition: PixelMap.h:139

+ Here is the call graph for this function:

+ Here is the caller graph for this function: