CMS 3D CMS Logo

PixelPortCardConfig.cc
Go to the documentation of this file.
1 //
2 // This class specifies the settings on the TKPCIFEC
3 // and the settings on the portcard
4 //
5 //
6 //
7 //
8 
12 #include <fstream>
13 #include <sstream>
14 #include <iostream>
15 #include <string>
16 #include <vector>
17 #include <cassert>
18 #include <stdexcept>
19 #include <set>
20 
21 using namespace std;
22 using namespace pos::PortCardSettingNames;
23 using namespace pos;
24 
25 //added by Umesh
26 PixelPortCardConfig::PixelPortCardConfig(vector<vector<string> > &tableMat) : PixelConfigBase(" ", " ", " ") {
27  string mthn = "]\t[PixelPortCardConfig::PixelPortCardConfig()]\t\t ";
28  map<string, int> colM;
29  vector<string> colNames;
30 
122  colNames.push_back("CONFIG_KEY");
123  colNames.push_back("KEY_TYPE");
124  colNames.push_back("KEY_ALIAS");
125  colNames.push_back("VERSION");
126  colNames.push_back("KIND_OF_COND");
127  colNames.push_back("PORT_CARD");
128  colNames.push_back("TRKFEC");
129  colNames.push_back("RING");
130  colNames.push_back("CHANNEL");
131  colNames.push_back("CCU_ADDR");
132  colNames.push_back("I2C_CNTRL");
133  colNames.push_back("I2C_SPEED");
134  colNames.push_back("AOH_BIAS1");
135  colNames.push_back("AOH_BIAS2");
136  colNames.push_back("AOH_BIAS3");
137  colNames.push_back("AOH_BIAS4");
138  colNames.push_back("AOH_BIAS5");
139  colNames.push_back("AOH_BIAS6");
140  colNames.push_back("AOH_GAIN1");
141  colNames.push_back("AOH_GAIN2");
142  colNames.push_back("AOH_GAIN3");
143  colNames.push_back("AOH_GAIN4");
144  colNames.push_back("AOH_GAIN5");
145  colNames.push_back("AOH_GAIN6");
146  colNames.push_back("AOH1_BIAS1");
147  colNames.push_back("AOH1_BIAS2");
148  colNames.push_back("AOH1_BIAS3");
149  colNames.push_back("AOH1_BIAS4");
150  colNames.push_back("AOH1_BIAS5");
151  colNames.push_back("AOH1_BIAS6");
152  colNames.push_back("AOH1_GAIN1");
153  colNames.push_back("AOH1_GAIN2");
154  colNames.push_back("AOH1_GAIN3");
155  colNames.push_back("AOH1_GAIN4");
156  colNames.push_back("AOH1_GAIN5");
157  colNames.push_back("AOH1_GAIN6");
158  colNames.push_back("AOH2_BIAS1");
159  colNames.push_back("AOH2_BIAS2");
160  colNames.push_back("AOH2_BIAS3");
161  colNames.push_back("AOH2_BIAS4");
162  colNames.push_back("AOH2_BIAS5");
163  colNames.push_back("AOH2_BIAS6");
164  colNames.push_back("AOH2_GAIN1");
165  colNames.push_back("AOH2_GAIN2");
166  colNames.push_back("AOH2_GAIN3");
167  colNames.push_back("AOH2_GAIN4");
168  colNames.push_back("AOH2_GAIN5");
169  colNames.push_back("AOH2_GAIN6");
170  colNames.push_back("AOH3_BIAS1");
171  colNames.push_back("AOH3_BIAS2");
172  colNames.push_back("AOH3_BIAS3");
173  colNames.push_back("AOH3_BIAS4");
174  colNames.push_back("AOH3_BIAS5");
175  colNames.push_back("AOH3_BIAS6");
176  colNames.push_back("AOH3_GAIN1");
177  colNames.push_back("AOH3_GAIN2");
178  colNames.push_back("AOH3_GAIN3");
179  colNames.push_back("AOH3_GAIN4");
180  colNames.push_back("AOH3_GAIN5");
181  colNames.push_back("AOH3_GAIN6");
182  colNames.push_back("AOH4_BIAS1");
183  colNames.push_back("AOH4_BIAS2");
184  colNames.push_back("AOH4_BIAS3");
185  colNames.push_back("AOH4_BIAS4");
186  colNames.push_back("AOH4_BIAS5");
187  colNames.push_back("AOH4_BIAS6");
188  colNames.push_back("AOH4_GAIN1");
189  colNames.push_back("AOH4_GAIN2");
190  colNames.push_back("AOH4_GAIN3");
191  colNames.push_back("AOH4_GAIN4");
192  colNames.push_back("AOH4_GAIN5");
193  colNames.push_back("AOH4_GAIN6");
194  colNames.push_back("DELAY25_GCR");
195  colNames.push_back("DELAY25_SCL");
196  colNames.push_back("DELAY25_TRG");
197  colNames.push_back("DELAY25_SDA");
198  colNames.push_back("DELAY25_RCL");
199  colNames.push_back("DELAY25_RDA");
200  colNames.push_back("DOH_BIAS0");
201  colNames.push_back("DOH_BIAS1");
202  colNames.push_back("DOH_SEU_GAIN");
203  colNames.push_back("PLL_CTR1");
204  colNames.push_back("PLL_CTR2");
205  colNames.push_back("PLL_CTR3");
206  colNames.push_back("PLL_CTR4");
207  colNames.push_back("PLL_CTR5");
208 
209  //these are arbitrary integers that control the sort order
210  unsigned int othercount = 100;
211  unsigned int delay25count = 50;
212  aohcount_ = 1000;
213  unsigned int pllcount = 1;
214 
215  for (unsigned int c = 0; c < tableMat[0].size(); c++) {
216  for (unsigned int n = 0; n < colNames.size(); n++) {
217  if (tableMat[0][c] == colNames[n]) {
218  colM[colNames[n]] = c;
219  break;
220  }
221  }
222  } //end for
223  for (unsigned int n = 0; n < colNames.size(); n++) {
224  if (colM.find(colNames[n]) == colM.end()) {
225  std::cerr << __LINE__ << mthn << "\tCouldn't find in the database the column with name " << colNames[n]
226  << std::endl;
227  assert(0);
228  }
229  }
230 
231  portcardname_ = tableMat[1][colM["PORT_CARD"]];
232  // cout << __LINE__ << mthn << "Loading PortCard " << portcardname_ << endl ;
233  if (portcardname_.find("FPix") != std::string::npos) {
234  type_ = "fpix";
235  } else if (portcardname_.find("BPix") != std::string::npos) {
236  type_ = "bpix";
237  }
238  fillNameToAddress();
239  fillDBToFileAddress();
240 
241  TKFECID_ = tableMat[1][colM["TRKFEC"]];
242  ringAddress_ = atoi(tableMat[1][colM["RING"]].c_str());
243  ccuAddress_ = atoi(tableMat[1][colM["CCU_ADDR"]].c_str());
244  channelAddress_ = atoi(tableMat[1][colM["CHANNEL"]].c_str());
245  i2cSpeed_ = atoi(tableMat[1][colM["I2C_SPEED"]].c_str());
246  /*
247  cout << __LINE__ << "]\t" << mthn <<
248  "ringAddress_\t" << ringAddress_ << endl <<
249  "ccuAddress_\t" << ccuAddress_ << endl <<
250  "channelAddress_\t" << channelAddress_ << endl <<
251  "i2cSpeed_\t" << i2cSpeed_ << endl ;
252  */
253 
254  for (unsigned int col = 0; col < tableMat[1].size(); col++) //Goes to every column of the Matrix
255  {
256  std::string settingName;
257  unsigned int i2c_address;
258  unsigned int i2c_values;
259 
260  settingName = tableMat[0][col];
261  i2c_values = atoi(tableMat[1][col].c_str());
262 
263  // Special handling for AOHX_GainY
264  if (type_ == "fpix" && settingName.find("AOH_") != string::npos &&
265  settingName.find("GAIN") != string::npos // contains both "AOH_" and "Gain"
266  && settingName.find("123") == string::npos &&
267  settingName.find("456") == string::npos) // does not contain "123" or "456"
268  {
269  setDataBaseAOHGain(settingName, i2c_values);
270  // cout << __LINE__ << "]\t" << mthn << "Setting " << settingName << "\tto value " << std::hex << i2c_values << std::dec << std::endl ;
271  } else if (type_ == "bpix" && settingName.find("AOH") != string::npos &&
272  settingName.find("GAIN") != string::npos // contains both "AOH" and "Gain"
273  && settingName.find("AOH_") == string::npos // must not contain AOH_ 'cause this is for forward
274  && settingName.find("123") == string::npos &&
275  settingName.find("456") == string::npos) // does not contain "123" or "456"
276  {
277  if (portcardname_.find("PRT2") != std::string::npos &&
278  (settingName.find("AOH3_") != std::string::npos || settingName.find("AOH4_") != std::string::npos))
279  continue;
280  setDataBaseAOHGain(settingName, i2c_values);
281  // cout << __LINE__ << "]\t" << mthn << "Setting " << settingName << "\tto value " << std::hex << i2c_values << std::dec << std::endl ;
282  }
283  // FIXMR
284  else if (settingName == k_PLL_CTR5) // special handling
285  {
286  unsigned int last_CTR2 = 0x0;
287  if (containsSetting(k_PLL_CTR2))
288  last_CTR2 = getdeviceValuesForSetting(k_PLL_CTR2);
289 
290  device_.push_back(make_pair(getdeviceAddressForSetting(k_PLL_CTR2), new_PLL_CTR2_value(settingName, last_CTR2)));
291  device_.push_back(make_pair(getdeviceAddressForSetting(k_PLL_CTR4or5), i2c_values));
292 
293  key_.push_back(pllcount++); //these are arbitrary integers that control the sort order
294  key_.push_back(pllcount++);
295  }
296  // FIXMR
297  else // no special handling for this name
298  {
299  if ((settingName.find("DELAY25_") != std::string::npos) || (settingName.find("_BIAS") != std::string::npos) ||
300  (settingName.find("PLL_CTR2") != std::string::npos) || (settingName.find("PLL_CTR5") != std::string::npos) ||
301  ((settingName.find("DOH_SEU_GAIN") != std::string::npos) && type_ == "bpix"))
302  //Note that DOH_SEU_GAIN will be *ignored* for fpix
303  {
304  map<string, string>::iterator iter = nameDBtoFileConversion_.find(settingName);
305  if (iter == nameDBtoFileConversion_.end())
306  continue;
307  map<string, unsigned int>::iterator foundName_itr = nameToAddress_.find(nameDBtoFileConversion_[settingName]);
308 
309  if (foundName_itr != nameToAddress_.end()) {
310  if (portcardname_.find("PRT2") != std::string::npos &&
311  (settingName.find("AOH3_") != std::string::npos || settingName.find("AOH4_") != std::string::npos))
312  continue;
313  i2c_address = foundName_itr->second;
314  } else {
315  i2c_address = strtoul(settingName.c_str(), nullptr, 16); // convert string to integer using base 16
316  }
317  if (type_ == "fpix" &&
318  (settingName.find("AOH1_") != std::string::npos || settingName.find("AOH2_") != std::string::npos ||
319  settingName.find("AOH3_") != std::string::npos || settingName.find("AOH4_") != std::string::npos))
320  continue;
321 
322  pair<unsigned int, unsigned int> p(i2c_address, i2c_values);
323  /*
324  cout << __LINE__
325  << mthn << "Setting\t"
326  << "|"
327  << settingName
328  << "|->"
329  << nameDBtoFileConversion_[settingName]
330  << "\twith pair:\t("
331  << i2c_address
332  << ","
333  << i2c_values
334  << ")"
335  << endl ;
336  */
337  device_.push_back(p);
338  if (settingName.find("AOH") != string::npos)
339  key_.push_back(aohcount_++);
340  else if (settingName.find("Delay25") != string::npos)
341  key_.push_back(delay25count++);
342  else if (settingName.find("PLL") != string::npos)
343  key_.push_back(pllcount++);
344  else
345  key_.push_back(othercount++);
346  }
347  }
348  } // End of table columns
349 
350  sortDeviceList();
351 }
352 
353 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
355  string mthn = "[PixelPortCardConfig::PixelPortCardConfig()]\t\t ";
356  //std::cout << __LINE__ << "]\t" << mthn << "filename:"<<filename<<std::endl;
357 
358  size_t portcardpos = filename.find(std::string("portcard_"));
359  //std::cout << __LINE__ << "]\t" << mthn << "portcardpos:"<<portcardpos<<std::endl;
360  assert(portcardpos != (unsigned int)std::string::npos);
361  size_t datpos = filename.find(std::string(".dat"));
362  //std::cout << __LINE__ << "]\t" << mthn << "datpos:"<<datpos<<std::endl;
363  assert(datpos != (unsigned int)std::string::npos);
364  assert(datpos > portcardpos);
365 
366  portcardname_ = filename.substr(portcardpos + 9, datpos - portcardpos - 9);
367 
368  //std::cout << "Portcard name extracted from file name:"<<portcardname_<<std::endl;
369 
370  std::ifstream in(filename.c_str());
371 
372  if (!in.good()) {
373  std::cout << __LINE__ << "]\t" << mthn << "Could not open: " << filename << std::endl;
374  throw std::runtime_error("Failed to open file " + filename);
375  } else {
376  std::cout << __LINE__ << "]\t" << mthn << "Opened: " << filename << std::endl;
377  }
378 
379  string dummy;
380 
381  in >> dummy;
382  if (dummy == "Name:") // check that port card name matches the file name
383  {
384  in >> dummy;
386  in >> dummy;
387  }
388  if (dummy == "Type:") // read in the type, defaulting to "fpix" if not specified
389  {
390  in >> type_;
391  assert(type_ == "fpix" || type_ == "bpix");
392  in >> dummy;
393  } else {
394  type_ = "fpix";
395  }
398  assert(dummy == "TKFECID:");
399  in >> TKFECID_;
400  in >> dummy;
401  assert(dummy == "ringAddress:");
402  in >> std::hex >> ringAddress_;
403  in >> dummy;
404  assert(dummy == "ccuAddress:");
405  in >> std::hex >> ccuAddress_;
406  in >> dummy;
407  assert(dummy == "channelAddress:");
408  in >> std::hex >> channelAddress_;
409  in >> dummy;
410  assert(dummy == "i2cSpeed:");
411  in >> std::hex >> i2cSpeed_;
412 
413  //std::cout << __LINE__ << "]\t" << mthn
414  // <<TKFECAddress_<<", "<<ringAddress_<<", "<<ccuAddress_<<", "<<channelAddress_<<", "<<i2cSpeed_<<std::endl;
415 
416  assert(!nameToAddress_.empty());
417  do {
418  std::string settingName;
419  unsigned int i2c_address;
420  unsigned int i2c_values;
421 
422  in >> settingName >> std::hex >> i2c_values >> std::dec;
423  if (in.eof())
424  break;
425 
426  if (settingName[settingName.size() - 1] == ':')
427  settingName.resize(settingName.size() - 1); // remove ':' from end of string, if it's there
428 
429  // Special handling for AOHX_GainY
430  if (settingName.find("AOH") != string::npos &&
431  settingName.find("Gain") != string::npos // contains both "AOH" and "Gain"
432  && settingName.find("123") == string::npos &&
433  settingName.find("456") == string::npos) // does not contain "123" or "456"
434  {
435  setAOHGain(settingName, i2c_values);
436  } else if (settingName == k_PLL_CTR4 || settingName == k_PLL_CTR5) // special handling
437  {
438  unsigned int last_CTR2 = 0x0;
441 
442  device_.push_back(make_pair(getdeviceAddressForSetting(k_PLL_CTR2), new_PLL_CTR2_value(settingName, last_CTR2)));
443  device_.push_back(make_pair(getdeviceAddressForSetting(k_PLL_CTR4or5), i2c_values));
444  } else // no special handling for this name
445  {
446  std::map<std::string, unsigned int>::iterator foundName_itr = nameToAddress_.find(settingName);
447 
448  if (foundName_itr != nameToAddress_.end()) {
449  i2c_address = foundName_itr->second;
450  } else {
451  i2c_address = strtoul(settingName.c_str(), nullptr, 16); // convert string to integer using base 16
452  }
453  pair<unsigned int, unsigned int> p(i2c_address, i2c_values);
454  device_.push_back(p);
455  }
456  } while (!in.eof());
457 
458  in.close();
459 }
460 
462  std::set<pair<unsigned int, pair<unsigned int, unsigned int> > > sorted;
463 
464  for (unsigned int i = 0; i < device_.size(); i++) {
465  //cout<<key_.at(i)<<"\t"<<device_.at(i).first<<" "<<device_.at(i).second<<endl;
466  sorted.insert(make_pair(key_.at(i), device_.at(i)));
467  }
468 
469  // cout<<" -=-=-=-= done with sorting -=-=-="<<endl;
470  device_.clear();
471  for (set<pair<unsigned int, pair<unsigned int, unsigned int> > >::iterator i = sorted.begin(); i != sorted.end();
472  ++i) {
473  device_.push_back(i->second);
474  }
475 
476  // for (unsigned int i=0; i<device_.size(); i++ ) {
477  // cout<<" \t"<<device_.at(i).first<<" "<<device_.at(i).second<<endl;
478  // }
479 }
480 
481 unsigned int PixelPortCardConfig::new_PLL_CTR2_value(std::string CTR4or5, unsigned int last_CTR2) const {
482  if (CTR4or5 == k_PLL_CTR4)
483  return 0xdf & last_CTR2;
484  else if (CTR4or5 == k_PLL_CTR5)
485  return 0x20 | last_CTR2;
486  else
487  assert(0);
488 }
489 
490 void PixelPortCardConfig::setAOHGain(std::string settingName, unsigned int value) {
491  assert(settingName.find("AOH") != string::npos &&
492  settingName.find("Gain") != string::npos // contains both "AOH" and "Gain"
493  && settingName.find("123") == string::npos &&
494  settingName.find("456") == string::npos); // does not contain "123" or "456"
495 
496  unsigned int i2c_address;
497 
498  // Get the i2c address of this AOH, and the channel on the AOH.
499  string::size_type GainPosition = settingName.find("Gain");
500  unsigned int whichAOH;
501  if (settingName[GainPosition - 2] == 'H')
502  whichAOH = 0; // fpix
503  else // bpix
504  {
505  char whichAOHDigit[2] = {0, 0};
506  whichAOHDigit[0] = settingName[GainPosition - 2];
507  whichAOH = atoi(whichAOHDigit);
508  }
509  char digit[2] = {0, 0};
510  digit[0] = settingName[GainPosition + 4];
511  unsigned int channelOnAOH = atoi(digit);
512  assert((type_ == "fpix" && whichAOH == 0) || (type_ == "bpix" && 1 <= whichAOH && whichAOH <= 4));
513  assert(1 <= channelOnAOH && channelOnAOH <= 6);
514 
515  if (whichAOH == 0 && channelOnAOH <= 3)
516  i2c_address = k_fpix_AOH_Gain123_address;
517  else if (whichAOH == 0 && channelOnAOH >= 4)
518  i2c_address = k_fpix_AOH_Gain456_address;
519  else if (whichAOH == 1 && channelOnAOH <= 3)
520  i2c_address = k_bpix_AOH1_Gain123_address;
521  else if (whichAOH == 1 && channelOnAOH >= 4)
522  i2c_address = k_bpix_AOH1_Gain456_address;
523  else if (whichAOH == 2 && channelOnAOH <= 3)
524  i2c_address = k_bpix_AOH2_Gain123_address;
525  else if (whichAOH == 2 && channelOnAOH >= 4)
526  i2c_address = k_bpix_AOH2_Gain456_address;
527  else if (whichAOH == 3 && channelOnAOH <= 3)
528  i2c_address = k_bpix_AOH3_Gain123_address;
529  else if (whichAOH == 3 && channelOnAOH >= 4)
530  i2c_address = k_bpix_AOH3_Gain456_address;
531  else if (whichAOH == 4 && channelOnAOH <= 3)
532  i2c_address = k_bpix_AOH4_Gain123_address;
533  else if (whichAOH == 4 && channelOnAOH >= 4)
534  i2c_address = k_bpix_AOH4_Gain456_address;
535  else
536  assert(0);
537 
538  // Search for this address in the previously-defined settings.
539  bool foundOne = false;
540  for (unsigned int i = 0; i < device_.size(); i++) {
541  if (device_[i].first == i2c_address) // Change this setting in all previous instances
542  {
543  foundOne = true;
544  unsigned int oldValue = device_[i].second;
545  if (channelOnAOH % 3 == 1)
546  device_[i].second = (0x3c & oldValue) + ((value & 0x3) << 0); // replace bits 0 and 1 with value
547  else if (channelOnAOH % 3 == 2)
548  device_[i].second = (0x33 & oldValue) + ((value & 0x3) << 2); // replace bits 2 and 3 with value
549  else if (channelOnAOH % 3 == 0)
550  device_[i].second = (0x0f & oldValue) + ((value & 0x3) << 4); // replace bits 4 and 5 with value
551  else
552  assert(0);
553  //std::cout << "Changed setting "<< k_fpix_AOH_Gain123 <<"(address 0x"<<std::hex<<k_fpix_AOH_Gain123_address<<") from 0x"<<oldValue<<" to 0x"<< device_[i].second << std::dec <<"\n";
554  }
555  }
556  if (foundOne)
557  return;
558  else // If this was not set previously, add this setting with the other two gains set to zero.
559  {
560  unsigned int i2c_value;
561  if (channelOnAOH % 3 == 1)
562  i2c_value = ((value & 0x3) << 0);
563  else if (channelOnAOH % 3 == 2)
564  i2c_value = ((value & 0x3) << 2);
565  else if (channelOnAOH % 3 == 0)
566  i2c_value = ((value & 0x3) << 4);
567  else
568  assert(0);
569 
570  pair<unsigned int, unsigned int> p(i2c_address, i2c_value);
571  device_.push_back(p);
572  return;
573  }
574 }
575 
577  unsigned int i2c_address;
578 
579  // Get the i2c address of this AOH, and the channel on the AOH.
580  string::size_type GainPosition = settingName.find("GAIN");
581  unsigned int whichAOH;
582  if (type_ == "fpix") {
583  whichAOH = 0; // fpix
584  } else // bpix
585  {
586  char whichAOHDigit[2] = {0, 0};
587  whichAOHDigit[0] = settingName[GainPosition - 2];
588  whichAOH = atoi(whichAOHDigit);
589  }
590  char digit[2] = {0, 0};
591  digit[0] = settingName[GainPosition + 4];
592  unsigned int channelOnAOH = atoi(digit);
593  assert((type_ == "fpix" && whichAOH == 0) || (type_ == "bpix" && 1 <= whichAOH && whichAOH <= 4));
594  assert(1 <= channelOnAOH && channelOnAOH <= 6);
595 
596  if (whichAOH == 0 && channelOnAOH <= 3)
597  i2c_address = k_fpix_AOH_Gain123_address;
598  else if (whichAOH == 0 && channelOnAOH >= 4)
599  i2c_address = k_fpix_AOH_Gain456_address;
600  else if (whichAOH == 1 && channelOnAOH <= 3)
601  i2c_address = k_bpix_AOH1_Gain123_address;
602  else if (whichAOH == 1 && channelOnAOH >= 4)
603  i2c_address = k_bpix_AOH1_Gain456_address;
604  else if (whichAOH == 2 && channelOnAOH <= 3)
605  i2c_address = k_bpix_AOH2_Gain123_address;
606  else if (whichAOH == 2 && channelOnAOH >= 4)
607  i2c_address = k_bpix_AOH2_Gain456_address;
608  else if (whichAOH == 3 && channelOnAOH <= 3)
609  i2c_address = k_bpix_AOH3_Gain123_address;
610  else if (whichAOH == 3 && channelOnAOH >= 4)
611  i2c_address = k_bpix_AOH3_Gain456_address;
612  else if (whichAOH == 4 && channelOnAOH <= 3)
613  i2c_address = k_bpix_AOH4_Gain123_address;
614  else if (whichAOH == 4 && channelOnAOH >= 4)
615  i2c_address = k_bpix_AOH4_Gain456_address;
616  else
617  assert(0);
618 
619  // Search for this address in the previously-defined settings.
620  bool foundOne = false;
621  for (unsigned int i = 0; i < device_.size(); i++) {
622  if (device_[i].first == i2c_address) // Change this setting in all previous instances
623  {
624  foundOne = true;
625  unsigned int oldValue = device_[i].second;
626  if (channelOnAOH % 3 == 1)
627  device_[i].second = (0x3c & oldValue) + ((value & 0x3) << 0); // replace bits 0 and 1 with value
628  else if (channelOnAOH % 3 == 2)
629  device_[i].second = (0x33 & oldValue) + ((value & 0x3) << 2); // replace bits 2 and 3 with value
630  else if (channelOnAOH % 3 == 0)
631  device_[i].second = (0x0f & oldValue) + ((value & 0x3) << 4); // replace bits 4 and 5 with value
632  else
633  assert(0);
634  //std::cout << "Changed setting "<< k_fpix_AOH_Gain123 <<"(address 0x"<<std::hex<<k_fpix_AOH_Gain123_address<<") from 0x"<<oldValue<<" to 0x"<< device_[i].second << std::dec <<"\n";
635  }
636  }
637  if (foundOne)
638  return;
639  else // If this was not set previously, add this setting with the other two gains set to zero.
640  {
641  unsigned int i2c_value;
642  if (channelOnAOH % 3 == 1)
643  i2c_value = ((value & 0x3) << 0);
644  else if (channelOnAOH % 3 == 2)
645  i2c_value = ((value & 0x3) << 2);
646  else if (channelOnAOH % 3 == 0)
647  i2c_value = ((value & 0x3) << 4);
648  else
649  assert(0);
650 
651  pair<unsigned int, unsigned int> p(i2c_address, i2c_value);
652  device_.push_back(p);
653  key_.push_back(aohcount_++);
654  return;
655  }
656 }
657 
659  if (!nameToAddress_.empty())
660  return;
661 
662  if (type_ == "fpix") {
671 
676 
683 
688  } else if (type_ == "bpix") {
697 
706 
715 
724 
729 
736 
741  } else
742  assert(0);
743 
744  return;
745 }
746 
748  if (type_ == "fpix") {
749  // nameDBtoFileConversion_["CONFIG_KEY_ID" ] = ;
750  // nameDBtoFileConversion_["CONFIG_KEY" ] = ;
751  // nameDBtoFileConversion_["VERSION" ] = ;
752  // nameDBtoFileConversion_["CONDITION_DATA_SET_ID" ] = ;
753  // nameDBtoFileConversion_["KIND_OF_CONDITION_ID" ] = ;
754  // nameDBtoFileConversion_["KIND_OF_COND" ] = ;
755  // nameDBtoFileConversion_["SERIAL_NUMBER" ] = ;
756  // nameDBtoFileConversion_["PORT_CARD_ID" ] = ;
757  // nameDBtoFileConversion_["PORT_CARD" ] = ;
758  // nameDBtoFileConversion_["TRKFEC_NAME" ] = ;
759  // nameDBtoFileConversion_["RINGADDRESS" ] = ;
760  // nameDBtoFileConversion_["CHANNELADDRESS" ] = ;
761  // nameDBtoFileConversion_["CCUADDRESS" ] = ;
762  // nameDBtoFileConversion_["I2C_CNTRL" ] = ;
763  // nameDBtoFileConversion_["I2CSPEED" ] = ;
764  nameDBtoFileConversion_["AOH_BIAS1"] = k_AOH_Bias1;
765  nameDBtoFileConversion_["AOH_BIAS2"] = k_AOH_Bias2;
766  nameDBtoFileConversion_["AOH_BIAS3"] = k_AOH_Bias3;
767  nameDBtoFileConversion_["AOH_BIAS4"] = k_AOH_Bias4;
768  nameDBtoFileConversion_["AOH_BIAS5"] = k_AOH_Bias5;
769  nameDBtoFileConversion_["AOH_BIAS6"] = k_AOH_Bias6;
770  nameDBtoFileConversion_["AOH1_BIAS1"] = k_AOH1_Bias1;
771  nameDBtoFileConversion_["AOH1_BIAS2"] = k_AOH1_Bias2;
772  nameDBtoFileConversion_["AOH1_BIAS3"] = k_AOH1_Bias3;
773  nameDBtoFileConversion_["AOH1_BIAS4"] = k_AOH1_Bias4;
774  nameDBtoFileConversion_["AOH1_BIAS5"] = k_AOH1_Bias5;
775  nameDBtoFileConversion_["AOH1_BIAS6"] = k_AOH1_Bias6;
776  // nameDBtoFileConversion_["AOH1_GAIN1" ] = ;
777  // nameDBtoFileConversion_["AOH1_GAIN2" ] = ;
778  // nameDBtoFileConversion_["AOH1_GAIN3" ] = ;
779  // nameDBtoFileConversion_["AOH1_GAIN4" ] = ;
780  // nameDBtoFileConversion_["AOH1_GAIN5" ] = ;
781  // nameDBtoFileConversion_["AOH1_GAIN6" ] = ;
782  nameDBtoFileConversion_["AOH2_BIAS1"] = k_AOH2_Bias1;
783  nameDBtoFileConversion_["AOH2_BIAS2"] = k_AOH2_Bias2;
784  nameDBtoFileConversion_["AOH2_BIAS3"] = k_AOH2_Bias3;
785  nameDBtoFileConversion_["AOH2_BIAS4"] = k_AOH2_Bias4;
786  nameDBtoFileConversion_["AOH2_BIAS5"] = k_AOH2_Bias5;
787  nameDBtoFileConversion_["AOH2_BIAS6"] = k_AOH2_Bias6;
788  // nameDBtoFileConversion_["AOH2_GAIN1" ] = ;
789  // nameDBtoFileConversion_["AOH2_GAIN2" ] = ;
790  // nameDBtoFileConversion_["AOH2_GAIN3" ] = ;
791  // nameDBtoFileConversion_["AOH2_GAIN4" ] = ;
792  // nameDBtoFileConversion_["AOH2_GAIN5" ] = ;
793  // nameDBtoFileConversion_["AOH2_GAIN6" ] = ;
794  nameDBtoFileConversion_["AOH3_BIAS1"] = k_AOH3_Bias1;
795  nameDBtoFileConversion_["AOH3_BIAS2"] = k_AOH3_Bias2;
796  nameDBtoFileConversion_["AOH3_BIAS3"] = k_AOH3_Bias3;
797  nameDBtoFileConversion_["AOH3_BIAS4"] = k_AOH3_Bias4;
798  nameDBtoFileConversion_["AOH3_BIAS5"] = k_AOH3_Bias5;
799  nameDBtoFileConversion_["AOH3_BIAS6"] = k_AOH3_Bias6;
800  // nameDBtoFileConversion_["AOH3_GAIN1" ] = ;
801  // nameDBtoFileConversion_["AOH3_GAIN2" ] = ;
802  // nameDBtoFileConversion_["AOH3_GAIN3" ] = ;
803  // nameDBtoFileConversion_["AOH3_GAIN4" ] = ;
804  // nameDBtoFileConversion_["AOH3_GAIN5" ] = ;
805  // nameDBtoFileConversion_["AOH3_GAIN6" ] = ;
806  nameDBtoFileConversion_["AOH4_BIAS1"] = k_AOH4_Bias1;
807  nameDBtoFileConversion_["AOH4_BIAS2"] = k_AOH4_Bias2;
808  nameDBtoFileConversion_["AOH4_BIAS3"] = k_AOH4_Bias3;
809  nameDBtoFileConversion_["AOH4_BIAS4"] = k_AOH4_Bias4;
810  nameDBtoFileConversion_["AOH4_BIAS5"] = k_AOH4_Bias5;
811  nameDBtoFileConversion_["AOH4_BIAS6"] = k_AOH4_Bias6;
812  // nameDBtoFileConversion_["AOH4_GAIN1" ] = ;
813  // nameDBtoFileConversion_["AOH4_GAIN2" ] = ;
814  // nameDBtoFileConversion_["AOH4_GAIN3" ] = ;
815  // nameDBtoFileConversion_["AOH4_GAIN4" ] = ;
816  // nameDBtoFileConversion_["AOH4_GAIN5" ] = ;
817  // nameDBtoFileConversion_["AOH4_GAIN6" ] = ;
818  // nameDBtoFileConversion_["AOH5_BIAS1" ] = ;
819  // nameDBtoFileConversion_["AOH5_BIAS2" ] = ;
820  // nameDBtoFileConversion_["AOH5_BIAS3" ] = ;
821  // nameDBtoFileConversion_["AOH5_BIAS4" ] = ;
822  // nameDBtoFileConversion_["AOH5_BIAS5" ] = ;
823  // nameDBtoFileConversion_["AOH5_BIAS6" ] = ;
824  // nameDBtoFileConversion_["AOH5_GAIN1" ] = ;
825  // nameDBtoFileConversion_["AOH5_GAIN2" ] = ;
826  // nameDBtoFileConversion_["AOH5_GAIN3" ] = ;
827  // nameDBtoFileConversion_["AOH5_GAIN4" ] = ;
828  // nameDBtoFileConversion_["AOH5_GAIN5" ] = ;
829  // nameDBtoFileConversion_["AOH5_GAIN6" ] = ;
830  // nameDBtoFileConversion_["AOH6_BIAS1" ] = ;
831  // nameDBtoFileConversion_["AOH6_BIAS2" ] = ;
832  // nameDBtoFileConversion_["AOH6_BIAS3" ] = ;
833  // nameDBtoFileConversion_["AOH6_BIAS4" ] = ;
834  // nameDBtoFileConversion_["AOH6_BIAS5" ] = ;
835  // nameDBtoFileConversion_["AOH6_BIAS6" ] = ;
836  // nameDBtoFileConversion_["AOH6_GAIN1" ] = ;
837  // nameDBtoFileConversion_["AOH6_GAIN2" ] = ;
838  // nameDBtoFileConversion_["AOH6_GAIN3" ] = ;
839  // nameDBtoFileConversion_["AOH6_GAIN4" ] = ;
840  // nameDBtoFileConversion_["AOH6_GAIN5" ] = ;
841  // nameDBtoFileConversion_["AOH6_GAIN6" ] = ;
842  nameDBtoFileConversion_["DELAY25_GCR"] = k_Delay25_GCR;
843  nameDBtoFileConversion_["DELAY25_SCL"] = k_Delay25_SCL;
844  nameDBtoFileConversion_["DELAY25_TRG"] = k_Delay25_TRG;
845  nameDBtoFileConversion_["DELAY25_SDA"] = k_Delay25_SDA;
846  nameDBtoFileConversion_["DELAY25_RCL"] = k_Delay25_RCL;
847  nameDBtoFileConversion_["DELAY25_RDA"] = k_Delay25_RDA;
848  // nameDBtoFileConversion_["DEL3_GCR" ] = ;
849  // nameDBtoFileConversion_["DEL3_SCL" ] = ;
850  // nameDBtoFileConversion_["DEL3_TRG" ] = ;
851  // nameDBtoFileConversion_["DEL3_SDA" ] = ;
852  // nameDBtoFileConversion_["DEL3_RCL" ] = ;
853  // nameDBtoFileConversion_["DEL3_RDA" ] = ;
856  nameDBtoFileConversion_["DOH_SEU_GAIN"] = k_DOH_Gain_SEU;
857  // nameDBtoFileConversion_["DOH3_BIAS0" ] = ;
858  // nameDBtoFileConversion_["DOH3_BIAS1" ] = ;
859  // nameDBtoFileConversion_["DOH3_SEU_GAIN" ] = ;
860  nameDBtoFileConversion_["PLL_CTR1"] = k_PLL_CTR1;
861  nameDBtoFileConversion_["PLL_CTR2"] = k_PLL_CTR2;
862  nameDBtoFileConversion_["PLL_CTR3"] = k_PLL_CTR3;
863  nameDBtoFileConversion_["PLL_CTR4"] = k_PLL_CTR4;
864  nameDBtoFileConversion_["PLL_CTR5"] = k_PLL_CTR5;
865  // nameDBtoFileConversion_["PLL3_CTR1" ] = ;
866  // nameDBtoFileConversion_["PLL3_CTR2" ] = ;
867  // nameDBtoFileConversion_["PLL3_CTR3" ] = ;
868  // nameDBtoFileConversion_["PLL3_CTR4_5" ] = ;
869  } else if (type_ == "bpix") {
870  // nameDBtoFileConversion_["CONFIG_KEY_ID" ] = ;
871  // nameDBtoFileConversion_["CONFIG_KEY" ] = ;
872  // nameDBtoFileConversion_["VERSION" ] = ;
873  // nameDBtoFileConversion_["CONDITION_DATA_SET_ID" ] = ;
874  // nameDBtoFileConversion_["KIND_OF_CONDITION_ID" ] = ;
875  // nameDBtoFileConversion_["KIND_OF_COND" ] = ;
876  // nameDBtoFileConversion_["SERIAL_NUMBER" ] = ;
877  // nameDBtoFileConversion_["PORT_CARD_ID" ] = ;
878  // nameDBtoFileConversion_["PORT_CARD" ] = ;
879  // nameDBtoFileConversion_["TRKFEC_NAME" ] = ;
880  // nameDBtoFileConversion_["RINGADDRESS" ] = ;
881  // nameDBtoFileConversion_["CHANNELADDRESS" ] = ;
882  // nameDBtoFileConversion_["CCUADDRESS" ] = ;
883  // nameDBtoFileConversion_["I2C_CNTRL" ] = ;
884  // nameDBtoFileConversion_["I2CSPEED" ] = ;
885  nameDBtoFileConversion_["AOH1_BIAS1"] = k_AOH1_Bias1;
886  nameDBtoFileConversion_["AOH1_BIAS2"] = k_AOH1_Bias2;
887  nameDBtoFileConversion_["AOH1_BIAS3"] = k_AOH1_Bias3;
888  nameDBtoFileConversion_["AOH1_BIAS4"] = k_AOH1_Bias4;
889  nameDBtoFileConversion_["AOH1_BIAS5"] = k_AOH1_Bias5;
890  nameDBtoFileConversion_["AOH1_BIAS6"] = k_AOH1_Bias6;
891  // nameDBtoFileConversion_["AOH1_GAIN1" ] = ;
892  // nameDBtoFileConversion_["AOH1_GAIN2" ] = ;
893  // nameDBtoFileConversion_["AOH1_GAIN3" ] = ;
894  // nameDBtoFileConversion_["AOH1_GAIN4" ] = ;
895  // nameDBtoFileConversion_["AOH1_GAIN5" ] = ;
896  // nameDBtoFileConversion_["AOH1_GAIN6" ] = ;
897  nameDBtoFileConversion_["AOH2_BIAS1"] = k_AOH2_Bias1;
898  nameDBtoFileConversion_["AOH2_BIAS2"] = k_AOH2_Bias2;
899  nameDBtoFileConversion_["AOH2_BIAS3"] = k_AOH2_Bias3;
900  nameDBtoFileConversion_["AOH2_BIAS4"] = k_AOH2_Bias4;
901  nameDBtoFileConversion_["AOH2_BIAS5"] = k_AOH2_Bias5;
902  nameDBtoFileConversion_["AOH2_BIAS6"] = k_AOH2_Bias6;
903  // nameDBtoFileConversion_["AOH2_GAIN1" ] = ;
904  // nameDBtoFileConversion_["AOH2_GAIN2" ] = ;
905  // nameDBtoFileConversion_["AOH2_GAIN3" ] = ;
906  // nameDBtoFileConversion_["AOH2_GAIN4" ] = ;
907  // nameDBtoFileConversion_["AOH2_GAIN5" ] = ;
908  // nameDBtoFileConversion_["AOH2_GAIN6" ] = ;
909  nameDBtoFileConversion_["AOH3_BIAS1"] = k_AOH3_Bias1;
910  nameDBtoFileConversion_["AOH3_BIAS2"] = k_AOH3_Bias2;
911  nameDBtoFileConversion_["AOH3_BIAS3"] = k_AOH3_Bias3;
912  nameDBtoFileConversion_["AOH3_BIAS4"] = k_AOH3_Bias4;
913  nameDBtoFileConversion_["AOH3_BIAS5"] = k_AOH3_Bias5;
914  nameDBtoFileConversion_["AOH3_BIAS6"] = k_AOH3_Bias6;
915  // nameDBtoFileConversion_["AOH3_GAIN1" ] = ;
916  // nameDBtoFileConversion_["AOH3_GAIN2" ] = ;
917  // nameDBtoFileConversion_["AOH3_GAIN3" ] = ;
918  // nameDBtoFileConversion_["AOH3_GAIN4" ] = ;
919  // nameDBtoFileConversion_["AOH3_GAIN5" ] = ;
920  // nameDBtoFileConversion_["AOH3_GAIN6" ] = ;
921  nameDBtoFileConversion_["AOH4_BIAS1"] = k_AOH4_Bias1;
922  nameDBtoFileConversion_["AOH4_BIAS2"] = k_AOH4_Bias2;
923  nameDBtoFileConversion_["AOH4_BIAS3"] = k_AOH4_Bias3;
924  nameDBtoFileConversion_["AOH4_BIAS4"] = k_AOH4_Bias4;
925  nameDBtoFileConversion_["AOH4_BIAS5"] = k_AOH4_Bias5;
926  nameDBtoFileConversion_["AOH4_BIAS6"] = k_AOH4_Bias6;
927  // nameDBtoFileConversion_["AOH4_GAIN1" ] = ;
928  // nameDBtoFileConversion_["AOH4_GAIN2" ] = ;
929  // nameDBtoFileConversion_["AOH4_GAIN3" ] = ;
930  // nameDBtoFileConversion_["AOH4_GAIN4" ] = ;
931  // nameDBtoFileConversion_["AOH4_GAIN5" ] = ;
932  // nameDBtoFileConversion_["AOH4_GAIN6" ] = ;
933  // nameDBtoFileConversion_["AOH5_BIAS1" ] = ;
934  // nameDBtoFileConversion_["AOH5_BIAS2" ] = ;
935  // nameDBtoFileConversion_["AOH5_BIAS3" ] = ;
936  // nameDBtoFileConversion_["AOH5_BIAS4" ] = ;
937  // nameDBtoFileConversion_["AOH5_BIAS5" ] = ;
938  // nameDBtoFileConversion_["AOH5_BIAS6" ] = ;
939  // nameDBtoFileConversion_["AOH5_GAIN1" ] = ;
940  // nameDBtoFileConversion_["AOH5_GAIN2" ] = ;
941  // nameDBtoFileConversion_["AOH5_GAIN3" ] = ;
942  // nameDBtoFileConversion_["AOH5_GAIN4" ] = ;
943  // nameDBtoFileConversion_["AOH5_GAIN5" ] = ;
944  // nameDBtoFileConversion_["AOH5_GAIN6" ] = ;
945  // nameDBtoFileConversion_["AOH6_BIAS1" ] = ;
946  // nameDBtoFileConversion_["AOH6_BIAS2" ] = ;
947  // nameDBtoFileConversion_["AOH6_BIAS3" ] = ;
948  // nameDBtoFileConversion_["AOH6_BIAS4" ] = ;
949  // nameDBtoFileConversion_["AOH6_BIAS5" ] = ;
950  // nameDBtoFileConversion_["AOH6_BIAS6" ] = ;
951  // nameDBtoFileConversion_["AOH6_GAIN1" ] = ;
952  // nameDBtoFileConversion_["AOH6_GAIN2" ] = ;
953  // nameDBtoFileConversion_["AOH6_GAIN3" ] = ;
954  // nameDBtoFileConversion_["AOH6_GAIN4" ] = ;
955  // nameDBtoFileConversion_["AOH6_GAIN5" ] = ;
956  // nameDBtoFileConversion_["AOH6_GAIN6" ] = ;
957  nameDBtoFileConversion_["DELAY25_GCR"] = k_Delay25_GCR;
958  nameDBtoFileConversion_["DELAY25_SCL"] = k_Delay25_SCL;
959  nameDBtoFileConversion_["DELAY25_TRG"] = k_Delay25_TRG;
960  nameDBtoFileConversion_["DELAY25_SDA"] = k_Delay25_SDA;
961  nameDBtoFileConversion_["DELAY25_RCL"] = k_Delay25_RCL;
962  nameDBtoFileConversion_["DELAY25_RDA"] = k_Delay25_RDA;
963  // nameDBtoFileConversion_["DEL3_GCR" ] = ;
964  // nameDBtoFileConversion_["DEL3_SCL" ] = ;
965  // nameDBtoFileConversion_["DEL3_TRG" ] = ;
966  // nameDBtoFileConversion_["DEL3_SDA" ] = ;
967  // nameDBtoFileConversion_["DEL3_RCL" ] = ;
968  // nameDBtoFileConversion_["DEL3_RDA" ] = ;
971  nameDBtoFileConversion_["DOH_SEU_GAIN"] = k_DOH_Gain_SEU;
972  // nameDBtoFileConversion_["DOH3_BIAS0" ] = ;
973  // nameDBtoFileConversion_["DOH3_BIAS1" ] = ;
974  // nameDBtoFileConversion_["DOH3_SEU_GAIN" ] = ;
975  nameDBtoFileConversion_["PLL_CTR1"] = k_PLL_CTR1;
976  nameDBtoFileConversion_["PLL_CTR2"] = k_PLL_CTR2;
977  nameDBtoFileConversion_["PLL_CTR3"] = k_PLL_CTR3;
978  nameDBtoFileConversion_["PLL_CTR4"] = k_PLL_CTR4;
979  nameDBtoFileConversion_["PLL_CTR5"] = k_PLL_CTR5;
980  // nameDBtoFileConversion_["PLL3_CTR1" ] = ;
981  // nameDBtoFileConversion_["PLL3_CTR2" ] = ;
982  // nameDBtoFileConversion_["PLL3_CTR3" ] = ;
983  // nameDBtoFileConversion_["PLL3_CTR4_5" ] = ;
984  }
985 }
986 
988  std::string mthn = "[PixelPortCardConfig::writeASCII()]\t\t\t\t ";
989  if (!dir.empty())
990  dir += "/";
991  std::string filename = dir + "portcard_" + portcardname_ + ".dat";
992 
993  std::ofstream out(filename.c_str());
994  if (!out.good()) {
995  std::cout << __LINE__ << "]\t" << mthn << "Could not open file: " << filename.c_str() << std::endl;
996  assert(0);
997  }
998 
999  out << "Name: " << portcardname_ << std::endl;
1000  out << "Type: " << type_ << std::endl;
1001  out << "TKFECID: " << TKFECID_ << std::endl;
1002  out << "ringAddress: 0x" << std::hex << ringAddress_ << std::dec << std::endl;
1003  out << "ccuAddress: 0x" << std::hex << ccuAddress_ << std::dec << std::endl;
1004 
1005  out << "channelAddress: 0x" << std::hex << channelAddress_ << std::dec << std::endl;
1006 
1007  out << "i2cSpeed: 0x" << std::hex << i2cSpeed_ << std::dec << std::endl;
1008 
1009  bool found_PLL_CTR2 = false;
1010  unsigned int last_PLL_CTR2_value = 0x0;
1011  for (unsigned int i = 0; i < device_.size(); i++) {
1012  unsigned int deviceAddress = device_.at(i).first;
1013 
1014  // Special handling for AOH gains
1015  if ((type_ == "fpix" && deviceAddress == k_fpix_AOH_Gain123_address) ||
1016  (type_ == "fpix" && deviceAddress == k_fpix_AOH_Gain456_address) ||
1017  (type_ == "bpix" && deviceAddress == k_bpix_AOH1_Gain123_address) ||
1018  (type_ == "bpix" && deviceAddress == k_bpix_AOH1_Gain456_address) ||
1019  (type_ == "bpix" && deviceAddress == k_bpix_AOH2_Gain123_address) ||
1020  (type_ == "bpix" && deviceAddress == k_bpix_AOH2_Gain456_address) ||
1021  (type_ == "bpix" && deviceAddress == k_bpix_AOH3_Gain123_address) ||
1022  (type_ == "bpix" && deviceAddress == k_bpix_AOH3_Gain456_address) ||
1023  (type_ == "bpix" && deviceAddress == k_bpix_AOH4_Gain123_address) ||
1024  (type_ == "bpix" && deviceAddress == k_bpix_AOH4_Gain456_address)) {
1025  std::string whichAOHString;
1026  unsigned int zeroOrThree;
1027  if (type_ == "fpix" && deviceAddress == k_fpix_AOH_Gain123_address) {
1028  whichAOHString = "";
1029  zeroOrThree = 0;
1030  } else if (type_ == "fpix" && deviceAddress == k_fpix_AOH_Gain456_address) {
1031  whichAOHString = "";
1032  zeroOrThree = 3;
1033  } else if (type_ == "bpix" && deviceAddress == k_bpix_AOH1_Gain123_address) {
1034  whichAOHString = "1";
1035  zeroOrThree = 0;
1036  } else if (type_ == "bpix" && deviceAddress == k_bpix_AOH1_Gain456_address) {
1037  whichAOHString = "1";
1038  zeroOrThree = 3;
1039  } else if (type_ == "bpix" && deviceAddress == k_bpix_AOH2_Gain123_address) {
1040  whichAOHString = "2";
1041  zeroOrThree = 0;
1042  } else if (type_ == "bpix" && deviceAddress == k_bpix_AOH2_Gain456_address) {
1043  whichAOHString = "2";
1044  zeroOrThree = 3;
1045  } else if (type_ == "bpix" && deviceAddress == k_bpix_AOH3_Gain123_address) {
1046  whichAOHString = "3";
1047  zeroOrThree = 0;
1048  } else if (type_ == "bpix" && deviceAddress == k_bpix_AOH3_Gain456_address) {
1049  whichAOHString = "3";
1050  zeroOrThree = 3;
1051  } else if (type_ == "bpix" && deviceAddress == k_bpix_AOH4_Gain123_address) {
1052  whichAOHString = "4";
1053  zeroOrThree = 0;
1054  } else if (type_ == "bpix" && deviceAddress == k_bpix_AOH4_Gain456_address) {
1055  whichAOHString = "4";
1056  zeroOrThree = 3;
1057  } else
1058  assert(0);
1059 
1060  out << "AOH" << whichAOHString << "_Gain" << zeroOrThree + 1 << ": 0x" << (((device_[i].second) & 0x03) >> 0)
1061  << std::endl; // output bits 0 & 1
1062  out << "AOH" << whichAOHString << "_Gain" << zeroOrThree + 2 << ": 0x" << (((device_[i].second) & 0x0c) >> 2)
1063  << std::endl; // output bits 2 & 3
1064  out << "AOH" << whichAOHString << "_Gain" << zeroOrThree + 3 << ": 0x" << (((device_[i].second) & 0x30) >> 4)
1065  << std::endl; // output bits 4 & 5
1066  continue;
1067  }
1068  // End of special handling
1069 
1070  // Check to see if there's a name corresponding to this address.
1071  std::string settingName = "";
1072  for (std::map<std::string, unsigned int>::const_iterator nameToAddress_itr = nameToAddress_.begin();
1073  nameToAddress_itr != nameToAddress_.end();
1074  ++nameToAddress_itr) {
1075  // cout << "[PixelPortCardConfig::WriteASCII()]\tnameToAddress.first: " << nameToAddress_itr->first << endl ;
1076  // cout << "[PixelPortCardConfig::WriteASCII()]\tnameToAddress.second: " << nameToAddress_itr->second << endl ;
1077  // cout << "[PixelPortCardConfig::WriteASCII()]\tdeviceAddress: " << deviceAddress << endl ;
1078  if (nameToAddress_itr->second == deviceAddress) {
1079  settingName = nameToAddress_itr->first;
1080  break;
1081  }
1082  if (nameToAddress_itr == (--nameToAddress_.end())) {
1083  cout << "[PixelPortCardConfig::WriteASCII()]\tdeviceAddress: " << deviceAddress << " NOT FOUND" << endl;
1084  }
1085  }
1086 
1087  // Special handling for PLL addresses.
1088  if (settingName == k_PLL_CTR2) {
1089  if (found_PLL_CTR2 && last_PLL_CTR2_value == device_.at(i).second)
1090  continue; // don't save duplicate CTR2 settings
1091  found_PLL_CTR2 = true;
1092  last_PLL_CTR2_value = device_.at(i).second;
1093  }
1094  if (found_PLL_CTR2 && settingName == k_PLL_CTR4or5) // change name to PLL_CTR4 or PLL_CTR5
1095  {
1096  if ((last_PLL_CTR2_value & 0x20) == 0x0)
1097  settingName = k_PLL_CTR4;
1098  else
1099  settingName = k_PLL_CTR5;
1100  }
1101  // end of special handling
1102 
1103  if (settingName.empty())
1104  out << "0x" << std::hex << device_.at(i).first << std::dec;
1105  else
1106  out << settingName << ":";
1107 
1108  out << " 0x" << std::hex << device_.at(i).second << std::dec << std::endl;
1109  }
1110 
1111  out.close();
1112 }
1113 
1114 unsigned int PixelPortCardConfig::getdevicesize() const { return device_.size(); }
1115 
1117 
1118 unsigned int PixelPortCardConfig::getringAddress() const { return ringAddress_; }
1119 
1120 unsigned int PixelPortCardConfig::getccuAddress() const { return ccuAddress_; }
1121 
1123 
1124 unsigned int PixelPortCardConfig::geti2cSpeed() const { return i2cSpeed_; }
1125 
1127 
1128 unsigned int PixelPortCardConfig::getdeviceAddress(unsigned int i) const {
1129  assert(i < device_.size());
1130  return device_[i].first;
1131 }
1132 
1133 unsigned int PixelPortCardConfig::getdeviceValues(unsigned int i) const {
1134  assert(i < device_.size());
1135  return device_[i].second;
1136 }
1137 
1138 void PixelPortCardConfig::setdeviceValues(unsigned int address, unsigned int value) {
1139  for (int i = device_.size() - 1; i >= 0;
1140  i--) // Change only the last occurance of address, if there are more than one.
1141  {
1142  if (device_.at(i).first == address) {
1143  device_.at(i).second = value;
1144  return;
1145  }
1146  }
1147 
1148  // This address wasn't found in the list, so add it and its value.
1149  pair<unsigned int, unsigned int> p(address, value);
1150  device_.push_back(p);
1151 
1152  return;
1153 }
1154 
1155 void PixelPortCardConfig::setdeviceValues(std::string settingName, unsigned int value) {
1157  return;
1158 }
1159 
1161  //std::cout << "[PixelPortCardConfig::getdeviceAddressForSetting()]\t settingName: " << settingName<< std::endl ;
1162  std::map<std::string, unsigned int>::const_iterator foundName_itr = nameToAddress_.find(settingName);
1163  assert(foundName_itr != nameToAddress_.end());
1164  return foundName_itr->second;
1165 }
1166 
1169 }
1170 
1171 unsigned int PixelPortCardConfig::getdeviceValuesForAddress(unsigned int address) const {
1172  for (int i = device_.size() - 1; i >= 0; i--) // Get the last occurance of address, if there are more than one.
1173  {
1174  if (device_.at(i).first == address) {
1175  return device_.at(i).second;
1176  }
1177  }
1178  assert(0); // didn't find this device
1179  return 0;
1180 }
1181 
1182 bool PixelPortCardConfig::containsDeviceAddress(unsigned int deviceAddress) const {
1183  for (std::vector<std::pair<unsigned int, unsigned int> >::const_iterator device_itr = device_.begin();
1184  device_itr != device_.end();
1185  ++device_itr) {
1186  if (device_itr->first == deviceAddress)
1187  return true;
1188  }
1189  return false;
1190 }
1191 
1192 unsigned int PixelPortCardConfig::AOHBiasAddressFromAOHNumber(unsigned int AOHNumber) const {
1193  std::string mthn = "[PixelPortCardConfig::AOHBiasAddressFromAOHNumber()] ";
1194  if (type_ == "fpix") {
1195  if (AOHNumber == 1)
1197  else if (AOHNumber == 2)
1199  else if (AOHNumber == 3)
1201  else if (AOHNumber == 4)
1203  else if (AOHNumber == 5)
1205  else if (AOHNumber == 6)
1207  else {
1208  std::cout << __LINE__ << "]\t" << mthn
1209  << "ERROR: For fpix, AOH number must be in the range 1-6, but the given AOH number was " << AOHNumber
1210  << "." << std::endl;
1211  assert(0);
1212  }
1213  } else if (type_ == "bpix") {
1214  if (AOHNumber == 1)
1216  else if (AOHNumber == 2)
1218  else if (AOHNumber == 3)
1220  else if (AOHNumber == 4)
1222  else if (AOHNumber == 5)
1224  else if (AOHNumber == 6)
1226  else if (AOHNumber == 7)
1228  else if (AOHNumber == 8)
1230  else if (AOHNumber == 9)
1232  else if (AOHNumber == 10)
1234  else if (AOHNumber == 11)
1236  else if (AOHNumber == 12)
1238  else if (AOHNumber == 13)
1240  else if (AOHNumber == 14)
1242  else if (AOHNumber == 15)
1244  else if (AOHNumber == 16)
1246  else if (AOHNumber == 17)
1248  else if (AOHNumber == 18)
1250  else if (AOHNumber == 19)
1252  else if (AOHNumber == 20)
1254  else if (AOHNumber == 21)
1256  else if (AOHNumber == 22)
1258  else if (AOHNumber == 23)
1260  else if (AOHNumber == 24)
1262  else {
1263  std::cout << __LINE__ << "]\t" << mthn
1264  << "ERROR: For bpix, AOH number must be in the range 1-24, but the given AOH number was " << AOHNumber
1265  << "." << std::endl;
1266  assert(0);
1267  }
1268  } else
1269  assert(0);
1270 }
1271 
1273  std::string mthn = "[PixelPortCardConfig::AOHGainStringFromAOHNumber()] ";
1274  if (type_ == "fpix") {
1275  if (AOHNumber == 1)
1276  return "AOH_Gain1";
1277  else if (AOHNumber == 2)
1278  return "AOH_Gain2";
1279  else if (AOHNumber == 3)
1280  return "AOH_Gain3";
1281  else if (AOHNumber == 4)
1282  return "AOH_Gain4";
1283  else if (AOHNumber == 5)
1284  return "AOH_Gain5";
1285  else if (AOHNumber == 6)
1286  return "AOH_Gain6";
1287  else {
1288  std::cout << __LINE__ << "]\t" << mthn
1289  << "ERROR: For fpix, AOH number must be in the range 1-6, but the given AOH number was " << AOHNumber
1290  << "." << std::endl;
1291  assert(0);
1292  }
1293  } else if (type_ == "bpix") {
1294  if (AOHNumber == 1)
1295  return "AOH1_Gain1";
1296  else if (AOHNumber == 2)
1297  return "AOH1_Gain2";
1298  else if (AOHNumber == 3)
1299  return "AOH1_Gain3";
1300  else if (AOHNumber == 4)
1301  return "AOH1_Gain4";
1302  else if (AOHNumber == 5)
1303  return "AOH1_Gain5";
1304  else if (AOHNumber == 6)
1305  return "AOH1_Gain6";
1306  else if (AOHNumber == 7)
1307  return "AOH2_Gain1";
1308  else if (AOHNumber == 8)
1309  return "AOH2_Gain2";
1310  else if (AOHNumber == 9)
1311  return "AOH2_Gain3";
1312  else if (AOHNumber == 10)
1313  return "AOH2_Gain4";
1314  else if (AOHNumber == 11)
1315  return "AOH2_Gain5";
1316  else if (AOHNumber == 12)
1317  return "AOH2_Gain6";
1318  else if (AOHNumber == 13)
1319  return "AOH3_Gain1";
1320  else if (AOHNumber == 14)
1321  return "AOH3_Gain2";
1322  else if (AOHNumber == 15)
1323  return "AOH3_Gain3";
1324  else if (AOHNumber == 16)
1325  return "AOH3_Gain4";
1326  else if (AOHNumber == 17)
1327  return "AOH3_Gain5";
1328  else if (AOHNumber == 18)
1329  return "AOH3_Gain6";
1330  else if (AOHNumber == 19)
1331  return "AOH4_Gain1";
1332  else if (AOHNumber == 20)
1333  return "AOH4_Gain2";
1334  else if (AOHNumber == 21)
1335  return "AOH4_Gain3";
1336  else if (AOHNumber == 22)
1337  return "AOH4_Gain4";
1338  else if (AOHNumber == 23)
1339  return "AOH4_Gain5";
1340  else if (AOHNumber == 24)
1341  return "AOH4_Gain6";
1342  else {
1343  std::cout << __LINE__ << "]\t" << mthn
1344  << "ERROR: For bpix, AOH number must be in the range 1-24, but the given AOH number was " << AOHNumber
1345  << "." << std::endl;
1346  assert(0);
1347  }
1348  } else
1349  assert(0);
1350 }
1351 
1352 unsigned int PixelPortCardConfig::AOHGainAddressFromAOHNumber(unsigned int AOHNumber) const {
1353  std::string mthn = "[PixelPortCardConfig::AOHGainAddressFromAOHNumber()] ";
1354  unsigned int address;
1355  if (type_ == "fpix") {
1356  if (AOHNumber == 1)
1358  else if (AOHNumber == 2)
1360  else if (AOHNumber == 3)
1362  else if (AOHNumber == 4)
1364  else if (AOHNumber == 5)
1366  else if (AOHNumber == 6)
1368  else {
1369  std::cout << __LINE__ << "]\t" << mthn
1370  << "ERROR: For fpix, AOH number must be in the range 1-6, but the given AOH number was " << AOHNumber
1371  << "." << std::endl;
1372  assert(0);
1373  }
1374  } else if (type_ == "bpix") {
1375  if (AOHNumber == 1)
1377  else if (AOHNumber == 2)
1379  else if (AOHNumber == 3)
1381  else if (AOHNumber == 4)
1383  else if (AOHNumber == 5)
1385  else if (AOHNumber == 6)
1387  else if (AOHNumber == 7)
1389  else if (AOHNumber == 8)
1391  else if (AOHNumber == 9)
1393  else if (AOHNumber == 10)
1395  else if (AOHNumber == 11)
1397  else if (AOHNumber == 12)
1399  else if (AOHNumber == 13)
1401  else if (AOHNumber == 14)
1403  else if (AOHNumber == 15)
1405  else if (AOHNumber == 16)
1407  else if (AOHNumber == 17)
1409  else if (AOHNumber == 18)
1411  else if (AOHNumber == 19)
1413  else if (AOHNumber == 20)
1415  else if (AOHNumber == 21)
1417  else if (AOHNumber == 22)
1419  else if (AOHNumber == 23)
1421  else if (AOHNumber == 24)
1423  else {
1424  std::cout << __LINE__ << "]\t" << mthn
1425  << "ERROR: For bpix, AOH number must be in the range 1-24, but the given AOH number was " << AOHNumber
1426  << "." << std::endl;
1427  assert(0);
1428  }
1429  } else
1430  assert(0);
1431 
1432  return address;
1433 }
1434 
1435 unsigned int PixelPortCardConfig::getAOHGain(unsigned int AOHNumber) const {
1436  const unsigned int address = AOHGainAddressFromAOHNumber(AOHNumber);
1437  const unsigned int threeGainsValue = getdeviceValuesForAddress(address);
1438 
1439  if (AOHNumber % 3 == 1)
1440  return (((threeGainsValue)&0x03) >> 0); // return bits 0 & 1
1441  if (AOHNumber % 3 == 2)
1442  return (((threeGainsValue)&0x0c) >> 2); // return bits 2 & 3
1443  if (AOHNumber % 3 == 0)
1444  return (((threeGainsValue)&0x30) >> 4); // return bits 4 & 5
1445 
1446  assert(0);
1447 }
1448 //=============================================================================================
1450  int version,
1451  std::string path,
1452  std::ofstream *outstream,
1453  std::ofstream *out1stream,
1454  std::ofstream *out2stream) const {
1455  std::string mthn = "[PixelPortCardConfig::writeXMLHeader()]\t\t\t ";
1456  std::stringstream fullPath;
1457  fullPath << path << "/Pixel_PortCardSettings_" << PixelTimeFormatter::getmSecTime() << ".xml";
1458  std::cout << __LINE__ << "]\t" << mthn << "Writing to: " << fullPath.str() << std::endl;
1459 
1460  outstream->open(fullPath.str().c_str());
1461 
1462  *outstream << "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>" << std::endl;
1463  *outstream << "<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" << std::endl;
1464  *outstream << " <HEADER>" << std::endl;
1465  *outstream << " <TYPE>" << std::endl;
1466  *outstream << " <EXTENSION_TABLE_NAME>PIXEL_PORTCARD_SETTINGS</EXTENSION_TABLE_NAME>" << std::endl;
1467  *outstream << " <NAME>Pixel Port Card Settings</NAME>" << std::endl;
1468  *outstream << " </TYPE>" << std::endl;
1469  *outstream << " <RUN>" << std::endl;
1470  *outstream << " <RUN_TYPE>Pixel Port Card Settings</RUN_TYPE>" << std::endl;
1471  *outstream << " <RUN_NUMBER>1</RUN_NUMBER>" << std::endl;
1472  *outstream << " <RUN_BEGIN_TIMESTAMP>" << pos::PixelTimeFormatter::getTime() << "</RUN_BEGIN_TIMESTAMP>"
1473  << std::endl;
1474  *outstream << " <LOCATION>CERN P5</LOCATION>" << std::endl;
1475  *outstream << " </RUN>" << std::endl;
1476  *outstream << " </HEADER>" << std::endl;
1477  *outstream << "" << std::endl;
1478  *outstream << " <DATA_SET>" << std::endl;
1479  *outstream << " <PART>" << std::endl;
1480  *outstream << " <NAME_LABEL>CMS-PIXEL-ROOT</NAME_LABEL>" << std::endl;
1481  *outstream << " <KIND_OF_PART>Detector ROOT</KIND_OF_PART>" << std::endl;
1482  *outstream << " </PART>" << std::endl;
1483  *outstream << " <VERSION>" << version << "</VERSION>" << std::endl;
1484  *outstream << " <COMMENT_DESCRIPTION>" << getComment() << "</COMMENT_DESCRIPTION>" << std::endl;
1485  *outstream << " <CREATED_BY_USER>" << getAuthor() << "</CREATED_BY_USER>" << std::endl;
1486  *outstream << "" << std::endl;
1487 }
1488 
1489 //=============================================================================================
1490 void PixelPortCardConfig::writeXML(std::ofstream *outstream,
1491  std::ofstream *out1stream,
1492  std::ofstream *out2stream) const {
1493  std::string mthn = "[PixelPortCardConfig::writeXML()]\t\t\t ";
1494 
1495  *outstream << " <DATA>" << std::endl;
1496  *outstream << " <PORT_CARD>" << portcardname_ << "</PORT_CARD>" << std::endl;
1497  *outstream << " <TRKFEC>" << TKFECID_ << "</TRKFEC>" << std::endl;
1498  *outstream << " <RING>" << ringAddress_ << "</RING>" << std::endl;
1499  *outstream << " <CCU_ADDR>" << ccuAddress_ << "</CCU_ADDR>" << std::endl;
1500  *outstream << " <CHANNEL>" << channelAddress_ << "</CHANNEL>" << std::endl;
1501  *outstream << " <I2C_SPEED>" << i2cSpeed_ << "</I2C_SPEED>" << std::endl;
1502 
1503  bool found_PLL_CTR2 = false;
1504  unsigned int last_PLL_CTR2_value = 0x0;
1505  for (unsigned int i = 0; i < device_.size(); i++) {
1506  unsigned int deviceAddress = device_.at(i).first;
1507 
1508  // Special handling for AOH gains
1509  if ((type_ == "fpix" && deviceAddress == k_fpix_AOH_Gain123_address) ||
1510  (type_ == "fpix" && deviceAddress == k_fpix_AOH_Gain456_address) ||
1511  (type_ == "bpix" && deviceAddress == k_bpix_AOH1_Gain123_address) ||
1512  (type_ == "bpix" && deviceAddress == k_bpix_AOH1_Gain456_address) ||
1513  (type_ == "bpix" && deviceAddress == k_bpix_AOH2_Gain123_address) ||
1514  (type_ == "bpix" && deviceAddress == k_bpix_AOH2_Gain456_address) ||
1515  (type_ == "bpix" && deviceAddress == k_bpix_AOH3_Gain123_address) ||
1516  (type_ == "bpix" && deviceAddress == k_bpix_AOH3_Gain456_address) ||
1517  (type_ == "bpix" && deviceAddress == k_bpix_AOH4_Gain123_address) ||
1518  (type_ == "bpix" && deviceAddress == k_bpix_AOH4_Gain456_address)) {
1519  std::string whichAOHString;
1520  unsigned int zeroOrThree;
1521  if (type_ == "fpix" && deviceAddress == k_fpix_AOH_Gain123_address) {
1522  whichAOHString = "";
1523  zeroOrThree = 0;
1524  } else if (type_ == "fpix" && deviceAddress == k_fpix_AOH_Gain456_address) {
1525  whichAOHString = "";
1526  zeroOrThree = 3;
1527  } else if (type_ == "bpix" && deviceAddress == k_bpix_AOH1_Gain123_address) {
1528  whichAOHString = "1";
1529  zeroOrThree = 0;
1530  } else if (type_ == "bpix" && deviceAddress == k_bpix_AOH1_Gain456_address) {
1531  whichAOHString = "1";
1532  zeroOrThree = 3;
1533  } else if (type_ == "bpix" && deviceAddress == k_bpix_AOH2_Gain123_address) {
1534  whichAOHString = "2";
1535  zeroOrThree = 0;
1536  } else if (type_ == "bpix" && deviceAddress == k_bpix_AOH2_Gain456_address) {
1537  whichAOHString = "2";
1538  zeroOrThree = 3;
1539  } else if (type_ == "bpix" && deviceAddress == k_bpix_AOH3_Gain123_address) {
1540  whichAOHString = "3";
1541  zeroOrThree = 0;
1542  } else if (type_ == "bpix" && deviceAddress == k_bpix_AOH3_Gain456_address) {
1543  whichAOHString = "3";
1544  zeroOrThree = 3;
1545  } else if (type_ == "bpix" && deviceAddress == k_bpix_AOH4_Gain123_address) {
1546  whichAOHString = "4";
1547  zeroOrThree = 0;
1548  } else if (type_ == "bpix" && deviceAddress == k_bpix_AOH4_Gain456_address) {
1549  whichAOHString = "4";
1550  zeroOrThree = 3;
1551  } else
1552  assert(0);
1553 
1554  *outstream << " <AOH" << whichAOHString << "_GAIN" << zeroOrThree + 1 << ">"
1555  << (((device_[i].second) & 0x03) >> 0) << "</AOH" << whichAOHString << "_GAIN" << zeroOrThree + 1
1556  << ">" << std::endl; // output bits 0 & 1
1557  *outstream << " <AOH" << whichAOHString << "_GAIN" << zeroOrThree + 2 << ">"
1558  << (((device_[i].second) & 0x0c) >> 2) << "</AOH" << whichAOHString << "_GAIN" << zeroOrThree + 2
1559  << ">" << std::endl; // output bits 2 & 3
1560  *outstream << " <AOH" << whichAOHString << "_GAIN" << zeroOrThree + 3 << ">"
1561  << (((device_[i].second) & 0x30) >> 4) << "</AOH" << whichAOHString << "_GAIN" << zeroOrThree + 3
1562  << ">" << std::endl; // output bits 4 & 5
1563  continue;
1564  }
1565  // End of special handling
1566 
1567  // Check to see if there's a name corresponding to this address.
1568  std::string settingName = "";
1569  for (std::map<std::string, unsigned int>::const_iterator nameToAddress_itr = nameToAddress_.begin();
1570  nameToAddress_itr != nameToAddress_.end();
1571  ++nameToAddress_itr) {
1572  if (nameToAddress_itr->second == deviceAddress) {
1573  settingName = nameToAddress_itr->first;
1574  break;
1575  }
1576  }
1577  for (std::map<std::string, std::string>::const_iterator nameDBtoFileConversion_itr =
1578  nameDBtoFileConversion_.begin();
1579  nameDBtoFileConversion_itr != nameDBtoFileConversion_.end();
1580  ++nameDBtoFileConversion_itr) {
1581  if (nameDBtoFileConversion_itr->second.find(settingName) != std::string::npos) {
1582  settingName = nameDBtoFileConversion_itr->first;
1583  break;
1584  }
1585  }
1586 
1587  // Special handling for PLL addresses.
1588  if (settingName == k_PLL_CTR2) {
1589  if (found_PLL_CTR2 && last_PLL_CTR2_value == device_.at(i).second)
1590  continue; // don't save duplicate CTR2 settings
1591  found_PLL_CTR2 = true;
1592  last_PLL_CTR2_value = device_.at(i).second;
1593  }
1594  if (found_PLL_CTR2 && settingName == k_PLL_CTR4or5) // change name to PLL_CTR4 or PLL_CTR5
1595  {
1596  if ((last_PLL_CTR2_value & 0x20) == 0x0)
1597  settingName = k_PLL_CTR4;
1598  else
1599  settingName = k_PLL_CTR5;
1600  }
1601  // end of special handling
1602 
1603  if (settingName.empty())
1604  *outstream << device_.at(i).first;
1605  else
1606  *outstream << " <" << settingName << ">";
1607 
1608  *outstream << device_.at(i).second << "</" << settingName << ">" << std::endl;
1609  }
1610 
1611  *outstream << " </DATA>" << std::endl;
1612 }
1613 //=============================================================================================
1614 void PixelPortCardConfig::writeXMLTrailer(std::ofstream *outstream,
1615  std::ofstream *out1stream,
1616  std::ofstream *out2stream) const {
1617  std::string mthn = "[PixelPortCardConfig::writeXMLTrailer()]\t\t\t ";
1618 
1619  *outstream << " </DATA_SET>" << std::endl;
1620  *outstream << "</ROOT> " << std::endl;
1621 
1622  outstream->close();
1623 }
std::string AOHGainStringFromAOHNumber(unsigned int AOHNumber) const
void writeXML(pos::PixelConfigKey key, int version, std::string path) const override
const unsigned int k_bpix_AOH4_Bias6_address
const unsigned int k_fpix_AOH_Bias6_address
This file contains the base class for "pixel configuration data" management.
const unsigned int k_fpix_PLL_CTR4or5_address
const unsigned int k_bpix_AOH1_Gain123_address
unsigned int getdeviceAddress(unsigned int i) const
const unsigned int k_bpix_AOH3_Bias4_address
const unsigned int k_fpix_DOH_Ch1Bias_Data_address
unsigned int AOHGainAddressFromAOHNumber(unsigned int AOHNumber) const
const unsigned int k_bpix_AOH3_Bias3_address
unsigned int getccuAddress() const
const unsigned int k_bpix_AOH2_Bias3_address
const unsigned int k_fpix_DOH_Dummy_address
unsigned int geti2cSpeed() const
const unsigned int k_bpix_DOH_Dummy_address
const unsigned int k_bpix_AOH2_Bias5_address
std::string getComment() const
const unsigned int k_fpix_Delay25_GCR_address
std::map< std::string, unsigned int > nameToAddress_
const unsigned int k_fpix_PLL_CTR1_address
void writeASCII(std::string dir="") const override
std::map< std::string, std::string > nameDBtoFileConversion_
const unsigned int k_bpix_AOH4_Bias2_address
unsigned int getAOHGain(unsigned int AOHNumber) const
const unsigned int k_bpix_AOH1_Gain456_address
const unsigned int k_bpix_DOH_Ch1Bias_Data_address
const unsigned int k_bpix_AOH1_Bias4_address
unsigned int getdeviceValuesForAddress(unsigned int address) const
const unsigned int k_bpix_AOH3_Bias1_address
assert(be >=bs)
PixelPortCardConfig(std::vector< std::vector< std::string > > &tableMat)
const unsigned int k_bpix_AOH4_Gain456_address
uint16_t size_type
const unsigned int k_bpix_AOH3_Bias5_address
const unsigned int k_bpix_Delay25_SDA_address
const unsigned int k_bpix_AOH2_Bias2_address
static std::string getmSecTime(void)
const unsigned int k_bpix_Delay25_SCL_address
const unsigned int k_bpix_PLL_CTR2_address
const unsigned int k_bpix_Delay25_TRG_address
bool containsSetting(std::string settingName) const
const unsigned int k_bpix_AOH1_Bias2_address
const unsigned int k_bpix_AOH2_Gain456_address
const unsigned int k_bpix_AOH1_Bias3_address
const unsigned int k_bpix_PLL_CTR3_address
const unsigned int k_bpix_AOH4_Bias4_address
unsigned int getdevicesize() const
const unsigned int k_bpix_PLL_CTR4or5_address
void setDataBaseAOHGain(std::string settingName, unsigned int value)
const unsigned int k_bpix_AOH3_Bias6_address
const unsigned int k_bpix_AOH4_Gain123_address
const unsigned int k_bpix_AOH4_Bias3_address
void writeXMLTrailer(std::ofstream *out, std::ofstream *out1=nullptr, std::ofstream *out2=nullptr) const override
const unsigned int k_fpix_AOH_Bias5_address
unsigned int getdeviceValues(unsigned int i) const
static std::string getTime(void)
const unsigned int k_bpix_AOH4_Bias1_address
const unsigned int k_bpix_AOH1_Bias6_address
const unsigned int k_fpix_AOH_Bias2_address
unsigned int getchannelAddress() const
const unsigned int k_bpix_AOH1_Bias1_address
const unsigned int k_fpix_AOH_Gain123_address
unsigned int new_PLL_CTR2_value(std::string CTR4or5, unsigned int last_CTR2) const
const unsigned int k_fpix_Delay25_TRG_address
const unsigned int k_fpix_AOH_Bias4_address
This class provides utility methods to manipulate ASCII formatted timestamps.
const unsigned int k_bpix_AOH2_Gain123_address
const unsigned int k_bpix_AOH3_Gain123_address
key
prepare the HTCondor submission files and eventually submit them
const unsigned int k_bpix_DOH_Gain_SEU_address
const unsigned int k_bpix_Delay25_RCL_address
Definition: value.py:1
unsigned int getringAddress() const
void setdeviceValues(unsigned int address, unsigned int value)
const unsigned int k_bpix_DOH_Ch0Bias_CLK_address
const unsigned int k_bpix_Delay25_RDA_address
This class implements..
const unsigned int k_bpix_Delay25_GCR_address
void writeXMLHeader(pos::PixelConfigKey key, int version, std::string path, std::ofstream *out, std::ofstream *out1=nullptr, std::ofstream *out2=nullptr) const override
std::vector< std::pair< unsigned int, unsigned int > > device_
const unsigned int k_fpix_Delay25_SDA_address
unsigned int AOHBiasAddressFromAOHNumber(unsigned int AOHNumber) const
const unsigned int k_fpix_DOH_Ch0Bias_CLK_address
const unsigned int k_fpix_DOH_Gain_SEU_address
unsigned int getdeviceAddressForSetting(std::string settingName) const
const unsigned int k_fpix_PLL_CTR2_address
const unsigned int k_bpix_PLL_CTR1_address
const unsigned int k_fpix_Delay25_RCL_address
std::vector< unsigned int > key_
key used for sorting device_
const unsigned int k_fpix_Delay25_SCL_address
unsigned int getdeviceValuesForSetting(std::string settingName) const
const unsigned int k_fpix_AOH_Bias3_address
const unsigned int k_bpix_AOH1_Bias5_address
col
Definition: cuy.py:1009
std::string getAuthor() const
const unsigned int k_fpix_AOH_Gain456_address
std::string getTKFECID() const
void setAOHGain(unsigned int AOHNumber, unsigned int value)
const unsigned int k_bpix_AOH3_Bias2_address
const unsigned int k_fpix_PLL_CTR3_address
const unsigned int k_bpix_AOH3_Gain456_address
const unsigned int k_bpix_AOH2_Bias1_address
This class specifies the settings on the TKPCIFEC and the settings on the portcard.
const unsigned int k_bpix_AOH2_Bias6_address
const unsigned int k_bpix_AOH4_Bias5_address
const unsigned int k_fpix_AOH_Bias1_address
bool containsDeviceAddress(unsigned int deviceAddress) const
const unsigned int k_fpix_Delay25_RDA_address
const unsigned int k_bpix_AOH2_Bias4_address