Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:47:28

0001 //
0002 // This class provide the data structure for the
0003 // ROC DAC parameters
0004 //
0005 // At this point I do not see a reason to make an
0006 // abstract layer for this code.
0007 //
0008 
0009 #include "CalibFormats/SiPixelObjects/interface/PixelROCDACSettings.h"
0010 #include "CalibFormats/SiPixelObjects/interface/PixelDACNames.h"
0011 #include <fstream>
0012 #include <iostream>
0013 
0014 using namespace pos;
0015 using namespace std;
0016 
0017 PixelROCDACSettings::PixelROCDACSettings() {}
0018 
0019 void PixelROCDACSettings::getDACs(vector<unsigned int>& dacs) const {
0020   dacs.clear();
0021   dacs.push_back(Vdd_);
0022   dacs.push_back(Vana_);
0023   dacs.push_back(Vsf_);
0024   dacs.push_back(Vcomp_);
0025   dacs.push_back(Vleak_);
0026   dacs.push_back(VrgPr_);
0027   dacs.push_back(VwllPr_);
0028   dacs.push_back(VrgSh_);
0029   dacs.push_back(VwllSh_);
0030   dacs.push_back(VHldDel_);
0031   dacs.push_back(Vtrim_);
0032   dacs.push_back(VcThr_);
0033   dacs.push_back(VIbias_bus_);
0034   dacs.push_back(VIbias_sf_);
0035   dacs.push_back(VOffsetOp_);
0036   dacs.push_back(VbiasOp_);
0037   dacs.push_back(VOffsetRO_);
0038   dacs.push_back(VIon_);
0039   dacs.push_back(VIbias_PH_);
0040   dacs.push_back(VIbias_DAC_);
0041   dacs.push_back(VIbias_roc_);
0042   dacs.push_back(VIColOr_);
0043   dacs.push_back(Vnpix_);
0044   dacs.push_back(VsumCol_);
0045   dacs.push_back(Vcal_);
0046   dacs.push_back(CalDel_);
0047   dacs.push_back(TempRange_);
0048   dacs.push_back(WBC_);
0049   dacs.push_back(ChipContReg_);
0050 }
0051 
0052 // Added by Dario
0053 void PixelROCDACSettings::getDACs(std::map<std::string, unsigned int>& dacs) const {
0054   dacs.clear();
0055   dacs[k_DACName_Vdd] = Vdd_;
0056   dacs[k_DACName_Vana] = Vana_;
0057   dacs[k_DACName_Vsf] = Vsf_;
0058   dacs[k_DACName_Vcomp] = Vcomp_;
0059   dacs[k_DACName_Vleak] = Vleak_;
0060   dacs[k_DACName_VrgPr] = VrgPr_;
0061   dacs[k_DACName_VwllPr] = VwllPr_;
0062   dacs[k_DACName_VrgSh] = VrgSh_;
0063   dacs[k_DACName_VwllSh] = VwllSh_;
0064   dacs[k_DACName_VHldDel] = VHldDel_;
0065   dacs[k_DACName_Vtrim] = Vtrim_;
0066   dacs[k_DACName_VcThr] = VcThr_;
0067   dacs[k_DACName_VIbias_bus] = VIbias_bus_;
0068   dacs[k_DACName_VIbias_sf] = VIbias_sf_;
0069   dacs[k_DACName_VOffsetOp] = VOffsetOp_;
0070   dacs[k_DACName_VbiasOp] = VbiasOp_;
0071   dacs[k_DACName_VOffsetRO] = VOffsetRO_;
0072   dacs[k_DACName_VIon] = VIon_;
0073   dacs[k_DACName_VIbias_PH] = VIbias_PH_;
0074   dacs[k_DACName_VIbias_DAC] = VIbias_DAC_;
0075   dacs[k_DACName_VIbias_roc] = VIbias_roc_;
0076   dacs[k_DACName_VIColOr] = VIColOr_;
0077   dacs[k_DACName_Vnpix] = Vnpix_;
0078   dacs[k_DACName_VsumCol] = VsumCol_;
0079   dacs[k_DACName_Vcal] = Vcal_;
0080   dacs[k_DACName_CalDel] = CalDel_;
0081   dacs[k_DACName_TempRange] = TempRange_;
0082   dacs[k_DACName_WBC] = WBC_;
0083   dacs[k_DACName_ChipContReg] = ChipContReg_;
0084 }
0085 
0086 // Added by Dario
0087 void PixelROCDACSettings::setDACs(std::map<std::string, unsigned int>& dacs) {
0088   Vdd_ = dacs[k_DACName_Vdd];
0089   Vana_ = dacs[k_DACName_Vana];
0090   Vsf_ = dacs[k_DACName_Vsf];
0091   Vcomp_ = dacs[k_DACName_Vcomp];
0092   Vleak_ = dacs[k_DACName_Vleak];
0093   VrgPr_ = dacs[k_DACName_VrgPr];
0094   VwllPr_ = dacs[k_DACName_VwllPr];
0095   VrgSh_ = dacs[k_DACName_VrgSh];
0096   VwllSh_ = dacs[k_DACName_VwllSh];
0097   VHldDel_ = dacs[k_DACName_VHldDel];
0098   Vtrim_ = dacs[k_DACName_Vtrim];
0099   VcThr_ = dacs[k_DACName_VcThr];
0100   VIbias_bus_ = dacs[k_DACName_VIbias_bus];
0101   VIbias_sf_ = dacs[k_DACName_VIbias_sf];
0102   VOffsetOp_ = dacs[k_DACName_VOffsetOp];
0103   VbiasOp_ = dacs[k_DACName_VbiasOp];
0104   VOffsetRO_ = dacs[k_DACName_VOffsetRO];
0105   VIon_ = dacs[k_DACName_VIon];
0106   VIbias_PH_ = dacs[k_DACName_VIbias_PH];
0107   VIbias_DAC_ = dacs[k_DACName_VIbias_DAC];
0108   VIbias_roc_ = dacs[k_DACName_VIbias_roc];
0109   VIColOr_ = dacs[k_DACName_VIColOr];
0110   Vnpix_ = dacs[k_DACName_Vnpix];
0111   VsumCol_ = dacs[k_DACName_VsumCol];
0112   Vcal_ = dacs[k_DACName_Vcal];
0113   CalDel_ = dacs[k_DACName_CalDel];
0114   TempRange_ = dacs[k_DACName_TempRange];
0115   WBC_ = dacs[k_DACName_WBC];
0116   ChipContReg_ = dacs[k_DACName_ChipContReg];
0117 }
0118 
0119 // Added by Dario
0120 void PixelROCDACSettings::compareDACs(std::map<std::string, unsigned int>& dacs,
0121                                       std::map<std::string, bool>& changes,
0122                                       std::map<std::string, unsigned int>& previous) {
0123   changes[k_DACName_Vdd] = false;
0124   changes[k_DACName_Vana] = false;
0125   changes[k_DACName_Vsf] = false;
0126   changes[k_DACName_Vcomp] = false;
0127   changes[k_DACName_Vleak] = false;
0128   changes[k_DACName_VrgPr] = false;
0129   changes[k_DACName_VwllPr] = false;
0130   changes[k_DACName_VrgSh] = false;
0131   changes[k_DACName_VwllSh] = false;
0132   changes[k_DACName_VHldDel] = false;
0133   changes[k_DACName_Vtrim] = false;
0134   changes[k_DACName_VcThr] = false;
0135   changes[k_DACName_VIbias_bus] = false;
0136   changes[k_DACName_VIbias_sf] = false;
0137   changes[k_DACName_VOffsetOp] = false;
0138   changes[k_DACName_VbiasOp] = false;
0139   changes[k_DACName_VOffsetRO] = false;
0140   changes[k_DACName_VIon] = false;
0141   changes[k_DACName_VIbias_PH] = false;
0142   changes[k_DACName_VIbias_DAC] = false;
0143   changes[k_DACName_VIbias_roc] = false;
0144   changes[k_DACName_VIColOr] = false;
0145   changes[k_DACName_Vnpix] = false;
0146   changes[k_DACName_VsumCol] = false;
0147   changes[k_DACName_Vcal] = false;
0148   changes[k_DACName_CalDel] = false;
0149   changes[k_DACName_TempRange] = false;
0150   changes[k_DACName_WBC] = false;
0151   changes[k_DACName_ChipContReg] = false;
0152 
0153   if (Vdd_ != dacs[k_DACName_Vdd]) {
0154     changes[k_DACName_Vdd] = true;
0155     previous[k_DACName_Vdd] = Vdd_;
0156   }
0157   if (Vana_ != dacs[k_DACName_Vana]) {
0158     changes[k_DACName_Vana] = true;
0159     previous[k_DACName_Vana] = Vana_;
0160   }
0161   if (Vsf_ != dacs[k_DACName_Vsf]) {
0162     changes[k_DACName_Vsf] = true;
0163     previous[k_DACName_Vsf] = Vsf_;
0164   }
0165   if (Vcomp_ != dacs[k_DACName_Vcomp]) {
0166     changes[k_DACName_Vcomp] = true;
0167     previous[k_DACName_Vcomp] = Vcomp_;
0168   }
0169   if (Vleak_ != dacs[k_DACName_Vleak]) {
0170     changes[k_DACName_Vleak] = true;
0171     previous[k_DACName_Vleak] = Vleak_;
0172   }
0173   if (VrgPr_ != dacs[k_DACName_VrgPr]) {
0174     changes[k_DACName_VrgPr] = true;
0175     previous[k_DACName_VrgPr] = VrgPr_;
0176   }
0177   if (VwllPr_ != dacs[k_DACName_VwllPr]) {
0178     changes[k_DACName_VwllPr] = true;
0179     previous[k_DACName_VwllPr] = VwllPr_;
0180   }
0181   if (VrgSh_ != dacs[k_DACName_VrgSh]) {
0182     changes[k_DACName_VrgSh] = true;
0183     previous[k_DACName_VrgSh] = VrgSh_;
0184   }
0185   if (VwllSh_ != dacs[k_DACName_VwllSh]) {
0186     changes[k_DACName_VwllSh] = true;
0187     previous[k_DACName_VwllSh] = VwllSh_;
0188   }
0189   if (VHldDel_ != dacs[k_DACName_VHldDel]) {
0190     changes[k_DACName_VHldDel] = true;
0191     previous[k_DACName_VHldDel] = VHldDel_;
0192   }
0193   if (Vtrim_ != dacs[k_DACName_Vtrim]) {
0194     changes[k_DACName_Vtrim] = true;
0195     previous[k_DACName_Vtrim] = Vtrim_;
0196   }
0197   if (VcThr_ != dacs[k_DACName_VcThr]) {
0198     changes[k_DACName_VcThr] = true;
0199     previous[k_DACName_VcThr] = VcThr_;
0200   }
0201   if (VIbias_bus_ != dacs[k_DACName_VIbias_bus]) {
0202     changes[k_DACName_VIbias_bus] = true;
0203     previous[k_DACName_VIbias_bus] = VIbias_bus_;
0204   }
0205   if (VIbias_sf_ != dacs[k_DACName_VIbias_sf]) {
0206     changes[k_DACName_VIbias_sf] = true;
0207     previous[k_DACName_VIbias_sf] = VIbias_sf_;
0208   }
0209   if (VOffsetOp_ != dacs[k_DACName_VOffsetOp]) {
0210     changes[k_DACName_VOffsetOp] = true;
0211     previous[k_DACName_VOffsetOp] = VOffsetOp_;
0212   }
0213   if (VbiasOp_ != dacs[k_DACName_VbiasOp]) {
0214     changes[k_DACName_VbiasOp] = true;
0215     previous[k_DACName_VbiasOp] = VbiasOp_;
0216   }
0217   if (VOffsetRO_ != dacs[k_DACName_VOffsetRO]) {
0218     changes[k_DACName_VOffsetRO] = true;
0219     previous[k_DACName_VOffsetRO] = VOffsetRO_;
0220   }
0221   if (VIon_ != dacs[k_DACName_VIon]) {
0222     changes[k_DACName_VIon] = true;
0223     previous[k_DACName_VIon] = VIon_;
0224   }
0225   if (VIbias_PH_ != dacs[k_DACName_VIbias_PH]) {
0226     changes[k_DACName_VIbias_PH] = true;
0227     previous[k_DACName_VIbias_PH] = VIbias_PH_;
0228   }
0229   if (VIbias_DAC_ != dacs[k_DACName_VIbias_DAC]) {
0230     changes[k_DACName_VIbias_DAC] = true;
0231     previous[k_DACName_VIbias_DAC] = VIbias_DAC_;
0232   }
0233   if (VIbias_roc_ != dacs[k_DACName_VIbias_roc]) {
0234     changes[k_DACName_VIbias_roc] = true;
0235     previous[k_DACName_VIbias_roc] = VIbias_roc_;
0236   }
0237   if (VIColOr_ != dacs[k_DACName_VIColOr]) {
0238     changes[k_DACName_VIColOr] = true;
0239     previous[k_DACName_VIColOr] = VIColOr_;
0240   }
0241   if (Vnpix_ != dacs[k_DACName_Vnpix]) {
0242     changes[k_DACName_Vnpix] = true;
0243     previous[k_DACName_Vnpix] = Vnpix_;
0244   }
0245   if (VsumCol_ != dacs[k_DACName_VsumCol]) {
0246     changes[k_DACName_VsumCol] = true;
0247     previous[k_DACName_VsumCol] = VsumCol_;
0248   }
0249   if (Vcal_ != dacs[k_DACName_Vcal]) {
0250     changes[k_DACName_Vcal] = true;
0251     previous[k_DACName_Vcal] = Vcal_;
0252   }
0253   if (CalDel_ != dacs[k_DACName_CalDel]) {
0254     changes[k_DACName_CalDel] = true;
0255     previous[k_DACName_CalDel] = CalDel_;
0256   }
0257   if (TempRange_ != dacs[k_DACName_TempRange]) {
0258     changes[k_DACName_TempRange] = true;
0259     previous[k_DACName_TempRange] = TempRange_;
0260   }
0261   if (WBC_ != dacs[k_DACName_WBC]) {
0262     changes[k_DACName_WBC] = true;
0263     previous[k_DACName_WBC] = WBC_;
0264   }
0265   if (ChipContReg_ != dacs[k_DACName_ChipContReg]) {
0266     changes[k_DACName_ChipContReg] = true;
0267     previous[k_DACName_ChipContReg] = ChipContReg_;
0268   }
0269 }
0270 
0271 void PixelROCDACSettings::setDAC(unsigned int dacaddress, unsigned int dacvalue) {
0272   std::string mthn = "[PixelROCDACSettings::setDAC()]\t\t\t\t    ";
0273   switch (dacaddress) {
0274     case 1:
0275       Vdd_ = dacvalue;
0276       break;
0277     case 2:
0278       Vana_ = dacvalue;
0279       break;
0280     case 3:
0281       Vsf_ = dacvalue;
0282       break;
0283     case 4:
0284       Vcomp_ = dacvalue;
0285       break;
0286     case 5:
0287       Vleak_ = dacvalue;
0288       break;
0289     case 6:
0290       VrgPr_ = dacvalue;
0291       break;
0292     case 7:
0293       VwllPr_ = dacvalue;
0294       break;
0295     case 8:
0296       VrgSh_ = dacvalue;
0297       break;
0298     case 9:
0299       VwllSh_ = dacvalue;
0300       break;
0301     case 10:
0302       VHldDel_ = dacvalue;
0303       break;
0304     case 11:
0305       Vtrim_ = dacvalue;
0306       break;
0307     case 12:
0308       VcThr_ = dacvalue;
0309       break;
0310     case 13:
0311       VIbias_bus_ = dacvalue;
0312       break;
0313     case 14:
0314       VIbias_sf_ = dacvalue;
0315       break;
0316     case 15:
0317       VOffsetOp_ = dacvalue;
0318       break;
0319     case 16:
0320       VbiasOp_ = dacvalue;
0321       break;
0322     case 17:
0323       VOffsetRO_ = dacvalue;
0324       break;
0325     case 18:
0326       VIon_ = dacvalue;
0327       break;
0328     case 19:
0329       VIbias_PH_ = dacvalue;
0330       break;
0331     case 20:
0332       VIbias_DAC_ = dacvalue;
0333       break;
0334     case 21:
0335       VIbias_roc_ = dacvalue;
0336       break;
0337     case 22:
0338       VIColOr_ = dacvalue;
0339       break;
0340     case 23:
0341       Vnpix_ = dacvalue;
0342       break;
0343     case 24:
0344       VsumCol_ = dacvalue;
0345       break;
0346     case 25:
0347       Vcal_ = dacvalue;
0348       break;
0349     case 26:
0350       CalDel_ = dacvalue;
0351       break;
0352     case 27:
0353       TempRange_ = dacvalue;
0354       break;
0355     case 254:
0356       WBC_ = dacvalue;
0357       break;
0358     case 253:
0359       ChipContReg_ = dacvalue;
0360       break;
0361     default:
0362       cout << __LINE__ << "]\t" << mthn << "DAC Address " << dacaddress << " does not exist!" << endl;
0363   }
0364 }
0365 
0366 void PixelROCDACSettings::writeBinary(ofstream& out) const {
0367   out << (char)rocid_.rocname().size();
0368   out.write(rocid_.rocname().c_str(), rocid_.rocname().size());
0369 
0370   out << Vdd_;
0371   out << Vana_;
0372   out << Vsf_;
0373   out << Vcomp_;
0374   out << Vleak_;
0375   out << VrgPr_;
0376   out << VwllPr_;
0377   out << VrgSh_;
0378   out << VwllSh_;
0379   out << VHldDel_;
0380   out << Vtrim_;
0381   out << VcThr_;
0382   out << VIbias_bus_;
0383   out << VIbias_sf_;
0384   out << VOffsetOp_;
0385   out << VbiasOp_;
0386   out << VOffsetRO_;
0387   out << VIon_;
0388   out << VIbias_PH_;
0389   out << VIbias_DAC_;
0390   out << VIbias_roc_;
0391   out << VIColOr_;
0392   out << Vnpix_;
0393   out << VsumCol_;
0394   out << Vcal_;
0395   out << CalDel_;
0396   out << TempRange_;
0397   out << WBC_;
0398   out << ChipContReg_;
0399 }
0400 
0401 int PixelROCDACSettings::readBinary(ifstream& in, const PixelROCName& rocid) {
0402   rocid_ = rocid;
0403 
0404   in.read((char*)&Vdd_, 1);
0405   in.read((char*)&Vana_, 1);
0406   in.read((char*)&Vsf_, 1);
0407   in.read((char*)&Vcomp_, 1);
0408   in.read((char*)&Vleak_, 1);
0409   in.read((char*)&VrgPr_, 1);
0410   in.read((char*)&VwllPr_, 1);
0411   in.read((char*)&VrgSh_, 1);
0412   in.read((char*)&VwllSh_, 1);
0413   in.read((char*)&VHldDel_, 1);
0414   in.read((char*)&Vtrim_, 1);
0415   in.read((char*)&VcThr_, 1);
0416   in.read((char*)&VIbias_bus_, 1);
0417   in.read((char*)&VIbias_sf_, 1);
0418   in.read((char*)&VOffsetOp_, 1);
0419   in.read((char*)&VbiasOp_, 1);
0420   in.read((char*)&VOffsetRO_, 1);
0421   in.read((char*)&VIon_, 1);
0422   in.read((char*)&VIbias_PH_, 1);
0423   in.read((char*)&VIbias_DAC_, 1);
0424   in.read((char*)&VIbias_roc_, 1);
0425   in.read((char*)&VIColOr_, 1);
0426   in.read((char*)&Vnpix_, 1);
0427   in.read((char*)&VsumCol_, 1);
0428   in.read((char*)&Vcal_, 1);
0429   in.read((char*)&CalDel_, 1);
0430   in.read((char*)&TempRange_, 1);
0431   in.read((char*)&WBC_, 1);
0432   in.read((char*)&ChipContReg_, 1);
0433 
0434   return 1;
0435 }
0436 
0437 void PixelROCDACSettings::writeASCII(ostream& out) const {
0438   out << "ROC:           " << rocid_.rocname() << endl;
0439 
0440   out << k_DACName_Vdd << ":           " << (int)Vdd_ << endl;
0441   out << k_DACName_Vana << ":          " << (int)Vana_ << endl;
0442   out << k_DACName_Vsf << ":           " << (int)Vsf_ << endl;
0443   out << k_DACName_Vcomp << ":         " << (int)Vcomp_ << endl;
0444   out << k_DACName_Vleak << ":         " << (int)Vleak_ << endl;
0445   out << k_DACName_VrgPr << ":         " << (int)VrgPr_ << endl;
0446   out << k_DACName_VwllPr << ":        " << (int)VwllPr_ << endl;
0447   out << k_DACName_VrgSh << ":         " << (int)VrgSh_ << endl;
0448   out << k_DACName_VwllSh << ":        " << (int)VwllSh_ << endl;
0449   out << k_DACName_VHldDel << ":       " << (int)VHldDel_ << endl;
0450   out << k_DACName_Vtrim << ":         " << (int)Vtrim_ << endl;
0451   out << k_DACName_VcThr << ":         " << (int)VcThr_ << endl;
0452   out << k_DACName_VIbias_bus << ":    " << (int)VIbias_bus_ << endl;
0453   out << k_DACName_VIbias_sf << ":     " << (int)VIbias_sf_ << endl;
0454   out << k_DACName_VOffsetOp << ":     " << (int)VOffsetOp_ << endl;
0455   out << k_DACName_VbiasOp << ":       " << (int)VbiasOp_ << endl;
0456   out << k_DACName_VOffsetRO << ":     " << (int)VOffsetRO_ << endl;
0457   out << k_DACName_VIon << ":          " << (int)VIon_ << endl;
0458   out << k_DACName_VIbias_PH << ":     " << (int)VIbias_PH_ << endl;
0459   out << k_DACName_VIbias_DAC << ":    " << (int)VIbias_DAC_ << endl;
0460   out << k_DACName_VIbias_roc << ":    " << (int)VIbias_roc_ << endl;
0461   out << k_DACName_VIColOr << ":       " << (int)VIColOr_ << endl;
0462   out << k_DACName_Vnpix << ":         " << (int)Vnpix_ << endl;
0463   out << k_DACName_VsumCol << ":       " << (int)VsumCol_ << endl;
0464   out << k_DACName_Vcal << ":          " << (int)Vcal_ << endl;
0465   out << k_DACName_CalDel << ":        " << (int)CalDel_ << endl;
0466   out << k_DACName_TempRange << ":     " << (int)TempRange_ << endl;
0467   out << k_DACName_WBC << ":           " << (int)WBC_ << endl;
0468   out << k_DACName_ChipContReg << ":   " << (int)ChipContReg_ << endl;
0469 }
0470 
0471 //=============================================================================================
0472 void PixelROCDACSettings::writeXML(ofstream* out) const {
0473   std::string mthn = "[PixelROCDACSettings::writeXML()]\t\t\t    ";
0474 
0475   *out << "  <DATA>" << endl;
0476   *out << "   <ROC_NAME>" << rocid_.rocname() << "</ROC_NAME>" << endl;
0477   *out << "   <VDD>" << (int)Vdd_ << "</VDD>" << endl;
0478   *out << "   <VANA>" << (int)Vana_ << "</VANA>" << endl;
0479   *out << "   <VSF>" << (int)Vsf_ << "</VSF>" << endl;
0480   *out << "   <VCOMP>" << (int)Vcomp_ << "</VCOMP>" << endl;
0481   *out << "   <VLEAK>" << (int)Vleak_ << "</VLEAK>" << endl;
0482   *out << "   <VRGPR>" << (int)VrgPr_ << "</VRGPR>" << endl;
0483   *out << "   <VWLLPR>" << (int)VwllPr_ << "</VWLLPR>" << endl;
0484   *out << "   <VRGSH>" << (int)VrgSh_ << "</VRGSH>" << endl;
0485   *out << "   <VWLLSH>" << (int)VwllSh_ << "</VWLLSH>" << endl;
0486   *out << "   <VHLDDEL>" << (int)VHldDel_ << "</VHLDDEL>" << endl;
0487   *out << "   <VTRIM>" << (int)Vtrim_ << "</VTRIM>" << endl;
0488   *out << "   <VCTHR>" << (int)VcThr_ << "</VCTHR>" << endl;
0489   *out << "   <VIBIAS_BUS>" << (int)VIbias_bus_ << "</VIBIAS_BUS>" << endl;
0490   *out << "   <VIBIAS_SF>" << (int)VIbias_sf_ << "</VIBIAS_SF>" << endl;
0491   *out << "   <VOFFSETOP>" << (int)VOffsetOp_ << "</VOFFSETOP>" << endl;
0492   *out << "   <VBIASOP>" << (int)VbiasOp_ << "</VBIASOP>" << endl;
0493   *out << "   <VOFFSETRO>" << (int)VOffsetRO_ << "</VOFFSETRO>" << endl;
0494   *out << "   <VION>" << (int)VIon_ << "</VION>" << endl;
0495   *out << "   <VIBIAS_PH>" << (int)VIbias_PH_ << "</VIBIAS_PH>" << endl;
0496   *out << "   <VIBIAS_DAC>" << (int)VIbias_DAC_ << "</VIBIAS_DAC>" << endl;
0497   *out << "   <VIBIAS_ROC>" << (int)VIbias_roc_ << "</VIBIAS_ROC>" << endl;
0498   *out << "   <VICOLOR>" << (int)VIColOr_ << "</VICOLOR>" << endl;
0499   *out << "   <VNPIX>" << (int)Vnpix_ << "</VNPIX>" << endl;
0500   *out << "   <VSUMCOL>" << (int)VsumCol_ << "</VSUMCOL>" << endl;
0501   *out << "   <VCAL>" << (int)Vcal_ << "</VCAL>" << endl;
0502   *out << "   <CALDEL>" << (int)CalDel_ << "</CALDEL>" << endl;
0503   *out << "   <TEMPRANGE>" << (int)TempRange_ << "</TEMPRANGE>" << endl;
0504   *out << "   <WBC>" << (int)WBC_ << "</WBC>" << endl;
0505   *out << "   <CHIPCONTREG>" << (int)ChipContReg_ << "</CHIPCONTREG>" << endl;
0506   *out << "  </DATA>" << endl;
0507   *out << " " << endl;
0508 }
0509 
0510 //=============================================================================================
0511 void PixelROCDACSettings::checkTag(string tag, string dacName, const PixelROCName& rocid) {
0512   std::string mthn = "[PixelROCDACSettings::checkTag()]\t\t\t\t    ";
0513   dacName += ":";
0514   if (tag != dacName) {
0515     cout << __LINE__ << "]\t" << mthn << "Read ROC name       : " << tag << endl;
0516     cout << __LINE__ << "]\t" << mthn << "But expected to find: " << dacName << endl;
0517     cout << __LINE__ << "]\t" << mthn << "When reading DAC settings for ROC " << rocid << endl;
0518     assert(0);
0519   }
0520 }
0521 
0522 int PixelROCDACSettings::read(std::istringstream& in, const PixelROCName& rocid) {
0523   std::string mthn = "[PixelROCDACSettings::read()]\t\t\t\t    ";
0524 
0525   rocid_ = rocid;
0526 
0527   unsigned int tmp;
0528   string tag;
0529 
0530   //    cout << "[PixelROCDACSettings::read()] |" << in.str() << "|" << endl ;
0531   in >> tag;
0532   checkTag(tag, k_DACName_Vdd, rocid);
0533   in >> tmp;
0534   Vdd_ = tmp;
0535   in >> tag;
0536   checkTag(tag, k_DACName_Vana, rocid);
0537   in >> tmp;
0538   Vana_ = tmp;
0539   in >> tag;
0540   checkTag(tag, k_DACName_Vsf, rocid);
0541   in >> tmp;
0542   Vsf_ = tmp;
0543   in >> tag;
0544   checkTag(tag, k_DACName_Vcomp, rocid);
0545   in >> tmp;
0546   Vcomp_ = tmp;
0547   in >> tag;
0548   checkTag(tag, k_DACName_Vleak, rocid);
0549   in >> tmp;
0550   Vleak_ = tmp;
0551   in >> tag;
0552   checkTag(tag, k_DACName_VrgPr, rocid);
0553   in >> tmp;
0554   VrgPr_ = tmp;
0555   in >> tag;
0556   checkTag(tag, k_DACName_VwllPr, rocid);
0557   in >> tmp;
0558   VwllPr_ = tmp;
0559   in >> tag;
0560   checkTag(tag, k_DACName_VrgSh, rocid);
0561   in >> tmp;
0562   VrgSh_ = tmp;
0563   in >> tag;
0564   checkTag(tag, k_DACName_VwllSh, rocid);
0565   in >> tmp;
0566   VwllSh_ = tmp;
0567   in >> tag;
0568   checkTag(tag, k_DACName_VHldDel, rocid);
0569   in >> tmp;
0570   VHldDel_ = tmp;
0571   in >> tag;
0572   checkTag(tag, k_DACName_Vtrim, rocid);
0573   in >> tmp;
0574   Vtrim_ = tmp;
0575   in >> tag;
0576   checkTag(tag, k_DACName_VcThr, rocid);
0577   in >> tmp;
0578   VcThr_ = tmp;
0579   in >> tag;
0580   checkTag(tag, k_DACName_VIbias_bus, rocid);
0581   in >> tmp;
0582   VIbias_bus_ = tmp;
0583   in >> tag;
0584   checkTag(tag, k_DACName_VIbias_sf, rocid);
0585   in >> tmp;
0586   VIbias_sf_ = tmp;
0587   in >> tag;
0588   checkTag(tag, k_DACName_VOffsetOp, rocid);
0589   in >> tmp;
0590   VOffsetOp_ = tmp;
0591   in >> tag;
0592   checkTag(tag, k_DACName_VbiasOp, rocid);
0593   in >> tmp;
0594   VbiasOp_ = tmp;
0595   in >> tag;
0596   checkTag(tag, k_DACName_VOffsetRO, rocid);
0597   in >> tmp;
0598   VOffsetRO_ = tmp;
0599   in >> tag;
0600   checkTag(tag, k_DACName_VIon, rocid);
0601   in >> tmp;
0602   VIon_ = tmp;
0603   in >> tag;
0604   checkTag(tag, k_DACName_VIbias_PH, rocid);
0605   in >> tmp;
0606   VIbias_PH_ = tmp;
0607   in >> tag;
0608   checkTag(tag, k_DACName_VIbias_DAC, rocid);
0609   in >> tmp;
0610   VIbias_DAC_ = tmp;
0611   in >> tag;
0612   checkTag(tag, k_DACName_VIbias_roc, rocid);
0613   in >> tmp;
0614   VIbias_roc_ = tmp;
0615   in >> tag;
0616   checkTag(tag, k_DACName_VIColOr, rocid);
0617   in >> tmp;
0618   VIColOr_ = tmp;
0619   in >> tag;
0620   checkTag(tag, k_DACName_Vnpix, rocid);
0621   in >> tmp;
0622   Vnpix_ = tmp;
0623   in >> tag;
0624   checkTag(tag, k_DACName_VsumCol, rocid);
0625   in >> tmp;
0626   VsumCol_ = tmp;
0627   in >> tag;
0628   checkTag(tag, k_DACName_Vcal, rocid);
0629   in >> tmp;
0630   Vcal_ = tmp;
0631   in >> tag;
0632   checkTag(tag, k_DACName_CalDel, rocid);
0633   in >> tmp;
0634   CalDel_ = tmp;
0635   in >> tag;
0636   if (tag == k_DACName_WBC + ":") {
0637     static bool first = true;
0638     if (first) {
0639       cout << __LINE__ << "]\t" << mthn << "**********************************************" << endl;
0640       cout << __LINE__ << "]\t" << mthn << "Did not find TempRange setting in DAC settings" << endl;
0641       cout << __LINE__ << "]\t" << mthn << "Will use a default value of 4." << endl;
0642       cout << __LINE__ << "]\t" << mthn << "This message will only be printed out once" << endl;
0643       cout << __LINE__ << "]\t" << mthn << "**********************************************" << endl;
0644       TempRange_ = 4;
0645       first = false;
0646     }
0647     in >> tmp;
0648     WBC_ = tmp;
0649   } else {
0650     checkTag(tag, k_DACName_TempRange, rocid);
0651     in >> tmp;
0652     TempRange_ = tmp;
0653     in >> tag;
0654     checkTag(tag, k_DACName_WBC, rocid);
0655     in >> tmp;
0656     WBC_ = tmp;
0657   }
0658   in >> tag;
0659   checkTag(tag, k_DACName_ChipContReg, rocid);
0660   in >> tmp;
0661   ChipContReg_ = tmp;
0662 
0663   return 0;
0664 }
0665 
0666 int PixelROCDACSettings::read(ifstream& in, const PixelROCName& rocid) {
0667   std::string mthn = "[PixelROCDACSettings::read()]\t\t\t\t    ";
0668   rocid_ = rocid;
0669 
0670   unsigned int tmp;
0671   string tag;
0672 
0673   in >> tag;
0674   checkTag(tag, k_DACName_Vdd, rocid);
0675   in >> tmp;
0676   Vdd_ = tmp;
0677   in >> tag;
0678   checkTag(tag, k_DACName_Vana, rocid);
0679   in >> tmp;
0680   Vana_ = tmp;
0681   in >> tag;
0682   checkTag(tag, k_DACName_Vsf, rocid);
0683   in >> tmp;
0684   Vsf_ = tmp;
0685   in >> tag;
0686   checkTag(tag, k_DACName_Vcomp, rocid);
0687   in >> tmp;
0688   Vcomp_ = tmp;
0689   in >> tag;
0690   checkTag(tag, k_DACName_Vleak, rocid);
0691   in >> tmp;
0692   Vleak_ = tmp;
0693   in >> tag;
0694   checkTag(tag, k_DACName_VrgPr, rocid);
0695   in >> tmp;
0696   VrgPr_ = tmp;
0697   in >> tag;
0698   checkTag(tag, k_DACName_VwllPr, rocid);
0699   in >> tmp;
0700   VwllPr_ = tmp;
0701   in >> tag;
0702   checkTag(tag, k_DACName_VrgSh, rocid);
0703   in >> tmp;
0704   VrgSh_ = tmp;
0705   in >> tag;
0706   checkTag(tag, k_DACName_VwllSh, rocid);
0707   in >> tmp;
0708   VwllSh_ = tmp;
0709   in >> tag;
0710   checkTag(tag, k_DACName_VHldDel, rocid);
0711   in >> tmp;
0712   VHldDel_ = tmp;
0713   in >> tag;
0714   checkTag(tag, k_DACName_Vtrim, rocid);
0715   in >> tmp;
0716   Vtrim_ = tmp;
0717   in >> tag;
0718   checkTag(tag, k_DACName_VcThr, rocid);
0719   in >> tmp;
0720   VcThr_ = tmp;
0721   in >> tag;
0722   checkTag(tag, k_DACName_VIbias_bus, rocid);
0723   in >> tmp;
0724   VIbias_bus_ = tmp;
0725   in >> tag;
0726   checkTag(tag, k_DACName_VIbias_sf, rocid);
0727   in >> tmp;
0728   VIbias_sf_ = tmp;
0729   in >> tag;
0730   checkTag(tag, k_DACName_VOffsetOp, rocid);
0731   in >> tmp;
0732   VOffsetOp_ = tmp;
0733   in >> tag;
0734   checkTag(tag, k_DACName_VbiasOp, rocid);
0735   in >> tmp;
0736   VbiasOp_ = tmp;
0737   in >> tag;
0738   checkTag(tag, k_DACName_VOffsetRO, rocid);
0739   in >> tmp;
0740   VOffsetRO_ = tmp;
0741   in >> tag;
0742   checkTag(tag, k_DACName_VIon, rocid);
0743   in >> tmp;
0744   VIon_ = tmp;
0745   in >> tag;
0746   checkTag(tag, k_DACName_VIbias_PH, rocid);
0747   in >> tmp;
0748   VIbias_PH_ = tmp;
0749   in >> tag;
0750   checkTag(tag, k_DACName_VIbias_DAC, rocid);
0751   in >> tmp;
0752   VIbias_DAC_ = tmp;
0753   in >> tag;
0754   checkTag(tag, k_DACName_VIbias_roc, rocid);
0755   in >> tmp;
0756   VIbias_roc_ = tmp;
0757   in >> tag;
0758   checkTag(tag, k_DACName_VIColOr, rocid);
0759   in >> tmp;
0760   VIColOr_ = tmp;
0761   in >> tag;
0762   checkTag(tag, k_DACName_Vnpix, rocid);
0763   in >> tmp;
0764   Vnpix_ = tmp;
0765   in >> tag;
0766   checkTag(tag, k_DACName_VsumCol, rocid);
0767   in >> tmp;
0768   VsumCol_ = tmp;
0769   in >> tag;
0770   checkTag(tag, k_DACName_Vcal, rocid);
0771   in >> tmp;
0772   Vcal_ = tmp;
0773   in >> tag;
0774   checkTag(tag, k_DACName_CalDel, rocid);
0775   in >> tmp;
0776   CalDel_ = tmp;
0777   in >> tag;
0778   if (tag == k_DACName_WBC + ":") {
0779     static bool first = true;
0780     if (first) {
0781       cout << __LINE__ << "]\t" << mthn << "**********************************************" << endl;
0782       cout << __LINE__ << "]\t" << mthn << "Did not find TempRange setting in DAC settings" << endl;
0783       cout << __LINE__ << "]\t" << mthn << "Will use a default value of 4." << endl;
0784       cout << __LINE__ << "]\t" << mthn << "This message will only be printed out once" << endl;
0785       cout << __LINE__ << "]\t" << mthn << "**********************************************" << endl;
0786       TempRange_ = 4;
0787       first = false;
0788     }
0789     in >> tmp;
0790     WBC_ = tmp;
0791   } else {
0792     checkTag(tag, k_DACName_TempRange, rocid);
0793     in >> tmp;
0794     TempRange_ = tmp;
0795     in >> tag;
0796     checkTag(tag, k_DACName_WBC, rocid);
0797     in >> tmp;
0798     WBC_ = tmp;
0799   }
0800   in >> tag;
0801   checkTag(tag, k_DACName_ChipContReg, rocid);
0802   in >> tmp;
0803   ChipContReg_ = tmp;
0804 
0805   return 0;
0806 }
0807 
0808 string PixelROCDACSettings::getConfigCommand() {
0809   string s;
0810 
0811   return s;
0812 }
0813 
0814 ostream& pos::operator<<(ostream& s, const PixelROCDACSettings& dacs) {
0815   s << k_DACName_Vdd << "          :" << (unsigned int)dacs.Vdd_ << endl;
0816   s << k_DACName_Vana << "         :" << (unsigned int)dacs.Vana_ << endl;
0817   s << k_DACName_Vsf << "          :" << (unsigned int)dacs.Vsf_ << endl;
0818   s << k_DACName_Vcomp << "        :" << (unsigned int)dacs.Vcomp_ << endl;
0819   s << k_DACName_Vleak << "        :" << (unsigned int)dacs.Vleak_ << endl;
0820   s << k_DACName_VrgPr << "        :" << (unsigned int)dacs.VrgPr_ << endl;
0821   s << k_DACName_VwllPr << "       :" << (unsigned int)dacs.VwllPr_ << endl;
0822   s << k_DACName_VrgSh << "        :" << (unsigned int)dacs.VrgSh_ << endl;
0823   s << k_DACName_VwllSh << "       :" << (unsigned int)dacs.VwllSh_ << endl;
0824   s << k_DACName_VHldDel << "      :" << (unsigned int)dacs.VHldDel_ << endl;
0825   s << k_DACName_Vtrim << "        :" << (unsigned int)dacs.Vtrim_ << endl;
0826   s << k_DACName_VcThr << "        :" << (unsigned int)dacs.VcThr_ << endl;
0827   s << k_DACName_VIbias_bus << "   :" << (unsigned int)dacs.VIbias_bus_ << endl;
0828   s << k_DACName_VIbias_sf << "    :" << (unsigned int)dacs.VIbias_sf_ << endl;
0829   s << k_DACName_VOffsetOp << "    :" << (unsigned int)dacs.VOffsetOp_ << endl;
0830   s << k_DACName_VbiasOp << "      :" << (unsigned int)dacs.VbiasOp_ << endl;
0831   s << k_DACName_VOffsetRO << "    :" << (unsigned int)dacs.VOffsetRO_ << endl;
0832   s << k_DACName_VIon << "         :" << (unsigned int)dacs.VIon_ << endl;
0833   s << k_DACName_VIbias_PH << "    :" << (unsigned int)dacs.VIbias_PH_ << endl;
0834   s << k_DACName_VIbias_DAC << "   :" << (unsigned int)dacs.VIbias_DAC_ << endl;
0835   s << k_DACName_VIbias_roc << "   :" << (unsigned int)dacs.VIbias_roc_ << endl;
0836   s << k_DACName_VIColOr << "      :" << (unsigned int)dacs.VIColOr_ << endl;
0837   s << k_DACName_Vnpix << "        :" << (unsigned int)dacs.Vnpix_ << endl;
0838   s << k_DACName_VsumCol << "      :" << (unsigned int)dacs.VsumCol_ << endl;
0839   s << k_DACName_Vcal << "         :" << (unsigned int)dacs.Vcal_ << endl;
0840   s << k_DACName_CalDel << "       :" << (unsigned int)dacs.CalDel_ << endl;
0841   s << k_DACName_TempRange << "    :" << (unsigned int)dacs.TempRange_ << endl;
0842   s << k_DACName_WBC << "          :" << (unsigned int)dacs.WBC_ << endl;
0843   s << k_DACName_ChipContReg << "  :" << (unsigned int)dacs.ChipContReg_ << endl;
0844 
0845   return s;
0846 }
0847 
0848 //Added by Umesh
0849 void PixelROCDACSettings::setDac(string dacName, int dacValue) {
0850   if (ToLower(dacName) == ToLower(k_DACName_Vdd)) {
0851     Vdd_ = dacValue;
0852   } else if (ToLower(dacName) == ToLower(k_DACName_Vana)) {
0853     Vana_ = dacValue;
0854   } else if (ToLower(dacName) == ToLower(k_DACName_Vsf)) {
0855     Vsf_ = dacValue;
0856   } else if (ToLower(dacName) == ToLower(k_DACName_Vcomp)) {
0857     Vcomp_ = dacValue;
0858   } else if (ToLower(dacName) == ToLower(k_DACName_Vleak)) {
0859     Vleak_ = dacValue;
0860   } else if (ToLower(dacName) == ToLower(k_DACName_VrgPr)) {
0861     VrgPr_ = dacValue;
0862   } else if (ToLower(dacName) == ToLower(k_DACName_VwllPr)) {
0863     VwllPr_ = dacValue;
0864   } else if (ToLower(dacName) == ToLower(k_DACName_VrgSh)) {
0865     VrgSh_ = dacValue;
0866   } else if (ToLower(dacName) == ToLower(k_DACName_VwllSh)) {
0867     VwllSh_ = dacValue;
0868   } else if (ToLower(dacName) == ToLower(k_DACName_VHldDel)) {
0869     VHldDel_ = dacValue;
0870   } else if (ToLower(dacName) == ToLower(k_DACName_Vtrim)) {
0871     Vtrim_ = dacValue;
0872   } else if (ToLower(dacName) == ToLower(k_DACName_VcThr)) {
0873     VcThr_ = dacValue;
0874   } else if (ToLower(dacName) == ToLower(k_DACName_VIbias_bus)) {
0875     VIbias_bus_ = dacValue;
0876   } else if (ToLower(dacName) == ToLower(k_DACName_VIbias_sf)) {
0877     VIbias_sf_ = dacValue;
0878   } else if (ToLower(dacName) == ToLower(k_DACName_VOffsetOp)) {
0879     VOffsetOp_ = dacValue;
0880   } else if (ToLower(dacName) == ToLower(k_DACName_VbiasOp)) {
0881     VbiasOp_ = dacValue;
0882   } else if (ToLower(dacName) == ToLower(k_DACName_VOffsetRO)) {
0883     VOffsetRO_ = dacValue;
0884   } else if (ToLower(dacName) == ToLower(k_DACName_VIon)) {
0885     VIon_ = dacValue;
0886   } else if (ToLower(dacName) == ToLower(k_DACName_VIbias_PH)) {
0887     VIbias_PH_ = dacValue;
0888   } else if (ToLower(dacName) == ToLower(k_DACName_VIbias_DAC)) {
0889     VIbias_DAC_ = dacValue;
0890   } else if (ToLower(dacName) == ToLower(k_DACName_VIbias_roc)) {
0891     VIbias_roc_ = dacValue;
0892   } else if (ToLower(dacName) == ToLower(k_DACName_VIColOr)) {
0893     VIColOr_ = dacValue;
0894   } else if (ToLower(dacName) == ToLower(k_DACName_Vnpix)) {
0895     ;
0896     Vnpix_ = dacValue;
0897   } else if (ToLower(dacName) == ToLower(k_DACName_VsumCol)) {
0898     VsumCol_ = dacValue;
0899   } else if (ToLower(dacName) == ToLower(k_DACName_Vcal)) {
0900     Vcal_ = dacValue;
0901   } else if (ToLower(dacName) == ToLower(k_DACName_CalDel)) {
0902     CalDel_ = dacValue;
0903   } else if (ToLower(dacName) == ToLower(k_DACName_TempRange)) {
0904     TempRange_ = dacValue;
0905   } else if (ToLower(dacName) == ToLower(k_DACName_WBC)) {
0906     WBC_ = dacValue;
0907   } else if (ToLower(dacName) == ToLower(k_DACName_ChipContReg)) {
0908     ChipContReg_ = dacValue;
0909   } else {
0910     cout << "ERROR in PixelROCDACSettings::setDac: DAC name " << dacName << " does not exist." << endl;
0911     assert(0);
0912   }
0913 }
0914 
0915 unsigned int PixelROCDACSettings::getDac(string dacName) const {
0916   if (dacName == k_DACName_Vdd) {
0917     return Vdd_;
0918   } else if (dacName == k_DACName_Vana) {
0919     return Vana_;
0920   } else if (dacName == k_DACName_Vsf) {
0921     return Vsf_;
0922   } else if (dacName == k_DACName_Vcomp) {
0923     return Vcomp_;
0924   } else if (dacName == k_DACName_Vleak) {
0925     return Vleak_;
0926   } else if (dacName == k_DACName_VrgPr) {
0927     return VrgPr_;
0928   } else if (dacName == k_DACName_VwllPr) {
0929     return VwllPr_;
0930   } else if (dacName == k_DACName_VrgSh) {
0931     return VrgSh_;
0932   } else if (dacName == k_DACName_VwllSh) {
0933     return VwllSh_;
0934   } else if (dacName == k_DACName_VHldDel) {
0935     return VHldDel_;
0936   } else if (dacName == k_DACName_Vtrim) {
0937     return Vtrim_;
0938   } else if (dacName == k_DACName_VcThr) {
0939     return VcThr_;
0940   } else if (dacName == k_DACName_VIbias_bus) {
0941     return VIbias_bus_;
0942   } else if (dacName == k_DACName_VIbias_sf) {
0943     return VIbias_sf_;
0944   } else if (dacName == k_DACName_VOffsetOp) {
0945     return VOffsetOp_;
0946   } else if (dacName == k_DACName_VbiasOp) {
0947     return VbiasOp_;
0948   } else if (dacName == k_DACName_VOffsetRO) {
0949     return VOffsetRO_;
0950   } else if (dacName == k_DACName_VIon) {
0951     return VIon_;
0952   } else if (dacName == k_DACName_VIbias_PH) {
0953     return VIbias_PH_;
0954   } else if (dacName == k_DACName_VIbias_DAC) {
0955     return VIbias_DAC_;
0956   } else if (dacName == k_DACName_VIbias_roc) {
0957     return VIbias_roc_;
0958   } else if (dacName == k_DACName_VIColOr) {
0959     return VIColOr_;
0960   } else if (dacName == k_DACName_Vnpix) {
0961     return Vnpix_;
0962   } else if (dacName == k_DACName_VsumCol) {
0963     return VsumCol_;
0964   } else if (dacName == k_DACName_Vcal) {
0965     return Vcal_;
0966   } else if (dacName == k_DACName_CalDel) {
0967     return CalDel_;
0968   } else if (dacName == k_DACName_TempRange) {
0969     return TempRange_;
0970   } else if (dacName == k_DACName_WBC) {
0971     return WBC_;
0972   } else if (dacName == k_DACName_ChipContReg) {
0973     return ChipContReg_;
0974   } else {
0975     cout << "ERROR in PixelROCDACSettings::getDac: DAC name " << dacName << " does not exist." << endl;
0976     assert(0);
0977   }
0978 }
0979 
0980 string PixelROCDACSettings::ToLower(string generic) {
0981   string result;
0982   for (unsigned int i = 0; i < generic.length(); i++) {
0983     result.append(1, (char)tolower(generic[i]));
0984   }
0985   return result;
0986 }