22 using namespace pos::PortCardSettingNames;
26 PixelPortCardConfig::PixelPortCardConfig(
vector<vector<string> > &tableMat) :
PixelConfigBase(
" ",
" ",
" ") {
27 string mthn =
"]\t[PixelPortCardConfig::PixelPortCardConfig()]\t\t ";
28 map<string, int> colM;
29 vector<string> colNames;
122 colNames.push_back(
"CONFIG_KEY");
123 colNames.push_back(
"KEY_TYPE");
124 colNames.push_back(
"KEY_ALIAS");
125 colNames.push_back(
"VERSION");
126 colNames.push_back(
"KIND_OF_COND");
127 colNames.push_back(
"PORT_CARD");
128 colNames.push_back(
"TRKFEC");
129 colNames.push_back(
"RING");
130 colNames.push_back(
"CHANNEL");
131 colNames.push_back(
"CCU_ADDR");
132 colNames.push_back(
"I2C_CNTRL");
133 colNames.push_back(
"I2C_SPEED");
134 colNames.push_back(
"AOH_BIAS1");
135 colNames.push_back(
"AOH_BIAS2");
136 colNames.push_back(
"AOH_BIAS3");
137 colNames.push_back(
"AOH_BIAS4");
138 colNames.push_back(
"AOH_BIAS5");
139 colNames.push_back(
"AOH_BIAS6");
140 colNames.push_back(
"AOH_GAIN1");
141 colNames.push_back(
"AOH_GAIN2");
142 colNames.push_back(
"AOH_GAIN3");
143 colNames.push_back(
"AOH_GAIN4");
144 colNames.push_back(
"AOH_GAIN5");
145 colNames.push_back(
"AOH_GAIN6");
146 colNames.push_back(
"AOH1_BIAS1");
147 colNames.push_back(
"AOH1_BIAS2");
148 colNames.push_back(
"AOH1_BIAS3");
149 colNames.push_back(
"AOH1_BIAS4");
150 colNames.push_back(
"AOH1_BIAS5");
151 colNames.push_back(
"AOH1_BIAS6");
152 colNames.push_back(
"AOH1_GAIN1");
153 colNames.push_back(
"AOH1_GAIN2");
154 colNames.push_back(
"AOH1_GAIN3");
155 colNames.push_back(
"AOH1_GAIN4");
156 colNames.push_back(
"AOH1_GAIN5");
157 colNames.push_back(
"AOH1_GAIN6");
158 colNames.push_back(
"AOH2_BIAS1");
159 colNames.push_back(
"AOH2_BIAS2");
160 colNames.push_back(
"AOH2_BIAS3");
161 colNames.push_back(
"AOH2_BIAS4");
162 colNames.push_back(
"AOH2_BIAS5");
163 colNames.push_back(
"AOH2_BIAS6");
164 colNames.push_back(
"AOH2_GAIN1");
165 colNames.push_back(
"AOH2_GAIN2");
166 colNames.push_back(
"AOH2_GAIN3");
167 colNames.push_back(
"AOH2_GAIN4");
168 colNames.push_back(
"AOH2_GAIN5");
169 colNames.push_back(
"AOH2_GAIN6");
170 colNames.push_back(
"AOH3_BIAS1");
171 colNames.push_back(
"AOH3_BIAS2");
172 colNames.push_back(
"AOH3_BIAS3");
173 colNames.push_back(
"AOH3_BIAS4");
174 colNames.push_back(
"AOH3_BIAS5");
175 colNames.push_back(
"AOH3_BIAS6");
176 colNames.push_back(
"AOH3_GAIN1");
177 colNames.push_back(
"AOH3_GAIN2");
178 colNames.push_back(
"AOH3_GAIN3");
179 colNames.push_back(
"AOH3_GAIN4");
180 colNames.push_back(
"AOH3_GAIN5");
181 colNames.push_back(
"AOH3_GAIN6");
182 colNames.push_back(
"AOH4_BIAS1");
183 colNames.push_back(
"AOH4_BIAS2");
184 colNames.push_back(
"AOH4_BIAS3");
185 colNames.push_back(
"AOH4_BIAS4");
186 colNames.push_back(
"AOH4_BIAS5");
187 colNames.push_back(
"AOH4_BIAS6");
188 colNames.push_back(
"AOH4_GAIN1");
189 colNames.push_back(
"AOH4_GAIN2");
190 colNames.push_back(
"AOH4_GAIN3");
191 colNames.push_back(
"AOH4_GAIN4");
192 colNames.push_back(
"AOH4_GAIN5");
193 colNames.push_back(
"AOH4_GAIN6");
194 colNames.push_back(
"DELAY25_GCR");
195 colNames.push_back(
"DELAY25_SCL");
196 colNames.push_back(
"DELAY25_TRG");
197 colNames.push_back(
"DELAY25_SDA");
198 colNames.push_back(
"DELAY25_RCL");
199 colNames.push_back(
"DELAY25_RDA");
200 colNames.push_back(
"DOH_BIAS0");
201 colNames.push_back(
"DOH_BIAS1");
202 colNames.push_back(
"DOH_SEU_GAIN");
203 colNames.push_back(
"PLL_CTR1");
204 colNames.push_back(
"PLL_CTR2");
205 colNames.push_back(
"PLL_CTR3");
206 colNames.push_back(
"PLL_CTR4");
207 colNames.push_back(
"PLL_CTR5");
210 unsigned int othercount = 100;
211 unsigned int delay25count = 50;
213 unsigned int pllcount = 1;
215 for (
unsigned int c = 0;
c < tableMat[0].size();
c++) {
216 for (
unsigned int n = 0;
n < colNames.size();
n++) {
217 if (tableMat[0][
c] == colNames[
n]) {
218 colM[colNames[
n]] =
c;
223 for (
unsigned int n = 0;
n < colNames.size();
n++) {
224 if (colM.find(colNames[
n]) == colM.end()) {
225 std::cerr << __LINE__ << mthn <<
"\tCouldn't find in the database the column with name " << colNames[
n]
231 portcardname_ = tableMat[1][colM[
"PORT_CARD"]];
233 if (portcardname_.find(
"FPix") != std::string::npos) {
235 }
else if (portcardname_.find(
"BPix") != std::string::npos) {
239 fillDBToFileAddress();
241 TKFECID_ = tableMat[1][colM[
"TRKFEC"]];
242 ringAddress_ = atoi(tableMat[1][colM[
"RING"]].c_str());
243 ccuAddress_ = atoi(tableMat[1][colM[
"CCU_ADDR"]].c_str());
244 channelAddress_ = atoi(tableMat[1][colM[
"CHANNEL"]].c_str());
245 i2cSpeed_ = atoi(tableMat[1][colM[
"I2C_SPEED"]].c_str());
254 for (
unsigned int col = 0;
col < tableMat[1].size();
col++)
257 unsigned int i2c_address;
258 unsigned int i2c_values;
260 settingName = tableMat[0][
col];
261 i2c_values = atoi(tableMat[1][
col].c_str());
264 if (type_ ==
"fpix" && settingName.find(
"AOH_") != string::npos &&
265 settingName.find(
"GAIN") != string::npos
266 && settingName.find(
"123") == string::npos &&
267 settingName.find(
"456") == string::npos)
269 setDataBaseAOHGain(settingName, i2c_values);
271 }
else if (type_ ==
"bpix" && settingName.find(
"AOH") != string::npos &&
272 settingName.find(
"GAIN") != string::npos
273 && settingName.find(
"AOH_") == string::npos
274 && settingName.find(
"123") == string::npos &&
275 settingName.find(
"456") == string::npos)
277 if (portcardname_.find(
"PRT2") != std::string::npos &&
278 (settingName.find(
"AOH3_") != std::string::npos || settingName.find(
"AOH4_") != std::string::npos))
280 setDataBaseAOHGain(settingName, i2c_values);
286 unsigned int last_CTR2 = 0x0;
288 last_CTR2 = getdeviceValuesForSetting(
k_PLL_CTR2);
290 device_.push_back(make_pair(getdeviceAddressForSetting(
k_PLL_CTR2), new_PLL_CTR2_value(settingName, last_CTR2)));
291 device_.push_back(make_pair(getdeviceAddressForSetting(
k_PLL_CTR4or5), i2c_values));
293 key_.push_back(pllcount++);
294 key_.push_back(pllcount++);
299 if ((settingName.find(
"DELAY25_") != std::string::npos) || (settingName.find(
"_BIAS") != std::string::npos) ||
300 (settingName.find(
"PLL_CTR2") != std::string::npos) || (settingName.find(
"PLL_CTR5") != std::string::npos) ||
301 ((settingName.find(
"DOH_SEU_GAIN") != std::string::npos) && type_ ==
"bpix"))
304 map<string, string>::iterator iter = nameDBtoFileConversion_.find(settingName);
305 if (iter == nameDBtoFileConversion_.end())
307 map<string, unsigned int>::iterator foundName_itr = nameToAddress_.find(nameDBtoFileConversion_[settingName]);
309 if (foundName_itr != nameToAddress_.end()) {
310 if (portcardname_.find(
"PRT2") != std::string::npos &&
311 (settingName.find(
"AOH3_") != std::string::npos || settingName.find(
"AOH4_") != std::string::npos))
313 i2c_address = foundName_itr->second;
315 i2c_address = strtoul(settingName.c_str(),
nullptr, 16);
317 if (type_ ==
"fpix" &&
318 (settingName.find(
"AOH1_") != std::string::npos || settingName.find(
"AOH2_") != std::string::npos ||
319 settingName.find(
"AOH3_") != std::string::npos || settingName.find(
"AOH4_") != std::string::npos))
322 pair<unsigned int, unsigned int>
p(i2c_address, i2c_values);
337 device_.push_back(
p);
338 if (settingName.find(
"AOH") != string::npos)
339 key_.push_back(aohcount_++);
340 else if (settingName.find(
"Delay25") != string::npos)
341 key_.push_back(delay25count++);
342 else if (settingName.find(
"PLL") != string::npos)
343 key_.push_back(pllcount++);
345 key_.push_back(othercount++);
355 string mthn =
"[PixelPortCardConfig::PixelPortCardConfig()]\t\t ";
358 size_t portcardpos = filename.find(
std::string(
"portcard_"));
360 assert(portcardpos != (
unsigned int)std::string::npos);
361 size_t datpos = filename.find(
std::string(
".dat"));
363 assert(datpos != (
unsigned int)std::string::npos);
364 assert(datpos > portcardpos);
366 portcardname_ = filename.substr(portcardpos + 9, datpos - portcardpos - 9);
370 std::ifstream
in(filename.c_str());
373 std::cout << __LINE__ <<
"]\t" << mthn <<
"Could not open: " << filename << std::endl;
374 throw std::runtime_error(
"Failed to open file " + filename);
376 std::cout << __LINE__ <<
"]\t" << mthn <<
"Opened: " << filename << std::endl;
382 if (dummy ==
"Name:")
388 if (dummy ==
"Type:")
391 assert(type_ ==
"fpix" || type_ ==
"bpix");
398 assert(dummy ==
"TKFECID:");
401 assert(dummy ==
"ringAddress:");
404 assert(dummy ==
"ccuAddress:");
407 assert(dummy ==
"channelAddress:");
410 assert(dummy ==
"i2cSpeed:");
419 unsigned int i2c_address;
420 unsigned int i2c_values;
422 in >> settingName >> std::hex >> i2c_values >>
std::dec;
426 if (settingName[settingName.size() - 1] ==
':')
427 settingName.resize(settingName.size() - 1);
430 if (settingName.find(
"AOH") != string::npos &&
431 settingName.find(
"Gain") != string::npos
432 && settingName.find(
"123") == string::npos &&
433 settingName.find(
"456") == string::npos)
438 unsigned int last_CTR2 = 0x0;
446 std::map<std::string, unsigned int>::iterator foundName_itr =
nameToAddress_.find(settingName);
449 i2c_address = foundName_itr->second;
451 i2c_address = strtoul(settingName.c_str(),
nullptr, 16);
453 pair<unsigned int, unsigned int>
p(i2c_address, i2c_values);
462 std::set<pair<unsigned int, pair<unsigned int, unsigned int> > > sorted;
464 for (
unsigned int i = 0;
i <
device_.size();
i++) {
471 for (set<pair<
unsigned int, pair<unsigned int, unsigned int> > >::iterator
i = sorted.begin();
i != sorted.end();
483 return 0xdf & last_CTR2;
485 return 0x20 | last_CTR2;
491 assert(settingName.find(
"AOH") != string::npos &&
492 settingName.find(
"Gain") != string::npos
493 && settingName.find(
"123") == string::npos &&
494 settingName.find(
"456") == string::npos);
496 unsigned int i2c_address;
500 unsigned int whichAOH;
501 if (settingName[GainPosition - 2] ==
'H')
505 char whichAOHDigit[2] = {0, 0};
506 whichAOHDigit[0] = settingName[GainPosition - 2];
507 whichAOH = atoi(whichAOHDigit);
509 char digit[2] = {0, 0};
510 digit[0] = settingName[GainPosition + 4];
511 unsigned int channelOnAOH = atoi(digit);
512 assert((
type_ ==
"fpix" && whichAOH == 0) || (
type_ ==
"bpix" && 1 <= whichAOH && whichAOH <= 4));
513 assert(1 <= channelOnAOH && channelOnAOH <= 6);
515 if (whichAOH == 0 && channelOnAOH <= 3)
517 else if (whichAOH == 0 && channelOnAOH >= 4)
519 else if (whichAOH == 1 && channelOnAOH <= 3)
521 else if (whichAOH == 1 && channelOnAOH >= 4)
523 else if (whichAOH == 2 && channelOnAOH <= 3)
525 else if (whichAOH == 2 && channelOnAOH >= 4)
527 else if (whichAOH == 3 && channelOnAOH <= 3)
529 else if (whichAOH == 3 && channelOnAOH >= 4)
531 else if (whichAOH == 4 && channelOnAOH <= 3)
533 else if (whichAOH == 4 && channelOnAOH >= 4)
539 bool foundOne =
false;
540 for (
unsigned int i = 0;
i <
device_.size();
i++) {
544 unsigned int oldValue =
device_[
i].second;
545 if (channelOnAOH % 3 == 1)
546 device_[
i].second = (0x3c & oldValue) + ((value & 0x3) << 0);
547 else if (channelOnAOH % 3 == 2)
548 device_[
i].second = (0x33 & oldValue) + ((value & 0x3) << 2);
549 else if (channelOnAOH % 3 == 0)
550 device_[
i].second = (0x0f & oldValue) + ((value & 0x3) << 4);
560 unsigned int i2c_value;
561 if (channelOnAOH % 3 == 1)
562 i2c_value = ((value & 0x3) << 0);
563 else if (channelOnAOH % 3 == 2)
564 i2c_value = ((value & 0x3) << 2);
565 else if (channelOnAOH % 3 == 0)
566 i2c_value = ((value & 0x3) << 4);
570 pair<unsigned int, unsigned int>
p(i2c_address, i2c_value);
577 unsigned int i2c_address;
581 unsigned int whichAOH;
582 if (
type_ ==
"fpix") {
586 char whichAOHDigit[2] = {0, 0};
587 whichAOHDigit[0] = settingName[GainPosition - 2];
588 whichAOH = atoi(whichAOHDigit);
590 char digit[2] = {0, 0};
591 digit[0] = settingName[GainPosition + 4];
592 unsigned int channelOnAOH = atoi(digit);
593 assert((
type_ ==
"fpix" && whichAOH == 0) || (
type_ ==
"bpix" && 1 <= whichAOH && whichAOH <= 4));
594 assert(1 <= channelOnAOH && channelOnAOH <= 6);
596 if (whichAOH == 0 && channelOnAOH <= 3)
598 else if (whichAOH == 0 && channelOnAOH >= 4)
600 else if (whichAOH == 1 && channelOnAOH <= 3)
602 else if (whichAOH == 1 && channelOnAOH >= 4)
604 else if (whichAOH == 2 && channelOnAOH <= 3)
606 else if (whichAOH == 2 && channelOnAOH >= 4)
608 else if (whichAOH == 3 && channelOnAOH <= 3)
610 else if (whichAOH == 3 && channelOnAOH >= 4)
612 else if (whichAOH == 4 && channelOnAOH <= 3)
614 else if (whichAOH == 4 && channelOnAOH >= 4)
620 bool foundOne =
false;
621 for (
unsigned int i = 0;
i <
device_.size();
i++) {
625 unsigned int oldValue =
device_[
i].second;
626 if (channelOnAOH % 3 == 1)
627 device_[
i].second = (0x3c & oldValue) + ((value & 0x3) << 0);
628 else if (channelOnAOH % 3 == 2)
629 device_[
i].second = (0x33 & oldValue) + ((value & 0x3) << 2);
630 else if (channelOnAOH % 3 == 0)
631 device_[
i].second = (0x0f & oldValue) + ((value & 0x3) << 4);
641 unsigned int i2c_value;
642 if (channelOnAOH % 3 == 1)
643 i2c_value = ((value & 0x3) << 0);
644 else if (channelOnAOH % 3 == 2)
645 i2c_value = ((value & 0x3) << 2);
646 else if (channelOnAOH % 3 == 0)
647 i2c_value = ((value & 0x3) << 4);
651 pair<unsigned int, unsigned int>
p(i2c_address, i2c_value);
662 if (
type_ ==
"fpix") {
688 }
else if (
type_ ==
"bpix") {
748 if (
type_ ==
"fpix") {
869 }
else if (
type_ ==
"bpix") {
988 std::string mthn =
"[PixelPortCardConfig::writeASCII()]\t\t\t\t ";
993 std::ofstream
out(filename.c_str());
995 std::cout << __LINE__ <<
"]\t" << mthn <<
"Could not open file: " << filename.c_str() << std::endl;
999 out <<
"Name: " << portcardname_ << std::endl;
1000 out <<
"Type: " <<
type_ << std::endl;
1009 bool found_PLL_CTR2 =
false;
1010 unsigned int last_PLL_CTR2_value = 0x0;
1011 for (
unsigned int i = 0;
i <
device_.size();
i++) {
1012 unsigned int deviceAddress =
device_.at(
i).first;
1026 unsigned int zeroOrThree;
1028 whichAOHString =
"";
1031 whichAOHString =
"";
1034 whichAOHString =
"1";
1037 whichAOHString =
"1";
1040 whichAOHString =
"2";
1043 whichAOHString =
"2";
1046 whichAOHString =
"3";
1049 whichAOHString =
"3";
1052 whichAOHString =
"4";
1055 whichAOHString =
"4";
1060 out <<
"AOH" << whichAOHString <<
"_Gain" << zeroOrThree + 1 <<
": 0x" << (((
device_[
i].second) & 0x03) >> 0)
1062 out <<
"AOH" << whichAOHString <<
"_Gain" << zeroOrThree + 2 <<
": 0x" << (((
device_[
i].second) & 0x0c) >> 2)
1064 out <<
"AOH" << whichAOHString <<
"_Gain" << zeroOrThree + 3 <<
": 0x" << (((
device_[
i].second) & 0x30) >> 4)
1072 for (std::map<std::string, unsigned int>::const_iterator nameToAddress_itr =
nameToAddress_.begin();
1074 ++nameToAddress_itr) {
1078 if (nameToAddress_itr->second == deviceAddress) {
1079 settingName = nameToAddress_itr->first;
1083 cout <<
"[PixelPortCardConfig::WriteASCII()]\tdeviceAddress: " << deviceAddress <<
" NOT FOUND" << endl;
1089 if (found_PLL_CTR2 && last_PLL_CTR2_value ==
device_.at(
i).second)
1091 found_PLL_CTR2 =
true;
1092 last_PLL_CTR2_value =
device_.at(
i).second;
1096 if ((last_PLL_CTR2_value & 0x20) == 0x0)
1103 if (settingName.empty())
1106 out << settingName <<
":";
1139 for (
int i =
device_.size() - 1;
i >= 0;
1142 if (
device_.at(
i).first == address) {
1149 pair<unsigned int, unsigned int>
p(address, value);
1162 std::map<std::string, unsigned int>::const_iterator foundName_itr =
nameToAddress_.find(settingName);
1164 return foundName_itr->second;
1172 for (
int i =
device_.size() - 1;
i >= 0;
i--)
1174 if (
device_.at(
i).first == address) {
1183 for (
std::vector<std::pair<unsigned int, unsigned int> >::const_iterator device_itr =
device_.begin();
1186 if (device_itr->first == deviceAddress)
1193 std::string mthn =
"[PixelPortCardConfig::AOHBiasAddressFromAOHNumber()] ";
1194 if (
type_ ==
"fpix") {
1197 else if (AOHNumber == 2)
1199 else if (AOHNumber == 3)
1201 else if (AOHNumber == 4)
1203 else if (AOHNumber == 5)
1205 else if (AOHNumber == 6)
1209 <<
"ERROR: For fpix, AOH number must be in the range 1-6, but the given AOH number was " << AOHNumber
1210 <<
"." << std::endl;
1213 }
else if (
type_ ==
"bpix") {
1216 else if (AOHNumber == 2)
1218 else if (AOHNumber == 3)
1220 else if (AOHNumber == 4)
1222 else if (AOHNumber == 5)
1224 else if (AOHNumber == 6)
1226 else if (AOHNumber == 7)
1228 else if (AOHNumber == 8)
1230 else if (AOHNumber == 9)
1232 else if (AOHNumber == 10)
1234 else if (AOHNumber == 11)
1236 else if (AOHNumber == 12)
1238 else if (AOHNumber == 13)
1240 else if (AOHNumber == 14)
1242 else if (AOHNumber == 15)
1244 else if (AOHNumber == 16)
1246 else if (AOHNumber == 17)
1248 else if (AOHNumber == 18)
1250 else if (AOHNumber == 19)
1252 else if (AOHNumber == 20)
1254 else if (AOHNumber == 21)
1256 else if (AOHNumber == 22)
1258 else if (AOHNumber == 23)
1260 else if (AOHNumber == 24)
1264 <<
"ERROR: For bpix, AOH number must be in the range 1-24, but the given AOH number was " << AOHNumber
1265 <<
"." << std::endl;
1273 std::string mthn =
"[PixelPortCardConfig::AOHGainStringFromAOHNumber()] ";
1274 if (
type_ ==
"fpix") {
1277 else if (AOHNumber == 2)
1279 else if (AOHNumber == 3)
1281 else if (AOHNumber == 4)
1283 else if (AOHNumber == 5)
1285 else if (AOHNumber == 6)
1289 <<
"ERROR: For fpix, AOH number must be in the range 1-6, but the given AOH number was " << AOHNumber
1290 <<
"." << std::endl;
1293 }
else if (
type_ ==
"bpix") {
1295 return "AOH1_Gain1";
1296 else if (AOHNumber == 2)
1297 return "AOH1_Gain2";
1298 else if (AOHNumber == 3)
1299 return "AOH1_Gain3";
1300 else if (AOHNumber == 4)
1301 return "AOH1_Gain4";
1302 else if (AOHNumber == 5)
1303 return "AOH1_Gain5";
1304 else if (AOHNumber == 6)
1305 return "AOH1_Gain6";
1306 else if (AOHNumber == 7)
1307 return "AOH2_Gain1";
1308 else if (AOHNumber == 8)
1309 return "AOH2_Gain2";
1310 else if (AOHNumber == 9)
1311 return "AOH2_Gain3";
1312 else if (AOHNumber == 10)
1313 return "AOH2_Gain4";
1314 else if (AOHNumber == 11)
1315 return "AOH2_Gain5";
1316 else if (AOHNumber == 12)
1317 return "AOH2_Gain6";
1318 else if (AOHNumber == 13)
1319 return "AOH3_Gain1";
1320 else if (AOHNumber == 14)
1321 return "AOH3_Gain2";
1322 else if (AOHNumber == 15)
1323 return "AOH3_Gain3";
1324 else if (AOHNumber == 16)
1325 return "AOH3_Gain4";
1326 else if (AOHNumber == 17)
1327 return "AOH3_Gain5";
1328 else if (AOHNumber == 18)
1329 return "AOH3_Gain6";
1330 else if (AOHNumber == 19)
1331 return "AOH4_Gain1";
1332 else if (AOHNumber == 20)
1333 return "AOH4_Gain2";
1334 else if (AOHNumber == 21)
1335 return "AOH4_Gain3";
1336 else if (AOHNumber == 22)
1337 return "AOH4_Gain4";
1338 else if (AOHNumber == 23)
1339 return "AOH4_Gain5";
1340 else if (AOHNumber == 24)
1341 return "AOH4_Gain6";
1344 <<
"ERROR: For bpix, AOH number must be in the range 1-24, but the given AOH number was " << AOHNumber
1345 <<
"." << std::endl;
1353 std::string mthn =
"[PixelPortCardConfig::AOHGainAddressFromAOHNumber()] ";
1354 unsigned int address;
1355 if (
type_ ==
"fpix") {
1358 else if (AOHNumber == 2)
1360 else if (AOHNumber == 3)
1362 else if (AOHNumber == 4)
1364 else if (AOHNumber == 5)
1366 else if (AOHNumber == 6)
1370 <<
"ERROR: For fpix, AOH number must be in the range 1-6, but the given AOH number was " << AOHNumber
1371 <<
"." << std::endl;
1374 }
else if (
type_ ==
"bpix") {
1377 else if (AOHNumber == 2)
1379 else if (AOHNumber == 3)
1381 else if (AOHNumber == 4)
1383 else if (AOHNumber == 5)
1385 else if (AOHNumber == 6)
1387 else if (AOHNumber == 7)
1389 else if (AOHNumber == 8)
1391 else if (AOHNumber == 9)
1393 else if (AOHNumber == 10)
1395 else if (AOHNumber == 11)
1397 else if (AOHNumber == 12)
1399 else if (AOHNumber == 13)
1401 else if (AOHNumber == 14)
1403 else if (AOHNumber == 15)
1405 else if (AOHNumber == 16)
1407 else if (AOHNumber == 17)
1409 else if (AOHNumber == 18)
1411 else if (AOHNumber == 19)
1413 else if (AOHNumber == 20)
1415 else if (AOHNumber == 21)
1417 else if (AOHNumber == 22)
1419 else if (AOHNumber == 23)
1421 else if (AOHNumber == 24)
1425 <<
"ERROR: For bpix, AOH number must be in the range 1-24, but the given AOH number was " << AOHNumber
1426 <<
"." << std::endl;
1439 if (AOHNumber % 3 == 1)
1440 return (((threeGainsValue)&0x03) >> 0);
1441 if (AOHNumber % 3 == 2)
1442 return (((threeGainsValue)&0x0c) >> 2);
1443 if (AOHNumber % 3 == 0)
1444 return (((threeGainsValue)&0x30) >> 4);
1452 std::ofstream *outstream,
1453 std::ofstream *out1stream,
1454 std::ofstream *out2stream)
const {
1455 std::string mthn =
"[PixelPortCardConfig::writeXMLHeader()]\t\t\t ";
1458 std::cout << __LINE__ <<
"]\t" << mthn <<
"Writing to: " << fullPath.str() << std::endl;
1460 outstream->open(fullPath.str().c_str());
1462 *outstream <<
"<?xml version='1.0' encoding='UTF-8' standalone='yes'?>" << std::endl;
1463 *outstream <<
"<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" << std::endl;
1464 *outstream <<
" <HEADER>" << std::endl;
1465 *outstream <<
" <TYPE>" << std::endl;
1466 *outstream <<
" <EXTENSION_TABLE_NAME>PIXEL_PORTCARD_SETTINGS</EXTENSION_TABLE_NAME>" << std::endl;
1467 *outstream <<
" <NAME>Pixel Port Card Settings</NAME>" << std::endl;
1468 *outstream <<
" </TYPE>" << std::endl;
1469 *outstream <<
" <RUN>" << std::endl;
1470 *outstream <<
" <RUN_TYPE>Pixel Port Card Settings</RUN_TYPE>" << std::endl;
1471 *outstream <<
" <RUN_NUMBER>1</RUN_NUMBER>" << std::endl;
1474 *outstream <<
" <LOCATION>CERN P5</LOCATION>" << std::endl;
1475 *outstream <<
" </RUN>" << std::endl;
1476 *outstream <<
" </HEADER>" << std::endl;
1477 *outstream <<
"" << std::endl;
1478 *outstream <<
" <DATA_SET>" << std::endl;
1479 *outstream <<
" <PART>" << std::endl;
1480 *outstream <<
" <NAME_LABEL>CMS-PIXEL-ROOT</NAME_LABEL>" << std::endl;
1481 *outstream <<
" <KIND_OF_PART>Detector ROOT</KIND_OF_PART>" << std::endl;
1482 *outstream <<
" </PART>" << std::endl;
1483 *outstream <<
" <VERSION>" << version <<
"</VERSION>" << std::endl;
1484 *outstream <<
" <COMMENT_DESCRIPTION>" <<
getComment() <<
"</COMMENT_DESCRIPTION>" << std::endl;
1485 *outstream <<
" <CREATED_BY_USER>" <<
getAuthor() <<
"</CREATED_BY_USER>" << std::endl;
1486 *outstream <<
"" << std::endl;
1491 std::ofstream *out1stream,
1492 std::ofstream *out2stream)
const {
1493 std::string mthn =
"[PixelPortCardConfig::writeXML()]\t\t\t ";
1495 *outstream <<
" <DATA>" << std::endl;
1496 *outstream <<
" <PORT_CARD>" <<
portcardname_ <<
"</PORT_CARD>" << std::endl;
1497 *outstream <<
" <TRKFEC>" <<
TKFECID_ <<
"</TRKFEC>" << std::endl;
1498 *outstream <<
" <RING>" <<
ringAddress_ <<
"</RING>" << std::endl;
1499 *outstream <<
" <CCU_ADDR>" <<
ccuAddress_ <<
"</CCU_ADDR>" << std::endl;
1500 *outstream <<
" <CHANNEL>" <<
channelAddress_ <<
"</CHANNEL>" << std::endl;
1501 *outstream <<
" <I2C_SPEED>" <<
i2cSpeed_ <<
"</I2C_SPEED>" << std::endl;
1503 bool found_PLL_CTR2 =
false;
1504 unsigned int last_PLL_CTR2_value = 0x0;
1505 for (
unsigned int i = 0;
i <
device_.size();
i++) {
1506 unsigned int deviceAddress =
device_.at(
i).first;
1520 unsigned int zeroOrThree;
1522 whichAOHString =
"";
1525 whichAOHString =
"";
1528 whichAOHString =
"1";
1531 whichAOHString =
"1";
1534 whichAOHString =
"2";
1537 whichAOHString =
"2";
1540 whichAOHString =
"3";
1543 whichAOHString =
"3";
1546 whichAOHString =
"4";
1549 whichAOHString =
"4";
1554 *outstream <<
" <AOH" << whichAOHString <<
"_GAIN" << zeroOrThree + 1 <<
">"
1555 << (((
device_[
i].second) & 0x03) >> 0) <<
"</AOH" << whichAOHString <<
"_GAIN" << zeroOrThree + 1
1556 <<
">" << std::endl;
1557 *outstream <<
" <AOH" << whichAOHString <<
"_GAIN" << zeroOrThree + 2 <<
">"
1558 << (((
device_[
i].second) & 0x0c) >> 2) <<
"</AOH" << whichAOHString <<
"_GAIN" << zeroOrThree + 2
1559 <<
">" << std::endl;
1560 *outstream <<
" <AOH" << whichAOHString <<
"_GAIN" << zeroOrThree + 3 <<
">"
1561 << (((
device_[
i].second) & 0x30) >> 4) <<
"</AOH" << whichAOHString <<
"_GAIN" << zeroOrThree + 3
1562 <<
">" << std::endl;
1569 for (std::map<std::string, unsigned int>::const_iterator nameToAddress_itr =
nameToAddress_.begin();
1571 ++nameToAddress_itr) {
1572 if (nameToAddress_itr->second == deviceAddress) {
1573 settingName = nameToAddress_itr->first;
1577 for (std::map<std::string, std::string>::const_iterator nameDBtoFileConversion_itr =
1580 ++nameDBtoFileConversion_itr) {
1581 if (nameDBtoFileConversion_itr->second.find(settingName) != std::string::npos) {
1582 settingName = nameDBtoFileConversion_itr->first;
1589 if (found_PLL_CTR2 && last_PLL_CTR2_value ==
device_.at(
i).second)
1591 found_PLL_CTR2 =
true;
1592 last_PLL_CTR2_value =
device_.at(
i).second;
1596 if ((last_PLL_CTR2_value & 0x20) == 0x0)
1603 if (settingName.empty())
1606 *outstream <<
" <" << settingName <<
">";
1608 *outstream <<
device_.at(
i).second <<
"</" << settingName <<
">" << std::endl;
1611 *outstream <<
" </DATA>" << std::endl;
1615 std::ofstream *out1stream,
1616 std::ofstream *out2stream)
const {
1617 std::string mthn =
"[PixelPortCardConfig::writeXMLTrailer()]\t\t\t ";
1619 *outstream <<
" </DATA_SET>" << std::endl;
1620 *outstream <<
"</ROOT> " << std::endl;
void writeXML(pos::PixelConfigKey key, int version, std::string path) const override
const unsigned int k_bpix_AOH4_Bias6_address
const std::string k_AOH_Bias6
unsigned int new_PLL_CTR2_value(std::string CTR4or5, unsigned int last_CTR2) const
const unsigned int k_fpix_AOH_Bias6_address
bool containsDeviceAddress(unsigned int deviceAddress) const
const std::string k_AOH2_Bias1
This file contains the base class for "pixel configuration data" management.
const unsigned int k_fpix_PLL_CTR4or5_address
const edm::EventSetup & c
const std::string k_AOH3_Gain123
const unsigned int k_bpix_AOH1_Gain123_address
const unsigned int k_bpix_AOH3_Bias4_address
const unsigned int k_fpix_DOH_Ch1Bias_Data_address
const unsigned int k_bpix_AOH3_Bias3_address
const std::string k_Delay25_RCL
std::string portcardname_
const std::string k_AOH4_Bias6
const std::string k_Delay25_GCR
const std::string k_AOH2_Bias2
const unsigned int k_bpix_AOH2_Bias3_address
const unsigned int k_fpix_DOH_Dummy_address
const std::string k_PLL_CTR4
unsigned int getchannelAddress() const
const unsigned int k_bpix_DOH_Dummy_address
const unsigned int k_bpix_AOH2_Bias5_address
unsigned int getdeviceValues(unsigned int i) const
const std::string k_Delay25_SDA
const unsigned int k_fpix_Delay25_GCR_address
std::map< std::string, unsigned int > nameToAddress_
const unsigned int k_fpix_PLL_CTR1_address
const std::string k_AOH_Gain456
void writeASCII(std::string dir="") const override
const std::string k_AOH2_Bias4
std::map< std::string, std::string > nameDBtoFileConversion_
const unsigned int k_bpix_AOH4_Bias2_address
const std::string k_AOH_Gain123
const unsigned int k_bpix_AOH1_Gain456_address
unsigned int getccuAddress() const
const std::string k_AOH3_Bias3
unsigned int getdeviceValuesForSetting(std::string settingName) const
const unsigned int k_bpix_DOH_Ch1Bias_Data_address
const std::string k_PLL_CTR5
const std::string k_AOH3_Bias5
const unsigned int k_bpix_AOH1_Bias4_address
const std::string k_AOH1_Gain456
unsigned int ringAddress_
const unsigned int k_bpix_AOH3_Bias1_address
PixelPortCardConfig(std::vector< std::vector< std::string > > &tableMat)
unsigned int getdeviceAddressForSetting(std::string settingName) const
const unsigned int k_bpix_AOH4_Gain456_address
const unsigned int k_bpix_AOH3_Bias5_address
const unsigned int k_bpix_Delay25_SDA_address
const std::string k_AOH2_Bias5
const unsigned int k_bpix_AOH2_Bias2_address
const std::string k_AOH4_Bias1
const std::string k_DOH_Ch1Bias_Data
unsigned int channelAddress_
const unsigned int k_bpix_Delay25_SCL_address
const unsigned int k_bpix_PLL_CTR2_address
unsigned int AOHBiasAddressFromAOHNumber(unsigned int AOHNumber) const
const unsigned int k_bpix_Delay25_TRG_address
const unsigned int k_bpix_AOH1_Bias2_address
const unsigned int k_bpix_AOH2_Gain456_address
const unsigned int k_bpix_AOH1_Bias3_address
const std::string k_AOH_Bias2
const unsigned int k_bpix_PLL_CTR3_address
const unsigned int k_bpix_AOH4_Bias4_address
const std::string k_AOH4_Bias4
unsigned int AOHGainAddressFromAOHNumber(unsigned int AOHNumber) const
const unsigned int k_bpix_PLL_CTR4or5_address
const std::string k_Delay25_RDA
void setDataBaseAOHGain(std::string settingName, unsigned int value)
const std::string k_AOH2_Gain123
const unsigned int k_bpix_AOH3_Bias6_address
const unsigned int k_bpix_AOH4_Gain123_address
const std::string k_AOH2_Gain456
const unsigned int k_bpix_AOH4_Bias3_address
void writeXMLTrailer(std::ofstream *out, std::ofstream *out1=nullptr, std::ofstream *out2=nullptr) const override
const std::string k_PLL_CTR2
const unsigned int k_fpix_AOH_Bias5_address
const std::string k_DOH_Gain_SEU
const std::string k_PLL_CTR4or5
const std::string k_AOH1_Bias2
const unsigned int k_bpix_AOH4_Bias1_address
const unsigned int k_bpix_AOH1_Bias6_address
const unsigned int k_fpix_AOH_Bias2_address
std::string getComment() const
const unsigned int k_bpix_AOH1_Bias1_address
const unsigned int k_fpix_AOH_Gain123_address
void fillDBToFileAddress()
unsigned int getdeviceAddress(unsigned int i) const
std::string getTKFECID() const
tuple key
prepare the HTCondor submission files and eventually submit them
const std::string k_AOH1_Bias6
const unsigned int k_fpix_Delay25_TRG_address
const unsigned int k_fpix_AOH_Bias4_address
const unsigned int k_bpix_AOH2_Gain123_address
unsigned int getdevicesize() const
const unsigned int k_bpix_AOH3_Gain123_address
const unsigned int k_bpix_DOH_Gain_SEU_address
std::string getAuthor() const
const unsigned int k_bpix_Delay25_RCL_address
const std::string k_AOH4_Bias5
std::string AOHGainStringFromAOHNumber(unsigned int AOHNumber) const
const std::string k_AOH4_Gain456
const std::string k_AOH_Bias5
void setdeviceValues(unsigned int address, unsigned int value)
unsigned int getAOHGain(unsigned int AOHNumber) const
const unsigned int k_bpix_DOH_Ch0Bias_CLK_address
const unsigned int k_bpix_Delay25_RDA_address
const std::string k_AOH4_Bias2
const std::string k_Delay25_SCL
const std::string k_AOH3_Bias1
const std::string k_AOH1_Bias4
const std::string k_PLL_CTR3
const unsigned int k_bpix_Delay25_GCR_address
const std::string k_AOH1_Bias3
void writeXMLHeader(pos::PixelConfigKey key, int version, std::string path, std::ofstream *out, std::ofstream *out1=nullptr, std::ofstream *out2=nullptr) const override
const std::string k_Delay25_TRG
std::vector< std::pair< unsigned int, unsigned int > > device_
const unsigned int k_fpix_Delay25_SDA_address
bool containsSetting(std::string settingName) const
const std::string k_AOH_Bias4
unsigned int getringAddress() const
const unsigned int k_fpix_DOH_Ch0Bias_CLK_address
const std::string k_AOH_Bias1
const unsigned int k_fpix_DOH_Gain_SEU_address
const unsigned int k_fpix_PLL_CTR2_address
const unsigned int k_bpix_PLL_CTR1_address
const unsigned int k_fpix_Delay25_RCL_address
std::vector< unsigned int > key_
key used for sorting device_
const unsigned int k_fpix_Delay25_SCL_address
const std::string k_AOH2_Bias6
const std::string k_AOH1_Bias5
const std::string k_AOH_Bias3
const std::string k_AOH1_Bias1
unsigned int geti2cSpeed() const
const unsigned int k_fpix_AOH_Bias3_address
const std::string k_AOH3_Gain456
const unsigned int k_bpix_AOH1_Bias5_address
const unsigned int k_fpix_AOH_Gain456_address
const std::string k_AOH1_Gain123
const std::string k_DOH_Ch0Bias_CLK
const std::string k_AOH3_Bias4
const std::string k_DOH_Dummy
void setAOHGain(unsigned int AOHNumber, unsigned int value)
const unsigned int k_bpix_AOH3_Bias2_address
const unsigned int k_fpix_PLL_CTR3_address
const unsigned int k_bpix_AOH3_Gain456_address
const unsigned int k_bpix_AOH2_Bias1_address
This class specifies the settings on the TKPCIFEC and the settings on the portcard.
const std::string k_AOH2_Bias3
const unsigned int k_bpix_AOH2_Bias6_address
const std::string k_AOH4_Gain123
const unsigned int k_bpix_AOH4_Bias5_address
const std::string k_PLL_CTR1
std::string gettype() const
const std::string k_AOH3_Bias6
const std::string k_AOH4_Bias3
const unsigned int k_fpix_AOH_Bias1_address
const std::string k_AOH3_Bias2
unsigned int getdeviceValuesForAddress(unsigned int address) const
const unsigned int k_fpix_Delay25_RDA_address
const unsigned int k_bpix_AOH2_Bias4_address