CMS 3D CMS Logo

PixelDACSettings.cc
Go to the documentation of this file.
1 //
2 // This class provide a base class for the
3 // pixel ROC DAC data for the pixel FEC configuration
4 //
5 //
6 //
7 //
8 
13 #include <fstream>
14 #include <iostream>
15 #include <ios>
16 #include <cassert>
17 #include <stdexcept>
18 #include <map>
19 #include <sstream>
20 #include <sys/time.h>
21 #include <cstdlib>
22 
23 using namespace pos;
24 
25 namespace {
26  const bool readTemperatures = false;
27  //const bool readTemperatures = true;
28  //const int temperatureReg = 0x9; // hardwire to fixed reference voltage 0x8 + 0x1
29  const int temperatureReg = 0x1; // hardwire to the usefull range, change to range 1, Marco's request, 25/10/11
30 } // namespace
31 
33  std::string mthn = "[PixelDACSettings::PixelDACSettings()]\t\t\t ";
34 
35  if (filename[filename.size() - 1] == 't') {
36  std::ifstream in(filename.c_str());
37 
38  if (!in.good()) {
39  std::cout << __LINE__ << "]\t" << mthn << "Could not open: " << filename << std::endl;
40  // assert(0); //in case of failure, we don't want POS to die here
41  throw std::runtime_error("Failed to open file " + filename);
42  } else {
43  // std::cout << "Opened:"<<filename<<std::endl;
44  }
45 
46  dacsettings_.clear();
47 
49 
50  in >> tag;
51 
52  while (!in.eof()) {
53  PixelROCName rocid(in);
54 
55  // std::cout << "[PixelDACSettings::PixelDACSettings()] DAC setting ROC id:"<<rocid<<std::endl;
56 
58 
59  tmp.read(in, rocid);
60 
61  // std::cout << "[PixelDACSettings::PixelDACSettings()] DACSetting: " << std::endl << tmp << std::endl ;
62  dacsettings_.push_back(tmp);
63 
64  in >> tag;
65 
66  assert(dacsettings_.size() < 100);
67  }
68 
69  in.close();
70 
71  } else {
72  std::ifstream in(filename.c_str(), std::ios::binary);
73 
74  if (!in.good()) {
75  std::cout << __LINE__ << "]\t" << mthn << "Could not open: " << filename << std::endl;
76  assert(0);
77  } else {
78  std::cout << __LINE__ << "]\t" << mthn << "Opened: " << filename << std::endl;
79  }
80 
81  char nchar;
82 
83  in.read(&nchar, 1);
84 
85  std::string s1;
86 
87  //wrote these lines of code without ref. needs to be fixed
88  for (int i = 0; i < nchar; i++) {
89  char c;
90  in >> c;
91  s1.push_back(c);
92  }
93 
94  //std::cout << __LINE__ << "]\t" << mthn << "READ ROC name: " << s1 << std::endl;
95 
96  dacsettings_.clear();
97 
98  while (!in.eof()) {
99  //std::cout << __LINE__ << "]\t" << mthn << "read s1 : " << s1 << std::endl;
100 
101  PixelROCName rocid(s1);
102 
103  //std::cout << __LINE__ << "]\t" << mthn << "read rocid: " << rocid << std::endl;
104 
106 
107  tmp.readBinary(in, rocid);
108 
109  dacsettings_.push_back(tmp);
110 
111  in.read(&nchar, 1);
112 
113  s1.clear();
114 
115  if (in.eof())
116  continue;
117 
118  //wrote these lines of code without ref. needs to be fixed
119  for (int i = 0; i < nchar; i++) {
120  char c;
121  in >> c;
122  s1.push_back(c);
123  }
124  }
125 
126  in.close();
127  }
128 
129  //std::cout << __LINE__ << "]\t" << mthn << "Read dac settings for "<<dacsettings_.size()<<" ROCs"<<std::endl;
130 }
131 // modified by MR on 10-01-2008 14:48:19
133  dacsettings_.push_back(rocname);
134 }
135 
136 // modified by MR on 24-01-2008 14:27:35a
137 void PixelDACSettings::addROC(PixelROCDACSettings& rocname) { dacsettings_.push_back(rocname); }
138 
139 PixelDACSettings::PixelDACSettings(std::vector<std::vector<std::string> >& tableMat) : PixelConfigBase("", "", "") {
140  /*
141  EXTENSION_TABLE_NAME: ROC_DAC_SETTINGS_COL (VIEW: CONF_KEY_ROCDAC_COL_V)
142 
143  CONFIG_KEY NOT NULL VARCHAR2(80)
144  KEY_TYPE NOT NULL VARCHAR2(80)
145  KEY_ALIAS NOT NULL VARCHAR2(80)
146  VERSION VARCHAR2(40)
147  KIND_OF_COND NOT NULL VARCHAR2(40)
148  ROC_NAME VARCHAR2(200)
149  VDD NOT NULL NUMBER(38)
150  VANA NOT NULL NUMBER(38)
151  VSF NOT NULL NUMBER(38)
152  VCOMP NOT NULL NUMBER(38)
153  VLEAK NOT NULL NUMBER(38)
154  VRGPR NOT NULL NUMBER(38)
155  VWLLPR NOT NULL NUMBER(38)
156  VRGSH NOT NULL NUMBER(38)
157  VWLLSH NOT NULL NUMBER(38)
158  VHLDDEL NOT NULL NUMBER(38)
159  VTRIM NOT NULL NUMBER(38)
160  VCTHR NOT NULL NUMBER(38)
161  VIBIAS_BUS NOT NULL NUMBER(38)
162  VIBIAS_SF NOT NULL NUMBER(38)
163  VOFFSETOP NOT NULL NUMBER(38)
164  VBIASOP NOT NULL NUMBER(38)
165  VOFFSETRO NOT NULL NUMBER(38)
166  VION NOT NULL NUMBER(38)
167  VIBIAS_PH NOT NULL NUMBER(38)
168  VIBIAS_DAC NOT NULL NUMBER(38)
169  VIBIAS_ROC NOT NULL NUMBER(38)
170  VICOLOR NOT NULL NUMBER(38)
171  VNPIX NOT NULL NUMBER(38)
172  VSUMCOL NOT NULL NUMBER(38)
173  VCAL NOT NULL NUMBER(38)
174  CALDEL NOT NULL NUMBER(38)
175  TEMPRANGE NOT NULL NUMBER(38)
176  WBC NOT NULL NUMBER(38)
177  CHIPCONTREG NOT NULL NUMBER(38)
178 */
179  // std::multimap<std::string,std::pair<std::string,int > > pDSM;
180  // std::stringstream currentRocName;
181  std::vector<std::string> ins = tableMat[0];
182  std::string mthn("[PixelDACSettings::PixelDACSettings()] ");
183  std::string dacName;
184  std::istringstream dbin;
185  // int dacValue;
186  int skipColumns = 0;
187  std::map<std::string, int> colM;
188  std::vector<std::string> colNames;
189  std::map<std::string, std::string> nameTranslation;
190 
191  colNames.push_back("CONFIG_KEY");
192  colNames.push_back("KEY_TYPE");
193  colNames.push_back("KEY_ALIAS");
194  colNames.push_back("VERSION");
195  colNames.push_back("KIND_OF_COND");
196  colNames.push_back("ROC_NAME");
197  colNames.push_back("VDD");
198  colNames.push_back("VANA");
199  colNames.push_back("VSF");
200  colNames.push_back("VCOMP");
201  colNames.push_back("VLEAK");
202  colNames.push_back("VRGPR");
203  colNames.push_back("VWLLPR");
204  colNames.push_back("VRGSH");
205  colNames.push_back("VWLLSH");
206  colNames.push_back("VHLDDEL");
207  colNames.push_back("VTRIM");
208  colNames.push_back("VCTHR");
209  colNames.push_back("VIBIAS_BUS");
210  colNames.push_back("VIBIAS_SF");
211  colNames.push_back("VOFFSETOP");
212  colNames.push_back("VBIASOP");
213  colNames.push_back("VOFFSETRO");
214  colNames.push_back("VION");
215  colNames.push_back("VIBIAS_PH");
216  colNames.push_back("VIBIAS_DAC");
217  colNames.push_back("VIBIAS_ROC");
218  colNames.push_back("VICOLOR");
219  colNames.push_back("VNPIX");
220  colNames.push_back("VSUMCOL");
221  colNames.push_back("VCAL");
222  colNames.push_back("CALDEL");
223  colNames.push_back("TEMPRANGE");
224  colNames.push_back("WBC");
225  colNames.push_back("CHIPCONTREG");
226 
227  nameTranslation["VDD"] = k_DACName_Vdd;
228  nameTranslation["VANA"] = k_DACName_Vana;
229  nameTranslation["VSF"] = k_DACName_Vsf;
230  nameTranslation["VCOMP"] = k_DACName_Vcomp;
231  nameTranslation["VLEAK"] = k_DACName_Vleak;
232  nameTranslation["VRGPR"] = k_DACName_VrgPr;
233  nameTranslation["VWLLPR"] = k_DACName_VwllPr;
234  nameTranslation["VRGSH"] = k_DACName_VrgSh;
235  nameTranslation["VWLLSH"] = k_DACName_VwllSh;
236  nameTranslation["VHLDDEL"] = k_DACName_VHldDel;
237  nameTranslation["VTRIM"] = k_DACName_Vtrim;
238  nameTranslation["VCTHR"] = k_DACName_VcThr;
239  nameTranslation["VIBIAS_BUS"] = k_DACName_VIbias_bus;
240  nameTranslation["VIBIAS_SF"] = k_DACName_VIbias_sf;
241  nameTranslation["VOFFSETOP"] = k_DACName_VOffsetOp;
242  nameTranslation["VBIASOP"] = k_DACName_VbiasOp;
243  nameTranslation["VOFFSETRO"] = k_DACName_VOffsetRO;
244  nameTranslation["VION"] = k_DACName_VIon;
245  nameTranslation["VIBIAS_PH"] = k_DACName_VIbias_PH;
246  nameTranslation["VIBIAS_DAC"] = k_DACName_VIbias_DAC;
247  nameTranslation["VIBIAS_ROC"] = k_DACName_VIbias_roc;
248  nameTranslation["VICOLOR"] = k_DACName_VIColOr;
249  nameTranslation["VNPIX"] = k_DACName_Vnpix;
250  nameTranslation["VSUMCOL"] = k_DACName_VsumCol;
251  nameTranslation["VCAL"] = k_DACName_Vcal;
252  nameTranslation["CALDEL"] = k_DACName_CalDel;
253  nameTranslation["TEMPRANGE"] = k_DACName_TempRange;
254  nameTranslation["WBC"] = k_DACName_WBC;
255  nameTranslation["CHIPCONTREG"] = k_DACName_ChipContReg;
256 
257  // modified by MR on 25-02-2008 10:00:45
258  // colM stores the index (referred to tableMat) where the specified dac setting is store!!!
259  for (unsigned int c = skipColumns; c < ins.size(); c++) {
260  for (unsigned int n = 0; n < colNames.size(); n++) {
261  if (tableMat[0][c] == colNames[n]) {
262  colM[colNames[n]] = c;
263  break;
264  }
265  }
266  } //end for
267  for (unsigned int n = skipColumns; n < colNames.size(); n++) {
268  if (colM.find(colNames[n]) == colM.end()) {
269  std::cerr << "[PixelDACSettings::PixelDACSettings()]\tCouldn't find in the database the column with name "
270  << colNames[n] << std::endl;
271  assert(0);
272  }
273  }
274 
275  dacsettings_.clear();
276  // struct timeval start_time ;
277  // struct timeval end_time ;
278  // gettimeofday(&start_time, (struct timezone *)0 );
279  for (unsigned int r = 1; r < tableMat.size(); r++) { //Goes to every row of the Matrix
280  // currentRocName.str("");
281  // currentRocName << tableMat[r][colM["NAME"]] ;
282  //currentRocName << "FPix_BmI_D" << tableMat[r][colM["HDISK_POSN"]]
283  // << "_BLD" << tableMat[r][colM["BLD_POSN"]]
284  // << "_PNL" << tableMat[r][colM["PANEL_POSITION"]]
285  // << "_PLQ" << tableMat[r][colM["PLAQ_POS"]]
286  // << "_ROC" << tableMat[r][colM["ROC_POSN"]];
287 
288  // modified by MR on 25-02-2008 10:04:55
289  PixelROCName rocid(tableMat[r][colM["ROC_NAME"]]);
290  PixelROCDACSettings tmp(rocid);
291  std::ostringstream dacs("");
292  // +6 to get rid of the first 5 columns not pertaining DAC Settings...
293  for (unsigned int n = skipColumns + 6; n < colNames.size(); n++) {
294  dacs << nameTranslation[colNames[n]] << ": " << atoi(tableMat[r][colM[colNames[n]]].c_str()) << std::endl;
295  // dacName = colNames[n];
296  // dacValue = atoi(tableMat[r][colM[colNames[n]]].c_str());
297  // pDSM.insert(std::pair<std::string,std::pair<std::string,int> >(tableMat[r][colM["ROC_NAME"]],std::pair<std::string,int>(dacName,dacValue)));
298  // std::cout << "On " << tableMat[r][colM["ROC_NAME"]] << " DAC:\t" << dacName << " value:\t" << dacValue<< std::endl ;
299  // tmp.setDac(dacName, dacValue) ;
300  }
301  // tmp.setDACs(tmpDACs) ;
302  dbin.str(dacs.str());
303  tmp.read(dbin, rocid);
304  dacsettings_.push_back(tmp);
305  } //end for r
306  // gettimeofday(&end_time, (struct timezone *)0 );
307  // int total_usecs = (end_time.tv_sec - start_time.tv_sec)*1000000 + (end_time.tv_usec - start_time.tv_usec);
308  // std::cout << mthn << "Time taken : " << total_usecs / 1000000. << " secs" << std::endl;
309 
310  // dacsettings_.clear();
311  // std::string currentRocName2 = "";
312  // for(std::multimap<std::string,std::pair<std::string,int> >::iterator tableMapIt=pDSM.begin(); tableMapIt!= pDSM.end(); tableMapIt++){
313  // if(currentRocName2 != tableMapIt->first){
314  // std::cout << tableMapIt->first << std::endl;
315  // std::cout << tableMapIt->second.first << std::endl;
316  // std::cout << tableMapIt->second.second << std::endl;
317  // currentRocName2 = tableMapIt->first;
318  // PixelROCName rocid(currentRocName2);
319 
320  // // std::cout << "DAC setting ROC id:"<<rocid<<std::endl;
321 
322  // PixelROCDACSettings tmp(rocid);
323 
324  // // tmp.read(in,rocid);
325 
326  // dacsettings_.push_back(tmp);
327  // }//end if
328  // dacsettings_[dacsettings_.size()-1].setDac(tableMapIt->second.first,tableMapIt->second.second);
329  // }//end for
330 
331  // for(unsigned int w = 0 ; w < dacsettings_.size() ; w++)
332  // {
333 
334  // PixelROCDACSettings tmp2 = dacsettings_[w];
335  // // std::cout<<tmp2<<std::endl;
336  // }
337  // std::cout<<"Number of ROCs in the PixelDACSettings::PixelDACSettings(vector <vector<string> >):"<<dacsettings_.size()<<std::endl;
338  // std::cout << "[PixelDACSettings::PixelDACSettings(std::vector)] before end of constructor" << std::endl ;
339 } //end PDSMatrix constructor
340 //end added by Umesh
341 
343 
345  for (unsigned int i = 0; i < dacsettings_.size(); i++) {
346  if (dacsettings_[i].getROCName() == name)
347  return &(dacsettings_[i]);
348  }
349 
350  return nullptr;
351 }
352 
354  std::ofstream out(filename.c_str(), std::ios::binary);
355 
356  for (unsigned int i = 0; i < dacsettings_.size(); i++) {
357  dacsettings_[i].writeBinary(out);
358  }
359 }
360 
362  std::string mthn = "[PixelDACSettings::writeASCII()]\t\t\t ";
363  PixelModuleName module(dacsettings_[0].getROCName().rocname());
364 
365  std::string filename = dir + "/ROC_DAC_module_" + module.modulename() + ".dat";
366  std::cout << __LINE__ << "]\t" << mthn << "Writing to file " << filename << std::endl;
367  std::ofstream out(filename.c_str());
368 
369  for (unsigned int i = 0; i < dacsettings_.size(); i++) {
370  dacsettings_[i].writeASCII(out);
371  }
372 }
373 
374 //=============================================================================================
376  int version,
378  std::ofstream* outstream,
379  std::ofstream* out1stream,
380  std::ofstream* out2stream) const {
381  std::string mthn = "[PixelDACSettings::writeXMLHeader()]\t\t\t ";
382  std::stringstream fullPath;
383 
384  fullPath << path << "/Pixel_RocDacSettings_" << PixelTimeFormatter::getmSecTime() << ".xml";
385  std::cout << __LINE__ << "]\t" << mthn << "Writing to: " << fullPath.str() << std::endl;
386 
387  outstream->open(fullPath.str().c_str());
388 
389  *outstream << "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>" << std::endl;
390  *outstream << "<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" << std::endl;
391  *outstream << "" << std::endl;
392  *outstream << " <!-- " << mthn << "-->" << std::endl;
393  *outstream << "" << std::endl;
394  *outstream << " <HEADER>" << std::endl;
395  *outstream << " <TYPE>" << std::endl;
396  *outstream << " <EXTENSION_TABLE_NAME>ROC_DAC_SETTINGS_COL</EXTENSION_TABLE_NAME>" << std::endl;
397  *outstream << " <NAME>ROC DAC Settings Col</NAME>" << std::endl;
398  *outstream << " </TYPE>" << std::endl;
399  *outstream << " <RUN>" << std::endl;
400  *outstream << " <RUN_TYPE>ROC DAC Settings</RUN_TYPE>" << std::endl;
401  *outstream << " <RUN_NUMBER>1</RUN_NUMBER>" << std::endl;
402  *outstream << " <RUN_BEGIN_TIMESTAMP>" << PixelTimeFormatter::getTime() << "</RUN_BEGIN_TIMESTAMP>" << std::endl;
403  *outstream << " <LOCATION>CERN P5</LOCATION>" << std::endl;
404  *outstream << " </RUN>" << std::endl;
405  *outstream << " </HEADER>" << std::endl;
406  *outstream << "" << std::endl;
407  *outstream << " <DATA_SET>" << std::endl;
408  *outstream << " <VERSION>" << version << "</VERSION>" << std::endl;
409  *outstream << " <COMMENT_DESCRIPTION>" << getComment() << "</COMMENT_DESCRIPTION>" << std::endl;
410  *outstream << " <CREATED_BY_USER>" << getAuthor() << "</CREATED_BY_USER>" << std::endl;
411  *outstream << " " << std::endl;
412  *outstream << " <PART>" << std::endl;
413  *outstream << " <NAME_LABEL>CMS-PIXEL-ROOT</NAME_LABEL>" << std::endl;
414  *outstream << " <KIND_OF_PART>Detector ROOT</KIND_OF_PART>" << std::endl;
415  *outstream << " </PART>" << std::endl;
416  *outstream << " " << std::endl;
417 
418  std::cout << __LINE__ << "]\t" << mthn << "Header written" << std::endl;
419 }
420 
421 //=============================================================================================
422 void PixelDACSettings::writeXML(std::ofstream* outstream, std::ofstream* out1stream, std::ofstream* out2stream) const {
423  std::string mthn = "[PixelDACSettings::writeXML()]\t\t\t ";
424 
425  for (unsigned int i = 0; i < dacsettings_.size(); i++) {
426  dacsettings_[i].writeXML(outstream);
427  }
428 }
429 
430 //=============================================================================================
431 void PixelDACSettings::writeXMLTrailer(std::ofstream* outstream,
432  std::ofstream* out1stream,
433  std::ofstream* out2stream) const {
434  std::string mthn = "[PixelDACSettings::writeXMLTrailer()]\t\t\t ";
435 
436  *outstream << " </DATA_SET>" << std::endl;
437  *outstream << "</ROOT>" << std::endl;
438 
439  outstream->close();
440  std::cout << __LINE__ << "]\t" << mthn << "Data written" << std::endl;
441 }
442 
443 /* O B S O L E T E -----
444 
445 //=============================================================================================
446 void PixelDACSettings::writeXML(pos::PixelConfigKey key, int version, std::string path) const {
447  std::string mthn = "[PixelDACSettings::writeXML()]\t\t\t " ;
448  std::stringstream fullPath ;
449 
450  PixelModuleName module(dacsettings_[0].getROCName().rocname());
451  fullPath << path << "/dacsettings_" << module.modulename() << ".xml" ;
452  std::cout << mthn << "Writing to: |" << fullPath.str() << "|" << std::endl ;
453 
454 
455  std::ofstream outstream(fullPath.str().c_str()) ;
456 
457  out << "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>" << std::endl ;
458  out << "<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" << std::endl ;
459  out << " <HEADER>" << std::endl ;
460  out << " <TYPE>" << std::endl ;
461  out << " <EXTENSION_TABLE_NAME>ROC_DAC_SETTINGS_COL</EXTENSION_TABLE_NAME>" << std::endl ;
462  out << " <NAME>ROC DAC Settings Col</NAME>" << std::endl ;
463  out << " </TYPE>" << std::endl ;
464  out << " <RUN>" << std::endl ;
465  out << " <RUN_TYPE>test</RUN_TYPE>" << std::endl ;
466  out << " <RUN_NUMBER>1</RUN_NUMBER>" << std::endl ;
467  out << " <RUN_BEGIN_TIMESTAMP>" << PixelTimeFormatter::getTime() << "</RUN_BEGIN_TIMESTAMP>" << std::endl ;
468  out << " <COMMENT_DESCRIPTION>Test of DAC Settings xml</COMMENT_DESCRIPTION>" << std::endl ;
469  out << " <LOCATION>CERN TAC</LOCATION>" << std::endl ;
470  out << " <CREATED_BY_USER>Dario Menasce</CREATED_BY_USER>" << std::endl ;
471  out << " </RUN>" << std::endl ;
472  out << " </HEADER>" << std::endl ;
473  out << "" << std::endl ;
474  out << " <DATA_SET>" << std::endl ;
475  out << " <VERSION>" << version << "</VERSION>" << std::endl ;
476  out << " " << std::endl ;
477  out << " <PART>" << std::endl ;
478  out << " <NAME_LABEL>CMS-PIXEL-ROOT</NAME_LABEL>" << std::endl ;
479  out << " <KIND_OF_PART>Detector ROOT</KIND_OF_PART>" << std::endl ;
480  out << " </PART>" << std::endl ;
481  out << " " << std::endl ;
482 
483  for(unsigned int i=0;i<dacsettings_.size();i++){
484 // dacsettings_[i].writeXML(out, key, version, path);
485  }
486 
487  out << " </DATA_SET>" << std::endl ;
488  out << "</ROOT>" << std::endl ;
489 
490  out.close() ;
491  std::cout << mthn << "Data written" << std::endl ;
492 }
493 */
494 
495 //=============================================================================================
497  PixelNameTranslation* trans,
498  PixelDetectorConfig* detconfig,
499  bool HVon) const {
500  bool bufferData = true;
501 
502  std::vector<unsigned int> dacs;
503 
504  //pixelFEC->fecDebug(1); //FIXME someday maybe don't want to take the time
505 
506  for (unsigned int i = 0; i < dacsettings_.size(); i++) { // loop over ROCs
507 
508  bool disableRoc = rocIsDisabled(detconfig, dacsettings_[i].getROCName());
509 
510  dacsettings_[i].getDACs(dacs);
511 
512  PixelHdwAddress theROC = *(trans->getHdwAddress(dacsettings_[i].getROCName()));
513 
514  //Need to set readout speed (40MHz) and Vcal range (0-1800 mV) and enable the chip
515 
516  // This is not needed. The ControlReg is programmed in setAllDAC(). d.k. 21.01.11
517  // pixelFEC->progdac(theROC.mfec(),
518  // theROC.mfecchannel(),
519  // theROC.hubaddress(),
520  // theROC.portaddress(),
521  // theROC.rocid(),
522  // 0xfd,
523  // controlreg,
524  // bufferData);
525 
526  if (!HVon || disableRoc)
527  dacs[11] = 0; //set Vcthr DAC to 0 (Vcthr is DAC 12=11+1)
528  // std::cout<<" ; setting VcThr to "<<dacs[11]<<std::endl; //for debugging
529  pixelFEC->setAllDAC(theROC, dacs, bufferData);
530 
531  // start with no pixels on for calibration
532  pixelFEC->clrcal(
533  theROC.mfec(), theROC.mfecchannel(), theROC.hubaddress(), theROC.portaddress(), theROC.rocid(), bufferData);
534 
535  const bool kmeKLUDGE = false;
536  if (kmeKLUDGE) //enable one pixel per ROC for calibration (all the time!)
537  {
538  unsigned int col = 0;
539  //for(unsigned int col=0;col<52;col+=50) //try 0, 50
540  {
541  pixelFEC->calpix(theROC.mfec(),
542  theROC.mfecchannel(),
543  theROC.hubaddress(),
544  theROC.portaddress(),
545  theROC.rocid(),
546  col, //column
547  0, //row
548  1, //caldata
549  bufferData);
550  }
551  }
552 
553  // enable all the double columns
554  for (int dcol = 0; dcol < 26; dcol++) {
555  pixelFEC->dcolenable(theROC.mfec(),
556  theROC.mfecchannel(),
557  theROC.hubaddress(),
558  theROC.portaddress(),
559  theROC.rocid(),
560  dcol,
561  1,
562  bufferData);
563  }
564 
565  if (!HVon || disableRoc) { //HV off
566  int controlreg = dacsettings_[i].getControlRegister();
567  // std::cout << "[PixelDACSettings::generateConfiguration] HV off! ROC control reg to be set to: " << (controlreg|0x2) <<std::endl;
568  pixelFEC->progdac(theROC.mfec(),
569  theROC.mfecchannel(),
570  theROC.hubaddress(),
571  theROC.portaddress(),
572  theROC.rocid(),
573  0xfd,
574  controlreg | 0x2, //=010 in binary. should disable the chip
575  bufferData);
576  } //HV off
577 
578  // Now program (again) the temperature register to make sure it is the last one
579  // and appears in the LastDAC
580  if (readTemperatures) {
581  // std::cout<<"ROC="<<dacsettings_[i].getROCName()<<" ; VcThr set to "<<dacs[11]
582  // << " ROC control reg to be set to: " << dacs[28] <<" LastDAC=Temp"<<std::endl;
583  if ((theROC.mfec() == 1) && (theROC.mfecchannel() == 1) && (theROC.hubaddress() == 0) &&
584  (theROC.portaddress() == 0) && (theROC.rocid()))
585  std::cout << "ROC=" << dacsettings_[i].getROCName() << " ROC control reg to be set to: " << dacs[28]
586  << " LastDAC=Temp " << temperatureReg << std::endl;
587  //int temperatureReg = dacs[26]; // overwrite with the number from DB
588  pixelFEC->progdac(theROC.mfec(),
589  theROC.mfecchannel(),
590  theROC.hubaddress(),
591  theROC.portaddress(),
592  theROC.rocid(),
593  0x1B,
594  temperatureReg,
595  bufferData);
596  } else {
597  // std::cout<<"ROC="<<dacsettings_[i].getROCName()<<" ; VcThr set to "<<dacs[11]
598  // << " ROC control reg to be set to: " << dacs[28] <<" LastDAC=Vcal"<<std::endl;
599  if ((theROC.mfec() == 1) && (theROC.mfecchannel() == 1) && (theROC.hubaddress() == 0) &&
600  (theROC.portaddress() == 0) && (theROC.rocid()))
601  std::cout << "ROC=" << dacsettings_[i].getROCName() << " ROC control reg to be set to: " << dacs[28]
602  << " LastDAC=Vcal" << std::endl;
603  // VCAL
604  pixelFEC->progdac(theROC.mfec(),
605  theROC.mfecchannel(),
606  theROC.hubaddress(),
607  theROC.portaddress(),
608  theROC.rocid(),
609  0x19,
610  200,
611  bufferData);
612  }
613 
614  } // end ROC loop
615 
616  if (bufferData) { // Send data to the FEC
617  pixelFEC->qbufsend();
618  }
619 }
620 
622  //the point here is to set Vcthr to 0
623  //then disable the ROCs
624 
625  //note -- no need to look at the detconfig here, because we're going to disable everything no matter what
626 
627  bool bufferData = true;
628 
629  std::vector<unsigned int> dacs;
630 
631  for (unsigned int i = 0; i < dacsettings_.size(); i++) { //loop over the ROCs
632 
633  dacsettings_[i].getDACs(dacs);
634  int controlreg = dacsettings_[i].getControlRegister();
635 
636  PixelHdwAddress theROC = *(trans->getHdwAddress(dacsettings_[i].getROCName()));
637 
638  //std::cout<<"disabling ROC="<<dacsettings_[i].getROCName()<<std::endl;
639  pixelFEC->progdac(theROC.mfec(),
640  theROC.mfecchannel(),
641  theROC.hubaddress(),
642  theROC.portaddress(),
643  theROC.rocid(),
644  12, //12 == Vcthr
645  0, //set Vcthr to 0
646  bufferData);
647 
648  //this should disable the roc
649  pixelFEC->progdac(theROC.mfec(),
650  theROC.mfecchannel(),
651  theROC.hubaddress(),
652  theROC.portaddress(),
653  theROC.rocid(),
654  0xfd,
655  controlreg | 0x2,
656  bufferData);
657 
658  // Now program (again) the temperature register to make sure it is the last one
659  // and appears in the LastDAC
660  if (readTemperatures) {
661  //int temperatureReg = dacs[26]; // value from DB
662  pixelFEC->progdac(theROC.mfec(),
663  theROC.mfecchannel(),
664  theROC.hubaddress(),
665  theROC.portaddress(),
666  theROC.rocid(),
667  0x1B,
668  temperatureReg,
669  bufferData);
670  } else {
671  // VCAL
672  pixelFEC->progdac(theROC.mfec(),
673  theROC.mfecchannel(),
674  theROC.hubaddress(),
675  theROC.portaddress(),
676  theROC.rocid(),
677  0x19,
678  200,
679  bufferData);
680  }
681  }
682 
683  if (bufferData) { //just copying the way it was done in the existing method
684  pixelFEC->qbufsend();
685  }
686 }
687 
689  PixelNameTranslation* trans,
690  PixelDetectorConfig* detconfig) const {
691  //the point here is to set Vcthr to the nominal values
692  //then enable the ROCs
693 
694  bool bufferData = true;
695 
696  std::vector<unsigned int> dacs;
697 
698  for (unsigned int i = 0; i < dacsettings_.size(); i++) { //loop over the ROCs
699 
700  bool disableRoc =
701  rocIsDisabled(detconfig, dacsettings_[i].getROCName()); //don't enable ROCs that are disabled in the detconfig
702 
703  //std::cout<<"ROC="<<dacsettings_[i].getROCName()<<" ; VcThr set to "<<dacs[11]
704  // << " ; ROC control reg to be set to: " << controlreg <<std::endl;
705 
706  if (!disableRoc) { // Disable
707 
708  dacsettings_[i].getDACs(dacs);
709  int controlreg = dacsettings_[i].getControlRegister();
710 
711  PixelHdwAddress theROC = *(trans->getHdwAddress(dacsettings_[i].getROCName()));
712 
713  pixelFEC->progdac(theROC.mfec(),
714  theROC.mfecchannel(),
715  theROC.hubaddress(),
716  theROC.portaddress(),
717  theROC.rocid(),
718  12, //12 == Vcthr
719  dacs[11],
720  bufferData);
721 
722  //enable the roc (assuming controlreg was set for the roc to be enabled)
723 
724  pixelFEC->progdac(theROC.mfec(),
725  theROC.mfecchannel(),
726  theROC.hubaddress(),
727  theROC.portaddress(),
728  theROC.rocid(),
729  0xfd,
730  controlreg,
731  bufferData);
732 
733  // Now program (again) the temperature register to make sure it is the last one
734  // and appears in the LastDAC
735  if (readTemperatures) {
736  //int temperatureReg = dacs[26]; // value from DB
737  pixelFEC->progdac(theROC.mfec(),
738  theROC.mfecchannel(),
739  theROC.hubaddress(),
740  theROC.portaddress(),
741  theROC.rocid(),
742  0x1B,
743  temperatureReg,
744  bufferData);
745  } else {
746  // VCAL
747  pixelFEC->progdac(theROC.mfec(),
748  theROC.mfecchannel(),
749  theROC.hubaddress(),
750  theROC.portaddress(),
751  theROC.rocid(),
752  0x19,
753  200,
754  bufferData);
755  }
756 
757  } // end disable
758 
759  } // loop over ROCs
760 
761  if (bufferData) { // Send data to FEC
762  pixelFEC->qbufsend();
763  }
764 }
765 
766 bool PixelDACSettings::rocIsDisabled(const PixelDetectorConfig* detconfig, const PixelROCName rocname) const {
767  const std::map<PixelROCName, PixelROCStatus>& roclist = detconfig->getROCsList();
768  const std::map<PixelROCName, PixelROCStatus>::const_iterator iroc = roclist.find(rocname);
769  assert(iroc != roclist.end()); // the roc name should always be found
770  PixelROCStatus thisROCstatus = iroc->second;
771 
772  return thisROCstatus.get(PixelROCStatus::noAnalogSignal);
773 }
774 
775 std::ostream& operator<<(std::ostream& s, const PixelDACSettings& dacs) {
776  s << dacs.getDACSettings(0) << std::endl;
777 
778  return s;
779 }
const std::string k_DACName_VcThr
Definition: PixelDACNames.h:24
const std::string k_DACName_VrgPr
Definition: PixelDACNames.h:18
void addROC(PixelROCDACSettings &rocname)
virtual int clrcal(int mfec, int fecchannel, int hubaddress, int portaddress, int rocid, bool buffermode=false)=0
This file contains the base class for "pixel configuration data" management.
const std::string k_DACName_ChipContReg
Definition: PixelDACNames.h:41
void writeXMLTrailer(std::ofstream *out, std::ofstream *out1=nullptr, std::ofstream *out2=nullptr) const override
virtual int progdac(int mfec, int fecchannel, int hubaddress, int portaddress, int rocid, int dacaddress, int dacvalue, bool buffermode=false)=0
const std::string k_DACName_Vsf
Definition: PixelDACNames.h:15
const std::string k_DACName_CalDel
Definition: PixelDACNames.h:38
const std::string k_DACName_TempRange
Definition: PixelDACNames.h:39
void writeXML(pos::PixelConfigKey key, int version, std::string path) const override
const std::string k_DACName_VIbias_sf
Definition: PixelDACNames.h:26
void setVcthrEnable(PixelFECConfigInterface *pixelFEC, PixelNameTranslation *trans, PixelDetectorConfig *detconfig) const
unsigned int mfec() const
const std::string k_DACName_Vtrim
Definition: PixelDACNames.h:23
std::string getComment() const
virtual int calpix(int mfec, int mfecchannel, int hubaddress, int portaddress, int rocid, int coladdr, int rowaddress, int caldata, bool buffermode=false)=0
const std::string k_DACName_VIbias_DAC
Definition: PixelDACNames.h:32
const std::string k_DACName_VwllSh
Definition: PixelDACNames.h:21
const std::string k_DACName_Vnpix
Definition: PixelDACNames.h:35
const std::string k_DACName_Vleak
Definition: PixelDACNames.h:17
virtual int dcolenable(int mfec, int mfecchannel, int hubaddress, int portaddress, int rocid, int dcol, int dcolstate, bool buffermode=false)=0
const std::string k_DACName_VIbias_PH
Definition: PixelDACNames.h:31
const std::string k_DACName_VOffsetRO
Definition: PixelDACNames.h:29
const std::string k_DACName_VIbias_bus
Definition: PixelDACNames.h:25
std::ostream & operator<<(std::ostream &s, const PixelCalibConfiguration &calib)
assert(be >=bs)
ins
Definition: cuy.py:313
const std::string k_DACName_VIColOr
Definition: PixelDACNames.h:34
static std::string getmSecTime(void)
This class provide the data structure for the ROC DAC parameters.
const std::string k_DACName_VOffsetOp
Definition: PixelDACNames.h:27
unsigned int portaddress() const
void setVcthrDisable(PixelFECConfigInterface *pixelFEC, PixelNameTranslation *trans) const
PixelROCDACSettings getDACSettings(int ROCId) const
This class is responsible for manipulating the DACsettings of a ROC.
static std::string getTime(void)
bool rocIsDisabled(const PixelDetectorConfig *detconfig, const PixelROCName rocname) const
This is the documentation about PixelDetectorConfig...
This class provides utility methods to manipulate ASCII formatted timestamps.
Store mfec, mfecchannel etc.
const std::map< PixelROCName, PixelROCStatus > & getROCsList() const
const PixelHdwAddress * getHdwAddress(const PixelROCName &aROC) const
std::vector< PixelROCDACSettings > dacsettings_
unsigned int mfecchannel() const
void writeBinary(std::string filename) const
const std::string k_DACName_VbiasOp
Definition: PixelDACNames.h:28
const std::string k_DACName_VIbias_roc
Definition: PixelDACNames.h:33
const std::string k_DACName_Vcal
Definition: PixelDACNames.h:37
virtual int qbufsend(void)=0
PixelDACSettings(std::string filename)
This class provide a base class for the pixel ROC dac data for the pixel FEC configuration.
unsigned int rocid() const
const std::string k_DACName_VrgSh
Definition: PixelDACNames.h:20
This class implements..
const std::string k_DACName_VIon
Definition: PixelDACNames.h:30
const std::string k_DACName_Vcomp
Definition: PixelDACNames.h:16
const std::string k_DACName_WBC
Definition: PixelDACNames.h:40
void writeASCII(std::string dir) const override
const std::string k_DACName_Vdd
Definition: PixelDACNames.h:13
const std::string k_DACName_VHldDel
Definition: PixelDACNames.h:22
This is the documentation about PixelNameTranslation...
const std::string k_DACName_VsumCol
Definition: PixelDACNames.h:36
This class implements..
This class implements..
Definition: PixelROCName.h:23
This class implements..
void generateConfiguration(PixelFECConfigInterface *pixelFEC, PixelNameTranslation *trans, PixelDetectorConfig *detconfig, bool HVon=true) const
col
Definition: cuy.py:1009
std::string getAuthor() const
A dummy class with ALL public variables.
This class implements..
void writeXMLHeader(pos::PixelConfigKey key, int version, std::string path, std::ofstream *out, std::ofstream *out1=nullptr, std::ofstream *out2=nullptr) const override
tmp
align.sh
Definition: createJobs.py:716
unsigned int hubaddress() const
const std::string k_DACName_Vana
Definition: PixelDACNames.h:14
virtual void setAllDAC(const PixelHdwAddress &theROC, const std::vector< unsigned int > &dacs, const bool buffermode=false)=0
bool get(ROCstatus stat) const
const std::string k_DACName_VwllPr
Definition: PixelDACNames.h:19