CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PixelROCDACSettings.cc
Go to the documentation of this file.
1 //
2 // This class provide the data structure for the
3 // ROC DAC parameters
4 //
5 // At this point I do not see a reason to make an
6 // abstract layer for this code.
7 //
8 
11 #include <fstream>
12 #include <iostream>
13 
14 using namespace pos;
15 using namespace std;
16 
18 
19 
20 void PixelROCDACSettings::getDACs(vector<unsigned int>& dacs) const
21 {
22  dacs.clear();
23  dacs.push_back(Vdd_);
24  dacs.push_back(Vana_);
25  dacs.push_back(Vsf_);
26  dacs.push_back(Vcomp_);
27  dacs.push_back(Vleak_);
28  dacs.push_back(VrgPr_);
29  dacs.push_back(VwllPr_);
30  dacs.push_back(VrgSh_);
31  dacs.push_back(VwllSh_);
32  dacs.push_back(VHldDel_);
33  dacs.push_back(Vtrim_);
34  dacs.push_back(VcThr_);
35  dacs.push_back(VIbias_bus_);
36  dacs.push_back(VIbias_sf_);
37  dacs.push_back(VOffsetOp_);
38  dacs.push_back(VbiasOp_);
39  dacs.push_back(VOffsetRO_);
40  dacs.push_back(VIon_);
41  dacs.push_back(VIbias_PH_);
42  dacs.push_back(VIbias_DAC_);
43  dacs.push_back(VIbias_roc_);
44  dacs.push_back(VIColOr_);
45  dacs.push_back(Vnpix_);
46  dacs.push_back(VsumCol_);
47  dacs.push_back(Vcal_);
48  dacs.push_back(CalDel_);
49  dacs.push_back(TempRange_);
50  dacs.push_back(WBC_);
51  dacs.push_back(ChipContReg_);
52 }
53 
54 // Added by Dario
55 void PixelROCDACSettings::getDACs(std::map<std::string, unsigned int>& dacs) const
56 {
57  dacs.clear();
58  dacs[k_DACName_Vdd ] = Vdd_ ;
59  dacs[k_DACName_Vana ] = Vana_ ;
60  dacs[k_DACName_Vsf ] = Vsf_ ;
61  dacs[k_DACName_Vcomp ] = Vcomp_ ;
62  dacs[k_DACName_Vleak ] = Vleak_ ;
63  dacs[k_DACName_VrgPr ] = VrgPr_ ;
64  dacs[k_DACName_VwllPr ] = VwllPr_ ;
65  dacs[k_DACName_VrgSh ] = VrgSh_ ;
66  dacs[k_DACName_VwllSh ] = VwllSh_ ;
67  dacs[k_DACName_VHldDel ] = VHldDel_ ;
68  dacs[k_DACName_Vtrim ] = Vtrim_ ;
69  dacs[k_DACName_VcThr ] = VcThr_ ;
70  dacs[k_DACName_VIbias_bus ] = VIbias_bus_ ;
71  dacs[k_DACName_VIbias_sf ] = VIbias_sf_ ;
72  dacs[k_DACName_VOffsetOp ] = VOffsetOp_ ;
73  dacs[k_DACName_VbiasOp ] = VbiasOp_ ;
74  dacs[k_DACName_VOffsetRO ] = VOffsetRO_ ;
75  dacs[k_DACName_VIon ] = VIon_ ;
76  dacs[k_DACName_VIbias_PH ] = VIbias_PH_ ;
77  dacs[k_DACName_VIbias_DAC ] = VIbias_DAC_ ;
78  dacs[k_DACName_VIbias_roc ] = VIbias_roc_ ;
79  dacs[k_DACName_VIColOr ] = VIColOr_ ;
80  dacs[k_DACName_Vnpix ] = Vnpix_ ;
81  dacs[k_DACName_VsumCol ] = VsumCol_ ;
82  dacs[k_DACName_Vcal ] = Vcal_ ;
83  dacs[k_DACName_CalDel ] = CalDel_ ;
84  dacs[k_DACName_TempRange ] = TempRange_ ;
85  dacs[k_DACName_WBC ] = WBC_ ;
86  dacs[k_DACName_ChipContReg] = ChipContReg_;
87 }
88 
89 // Added by Dario
90 void PixelROCDACSettings::setDACs(std::map<std::string, unsigned int>& dacs)
91 {
92  Vdd_ = dacs[k_DACName_Vdd ] ;
93  Vana_ = dacs[k_DACName_Vana ] ;
94  Vsf_ = dacs[k_DACName_Vsf ] ;
95  Vcomp_ = dacs[k_DACName_Vcomp ] ;
96  Vleak_ = dacs[k_DACName_Vleak ] ;
97  VrgPr_ = dacs[k_DACName_VrgPr ] ;
98  VwllPr_ = dacs[k_DACName_VwllPr ] ;
99  VrgSh_ = dacs[k_DACName_VrgSh ] ;
100  VwllSh_ = dacs[k_DACName_VwllSh ] ;
101  VHldDel_ = dacs[k_DACName_VHldDel ] ;
102  Vtrim_ = dacs[k_DACName_Vtrim ] ;
103  VcThr_ = dacs[k_DACName_VcThr ] ;
104  VIbias_bus_ = dacs[k_DACName_VIbias_bus ] ;
105  VIbias_sf_ = dacs[k_DACName_VIbias_sf ] ;
106  VOffsetOp_ = dacs[k_DACName_VOffsetOp ] ;
107  VbiasOp_ = dacs[k_DACName_VbiasOp ] ;
108  VOffsetRO_ = dacs[k_DACName_VOffsetRO ] ;
109  VIon_ = dacs[k_DACName_VIon ] ;
110  VIbias_PH_ = dacs[k_DACName_VIbias_PH ] ;
111  VIbias_DAC_ = dacs[k_DACName_VIbias_DAC ] ;
112  VIbias_roc_ = dacs[k_DACName_VIbias_roc ] ;
113  VIColOr_ = dacs[k_DACName_VIColOr ] ;
114  Vnpix_ = dacs[k_DACName_Vnpix ] ;
115  VsumCol_ = dacs[k_DACName_VsumCol ] ;
116  Vcal_ = dacs[k_DACName_Vcal ] ;
117  CalDel_ = dacs[k_DACName_CalDel ] ;
118  TempRange_ = dacs[k_DACName_TempRange ] ;
119  WBC_ = dacs[k_DACName_WBC ] ;
120  ChipContReg_ = dacs[k_DACName_ChipContReg] ;
121 }
122 
123 // Added by Dario
124 void PixelROCDACSettings::compareDACs(std::map<std::string, unsigned int>& dacs,
125  std::map<std::string, bool>& changes,
126  std::map<std::string, unsigned int>& previous)
127 {
128  changes[k_DACName_Vdd ] = false;
129  changes[k_DACName_Vana ] = false;
130  changes[k_DACName_Vsf ] = false;
131  changes[k_DACName_Vcomp ] = false;
132  changes[k_DACName_Vleak ] = false;
133  changes[k_DACName_VrgPr ] = false;
134  changes[k_DACName_VwllPr ] = false;
135  changes[k_DACName_VrgSh ] = false;
136  changes[k_DACName_VwllSh ] = false;
137  changes[k_DACName_VHldDel ] = false;
138  changes[k_DACName_Vtrim ] = false;
139  changes[k_DACName_VcThr ] = false;
140  changes[k_DACName_VIbias_bus ] = false;
141  changes[k_DACName_VIbias_sf ] = false;
142  changes[k_DACName_VOffsetOp ] = false;
143  changes[k_DACName_VbiasOp ] = false;
144  changes[k_DACName_VOffsetRO ] = false;
145  changes[k_DACName_VIon ] = false;
146  changes[k_DACName_VIbias_PH ] = false;
147  changes[k_DACName_VIbias_DAC ] = false;
148  changes[k_DACName_VIbias_roc ] = false;
149  changes[k_DACName_VIColOr ] = false;
150  changes[k_DACName_Vnpix ] = false;
151  changes[k_DACName_VsumCol ] = false;
152  changes[k_DACName_Vcal ] = false;
153  changes[k_DACName_CalDel ] = false;
154  changes[k_DACName_TempRange ] = false;
155  changes[k_DACName_WBC ] = false;
156  changes[k_DACName_ChipContReg] = false;
157 
158  if( Vdd_ != dacs[k_DACName_Vdd ] ) {changes[k_DACName_Vdd ] = true; previous[k_DACName_Vdd ] = Vdd_ ;}
159  if( Vana_ != dacs[k_DACName_Vana ] ) {changes[k_DACName_Vana ] = true; previous[k_DACName_Vana ] = Vana_ ;}
160  if( Vsf_ != dacs[k_DACName_Vsf ] ) {changes[k_DACName_Vsf ] = true; previous[k_DACName_Vsf ] = Vsf_ ;}
161  if( Vcomp_ != dacs[k_DACName_Vcomp ] ) {changes[k_DACName_Vcomp ] = true; previous[k_DACName_Vcomp ] = Vcomp_ ;}
162  if( Vleak_ != dacs[k_DACName_Vleak ] ) {changes[k_DACName_Vleak ] = true; previous[k_DACName_Vleak ] = Vleak_ ;}
163  if( VrgPr_ != dacs[k_DACName_VrgPr ] ) {changes[k_DACName_VrgPr ] = true; previous[k_DACName_VrgPr ] = VrgPr_ ;}
164  if( VwllPr_ != dacs[k_DACName_VwllPr ] ) {changes[k_DACName_VwllPr ] = true; previous[k_DACName_VwllPr ] = VwllPr_ ;}
165  if( VrgSh_ != dacs[k_DACName_VrgSh ] ) {changes[k_DACName_VrgSh ] = true; previous[k_DACName_VrgSh ] = VrgSh_ ;}
166  if( VwllSh_ != dacs[k_DACName_VwllSh ] ) {changes[k_DACName_VwllSh ] = true; previous[k_DACName_VwllSh ] = VwllSh_ ;}
167  if( VHldDel_ != dacs[k_DACName_VHldDel ] ) {changes[k_DACName_VHldDel ] = true; previous[k_DACName_VHldDel ] = VHldDel_ ;}
168  if( Vtrim_ != dacs[k_DACName_Vtrim ] ) {changes[k_DACName_Vtrim ] = true; previous[k_DACName_Vtrim ] = Vtrim_ ;}
169  if( VcThr_ != dacs[k_DACName_VcThr ] ) {changes[k_DACName_VcThr ] = true; previous[k_DACName_VcThr ] = VcThr_ ;}
170  if( VIbias_bus_ != dacs[k_DACName_VIbias_bus ] ) {changes[k_DACName_VIbias_bus ] = true; previous[k_DACName_VIbias_bus ] = VIbias_bus_ ;}
171  if( VIbias_sf_ != dacs[k_DACName_VIbias_sf ] ) {changes[k_DACName_VIbias_sf ] = true; previous[k_DACName_VIbias_sf ] = VIbias_sf_ ;}
172  if( VOffsetOp_ != dacs[k_DACName_VOffsetOp ] ) {changes[k_DACName_VOffsetOp ] = true; previous[k_DACName_VOffsetOp ] = VOffsetOp_ ;}
173  if( VbiasOp_ != dacs[k_DACName_VbiasOp ] ) {changes[k_DACName_VbiasOp ] = true; previous[k_DACName_VbiasOp ] = VbiasOp_ ;}
174  if( VOffsetRO_ != dacs[k_DACName_VOffsetRO ] ) {changes[k_DACName_VOffsetRO ] = true; previous[k_DACName_VOffsetRO ] = VOffsetRO_ ;}
175  if( VIon_ != dacs[k_DACName_VIon ] ) {changes[k_DACName_VIon ] = true; previous[k_DACName_VIon ] = VIon_ ;}
176  if( VIbias_PH_ != dacs[k_DACName_VIbias_PH ] ) {changes[k_DACName_VIbias_PH ] = true; previous[k_DACName_VIbias_PH ] = VIbias_PH_ ;}
177  if( VIbias_DAC_ != dacs[k_DACName_VIbias_DAC ] ) {changes[k_DACName_VIbias_DAC ] = true; previous[k_DACName_VIbias_DAC ] = VIbias_DAC_ ;}
178  if( VIbias_roc_ != dacs[k_DACName_VIbias_roc ] ) {changes[k_DACName_VIbias_roc ] = true; previous[k_DACName_VIbias_roc ] = VIbias_roc_ ;}
179  if( VIColOr_ != dacs[k_DACName_VIColOr ] ) {changes[k_DACName_VIColOr ] = true; previous[k_DACName_VIColOr ] = VIColOr_ ;}
180  if( Vnpix_ != dacs[k_DACName_Vnpix ] ) {changes[k_DACName_Vnpix ] = true; previous[k_DACName_Vnpix ] = Vnpix_ ;}
181  if( VsumCol_ != dacs[k_DACName_VsumCol ] ) {changes[k_DACName_VsumCol ] = true; previous[k_DACName_VsumCol ] = VsumCol_ ;}
182  if( Vcal_ != dacs[k_DACName_Vcal ] ) {changes[k_DACName_Vcal ] = true; previous[k_DACName_Vcal ] = Vcal_ ;}
183  if( CalDel_ != dacs[k_DACName_CalDel ] ) {changes[k_DACName_CalDel ] = true; previous[k_DACName_CalDel ] = CalDel_ ;}
184  if( TempRange_ != dacs[k_DACName_TempRange ] ) {changes[k_DACName_TempRange ] = true; previous[k_DACName_TempRange ] = TempRange_ ;}
185  if( WBC_ != dacs[k_DACName_WBC ] ) {changes[k_DACName_WBC ] = true; previous[k_DACName_WBC ] = WBC_ ;}
186  if( ChipContReg_ != dacs[k_DACName_ChipContReg] ) {changes[k_DACName_ChipContReg] = true; previous[k_DACName_ChipContReg] = ChipContReg_;}
187 }
188 
189 void PixelROCDACSettings::setDAC(unsigned int dacaddress, unsigned int dacvalue)
190 {
191  std::string mthn = "[PixelROCDACSettings::setDAC()]\t\t\t\t " ;
192  switch (dacaddress) {
193  case 1: Vdd_ = dacvalue; break;
194  case 2: Vana_ = dacvalue; break;
195  case 3: Vsf_ = dacvalue; break;
196  case 4: Vcomp_ = dacvalue; break;
197  case 5: Vleak_ = dacvalue; break;
198  case 6: VrgPr_ = dacvalue; break;
199  case 7: VwllPr_ = dacvalue; break;
200  case 8: VrgSh_ = dacvalue; break;
201  case 9: VwllSh_ = dacvalue; break;
202  case 10: VHldDel_ = dacvalue; break;
203  case 11: Vtrim_ = dacvalue; break;
204  case 12: VcThr_ = dacvalue; break;
205  case 13: VIbias_bus_ = dacvalue; break;
206  case 14: VIbias_sf_ = dacvalue; break;
207  case 15: VOffsetOp_ = dacvalue; break;
208  case 16: VbiasOp_ = dacvalue; break;
209  case 17: VOffsetRO_ = dacvalue; break;
210  case 18: VIon_ = dacvalue; break;
211  case 19: VIbias_PH_ = dacvalue; break;
212  case 20: VIbias_DAC_ = dacvalue; break;
213  case 21: VIbias_roc_ = dacvalue; break;
214  case 22: VIColOr_ = dacvalue; break;
215  case 23: Vnpix_ = dacvalue; break;
216  case 24: VsumCol_ = dacvalue; break;
217  case 25: Vcal_ = dacvalue; break;
218  case 26: CalDel_ = dacvalue; break;
219  case 27: TempRange_ = dacvalue; break;
220  case 254: WBC_ = dacvalue; break;
221  case 253: ChipContReg_ = dacvalue; break;
222  default: cout << __LINE__ << "]\t" << mthn
223  << "DAC Address " << dacaddress << " does not exist!" << endl;
224  }
225 
226 }
227 
229 {
230  out << (char)rocid_.rocname().size();
231  out.write(rocid_.rocname().c_str(),rocid_.rocname().size());
232 
233  out << Vdd_;
234  out << Vana_;
235  out << Vsf_;
236  out << Vcomp_;
237  out << Vleak_;
238  out << VrgPr_;
239  out << VwllPr_;
240  out << VrgSh_;
241  out << VwllSh_;
242  out << VHldDel_;
243  out << Vtrim_;
244  out << VcThr_;
245  out << VIbias_bus_;
246  out << VIbias_sf_;
247  out << VOffsetOp_;
248  out << VbiasOp_;
249  out << VOffsetRO_;
250  out << VIon_;
251  out << VIbias_PH_;
252  out << VIbias_DAC_;
253  out << VIbias_roc_;
254  out << VIColOr_;
255  out << Vnpix_;
256  out << VsumCol_;
257  out << Vcal_;
258  out << CalDel_;
259  out << TempRange_;
260  out << WBC_;
261  out << ChipContReg_;
262 }
263 
264 
265 int PixelROCDACSettings::readBinary(ifstream& in, const PixelROCName& rocid){
266 
267  rocid_=rocid;
268 
269  in.read((char*)&Vdd_,1);
270  in.read((char*)&Vana_,1);
271  in.read((char*)&Vsf_,1);
272  in.read((char*)&Vcomp_,1);
273  in.read((char*)&Vleak_,1);
274  in.read((char*)&VrgPr_,1);
275  in.read((char*)&VwllPr_,1);
276  in.read((char*)&VrgSh_,1);
277  in.read((char*)&VwllSh_,1);
278  in.read((char*)&VHldDel_,1);
279  in.read((char*)&Vtrim_,1);
280  in.read((char*)&VcThr_,1);
281  in.read((char*)&VIbias_bus_,1);
282  in.read((char*)&VIbias_sf_,1);
283  in.read((char*)&VOffsetOp_,1);
284  in.read((char*)&VbiasOp_,1);
285  in.read((char*)&VOffsetRO_,1);
286  in.read((char*)&VIon_,1);
287  in.read((char*)&VIbias_PH_,1);
288  in.read((char*)&VIbias_DAC_,1);
289  in.read((char*)&VIbias_roc_,1);
290  in.read((char*)&VIColOr_,1);
291  in.read((char*)&Vnpix_,1);
292  in.read((char*)&VsumCol_,1);
293  in.read((char*)&Vcal_,1);
294  in.read((char*)&CalDel_,1);
295  in.read((char*)&TempRange_,1);
296  in.read((char*)&WBC_,1);
297  in.read((char*)&ChipContReg_,1);
298 
299  return 1;
300 
301 }
302 
304 
305  out << "ROC: " << rocid_.rocname() <<endl;
306 
307  out << k_DACName_Vdd << ": " << (int)Vdd_ <<endl;
308  out << k_DACName_Vana << ": " << (int)Vana_ <<endl;
309  out << k_DACName_Vsf << ": " << (int)Vsf_ <<endl;
310  out << k_DACName_Vcomp << ": " << (int)Vcomp_ <<endl;
311  out << k_DACName_Vleak << ": " << (int)Vleak_ <<endl;
312  out << k_DACName_VrgPr << ": " << (int)VrgPr_ <<endl;
313  out << k_DACName_VwllPr << ": " << (int)VwllPr_ <<endl;
314  out << k_DACName_VrgSh << ": " << (int)VrgSh_ <<endl;
315  out << k_DACName_VwllSh << ": " << (int)VwllSh_ <<endl;
316  out << k_DACName_VHldDel << ": " << (int)VHldDel_ <<endl;
317  out << k_DACName_Vtrim << ": " << (int)Vtrim_ <<endl;
318  out << k_DACName_VcThr << ": " << (int)VcThr_ <<endl;
319  out << k_DACName_VIbias_bus << ": " << (int)VIbias_bus_ <<endl;
320  out << k_DACName_VIbias_sf << ": " << (int)VIbias_sf_ <<endl;
321  out << k_DACName_VOffsetOp << ": " << (int)VOffsetOp_ <<endl;
322  out << k_DACName_VbiasOp << ": " << (int)VbiasOp_ <<endl;
323  out << k_DACName_VOffsetRO << ": " << (int)VOffsetRO_ <<endl;
324  out << k_DACName_VIon << ": " << (int)VIon_ <<endl;
325  out << k_DACName_VIbias_PH << ": " << (int)VIbias_PH_ <<endl;
326  out << k_DACName_VIbias_DAC << ": " << (int)VIbias_DAC_ <<endl;
327  out << k_DACName_VIbias_roc << ": " << (int)VIbias_roc_ <<endl;
328  out << k_DACName_VIColOr << ": " << (int)VIColOr_ <<endl;
329  out << k_DACName_Vnpix << ": " << (int)Vnpix_ <<endl;
330  out << k_DACName_VsumCol << ": " << (int)VsumCol_ <<endl;
331  out << k_DACName_Vcal << ": " << (int)Vcal_ <<endl;
332  out << k_DACName_CalDel << ": " << (int)CalDel_ <<endl;
333  out << k_DACName_TempRange << ": " << (int)TempRange_ <<endl;
334  out << k_DACName_WBC << ": " << (int)WBC_ <<endl;
335  out << k_DACName_ChipContReg << ": " << (int)ChipContReg_ <<endl;
336 
337 }
338 
339 //=============================================================================================
340 void PixelROCDACSettings::writeXML(ofstream *out) const {
341  std::string mthn = "[PixelROCDACSettings::writeXML()]\t\t\t " ;
342 
343  *out << " <DATA>" << endl ;
344  *out << " <ROC_NAME>" << rocid_.rocname() << "</ROC_NAME>" << endl ;
345  *out << " <VDD>" << (int)Vdd_ << "</VDD>" << endl ;
346  *out << " <VANA>" << (int)Vana_ << "</VANA>" << endl ;
347  *out << " <VSF>" << (int)Vsf_ << "</VSF>" << endl ;
348  *out << " <VCOMP>" << (int)Vcomp_ << "</VCOMP>" << endl ;
349  *out << " <VLEAK>" << (int)Vleak_ << "</VLEAK>" << endl ;
350  *out << " <VRGPR>" << (int)VrgPr_ << "</VRGPR>" << endl ;
351  *out << " <VWLLPR>" << (int)VwllPr_ << "</VWLLPR>" << endl ;
352  *out << " <VRGSH>" << (int)VrgSh_ << "</VRGSH>" << endl ;
353  *out << " <VWLLSH>" << (int)VwllSh_ << "</VWLLSH>" << endl ;
354  *out << " <VHLDDEL>" << (int)VHldDel_ << "</VHLDDEL>" << endl ;
355  *out << " <VTRIM>" << (int)Vtrim_ << "</VTRIM>" << endl ;
356  *out << " <VCTHR>" << (int)VcThr_ << "</VCTHR>" << endl ;
357  *out << " <VIBIAS_BUS>" << (int)VIbias_bus_ << "</VIBIAS_BUS>" << endl ;
358  *out << " <VIBIAS_SF>" << (int)VIbias_sf_ << "</VIBIAS_SF>" << endl ;
359  *out << " <VOFFSETOP>" << (int)VOffsetOp_ << "</VOFFSETOP>" << endl ;
360  *out << " <VBIASOP>" << (int)VbiasOp_ << "</VBIASOP>" << endl ;
361  *out << " <VOFFSETRO>" << (int)VOffsetRO_ << "</VOFFSETRO>" << endl ;
362  *out << " <VION>" << (int)VIon_ << "</VION>" << endl ;
363  *out << " <VIBIAS_PH>" << (int)VIbias_PH_ << "</VIBIAS_PH>" << endl ;
364  *out << " <VIBIAS_DAC>" << (int)VIbias_DAC_ << "</VIBIAS_DAC>" << endl ;
365  *out << " <VIBIAS_ROC>" << (int)VIbias_roc_ << "</VIBIAS_ROC>" << endl ;
366  *out << " <VICOLOR>" << (int)VIColOr_ << "</VICOLOR>" << endl ;
367  *out << " <VNPIX>" << (int)Vnpix_ << "</VNPIX>" << endl ;
368  *out << " <VSUMCOL>" << (int)VsumCol_ << "</VSUMCOL>" << endl ;
369  *out << " <VCAL>" << (int)Vcal_ << "</VCAL>" << endl ;
370  *out << " <CALDEL>" << (int)CalDel_ << "</CALDEL>" << endl ;
371  *out << " <TEMPRANGE>" << (int)TempRange_ << "</TEMPRANGE>" << endl ;
372  *out << " <WBC>" << (int)WBC_ << "</WBC>" << endl ;
373  *out << " <CHIPCONTREG>" << (int)ChipContReg_ << "</CHIPCONTREG>" << endl ;
374  *out << " </DATA>" << endl ;
375  *out << " " << endl ;
376 
377 }
378 
379 //=============================================================================================
381  string dacName,
382  const PixelROCName& rocid){
383 
384  std::string mthn = "[PixelROCDACSettings::checkTag()]\t\t\t\t " ;
385  dacName+=":";
386  if (tag!=dacName) {
387  cout << __LINE__ << "]\t" << mthn << "Read ROC name : " << tag << endl;
388  cout << __LINE__ << "]\t" << mthn << "But expected to find: " << dacName << endl;
389  cout << __LINE__ << "]\t" << mthn << "When reading DAC settings for ROC " << rocid << endl;
390  assert(0);
391  }
392 
393 }
394 
395 int PixelROCDACSettings::read(std::istringstream& in, const PixelROCName& rocid)
396 {
397  std::string mthn = "[PixelROCDACSettings::read()]\t\t\t\t " ;
398 
399  rocid_=rocid;
400 
401  unsigned int tmp;
402  string tag;
403 
404  // cout << "[PixelROCDACSettings::read()] |" << in.str() << "|" << endl ;
405  in >> tag;
406  checkTag(tag,k_DACName_Vdd,rocid);
407  in >> tmp; Vdd_=tmp;
408  in >> tag;
409  checkTag(tag,k_DACName_Vana,rocid);
410  in >> tmp; Vana_=tmp;
411  in >> tag;
412  checkTag(tag,k_DACName_Vsf,rocid);
413  in >> tmp; Vsf_=tmp;
414  in >> tag;
415  checkTag(tag,k_DACName_Vcomp,rocid);
416  in >> tmp; Vcomp_=tmp;
417  in >> tag;
418  checkTag(tag,k_DACName_Vleak,rocid);
419  in >> tmp; Vleak_=tmp;
420  in >> tag;
421  checkTag(tag,k_DACName_VrgPr,rocid);
422  in >> tmp; VrgPr_=tmp;
423  in >> tag;
424  checkTag(tag,k_DACName_VwllPr,rocid);
425  in >> tmp; VwllPr_=tmp;
426  in >> tag;
427  checkTag(tag,k_DACName_VrgSh,rocid);
428  in >> tmp; VrgSh_=tmp;
429  in >> tag;
430  checkTag(tag,k_DACName_VwllSh,rocid);
431  in >> tmp; VwllSh_=tmp;
432  in >> tag;
433  checkTag(tag,k_DACName_VHldDel,rocid);
434  in >> tmp; VHldDel_=tmp;
435  in >> tag;
436  checkTag(tag,k_DACName_Vtrim,rocid);
437  in >> tmp; Vtrim_=tmp;
438  in >> tag;
439  checkTag(tag,k_DACName_VcThr,rocid);
440  in >> tmp; VcThr_=tmp;
441  in >> tag;
442  checkTag(tag,k_DACName_VIbias_bus,rocid);
443  in >> tmp; VIbias_bus_=tmp;
444  in >> tag;
445  checkTag(tag,k_DACName_VIbias_sf,rocid);
446  in >> tmp; VIbias_sf_=tmp;
447  in >> tag;
448  checkTag(tag,k_DACName_VOffsetOp,rocid);
449  in >> tmp; VOffsetOp_=tmp;
450  in >> tag;
451  checkTag(tag,k_DACName_VbiasOp,rocid);
452  in >> tmp; VbiasOp_=tmp;
453  in >> tag;
454  checkTag(tag,k_DACName_VOffsetRO,rocid);
455  in >> tmp; VOffsetRO_=tmp;
456  in >> tag;
457  checkTag(tag,k_DACName_VIon,rocid);
458  in >> tmp; VIon_=tmp;
459  in >> tag;
460  checkTag(tag,k_DACName_VIbias_PH,rocid);
461  in >> tmp; VIbias_PH_=tmp;
462  in >> tag;
463  checkTag(tag,k_DACName_VIbias_DAC,rocid);
464  in >> tmp; VIbias_DAC_=tmp;
465  in >> tag;
466  checkTag(tag,k_DACName_VIbias_roc,rocid);
467  in >> tmp; VIbias_roc_=tmp;
468  in >> tag;
469  checkTag(tag,k_DACName_VIColOr,rocid);
470  in >> tmp; VIColOr_=tmp;
471  in >> tag;
472  checkTag(tag,k_DACName_Vnpix,rocid);
473  in >> tmp; Vnpix_=tmp;
474  in >> tag;
475  checkTag(tag,k_DACName_VsumCol,rocid);
476  in >> tmp; VsumCol_=tmp;
477  in >> tag;
478  checkTag(tag,k_DACName_Vcal,rocid);
479  in >> tmp; Vcal_=tmp;
480  in >> tag;
481  checkTag(tag,k_DACName_CalDel,rocid);
482  in >> tmp; CalDel_=tmp;
483  in >> tag;
484  if (tag==k_DACName_WBC+":"){
485  static bool first=true;
486  if (first){
487  cout << __LINE__ << "]\t" << mthn << "**********************************************" << endl;
488  cout << __LINE__ << "]\t" << mthn << "Did not find TempRange setting in DAC settings" << endl;
489  cout << __LINE__ << "]\t" << mthn << "Will use a default value of 4." << endl;
490  cout << __LINE__ << "]\t" << mthn << "This message will only be printed out once" << endl;
491  cout << __LINE__ << "]\t" << mthn << "**********************************************" << endl;
492  TempRange_=4;
493  first=false;
494  }
495  in >> tmp; WBC_=tmp;
496  } else {
497  checkTag(tag,k_DACName_TempRange,rocid);
498  in >> tmp; TempRange_=tmp;
499  in >> tag;
500  checkTag(tag,k_DACName_WBC,rocid);
501  in >> tmp; WBC_=tmp;
502  }
503  in >> tag;
504  checkTag(tag,k_DACName_ChipContReg,rocid);
505  in >> tmp; ChipContReg_=tmp;
506 
507  return 0;
508 }
509 
510 int PixelROCDACSettings::read(ifstream& in, const PixelROCName& rocid){
511 
512  std::string mthn = "[PixelROCDACSettings::read()]\t\t\t\t " ;
513  rocid_=rocid;
514 
515  unsigned int tmp;
516  string tag;
517 
518  in >> tag;
519  checkTag(tag,k_DACName_Vdd,rocid);
520  in >> tmp; Vdd_=tmp;
521  in >> tag;
522  checkTag(tag,k_DACName_Vana,rocid);
523  in >> tmp; Vana_=tmp;
524  in >> tag;
525  checkTag(tag,k_DACName_Vsf,rocid);
526  in >> tmp; Vsf_=tmp;
527  in >> tag;
528  checkTag(tag,k_DACName_Vcomp,rocid);
529  in >> tmp; Vcomp_=tmp;
530  in >> tag;
531  checkTag(tag,k_DACName_Vleak,rocid);
532  in >> tmp; Vleak_=tmp;
533  in >> tag;
534  checkTag(tag,k_DACName_VrgPr,rocid);
535  in >> tmp; VrgPr_=tmp;
536  in >> tag;
537  checkTag(tag,k_DACName_VwllPr,rocid);
538  in >> tmp; VwllPr_=tmp;
539  in >> tag;
540  checkTag(tag,k_DACName_VrgSh,rocid);
541  in >> tmp; VrgSh_=tmp;
542  in >> tag;
543  checkTag(tag,k_DACName_VwllSh,rocid);
544  in >> tmp; VwllSh_=tmp;
545  in >> tag;
546  checkTag(tag,k_DACName_VHldDel,rocid);
547  in >> tmp; VHldDel_=tmp;
548  in >> tag;
549  checkTag(tag,k_DACName_Vtrim,rocid);
550  in >> tmp; Vtrim_=tmp;
551  in >> tag;
552  checkTag(tag,k_DACName_VcThr,rocid);
553  in >> tmp; VcThr_=tmp;
554  in >> tag;
555  checkTag(tag,k_DACName_VIbias_bus,rocid);
556  in >> tmp; VIbias_bus_=tmp;
557  in >> tag;
558  checkTag(tag,k_DACName_VIbias_sf,rocid);
559  in >> tmp; VIbias_sf_=tmp;
560  in >> tag;
561  checkTag(tag,k_DACName_VOffsetOp,rocid);
562  in >> tmp; VOffsetOp_=tmp;
563  in >> tag;
564  checkTag(tag,k_DACName_VbiasOp,rocid);
565  in >> tmp; VbiasOp_=tmp;
566  in >> tag;
567  checkTag(tag,k_DACName_VOffsetRO,rocid);
568  in >> tmp; VOffsetRO_=tmp;
569  in >> tag;
570  checkTag(tag,k_DACName_VIon,rocid);
571  in >> tmp; VIon_=tmp;
572  in >> tag;
573  checkTag(tag,k_DACName_VIbias_PH,rocid);
574  in >> tmp; VIbias_PH_=tmp;
575  in >> tag;
576  checkTag(tag,k_DACName_VIbias_DAC,rocid);
577  in >> tmp; VIbias_DAC_=tmp;
578  in >> tag;
579  checkTag(tag,k_DACName_VIbias_roc,rocid);
580  in >> tmp; VIbias_roc_=tmp;
581  in >> tag;
582  checkTag(tag,k_DACName_VIColOr,rocid);
583  in >> tmp; VIColOr_=tmp;
584  in >> tag;
585  checkTag(tag,k_DACName_Vnpix,rocid);
586  in >> tmp; Vnpix_=tmp;
587  in >> tag;
588  checkTag(tag,k_DACName_VsumCol,rocid);
589  in >> tmp; VsumCol_=tmp;
590  in >> tag;
591  checkTag(tag,k_DACName_Vcal,rocid);
592  in >> tmp; Vcal_=tmp;
593  in >> tag;
594  checkTag(tag,k_DACName_CalDel,rocid);
595  in >> tmp; CalDel_=tmp;
596  in >> tag;
597  if (tag==k_DACName_WBC+":"){
598  static bool first=true;
599  if (first){
600  cout << __LINE__ << "]\t" << mthn << "**********************************************" << endl;
601  cout << __LINE__ << "]\t" << mthn << "Did not find TempRange setting in DAC settings" << endl;
602  cout << __LINE__ << "]\t" << mthn << "Will use a default value of 4." << endl;
603  cout << __LINE__ << "]\t" << mthn << "This message will only be printed out once" << endl;
604  cout << __LINE__ << "]\t" << mthn << "**********************************************" << endl;
605  TempRange_=4;
606  first=false;
607  }
608  in >> tmp; WBC_=tmp;
609  } else {
610  checkTag(tag,k_DACName_TempRange,rocid);
611  in >> tmp; TempRange_=tmp;
612  in >> tag;
613  checkTag(tag,k_DACName_WBC,rocid);
614  in >> tmp; WBC_=tmp;
615  }
616  in >> tag;
617  checkTag(tag,k_DACName_ChipContReg,rocid);
618  in >> tmp; ChipContReg_=tmp;
619 
620  return 0;
621 }
622 
623 
625 
626  string s;
627 
628  return s;
629 
630 }
631 
632 ostream& pos::operator<<(ostream& s, const PixelROCDACSettings& dacs){
633 
634  s << k_DACName_Vdd << " :" << (unsigned int)dacs.Vdd_ << endl;
635  s << k_DACName_Vana << " :" << (unsigned int)dacs.Vana_ << endl;
636  s << k_DACName_Vsf << " :" << (unsigned int)dacs.Vsf_ << endl;
637  s << k_DACName_Vcomp << " :" << (unsigned int)dacs.Vcomp_ << endl;
638  s << k_DACName_Vleak << " :" << (unsigned int)dacs.Vleak_ << endl;
639  s << k_DACName_VrgPr << " :" << (unsigned int)dacs.VrgPr_ << endl;
640  s << k_DACName_VwllPr << " :" << (unsigned int)dacs.VwllPr_ << endl;
641  s << k_DACName_VrgSh << " :" << (unsigned int)dacs.VrgSh_ << endl;
642  s << k_DACName_VwllSh << " :" << (unsigned int)dacs.VwllSh_ << endl;
643  s << k_DACName_VHldDel << " :" << (unsigned int)dacs.VHldDel_ << endl;
644  s << k_DACName_Vtrim << " :" << (unsigned int)dacs.Vtrim_ << endl;
645  s << k_DACName_VcThr << " :" << (unsigned int)dacs.VcThr_ << endl;
646  s << k_DACName_VIbias_bus << " :" << (unsigned int)dacs.VIbias_bus_ << endl;
647  s << k_DACName_VIbias_sf << " :" << (unsigned int)dacs.VIbias_sf_ << endl;
648  s << k_DACName_VOffsetOp << " :" << (unsigned int)dacs.VOffsetOp_ << endl;
649  s << k_DACName_VbiasOp << " :" << (unsigned int)dacs.VbiasOp_ << endl;
650  s << k_DACName_VOffsetRO << " :" << (unsigned int)dacs.VOffsetRO_ << endl;
651  s << k_DACName_VIon << " :" << (unsigned int)dacs.VIon_ << endl;
652  s << k_DACName_VIbias_PH << " :" << (unsigned int)dacs.VIbias_PH_ << endl;
653  s << k_DACName_VIbias_DAC << " :" << (unsigned int)dacs.VIbias_DAC_ << endl;
654  s << k_DACName_VIbias_roc << " :" << (unsigned int)dacs.VIbias_roc_ << endl;
655  s << k_DACName_VIColOr << " :" << (unsigned int)dacs.VIColOr_ << endl;
656  s << k_DACName_Vnpix << " :" << (unsigned int)dacs.Vnpix_ << endl;
657  s << k_DACName_VsumCol << " :" << (unsigned int)dacs.VsumCol_ << endl;
658  s << k_DACName_Vcal << " :" << (unsigned int)dacs.Vcal_ << endl;
659  s << k_DACName_CalDel << " :" << (unsigned int)dacs.CalDel_ << endl;
660  s << k_DACName_TempRange << " :" << (unsigned int)dacs.TempRange_ << endl;
661  s << k_DACName_WBC << " :" << (unsigned int)dacs.WBC_ << endl;
662  s << k_DACName_ChipContReg << " :" << (unsigned int)dacs.ChipContReg_ << endl;
663 
664  return s;
665 
666 }
667 
668 //Added by Umesh
669 void PixelROCDACSettings::setDac(string dacName, int dacValue){
670  if(ToLower(dacName) == ToLower(k_DACName_Vdd)){
671  Vdd_ = dacValue;
672  }
673  else if(ToLower(dacName) == ToLower(k_DACName_Vana)){
674  Vana_ = dacValue;
675  }
676  else if(ToLower(dacName) == ToLower(k_DACName_Vsf)){
677  Vsf_ = dacValue;
678  }
679  else if(ToLower(dacName) == ToLower(k_DACName_Vcomp)){
680  Vcomp_ = dacValue;
681  }
682  else if(ToLower(dacName)==ToLower(k_DACName_Vleak)){
683  Vleak_ = dacValue;
684  }
685  else if(ToLower(dacName)==ToLower(k_DACName_VrgPr)){
686  VrgPr_ = dacValue;
687  }
688  else if(ToLower(dacName)==ToLower(k_DACName_VwllPr)){
689  VwllPr_ = dacValue;
690  }
691  else if(ToLower(dacName)==ToLower(k_DACName_VrgSh)){
692  VrgSh_ = dacValue;
693  }
694  else if(ToLower(dacName)==ToLower(k_DACName_VwllSh)){
695  VwllSh_ = dacValue;
696  }
697  else if(ToLower(dacName)==ToLower(k_DACName_VHldDel)){
698  VHldDel_ = dacValue;
699  }
700  else if(ToLower(dacName)==ToLower(k_DACName_Vtrim)){
701  Vtrim_ = dacValue;
702  }
703  else if(ToLower(dacName)==ToLower(k_DACName_VcThr)){
704  VcThr_ = dacValue;
705  }
706  else if(ToLower(dacName)==ToLower(k_DACName_VIbias_bus)){
707  VIbias_bus_ = dacValue;
708  }
709  else if(ToLower(dacName)==ToLower(k_DACName_VIbias_sf)){
710  VIbias_sf_ = dacValue;
711  }
712  else if(ToLower(dacName)==ToLower(k_DACName_VOffsetOp)){
713  VOffsetOp_ = dacValue;
714  }
715  else if(ToLower(dacName)==ToLower(k_DACName_VbiasOp)){
716  VbiasOp_ = dacValue;
717  }
718  else if(ToLower(dacName)==ToLower(k_DACName_VOffsetRO)){
719  VOffsetRO_ = dacValue;
720  }
721  else if(ToLower(dacName)==ToLower(k_DACName_VIon)){
722  VIon_ = dacValue;
723  }
724  else if(ToLower(dacName)==ToLower(k_DACName_VIbias_PH)){
725  VIbias_PH_ = dacValue;
726  }
727  else if(ToLower(dacName)==ToLower(k_DACName_VIbias_DAC)){
728  VIbias_DAC_ = dacValue;
729  }
730  else if(ToLower(dacName)==ToLower(k_DACName_VIbias_roc)){
731  VIbias_roc_ = dacValue;
732  }
733  else if(ToLower(dacName)==ToLower(k_DACName_VIColOr)){
734  VIColOr_ = dacValue;
735  }
736  else if(ToLower(dacName)==ToLower(k_DACName_Vnpix)){;
737  Vnpix_ = dacValue;
738  }
739  else if(ToLower(dacName)==ToLower(k_DACName_VsumCol)){
740  VsumCol_ = dacValue;
741  }
742  else if(ToLower(dacName)==ToLower(k_DACName_Vcal)){
743  Vcal_ = dacValue;
744  }
745  else if(ToLower(dacName)==ToLower(k_DACName_CalDel)){
746  CalDel_ = dacValue;
747  }
748  else if(ToLower(dacName)==ToLower(k_DACName_TempRange)){
749  TempRange_ = dacValue;
750  }
751  else if(ToLower(dacName)==ToLower(k_DACName_WBC)){
752  WBC_ = dacValue;
753  }
754  else if(ToLower(dacName)==ToLower(k_DACName_ChipContReg)){
755  ChipContReg_ = dacValue;
756  }
757  else
758  {
759  cout << "ERROR in PixelROCDACSettings::setDac: DAC name " << dacName << " does not exist." << endl;
760  assert(0);
761  }
762 
763 }
764 
765 unsigned int PixelROCDACSettings::getDac(string dacName) const {
766 
767  if(dacName == k_DACName_Vdd){
768  return Vdd_;
769  }
770  else if(dacName == k_DACName_Vana){
771  return Vana_;
772  }
773  else if(dacName == k_DACName_Vsf){
774  return Vsf_;
775  }
776  else if(dacName == k_DACName_Vcomp){
777  return Vcomp_;
778  }
779  else if(dacName == k_DACName_Vleak){
780  return Vleak_;
781  }
782  else if(dacName == k_DACName_VrgPr){
783  return VrgPr_;
784  }
785  else if(dacName == k_DACName_VwllPr){
786  return VwllPr_;
787  }
788  else if(dacName == k_DACName_VrgSh){
789  return VrgSh_;
790  }
791  else if(dacName == k_DACName_VwllSh){
792  return VwllSh_;
793  }
794  else if(dacName == k_DACName_VHldDel){
795  return VHldDel_;
796  }
797  else if(dacName == k_DACName_Vtrim){
798  return Vtrim_;
799  }
800  else if(dacName == k_DACName_VcThr){
801  return VcThr_;
802  }
803  else if(dacName == k_DACName_VIbias_bus){
804  return VIbias_bus_;
805  }
806  else if(dacName == k_DACName_VIbias_sf){
807  return VIbias_sf_;
808  }
809  else if(dacName == k_DACName_VOffsetOp){
810  return VOffsetOp_;
811  }
812  else if(dacName == k_DACName_VbiasOp){
813  return VbiasOp_;
814  }
815  else if(dacName == k_DACName_VOffsetRO){
816  return VOffsetRO_;
817  }
818  else if(dacName == k_DACName_VIon){
819  return VIon_;
820  }
821  else if(dacName == k_DACName_VIbias_PH){
822  return VIbias_PH_;
823  }
824  else if(dacName == k_DACName_VIbias_DAC){
825  return VIbias_DAC_;
826  }
827  else if(dacName == k_DACName_VIbias_roc){
828  return VIbias_roc_;
829  }
830  else if(dacName == k_DACName_VIColOr){
831  return VIColOr_;
832  }
833  else if(dacName == k_DACName_Vnpix){
834  return Vnpix_;
835  }
836  else if(dacName == k_DACName_VsumCol){
837  return VsumCol_;
838  }
839  else if(dacName == k_DACName_Vcal){
840  return Vcal_;
841  }
842  else if(dacName == k_DACName_CalDel){
843  return CalDel_;
844  }
845  else if(dacName == k_DACName_TempRange){
846  return TempRange_;
847  }
848  else if(dacName == k_DACName_WBC){
849  return WBC_;
850  }
851  else if(dacName == k_DACName_ChipContReg){
852  return ChipContReg_;
853  }
854  else {
855  cout << "ERROR in PixelROCDACSettings::getDac: DAC name " << dacName << " does not exist." << endl;
856  assert(0);
857  }
858 }
859 
860 
861 string PixelROCDACSettings::ToLower(string generic)
862 {
863  string result ;
864  for(unsigned int i = 0; i < generic.length() ; i++)
865  {
866  result.append(1,(char)tolower(generic[i]) );
867  }
868  return result ;
869 }
const std::string k_DACName_VcThr
Definition: PixelDACNames.h:24
const std::string k_DACName_VrgPr
Definition: PixelDACNames.h:18
unsigned int getDac(std::string dacName) const
int i
Definition: DBlmapReader.cc:9
const std::string k_DACName_ChipContReg
Definition: PixelDACNames.h:41
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
assert(m_qm.get())
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
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)
void getDACs(std::vector< unsigned int > &dacs) const
int read(std::ifstream &in, const PixelROCName &rocid)
const std::string k_DACName_VIColOr
Definition: PixelDACNames.h:34
void setDAC(unsigned int dacaddress, unsigned int dacvalue)
This class provide the data structure for the ROC DAC parameters.
const std::string k_DACName_VOffsetOp
Definition: PixelDACNames.h:27
void writeXML(pos::PixelConfigKey key, int version, std::string path) const
void setDACs(std::map< std::string, unsigned int > &dacs)
std::string ToLower(std::string)
tuple result
Definition: query.py:137
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
const std::string k_DACName_VrgSh
Definition: PixelDACNames.h:20
tuple out
Definition: dbtoconf.py:99
const std::string k_DACName_VIon
Definition: PixelDACNames.h:30
const std::string k_DACName_Vcomp
Definition: PixelDACNames.h:16
void checkTag(std::string tag, std::string dacName, const PixelROCName &rocid)
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
void compareDACs(std::map< std::string, unsigned int > &dacs, std::map< std::string, bool > &changes, std::map< std::string, unsigned int > &previous)
void setDac(std::string dacName, int value)
const std::string k_DACName_VsumCol
Definition: PixelDACNames.h:36
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
This class implements..
Definition: PixelROCName.h:23
void writeBinary(std::ofstream &out) const
int readBinary(std::ifstream &in, const PixelROCName &rocid)
A dummy class with ALL public variables.
This class implements..
tuple cout
Definition: gather_cfg.py:121
const std::string k_DACName_Vana
Definition: PixelDACNames.h:14
const std::string k_DACName_VwllPr
Definition: PixelDACNames.h:19
void writeASCII(std::ostream &out) const