CMS 3D CMS Logo

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