File indexing completed on 2024-09-07 04:34:55
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "CalibFormats/SiPixelObjects/interface/PixelPortCardConfig.h"
0010 #include "CalibFormats/SiPixelObjects/interface/PixelPortCardSettingNames.h"
0011 #include "CalibFormats/SiPixelObjects/interface/PixelTimeFormatter.h"
0012 #include <fstream>
0013 #include <sstream>
0014 #include <iostream>
0015 #include <string>
0016 #include <vector>
0017 #include <cassert>
0018 #include <stdexcept>
0019 #include <set>
0020
0021 using namespace std;
0022 using namespace pos::PortCardSettingNames;
0023 using namespace pos;
0024
0025
0026 PixelPortCardConfig::PixelPortCardConfig(vector<vector<string> > &tableMat) : PixelConfigBase(" ", " ", " ") {
0027 string mthn = "]\t[PixelPortCardConfig::PixelPortCardConfig()]\t\t ";
0028 map<string, int> colM;
0029 vector<string> colNames;
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122 colNames.push_back("CONFIG_KEY");
0123 colNames.push_back("KEY_TYPE");
0124 colNames.push_back("KEY_ALIAS");
0125 colNames.push_back("VERSION");
0126 colNames.push_back("KIND_OF_COND");
0127 colNames.push_back("PORT_CARD");
0128 colNames.push_back("TRKFEC");
0129 colNames.push_back("RING");
0130 colNames.push_back("CHANNEL");
0131 colNames.push_back("CCU_ADDR");
0132 colNames.push_back("I2C_CNTRL");
0133 colNames.push_back("I2C_SPEED");
0134 colNames.push_back("AOH_BIAS1");
0135 colNames.push_back("AOH_BIAS2");
0136 colNames.push_back("AOH_BIAS3");
0137 colNames.push_back("AOH_BIAS4");
0138 colNames.push_back("AOH_BIAS5");
0139 colNames.push_back("AOH_BIAS6");
0140 colNames.push_back("AOH_GAIN1");
0141 colNames.push_back("AOH_GAIN2");
0142 colNames.push_back("AOH_GAIN3");
0143 colNames.push_back("AOH_GAIN4");
0144 colNames.push_back("AOH_GAIN5");
0145 colNames.push_back("AOH_GAIN6");
0146 colNames.push_back("AOH1_BIAS1");
0147 colNames.push_back("AOH1_BIAS2");
0148 colNames.push_back("AOH1_BIAS3");
0149 colNames.push_back("AOH1_BIAS4");
0150 colNames.push_back("AOH1_BIAS5");
0151 colNames.push_back("AOH1_BIAS6");
0152 colNames.push_back("AOH1_GAIN1");
0153 colNames.push_back("AOH1_GAIN2");
0154 colNames.push_back("AOH1_GAIN3");
0155 colNames.push_back("AOH1_GAIN4");
0156 colNames.push_back("AOH1_GAIN5");
0157 colNames.push_back("AOH1_GAIN6");
0158 colNames.push_back("AOH2_BIAS1");
0159 colNames.push_back("AOH2_BIAS2");
0160 colNames.push_back("AOH2_BIAS3");
0161 colNames.push_back("AOH2_BIAS4");
0162 colNames.push_back("AOH2_BIAS5");
0163 colNames.push_back("AOH2_BIAS6");
0164 colNames.push_back("AOH2_GAIN1");
0165 colNames.push_back("AOH2_GAIN2");
0166 colNames.push_back("AOH2_GAIN3");
0167 colNames.push_back("AOH2_GAIN4");
0168 colNames.push_back("AOH2_GAIN5");
0169 colNames.push_back("AOH2_GAIN6");
0170 colNames.push_back("AOH3_BIAS1");
0171 colNames.push_back("AOH3_BIAS2");
0172 colNames.push_back("AOH3_BIAS3");
0173 colNames.push_back("AOH3_BIAS4");
0174 colNames.push_back("AOH3_BIAS5");
0175 colNames.push_back("AOH3_BIAS6");
0176 colNames.push_back("AOH3_GAIN1");
0177 colNames.push_back("AOH3_GAIN2");
0178 colNames.push_back("AOH3_GAIN3");
0179 colNames.push_back("AOH3_GAIN4");
0180 colNames.push_back("AOH3_GAIN5");
0181 colNames.push_back("AOH3_GAIN6");
0182 colNames.push_back("AOH4_BIAS1");
0183 colNames.push_back("AOH4_BIAS2");
0184 colNames.push_back("AOH4_BIAS3");
0185 colNames.push_back("AOH4_BIAS4");
0186 colNames.push_back("AOH4_BIAS5");
0187 colNames.push_back("AOH4_BIAS6");
0188 colNames.push_back("AOH4_GAIN1");
0189 colNames.push_back("AOH4_GAIN2");
0190 colNames.push_back("AOH4_GAIN3");
0191 colNames.push_back("AOH4_GAIN4");
0192 colNames.push_back("AOH4_GAIN5");
0193 colNames.push_back("AOH4_GAIN6");
0194 colNames.push_back("DELAY25_GCR");
0195 colNames.push_back("DELAY25_SCL");
0196 colNames.push_back("DELAY25_TRG");
0197 colNames.push_back("DELAY25_SDA");
0198 colNames.push_back("DELAY25_RCL");
0199 colNames.push_back("DELAY25_RDA");
0200 colNames.push_back("DOH_BIAS0");
0201 colNames.push_back("DOH_BIAS1");
0202 colNames.push_back("DOH_SEU_GAIN");
0203 colNames.push_back("PLL_CTR1");
0204 colNames.push_back("PLL_CTR2");
0205 colNames.push_back("PLL_CTR3");
0206 colNames.push_back("PLL_CTR4");
0207 colNames.push_back("PLL_CTR5");
0208
0209
0210 unsigned int othercount = 100;
0211 unsigned int delay25count = 50;
0212 aohcount_ = 1000;
0213 unsigned int pllcount = 1;
0214
0215 for (unsigned int c = 0; c < tableMat[0].size(); c++) {
0216 for (unsigned int n = 0; n < colNames.size(); n++) {
0217 if (tableMat[0][c] == colNames[n]) {
0218 colM[colNames[n]] = c;
0219 break;
0220 }
0221 }
0222 }
0223 for (unsigned int n = 0; n < colNames.size(); n++) {
0224 if (colM.find(colNames[n]) == colM.end()) {
0225 std::cerr << __LINE__ << mthn << "\tCouldn't find in the database the column with name " << colNames[n]
0226 << std::endl;
0227 assert(0);
0228 }
0229 }
0230
0231 portcardname_ = tableMat[1][colM["PORT_CARD"]];
0232
0233 if (portcardname_.find("FPix") != std::string::npos) {
0234 type_ = "fpix";
0235 } else if (portcardname_.find("BPix") != std::string::npos) {
0236 type_ = "bpix";
0237 }
0238 fillNameToAddress();
0239 fillDBToFileAddress();
0240
0241 TKFECID_ = tableMat[1][colM["TRKFEC"]];
0242 ringAddress_ = atoi(tableMat[1][colM["RING"]].c_str());
0243 ccuAddress_ = atoi(tableMat[1][colM["CCU_ADDR"]].c_str());
0244 channelAddress_ = atoi(tableMat[1][colM["CHANNEL"]].c_str());
0245 i2cSpeed_ = atoi(tableMat[1][colM["I2C_SPEED"]].c_str());
0246
0247
0248
0249
0250
0251
0252
0253
0254 for (unsigned int col = 0; col < tableMat[1].size(); col++)
0255 {
0256 std::string settingName;
0257 unsigned int i2c_address;
0258 unsigned int i2c_values;
0259
0260 settingName = tableMat[0][col];
0261 i2c_values = atoi(tableMat[1][col].c_str());
0262
0263
0264 if (type_ == "fpix" && settingName.find("AOH_") != string::npos &&
0265 settingName.find("GAIN") != string::npos
0266 && settingName.find("123") == string::npos &&
0267 settingName.find("456") == string::npos)
0268 {
0269 setDataBaseAOHGain(settingName, i2c_values);
0270
0271 } else if (type_ == "bpix" && settingName.find("AOH") != string::npos &&
0272 settingName.find("GAIN") != string::npos
0273 && settingName.find("AOH_") == string::npos
0274 && settingName.find("123") == string::npos &&
0275 settingName.find("456") == string::npos)
0276 {
0277 if (portcardname_.find("PRT2") != std::string::npos &&
0278 (settingName.find("AOH3_") != std::string::npos || settingName.find("AOH4_") != std::string::npos))
0279 continue;
0280 setDataBaseAOHGain(settingName, i2c_values);
0281
0282 }
0283
0284 else if (settingName == k_PLL_CTR5)
0285 {
0286 unsigned int last_CTR2 = 0x0;
0287 if (containsSetting(k_PLL_CTR2))
0288 last_CTR2 = getdeviceValuesForSetting(k_PLL_CTR2);
0289
0290 device_.push_back(make_pair(getdeviceAddressForSetting(k_PLL_CTR2), new_PLL_CTR2_value(settingName, last_CTR2)));
0291 device_.push_back(make_pair(getdeviceAddressForSetting(k_PLL_CTR4or5), i2c_values));
0292
0293 key_.push_back(pllcount++);
0294 key_.push_back(pllcount++);
0295 }
0296
0297 else
0298 {
0299 if ((settingName.find("DELAY25_") != std::string::npos) || (settingName.find("_BIAS") != std::string::npos) ||
0300 (settingName.find("PLL_CTR2") != std::string::npos) || (settingName.find("PLL_CTR5") != std::string::npos) ||
0301 ((settingName.find("DOH_SEU_GAIN") != std::string::npos) && type_ == "bpix"))
0302
0303 {
0304 map<string, string>::iterator iter = nameDBtoFileConversion_.find(settingName);
0305 if (iter == nameDBtoFileConversion_.end())
0306 continue;
0307 map<string, unsigned int>::iterator foundName_itr = nameToAddress_.find(nameDBtoFileConversion_[settingName]);
0308
0309 if (foundName_itr != nameToAddress_.end()) {
0310 if (portcardname_.find("PRT2") != std::string::npos &&
0311 (settingName.find("AOH3_") != std::string::npos || settingName.find("AOH4_") != std::string::npos))
0312 continue;
0313 i2c_address = foundName_itr->second;
0314 } else {
0315 i2c_address = strtoul(settingName.c_str(), nullptr, 16);
0316 }
0317 if (type_ == "fpix" &&
0318 (settingName.find("AOH1_") != std::string::npos || settingName.find("AOH2_") != std::string::npos ||
0319 settingName.find("AOH3_") != std::string::npos || settingName.find("AOH4_") != std::string::npos))
0320 continue;
0321
0322 pair<unsigned int, unsigned int> p(i2c_address, i2c_values);
0323
0324
0325
0326
0327
0328
0329
0330
0331
0332
0333
0334
0335
0336
0337 device_.push_back(p);
0338 if (settingName.find("AOH") != string::npos)
0339 key_.push_back(aohcount_++);
0340 else if (settingName.find("Delay25") != string::npos)
0341 key_.push_back(delay25count++);
0342 else if (settingName.find("PLL") != string::npos)
0343 key_.push_back(pllcount++);
0344 else
0345 key_.push_back(othercount++);
0346 }
0347 }
0348 }
0349
0350 sortDeviceList();
0351 }
0352
0353
0354 PixelPortCardConfig::PixelPortCardConfig(std::string filename) : PixelConfigBase(" ", " ", " ") {
0355 string mthn = "[PixelPortCardConfig::PixelPortCardConfig()]\t\t ";
0356
0357
0358 size_t portcardpos = filename.find(std::string("portcard_"));
0359
0360 assert(portcardpos != (unsigned int)std::string::npos);
0361 size_t datpos = filename.find(std::string(".dat"));
0362
0363 assert(datpos != (unsigned int)std::string::npos);
0364 assert(datpos > portcardpos);
0365
0366 portcardname_ = filename.substr(portcardpos + 9, datpos - portcardpos - 9);
0367
0368
0369
0370 std::ifstream in(filename.c_str());
0371
0372 if (!in.good()) {
0373 std::cout << __LINE__ << "]\t" << mthn << "Could not open: " << filename << std::endl;
0374 throw std::runtime_error("Failed to open file " + filename);
0375 } else {
0376 std::cout << __LINE__ << "]\t" << mthn << "Opened: " << filename << std::endl;
0377 }
0378
0379 string dummy;
0380
0381 in >> dummy;
0382 if (dummy == "Name:")
0383 {
0384 in >> dummy;
0385 assert(dummy == portcardname_);
0386 in >> dummy;
0387 }
0388 if (dummy == "Type:")
0389 {
0390 in >> type_;
0391 assert(type_ == "fpix" || type_ == "bpix");
0392 in >> dummy;
0393 } else {
0394 type_ = "fpix";
0395 }
0396 fillNameToAddress();
0397 fillDBToFileAddress();
0398 assert(dummy == "TKFECID:");
0399 in >> TKFECID_;
0400 in >> dummy;
0401 assert(dummy == "ringAddress:");
0402 in >> std::hex >> ringAddress_;
0403 in >> dummy;
0404 assert(dummy == "ccuAddress:");
0405 in >> std::hex >> ccuAddress_;
0406 in >> dummy;
0407 assert(dummy == "channelAddress:");
0408 in >> std::hex >> channelAddress_;
0409 in >> dummy;
0410 assert(dummy == "i2cSpeed:");
0411 in >> std::hex >> i2cSpeed_;
0412
0413
0414
0415
0416 assert(!nameToAddress_.empty());
0417 do {
0418 std::string settingName;
0419 unsigned int i2c_address;
0420 unsigned int i2c_values;
0421
0422 in >> settingName >> std::hex >> i2c_values >> std::dec;
0423 if (in.eof())
0424 break;
0425
0426 if (settingName[settingName.size() - 1] == ':')
0427 settingName.resize(settingName.size() - 1);
0428
0429
0430 if (settingName.find("AOH") != string::npos &&
0431 settingName.find("Gain") != string::npos
0432 && settingName.find("123") == string::npos &&
0433 settingName.find("456") == string::npos)
0434 {
0435 setAOHGain(settingName, i2c_values);
0436 } else if (settingName == k_PLL_CTR4 || settingName == k_PLL_CTR5)
0437 {
0438 unsigned int last_CTR2 = 0x0;
0439 if (containsSetting(k_PLL_CTR2))
0440 last_CTR2 = getdeviceValuesForSetting(k_PLL_CTR2);
0441
0442 device_.push_back(make_pair(getdeviceAddressForSetting(k_PLL_CTR2), new_PLL_CTR2_value(settingName, last_CTR2)));
0443 device_.push_back(make_pair(getdeviceAddressForSetting(k_PLL_CTR4or5), i2c_values));
0444 } else
0445 {
0446 std::map<std::string, unsigned int>::iterator foundName_itr = nameToAddress_.find(settingName);
0447
0448 if (foundName_itr != nameToAddress_.end()) {
0449 i2c_address = foundName_itr->second;
0450 } else {
0451 i2c_address = strtoul(settingName.c_str(), nullptr, 16);
0452 }
0453 pair<unsigned int, unsigned int> p(i2c_address, i2c_values);
0454 device_.push_back(p);
0455 }
0456 } while (!in.eof());
0457
0458 in.close();
0459 }
0460
0461 void PixelPortCardConfig::sortDeviceList() {
0462 std::set<pair<unsigned int, pair<unsigned int, unsigned int> > > sorted;
0463
0464 for (unsigned int i = 0; i < device_.size(); i++) {
0465
0466 sorted.insert(make_pair(key_.at(i), device_.at(i)));
0467 }
0468
0469
0470 device_.clear();
0471 for (set<pair<unsigned int, pair<unsigned int, unsigned int> > >::iterator i = sorted.begin(); i != sorted.end();
0472 ++i) {
0473 device_.push_back(i->second);
0474 }
0475
0476
0477
0478
0479 }
0480
0481 unsigned int PixelPortCardConfig::new_PLL_CTR2_value(std::string CTR4or5, unsigned int last_CTR2) const {
0482 if (CTR4or5 == k_PLL_CTR4)
0483 return 0xdf & last_CTR2;
0484 else if (CTR4or5 == k_PLL_CTR5)
0485 return 0x20 | last_CTR2;
0486 else
0487 assert(0);
0488 }
0489
0490 void PixelPortCardConfig::setAOHGain(std::string settingName, unsigned int value) {
0491 assert(settingName.find("AOH") != string::npos &&
0492 settingName.find("Gain") != string::npos
0493 && settingName.find("123") == string::npos &&
0494 settingName.find("456") == string::npos);
0495
0496 unsigned int i2c_address;
0497
0498
0499 string::size_type GainPosition = settingName.find("Gain");
0500 unsigned int whichAOH;
0501 if (settingName[GainPosition - 2] == 'H')
0502 whichAOH = 0;
0503 else
0504 {
0505 char whichAOHDigit[2] = {0, 0};
0506 whichAOHDigit[0] = settingName[GainPosition - 2];
0507 whichAOH = atoi(whichAOHDigit);
0508 }
0509 char digit[2] = {0, 0};
0510 digit[0] = settingName[GainPosition + 4];
0511 unsigned int channelOnAOH = atoi(digit);
0512 assert((type_ == "fpix" && whichAOH == 0) || (type_ == "bpix" && 1 <= whichAOH && whichAOH <= 4));
0513 assert(1 <= channelOnAOH && channelOnAOH <= 6);
0514
0515 if (whichAOH == 0 && channelOnAOH <= 3)
0516 i2c_address = k_fpix_AOH_Gain123_address;
0517 else if (whichAOH == 0 && channelOnAOH >= 4)
0518 i2c_address = k_fpix_AOH_Gain456_address;
0519 else if (whichAOH == 1 && channelOnAOH <= 3)
0520 i2c_address = k_bpix_AOH1_Gain123_address;
0521 else if (whichAOH == 1 && channelOnAOH >= 4)
0522 i2c_address = k_bpix_AOH1_Gain456_address;
0523 else if (whichAOH == 2 && channelOnAOH <= 3)
0524 i2c_address = k_bpix_AOH2_Gain123_address;
0525 else if (whichAOH == 2 && channelOnAOH >= 4)
0526 i2c_address = k_bpix_AOH2_Gain456_address;
0527 else if (whichAOH == 3 && channelOnAOH <= 3)
0528 i2c_address = k_bpix_AOH3_Gain123_address;
0529 else if (whichAOH == 3 && channelOnAOH >= 4)
0530 i2c_address = k_bpix_AOH3_Gain456_address;
0531 else if (whichAOH == 4 && channelOnAOH <= 3)
0532 i2c_address = k_bpix_AOH4_Gain123_address;
0533 else if (whichAOH == 4 && channelOnAOH >= 4)
0534 i2c_address = k_bpix_AOH4_Gain456_address;
0535 else
0536 assert(0);
0537
0538
0539 bool foundOne = false;
0540 for (unsigned int i = 0; i < device_.size(); i++) {
0541 if (device_[i].first == i2c_address)
0542 {
0543 foundOne = true;
0544 unsigned int oldValue = device_[i].second;
0545 if (channelOnAOH % 3 == 1)
0546 device_[i].second = (0x3c & oldValue) + ((value & 0x3) << 0);
0547 else if (channelOnAOH % 3 == 2)
0548 device_[i].second = (0x33 & oldValue) + ((value & 0x3) << 2);
0549 else if (channelOnAOH % 3 == 0)
0550 device_[i].second = (0x0f & oldValue) + ((value & 0x3) << 4);
0551 else
0552 assert(0);
0553
0554 }
0555 }
0556 if (foundOne)
0557 return;
0558 else
0559 {
0560 unsigned int i2c_value;
0561 if (channelOnAOH % 3 == 1)
0562 i2c_value = ((value & 0x3) << 0);
0563 else if (channelOnAOH % 3 == 2)
0564 i2c_value = ((value & 0x3) << 2);
0565 else if (channelOnAOH % 3 == 0)
0566 i2c_value = ((value & 0x3) << 4);
0567 else
0568 assert(0);
0569
0570 pair<unsigned int, unsigned int> p(i2c_address, i2c_value);
0571 device_.push_back(p);
0572 return;
0573 }
0574 }
0575
0576 void PixelPortCardConfig::setDataBaseAOHGain(std::string settingName, unsigned int value) {
0577 unsigned int i2c_address;
0578
0579
0580 string::size_type GainPosition = settingName.find("GAIN");
0581 unsigned int whichAOH;
0582 if (type_ == "fpix") {
0583 whichAOH = 0;
0584 } else
0585 {
0586 char whichAOHDigit[2] = {0, 0};
0587 whichAOHDigit[0] = settingName[GainPosition - 2];
0588 whichAOH = atoi(whichAOHDigit);
0589 }
0590 char digit[2] = {0, 0};
0591 digit[0] = settingName[GainPosition + 4];
0592 unsigned int channelOnAOH = atoi(digit);
0593 assert((type_ == "fpix" && whichAOH == 0) || (type_ == "bpix" && 1 <= whichAOH && whichAOH <= 4));
0594 assert(1 <= channelOnAOH && channelOnAOH <= 6);
0595
0596 if (whichAOH == 0 && channelOnAOH <= 3)
0597 i2c_address = k_fpix_AOH_Gain123_address;
0598 else if (whichAOH == 0 && channelOnAOH >= 4)
0599 i2c_address = k_fpix_AOH_Gain456_address;
0600 else if (whichAOH == 1 && channelOnAOH <= 3)
0601 i2c_address = k_bpix_AOH1_Gain123_address;
0602 else if (whichAOH == 1 && channelOnAOH >= 4)
0603 i2c_address = k_bpix_AOH1_Gain456_address;
0604 else if (whichAOH == 2 && channelOnAOH <= 3)
0605 i2c_address = k_bpix_AOH2_Gain123_address;
0606 else if (whichAOH == 2 && channelOnAOH >= 4)
0607 i2c_address = k_bpix_AOH2_Gain456_address;
0608 else if (whichAOH == 3 && channelOnAOH <= 3)
0609 i2c_address = k_bpix_AOH3_Gain123_address;
0610 else if (whichAOH == 3 && channelOnAOH >= 4)
0611 i2c_address = k_bpix_AOH3_Gain456_address;
0612 else if (whichAOH == 4 && channelOnAOH <= 3)
0613 i2c_address = k_bpix_AOH4_Gain123_address;
0614 else if (whichAOH == 4 && channelOnAOH >= 4)
0615 i2c_address = k_bpix_AOH4_Gain456_address;
0616 else
0617 assert(0);
0618
0619
0620 bool foundOne = false;
0621 for (unsigned int i = 0; i < device_.size(); i++) {
0622 if (device_[i].first == i2c_address)
0623 {
0624 foundOne = true;
0625 unsigned int oldValue = device_[i].second;
0626 if (channelOnAOH % 3 == 1)
0627 device_[i].second = (0x3c & oldValue) + ((value & 0x3) << 0);
0628 else if (channelOnAOH % 3 == 2)
0629 device_[i].second = (0x33 & oldValue) + ((value & 0x3) << 2);
0630 else if (channelOnAOH % 3 == 0)
0631 device_[i].second = (0x0f & oldValue) + ((value & 0x3) << 4);
0632 else
0633 assert(0);
0634
0635 }
0636 }
0637 if (foundOne)
0638 return;
0639 else
0640 {
0641 unsigned int i2c_value;
0642 if (channelOnAOH % 3 == 1)
0643 i2c_value = ((value & 0x3) << 0);
0644 else if (channelOnAOH % 3 == 2)
0645 i2c_value = ((value & 0x3) << 2);
0646 else if (channelOnAOH % 3 == 0)
0647 i2c_value = ((value & 0x3) << 4);
0648 else
0649 assert(0);
0650
0651 pair<unsigned int, unsigned int> p(i2c_address, i2c_value);
0652 device_.push_back(p);
0653 key_.push_back(aohcount_++);
0654 return;
0655 }
0656 }
0657
0658 void PixelPortCardConfig::fillNameToAddress() {
0659 if (!nameToAddress_.empty())
0660 return;
0661
0662 if (type_ == "fpix") {
0663 nameToAddress_[PortCardSettingNames::k_AOH_Bias1] = PortCardSettingNames::k_fpix_AOH_Bias1_address;
0664 nameToAddress_[PortCardSettingNames::k_AOH_Bias2] = PortCardSettingNames::k_fpix_AOH_Bias2_address;
0665 nameToAddress_[PortCardSettingNames::k_AOH_Bias3] = PortCardSettingNames::k_fpix_AOH_Bias3_address;
0666 nameToAddress_[PortCardSettingNames::k_AOH_Bias4] = PortCardSettingNames::k_fpix_AOH_Bias4_address;
0667 nameToAddress_[PortCardSettingNames::k_AOH_Bias5] = PortCardSettingNames::k_fpix_AOH_Bias5_address;
0668 nameToAddress_[PortCardSettingNames::k_AOH_Bias6] = PortCardSettingNames::k_fpix_AOH_Bias6_address;
0669 nameToAddress_[PortCardSettingNames::k_AOH_Gain123] = PortCardSettingNames::k_fpix_AOH_Gain123_address;
0670 nameToAddress_[PortCardSettingNames::k_AOH_Gain456] = PortCardSettingNames::k_fpix_AOH_Gain456_address;
0671
0672 nameToAddress_[PortCardSettingNames::k_PLL_CTR1] = PortCardSettingNames::k_fpix_PLL_CTR1_address;
0673 nameToAddress_[PortCardSettingNames::k_PLL_CTR2] = PortCardSettingNames::k_fpix_PLL_CTR2_address;
0674 nameToAddress_[PortCardSettingNames::k_PLL_CTR3] = PortCardSettingNames::k_fpix_PLL_CTR3_address;
0675 nameToAddress_[PortCardSettingNames::k_PLL_CTR4or5] = PortCardSettingNames::k_fpix_PLL_CTR4or5_address;
0676
0677 nameToAddress_[PortCardSettingNames::k_Delay25_RDA] = PortCardSettingNames::k_fpix_Delay25_RDA_address;
0678 nameToAddress_[PortCardSettingNames::k_Delay25_RCL] = PortCardSettingNames::k_fpix_Delay25_RCL_address;
0679 nameToAddress_[PortCardSettingNames::k_Delay25_SDA] = PortCardSettingNames::k_fpix_Delay25_SDA_address;
0680 nameToAddress_[PortCardSettingNames::k_Delay25_TRG] = PortCardSettingNames::k_fpix_Delay25_TRG_address;
0681 nameToAddress_[PortCardSettingNames::k_Delay25_SCL] = PortCardSettingNames::k_fpix_Delay25_SCL_address;
0682 nameToAddress_[PortCardSettingNames::k_Delay25_GCR] = PortCardSettingNames::k_fpix_Delay25_GCR_address;
0683
0684 nameToAddress_[PortCardSettingNames::k_DOH_Ch0Bias_CLK] = PortCardSettingNames::k_fpix_DOH_Ch0Bias_CLK_address;
0685 nameToAddress_[PortCardSettingNames::k_DOH_Dummy] = PortCardSettingNames::k_fpix_DOH_Dummy_address;
0686 nameToAddress_[PortCardSettingNames::k_DOH_Ch1Bias_Data] = PortCardSettingNames::k_fpix_DOH_Ch1Bias_Data_address;
0687 nameToAddress_[PortCardSettingNames::k_DOH_Gain_SEU] = PortCardSettingNames::k_fpix_DOH_Gain_SEU_address;
0688 } else if (type_ == "bpix") {
0689 nameToAddress_[PortCardSettingNames::k_AOH1_Bias1] = PortCardSettingNames::k_bpix_AOH1_Bias1_address;
0690 nameToAddress_[PortCardSettingNames::k_AOH1_Bias2] = PortCardSettingNames::k_bpix_AOH1_Bias2_address;
0691 nameToAddress_[PortCardSettingNames::k_AOH1_Bias3] = PortCardSettingNames::k_bpix_AOH1_Bias3_address;
0692 nameToAddress_[PortCardSettingNames::k_AOH1_Bias4] = PortCardSettingNames::k_bpix_AOH1_Bias4_address;
0693 nameToAddress_[PortCardSettingNames::k_AOH1_Bias5] = PortCardSettingNames::k_bpix_AOH1_Bias5_address;
0694 nameToAddress_[PortCardSettingNames::k_AOH1_Bias6] = PortCardSettingNames::k_bpix_AOH1_Bias6_address;
0695 nameToAddress_[PortCardSettingNames::k_AOH1_Gain123] = PortCardSettingNames::k_bpix_AOH1_Gain123_address;
0696 nameToAddress_[PortCardSettingNames::k_AOH1_Gain456] = PortCardSettingNames::k_bpix_AOH1_Gain456_address;
0697
0698 nameToAddress_[PortCardSettingNames::k_AOH2_Bias1] = PortCardSettingNames::k_bpix_AOH2_Bias1_address;
0699 nameToAddress_[PortCardSettingNames::k_AOH2_Bias2] = PortCardSettingNames::k_bpix_AOH2_Bias2_address;
0700 nameToAddress_[PortCardSettingNames::k_AOH2_Bias3] = PortCardSettingNames::k_bpix_AOH2_Bias3_address;
0701 nameToAddress_[PortCardSettingNames::k_AOH2_Bias4] = PortCardSettingNames::k_bpix_AOH2_Bias4_address;
0702 nameToAddress_[PortCardSettingNames::k_AOH2_Bias5] = PortCardSettingNames::k_bpix_AOH2_Bias5_address;
0703 nameToAddress_[PortCardSettingNames::k_AOH2_Bias6] = PortCardSettingNames::k_bpix_AOH2_Bias6_address;
0704 nameToAddress_[PortCardSettingNames::k_AOH2_Gain123] = PortCardSettingNames::k_bpix_AOH2_Gain123_address;
0705 nameToAddress_[PortCardSettingNames::k_AOH2_Gain456] = PortCardSettingNames::k_bpix_AOH2_Gain456_address;
0706
0707 nameToAddress_[PortCardSettingNames::k_AOH3_Bias1] = PortCardSettingNames::k_bpix_AOH3_Bias1_address;
0708 nameToAddress_[PortCardSettingNames::k_AOH3_Bias2] = PortCardSettingNames::k_bpix_AOH3_Bias2_address;
0709 nameToAddress_[PortCardSettingNames::k_AOH3_Bias3] = PortCardSettingNames::k_bpix_AOH3_Bias3_address;
0710 nameToAddress_[PortCardSettingNames::k_AOH3_Bias4] = PortCardSettingNames::k_bpix_AOH3_Bias4_address;
0711 nameToAddress_[PortCardSettingNames::k_AOH3_Bias5] = PortCardSettingNames::k_bpix_AOH3_Bias5_address;
0712 nameToAddress_[PortCardSettingNames::k_AOH3_Bias6] = PortCardSettingNames::k_bpix_AOH3_Bias6_address;
0713 nameToAddress_[PortCardSettingNames::k_AOH3_Gain123] = PortCardSettingNames::k_bpix_AOH3_Gain123_address;
0714 nameToAddress_[PortCardSettingNames::k_AOH3_Gain456] = PortCardSettingNames::k_bpix_AOH3_Gain456_address;
0715
0716 nameToAddress_[PortCardSettingNames::k_AOH4_Bias1] = PortCardSettingNames::k_bpix_AOH4_Bias1_address;
0717 nameToAddress_[PortCardSettingNames::k_AOH4_Bias2] = PortCardSettingNames::k_bpix_AOH4_Bias2_address;
0718 nameToAddress_[PortCardSettingNames::k_AOH4_Bias3] = PortCardSettingNames::k_bpix_AOH4_Bias3_address;
0719 nameToAddress_[PortCardSettingNames::k_AOH4_Bias4] = PortCardSettingNames::k_bpix_AOH4_Bias4_address;
0720 nameToAddress_[PortCardSettingNames::k_AOH4_Bias5] = PortCardSettingNames::k_bpix_AOH4_Bias5_address;
0721 nameToAddress_[PortCardSettingNames::k_AOH4_Bias6] = PortCardSettingNames::k_bpix_AOH4_Bias6_address;
0722 nameToAddress_[PortCardSettingNames::k_AOH4_Gain123] = PortCardSettingNames::k_bpix_AOH4_Gain123_address;
0723 nameToAddress_[PortCardSettingNames::k_AOH4_Gain456] = PortCardSettingNames::k_bpix_AOH4_Gain456_address;
0724
0725 nameToAddress_[PortCardSettingNames::k_PLL_CTR1] = PortCardSettingNames::k_bpix_PLL_CTR1_address;
0726 nameToAddress_[PortCardSettingNames::k_PLL_CTR2] = PortCardSettingNames::k_bpix_PLL_CTR2_address;
0727 nameToAddress_[PortCardSettingNames::k_PLL_CTR3] = PortCardSettingNames::k_bpix_PLL_CTR3_address;
0728 nameToAddress_[PortCardSettingNames::k_PLL_CTR4or5] = PortCardSettingNames::k_bpix_PLL_CTR4or5_address;
0729
0730 nameToAddress_[PortCardSettingNames::k_Delay25_RDA] = PortCardSettingNames::k_bpix_Delay25_RDA_address;
0731 nameToAddress_[PortCardSettingNames::k_Delay25_RCL] = PortCardSettingNames::k_bpix_Delay25_RCL_address;
0732 nameToAddress_[PortCardSettingNames::k_Delay25_SDA] = PortCardSettingNames::k_bpix_Delay25_SDA_address;
0733 nameToAddress_[PortCardSettingNames::k_Delay25_TRG] = PortCardSettingNames::k_bpix_Delay25_TRG_address;
0734 nameToAddress_[PortCardSettingNames::k_Delay25_SCL] = PortCardSettingNames::k_bpix_Delay25_SCL_address;
0735 nameToAddress_[PortCardSettingNames::k_Delay25_GCR] = PortCardSettingNames::k_bpix_Delay25_GCR_address;
0736
0737 nameToAddress_[PortCardSettingNames::k_DOH_Ch0Bias_CLK] = PortCardSettingNames::k_bpix_DOH_Ch0Bias_CLK_address;
0738 nameToAddress_[PortCardSettingNames::k_DOH_Dummy] = PortCardSettingNames::k_bpix_DOH_Dummy_address;
0739 nameToAddress_[PortCardSettingNames::k_DOH_Ch1Bias_Data] = PortCardSettingNames::k_bpix_DOH_Ch1Bias_Data_address;
0740 nameToAddress_[PortCardSettingNames::k_DOH_Gain_SEU] = PortCardSettingNames::k_bpix_DOH_Gain_SEU_address;
0741 } else
0742 assert(0);
0743
0744 return;
0745 }
0746
0747 void PixelPortCardConfig::fillDBToFileAddress() {
0748 if (type_ == "fpix") {
0749
0750
0751
0752
0753
0754
0755
0756
0757
0758
0759
0760
0761
0762
0763
0764 nameDBtoFileConversion_["AOH_BIAS1"] = k_AOH_Bias1;
0765 nameDBtoFileConversion_["AOH_BIAS2"] = k_AOH_Bias2;
0766 nameDBtoFileConversion_["AOH_BIAS3"] = k_AOH_Bias3;
0767 nameDBtoFileConversion_["AOH_BIAS4"] = k_AOH_Bias4;
0768 nameDBtoFileConversion_["AOH_BIAS5"] = k_AOH_Bias5;
0769 nameDBtoFileConversion_["AOH_BIAS6"] = k_AOH_Bias6;
0770 nameDBtoFileConversion_["AOH1_BIAS1"] = k_AOH1_Bias1;
0771 nameDBtoFileConversion_["AOH1_BIAS2"] = k_AOH1_Bias2;
0772 nameDBtoFileConversion_["AOH1_BIAS3"] = k_AOH1_Bias3;
0773 nameDBtoFileConversion_["AOH1_BIAS4"] = k_AOH1_Bias4;
0774 nameDBtoFileConversion_["AOH1_BIAS5"] = k_AOH1_Bias5;
0775 nameDBtoFileConversion_["AOH1_BIAS6"] = k_AOH1_Bias6;
0776
0777
0778
0779
0780
0781
0782 nameDBtoFileConversion_["AOH2_BIAS1"] = k_AOH2_Bias1;
0783 nameDBtoFileConversion_["AOH2_BIAS2"] = k_AOH2_Bias2;
0784 nameDBtoFileConversion_["AOH2_BIAS3"] = k_AOH2_Bias3;
0785 nameDBtoFileConversion_["AOH2_BIAS4"] = k_AOH2_Bias4;
0786 nameDBtoFileConversion_["AOH2_BIAS5"] = k_AOH2_Bias5;
0787 nameDBtoFileConversion_["AOH2_BIAS6"] = k_AOH2_Bias6;
0788
0789
0790
0791
0792
0793
0794 nameDBtoFileConversion_["AOH3_BIAS1"] = k_AOH3_Bias1;
0795 nameDBtoFileConversion_["AOH3_BIAS2"] = k_AOH3_Bias2;
0796 nameDBtoFileConversion_["AOH3_BIAS3"] = k_AOH3_Bias3;
0797 nameDBtoFileConversion_["AOH3_BIAS4"] = k_AOH3_Bias4;
0798 nameDBtoFileConversion_["AOH3_BIAS5"] = k_AOH3_Bias5;
0799 nameDBtoFileConversion_["AOH3_BIAS6"] = k_AOH3_Bias6;
0800
0801
0802
0803
0804
0805
0806 nameDBtoFileConversion_["AOH4_BIAS1"] = k_AOH4_Bias1;
0807 nameDBtoFileConversion_["AOH4_BIAS2"] = k_AOH4_Bias2;
0808 nameDBtoFileConversion_["AOH4_BIAS3"] = k_AOH4_Bias3;
0809 nameDBtoFileConversion_["AOH4_BIAS4"] = k_AOH4_Bias4;
0810 nameDBtoFileConversion_["AOH4_BIAS5"] = k_AOH4_Bias5;
0811 nameDBtoFileConversion_["AOH4_BIAS6"] = k_AOH4_Bias6;
0812
0813
0814
0815
0816
0817
0818
0819
0820
0821
0822
0823
0824
0825
0826
0827
0828
0829
0830
0831
0832
0833
0834
0835
0836
0837
0838
0839
0840
0841
0842 nameDBtoFileConversion_["DELAY25_GCR"] = k_Delay25_GCR;
0843 nameDBtoFileConversion_["DELAY25_SCL"] = k_Delay25_SCL;
0844 nameDBtoFileConversion_["DELAY25_TRG"] = k_Delay25_TRG;
0845 nameDBtoFileConversion_["DELAY25_SDA"] = k_Delay25_SDA;
0846 nameDBtoFileConversion_["DELAY25_RCL"] = k_Delay25_RCL;
0847 nameDBtoFileConversion_["DELAY25_RDA"] = k_Delay25_RDA;
0848
0849
0850
0851
0852
0853
0854 nameDBtoFileConversion_["DOH_BIAS0"] = k_DOH_Ch0Bias_CLK;
0855 nameDBtoFileConversion_["DOH_BIAS1"] = k_DOH_Ch1Bias_Data;
0856 nameDBtoFileConversion_["DOH_SEU_GAIN"] = k_DOH_Gain_SEU;
0857
0858
0859
0860 nameDBtoFileConversion_["PLL_CTR1"] = k_PLL_CTR1;
0861 nameDBtoFileConversion_["PLL_CTR2"] = k_PLL_CTR2;
0862 nameDBtoFileConversion_["PLL_CTR3"] = k_PLL_CTR3;
0863 nameDBtoFileConversion_["PLL_CTR4"] = k_PLL_CTR4;
0864 nameDBtoFileConversion_["PLL_CTR5"] = k_PLL_CTR5;
0865
0866
0867
0868
0869 } else if (type_ == "bpix") {
0870
0871
0872
0873
0874
0875
0876
0877
0878
0879
0880
0881
0882
0883
0884
0885 nameDBtoFileConversion_["AOH1_BIAS1"] = k_AOH1_Bias1;
0886 nameDBtoFileConversion_["AOH1_BIAS2"] = k_AOH1_Bias2;
0887 nameDBtoFileConversion_["AOH1_BIAS3"] = k_AOH1_Bias3;
0888 nameDBtoFileConversion_["AOH1_BIAS4"] = k_AOH1_Bias4;
0889 nameDBtoFileConversion_["AOH1_BIAS5"] = k_AOH1_Bias5;
0890 nameDBtoFileConversion_["AOH1_BIAS6"] = k_AOH1_Bias6;
0891
0892
0893
0894
0895
0896
0897 nameDBtoFileConversion_["AOH2_BIAS1"] = k_AOH2_Bias1;
0898 nameDBtoFileConversion_["AOH2_BIAS2"] = k_AOH2_Bias2;
0899 nameDBtoFileConversion_["AOH2_BIAS3"] = k_AOH2_Bias3;
0900 nameDBtoFileConversion_["AOH2_BIAS4"] = k_AOH2_Bias4;
0901 nameDBtoFileConversion_["AOH2_BIAS5"] = k_AOH2_Bias5;
0902 nameDBtoFileConversion_["AOH2_BIAS6"] = k_AOH2_Bias6;
0903
0904
0905
0906
0907
0908
0909 nameDBtoFileConversion_["AOH3_BIAS1"] = k_AOH3_Bias1;
0910 nameDBtoFileConversion_["AOH3_BIAS2"] = k_AOH3_Bias2;
0911 nameDBtoFileConversion_["AOH3_BIAS3"] = k_AOH3_Bias3;
0912 nameDBtoFileConversion_["AOH3_BIAS4"] = k_AOH3_Bias4;
0913 nameDBtoFileConversion_["AOH3_BIAS5"] = k_AOH3_Bias5;
0914 nameDBtoFileConversion_["AOH3_BIAS6"] = k_AOH3_Bias6;
0915
0916
0917
0918
0919
0920
0921 nameDBtoFileConversion_["AOH4_BIAS1"] = k_AOH4_Bias1;
0922 nameDBtoFileConversion_["AOH4_BIAS2"] = k_AOH4_Bias2;
0923 nameDBtoFileConversion_["AOH4_BIAS3"] = k_AOH4_Bias3;
0924 nameDBtoFileConversion_["AOH4_BIAS4"] = k_AOH4_Bias4;
0925 nameDBtoFileConversion_["AOH4_BIAS5"] = k_AOH4_Bias5;
0926 nameDBtoFileConversion_["AOH4_BIAS6"] = k_AOH4_Bias6;
0927
0928
0929
0930
0931
0932
0933
0934
0935
0936
0937
0938
0939
0940
0941
0942
0943
0944
0945
0946
0947
0948
0949
0950
0951
0952
0953
0954
0955
0956
0957 nameDBtoFileConversion_["DELAY25_GCR"] = k_Delay25_GCR;
0958 nameDBtoFileConversion_["DELAY25_SCL"] = k_Delay25_SCL;
0959 nameDBtoFileConversion_["DELAY25_TRG"] = k_Delay25_TRG;
0960 nameDBtoFileConversion_["DELAY25_SDA"] = k_Delay25_SDA;
0961 nameDBtoFileConversion_["DELAY25_RCL"] = k_Delay25_RCL;
0962 nameDBtoFileConversion_["DELAY25_RDA"] = k_Delay25_RDA;
0963
0964
0965
0966
0967
0968
0969 nameDBtoFileConversion_["DOH_BIAS0"] = k_DOH_Ch0Bias_CLK;
0970 nameDBtoFileConversion_["DOH_BIAS1"] = k_DOH_Ch1Bias_Data;
0971 nameDBtoFileConversion_["DOH_SEU_GAIN"] = k_DOH_Gain_SEU;
0972
0973
0974
0975 nameDBtoFileConversion_["PLL_CTR1"] = k_PLL_CTR1;
0976 nameDBtoFileConversion_["PLL_CTR2"] = k_PLL_CTR2;
0977 nameDBtoFileConversion_["PLL_CTR3"] = k_PLL_CTR3;
0978 nameDBtoFileConversion_["PLL_CTR4"] = k_PLL_CTR4;
0979 nameDBtoFileConversion_["PLL_CTR5"] = k_PLL_CTR5;
0980
0981
0982
0983
0984 }
0985 }
0986
0987 void PixelPortCardConfig::writeASCII(std::string dir) const {
0988 std::string mthn = "[PixelPortCardConfig::writeASCII()]\t\t\t\t ";
0989 if (!dir.empty())
0990 dir += "/";
0991 std::string filename = dir + "portcard_" + portcardname_ + ".dat";
0992
0993 std::ofstream out(filename.c_str());
0994 if (!out.good()) {
0995 std::cout << __LINE__ << "]\t" << mthn << "Could not open file: " << filename.c_str() << std::endl;
0996 assert(0);
0997 }
0998
0999 out << "Name: " << portcardname_ << std::endl;
1000 out << "Type: " << type_ << std::endl;
1001 out << "TKFECID: " << TKFECID_ << std::endl;
1002 out << "ringAddress: 0x" << std::hex << ringAddress_ << std::dec << std::endl;
1003 out << "ccuAddress: 0x" << std::hex << ccuAddress_ << std::dec << std::endl;
1004
1005 out << "channelAddress: 0x" << std::hex << channelAddress_ << std::dec << std::endl;
1006
1007 out << "i2cSpeed: 0x" << std::hex << i2cSpeed_ << std::dec << std::endl;
1008
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;
1013
1014
1015 if ((type_ == "fpix" && deviceAddress == k_fpix_AOH_Gain123_address) ||
1016 (type_ == "fpix" && deviceAddress == k_fpix_AOH_Gain456_address) ||
1017 (type_ == "bpix" && deviceAddress == k_bpix_AOH1_Gain123_address) ||
1018 (type_ == "bpix" && deviceAddress == k_bpix_AOH1_Gain456_address) ||
1019 (type_ == "bpix" && deviceAddress == k_bpix_AOH2_Gain123_address) ||
1020 (type_ == "bpix" && deviceAddress == k_bpix_AOH2_Gain456_address) ||
1021 (type_ == "bpix" && deviceAddress == k_bpix_AOH3_Gain123_address) ||
1022 (type_ == "bpix" && deviceAddress == k_bpix_AOH3_Gain456_address) ||
1023 (type_ == "bpix" && deviceAddress == k_bpix_AOH4_Gain123_address) ||
1024 (type_ == "bpix" && deviceAddress == k_bpix_AOH4_Gain456_address)) {
1025 std::string whichAOHString;
1026 unsigned int zeroOrThree;
1027 if (type_ == "fpix" && deviceAddress == k_fpix_AOH_Gain123_address) {
1028 whichAOHString = "";
1029 zeroOrThree = 0;
1030 } else if (type_ == "fpix" && deviceAddress == k_fpix_AOH_Gain456_address) {
1031 whichAOHString = "";
1032 zeroOrThree = 3;
1033 } else if (type_ == "bpix" && deviceAddress == k_bpix_AOH1_Gain123_address) {
1034 whichAOHString = "1";
1035 zeroOrThree = 0;
1036 } else if (type_ == "bpix" && deviceAddress == k_bpix_AOH1_Gain456_address) {
1037 whichAOHString = "1";
1038 zeroOrThree = 3;
1039 } else if (type_ == "bpix" && deviceAddress == k_bpix_AOH2_Gain123_address) {
1040 whichAOHString = "2";
1041 zeroOrThree = 0;
1042 } else if (type_ == "bpix" && deviceAddress == k_bpix_AOH2_Gain456_address) {
1043 whichAOHString = "2";
1044 zeroOrThree = 3;
1045 } else if (type_ == "bpix" && deviceAddress == k_bpix_AOH3_Gain123_address) {
1046 whichAOHString = "3";
1047 zeroOrThree = 0;
1048 } else if (type_ == "bpix" && deviceAddress == k_bpix_AOH3_Gain456_address) {
1049 whichAOHString = "3";
1050 zeroOrThree = 3;
1051 } else if (type_ == "bpix" && deviceAddress == k_bpix_AOH4_Gain123_address) {
1052 whichAOHString = "4";
1053 zeroOrThree = 0;
1054 } else if (type_ == "bpix" && deviceAddress == k_bpix_AOH4_Gain456_address) {
1055 whichAOHString = "4";
1056 zeroOrThree = 3;
1057 } else
1058 assert(0);
1059
1060 out << "AOH" << whichAOHString << "_Gain" << zeroOrThree + 1 << ": 0x" << (((device_[i].second) & 0x03) >> 0)
1061 << std::endl;
1062 out << "AOH" << whichAOHString << "_Gain" << zeroOrThree + 2 << ": 0x" << (((device_[i].second) & 0x0c) >> 2)
1063 << std::endl;
1064 out << "AOH" << whichAOHString << "_Gain" << zeroOrThree + 3 << ": 0x" << (((device_[i].second) & 0x30) >> 4)
1065 << std::endl;
1066 continue;
1067 }
1068
1069
1070
1071 std::string settingName = "";
1072 for (std::map<std::string, unsigned int>::const_iterator nameToAddress_itr = nameToAddress_.begin();
1073 nameToAddress_itr != nameToAddress_.end();
1074 ++nameToAddress_itr) {
1075
1076
1077
1078 if (nameToAddress_itr->second == deviceAddress) {
1079 settingName = nameToAddress_itr->first;
1080 break;
1081 }
1082 if (nameToAddress_itr == (--nameToAddress_.end())) {
1083 cout << "[PixelPortCardConfig::WriteASCII()]\tdeviceAddress: " << deviceAddress << " NOT FOUND" << endl;
1084 }
1085 }
1086
1087
1088 if (settingName == k_PLL_CTR2) {
1089 if (found_PLL_CTR2 && last_PLL_CTR2_value == device_.at(i).second)
1090 continue;
1091 found_PLL_CTR2 = true;
1092 last_PLL_CTR2_value = device_.at(i).second;
1093 }
1094 if (found_PLL_CTR2 && settingName == k_PLL_CTR4or5)
1095 {
1096 if ((last_PLL_CTR2_value & 0x20) == 0x0)
1097 settingName = k_PLL_CTR4;
1098 else
1099 settingName = k_PLL_CTR5;
1100 }
1101
1102
1103 if (settingName.empty())
1104 out << "0x" << std::hex << device_.at(i).first << std::dec;
1105 else
1106 out << settingName << ":";
1107
1108 out << " 0x" << std::hex << device_.at(i).second << std::dec << std::endl;
1109 }
1110
1111 out.close();
1112 }
1113
1114 unsigned int PixelPortCardConfig::getdevicesize() const { return device_.size(); }
1115
1116 std::string PixelPortCardConfig::getTKFECID() const { return TKFECID_; }
1117
1118 unsigned int PixelPortCardConfig::getringAddress() const { return ringAddress_; }
1119
1120 unsigned int PixelPortCardConfig::getccuAddress() const { return ccuAddress_; }
1121
1122 unsigned int PixelPortCardConfig::getchannelAddress() const { return channelAddress_; }
1123
1124 unsigned int PixelPortCardConfig::geti2cSpeed() const { return i2cSpeed_; }
1125
1126 std::string PixelPortCardConfig::gettype() const { return type_; }
1127
1128 unsigned int PixelPortCardConfig::getdeviceAddress(unsigned int i) const {
1129 assert(i < device_.size());
1130 return device_[i].first;
1131 }
1132
1133 unsigned int PixelPortCardConfig::getdeviceValues(unsigned int i) const {
1134 assert(i < device_.size());
1135 return device_[i].second;
1136 }
1137
1138 void PixelPortCardConfig::setdeviceValues(unsigned int address, unsigned int value) {
1139 for (int i = device_.size() - 1; i >= 0;
1140 i--)
1141 {
1142 if (device_.at(i).first == address) {
1143 device_.at(i).second = value;
1144 return;
1145 }
1146 }
1147
1148
1149 pair<unsigned int, unsigned int> p(address, value);
1150 device_.push_back(p);
1151
1152 return;
1153 }
1154
1155 void PixelPortCardConfig::setdeviceValues(std::string settingName, unsigned int value) {
1156 setdeviceValues(getdeviceAddressForSetting(settingName), value);
1157 return;
1158 }
1159
1160 unsigned int PixelPortCardConfig::getdeviceAddressForSetting(std::string settingName) const {
1161
1162 std::map<std::string, unsigned int>::const_iterator foundName_itr = nameToAddress_.find(settingName);
1163 assert(foundName_itr != nameToAddress_.end());
1164 return foundName_itr->second;
1165 }
1166
1167 unsigned int PixelPortCardConfig::getdeviceValuesForSetting(std::string settingName) const {
1168 return getdeviceValuesForAddress(getdeviceAddressForSetting(settingName));
1169 }
1170
1171 unsigned int PixelPortCardConfig::getdeviceValuesForAddress(unsigned int address) const {
1172 for (int i = device_.size() - 1; i >= 0; i--)
1173 {
1174 if (device_.at(i).first == address) {
1175 return device_.at(i).second;
1176 }
1177 }
1178 assert(0);
1179 return 0;
1180 }
1181
1182 bool PixelPortCardConfig::containsDeviceAddress(unsigned int deviceAddress) const {
1183 for (std::vector<std::pair<unsigned int, unsigned int> >::const_iterator device_itr = device_.begin();
1184 device_itr != device_.end();
1185 ++device_itr) {
1186 if (device_itr->first == deviceAddress)
1187 return true;
1188 }
1189 return false;
1190 }
1191
1192 unsigned int PixelPortCardConfig::AOHBiasAddressFromAOHNumber(unsigned int AOHNumber) const {
1193 std::string mthn = "[PixelPortCardConfig::AOHBiasAddressFromAOHNumber()] ";
1194 if (type_ == "fpix") {
1195 if (AOHNumber == 1)
1196 return PortCardSettingNames::k_fpix_AOH_Bias1_address;
1197 else if (AOHNumber == 2)
1198 return PortCardSettingNames::k_fpix_AOH_Bias2_address;
1199 else if (AOHNumber == 3)
1200 return PortCardSettingNames::k_fpix_AOH_Bias3_address;
1201 else if (AOHNumber == 4)
1202 return PortCardSettingNames::k_fpix_AOH_Bias4_address;
1203 else if (AOHNumber == 5)
1204 return PortCardSettingNames::k_fpix_AOH_Bias5_address;
1205 else if (AOHNumber == 6)
1206 return PortCardSettingNames::k_fpix_AOH_Bias6_address;
1207 else {
1208 std::cout << __LINE__ << "]\t" << mthn
1209 << "ERROR: For fpix, AOH number must be in the range 1-6, but the given AOH number was " << AOHNumber
1210 << "." << std::endl;
1211 assert(0);
1212 }
1213 } else if (type_ == "bpix") {
1214 if (AOHNumber == 1)
1215 return PortCardSettingNames::k_bpix_AOH1_Bias1_address;
1216 else if (AOHNumber == 2)
1217 return PortCardSettingNames::k_bpix_AOH1_Bias2_address;
1218 else if (AOHNumber == 3)
1219 return PortCardSettingNames::k_bpix_AOH1_Bias3_address;
1220 else if (AOHNumber == 4)
1221 return PortCardSettingNames::k_bpix_AOH1_Bias4_address;
1222 else if (AOHNumber == 5)
1223 return PortCardSettingNames::k_bpix_AOH1_Bias5_address;
1224 else if (AOHNumber == 6)
1225 return PortCardSettingNames::k_bpix_AOH1_Bias6_address;
1226 else if (AOHNumber == 7)
1227 return PortCardSettingNames::k_bpix_AOH2_Bias1_address;
1228 else if (AOHNumber == 8)
1229 return PortCardSettingNames::k_bpix_AOH2_Bias2_address;
1230 else if (AOHNumber == 9)
1231 return PortCardSettingNames::k_bpix_AOH2_Bias3_address;
1232 else if (AOHNumber == 10)
1233 return PortCardSettingNames::k_bpix_AOH2_Bias4_address;
1234 else if (AOHNumber == 11)
1235 return PortCardSettingNames::k_bpix_AOH2_Bias5_address;
1236 else if (AOHNumber == 12)
1237 return PortCardSettingNames::k_bpix_AOH2_Bias6_address;
1238 else if (AOHNumber == 13)
1239 return PortCardSettingNames::k_bpix_AOH3_Bias1_address;
1240 else if (AOHNumber == 14)
1241 return PortCardSettingNames::k_bpix_AOH3_Bias2_address;
1242 else if (AOHNumber == 15)
1243 return PortCardSettingNames::k_bpix_AOH3_Bias3_address;
1244 else if (AOHNumber == 16)
1245 return PortCardSettingNames::k_bpix_AOH3_Bias4_address;
1246 else if (AOHNumber == 17)
1247 return PortCardSettingNames::k_bpix_AOH3_Bias5_address;
1248 else if (AOHNumber == 18)
1249 return PortCardSettingNames::k_bpix_AOH3_Bias6_address;
1250 else if (AOHNumber == 19)
1251 return PortCardSettingNames::k_bpix_AOH4_Bias1_address;
1252 else if (AOHNumber == 20)
1253 return PortCardSettingNames::k_bpix_AOH4_Bias2_address;
1254 else if (AOHNumber == 21)
1255 return PortCardSettingNames::k_bpix_AOH4_Bias3_address;
1256 else if (AOHNumber == 22)
1257 return PortCardSettingNames::k_bpix_AOH4_Bias4_address;
1258 else if (AOHNumber == 23)
1259 return PortCardSettingNames::k_bpix_AOH4_Bias5_address;
1260 else if (AOHNumber == 24)
1261 return PortCardSettingNames::k_bpix_AOH4_Bias6_address;
1262 else {
1263 std::cout << __LINE__ << "]\t" << mthn
1264 << "ERROR: For bpix, AOH number must be in the range 1-24, but the given AOH number was " << AOHNumber
1265 << "." << std::endl;
1266 assert(0);
1267 }
1268 } else
1269 assert(0);
1270 }
1271
1272 std::string PixelPortCardConfig::AOHGainStringFromAOHNumber(unsigned int AOHNumber) const {
1273 std::string mthn = "[PixelPortCardConfig::AOHGainStringFromAOHNumber()] ";
1274 if (type_ == "fpix") {
1275 if (AOHNumber == 1)
1276 return "AOH_Gain1";
1277 else if (AOHNumber == 2)
1278 return "AOH_Gain2";
1279 else if (AOHNumber == 3)
1280 return "AOH_Gain3";
1281 else if (AOHNumber == 4)
1282 return "AOH_Gain4";
1283 else if (AOHNumber == 5)
1284 return "AOH_Gain5";
1285 else if (AOHNumber == 6)
1286 return "AOH_Gain6";
1287 else {
1288 std::cout << __LINE__ << "]\t" << mthn
1289 << "ERROR: For fpix, AOH number must be in the range 1-6, but the given AOH number was " << AOHNumber
1290 << "." << std::endl;
1291 assert(0);
1292 }
1293 } else if (type_ == "bpix") {
1294 if (AOHNumber == 1)
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";
1342 else {
1343 std::cout << __LINE__ << "]\t" << mthn
1344 << "ERROR: For bpix, AOH number must be in the range 1-24, but the given AOH number was " << AOHNumber
1345 << "." << std::endl;
1346 assert(0);
1347 }
1348 } else
1349 assert(0);
1350 }
1351
1352 unsigned int PixelPortCardConfig::AOHGainAddressFromAOHNumber(unsigned int AOHNumber) const {
1353 std::string mthn = "[PixelPortCardConfig::AOHGainAddressFromAOHNumber()] ";
1354 unsigned int address;
1355 if (type_ == "fpix") {
1356 if (AOHNumber == 1)
1357 address = PortCardSettingNames::k_fpix_AOH_Gain123_address;
1358 else if (AOHNumber == 2)
1359 address = PortCardSettingNames::k_fpix_AOH_Gain123_address;
1360 else if (AOHNumber == 3)
1361 address = PortCardSettingNames::k_fpix_AOH_Gain123_address;
1362 else if (AOHNumber == 4)
1363 address = PortCardSettingNames::k_fpix_AOH_Gain456_address;
1364 else if (AOHNumber == 5)
1365 address = PortCardSettingNames::k_fpix_AOH_Gain456_address;
1366 else if (AOHNumber == 6)
1367 address = PortCardSettingNames::k_fpix_AOH_Gain456_address;
1368 else {
1369 std::cout << __LINE__ << "]\t" << mthn
1370 << "ERROR: For fpix, AOH number must be in the range 1-6, but the given AOH number was " << AOHNumber
1371 << "." << std::endl;
1372 assert(0);
1373 }
1374 } else if (type_ == "bpix") {
1375 if (AOHNumber == 1)
1376 address = PortCardSettingNames::k_bpix_AOH1_Gain123_address;
1377 else if (AOHNumber == 2)
1378 address = PortCardSettingNames::k_bpix_AOH1_Gain123_address;
1379 else if (AOHNumber == 3)
1380 address = PortCardSettingNames::k_bpix_AOH1_Gain123_address;
1381 else if (AOHNumber == 4)
1382 address = PortCardSettingNames::k_bpix_AOH1_Gain456_address;
1383 else if (AOHNumber == 5)
1384 address = PortCardSettingNames::k_bpix_AOH1_Gain456_address;
1385 else if (AOHNumber == 6)
1386 address = PortCardSettingNames::k_bpix_AOH1_Gain456_address;
1387 else if (AOHNumber == 7)
1388 address = PortCardSettingNames::k_bpix_AOH2_Gain123_address;
1389 else if (AOHNumber == 8)
1390 address = PortCardSettingNames::k_bpix_AOH2_Gain123_address;
1391 else if (AOHNumber == 9)
1392 address = PortCardSettingNames::k_bpix_AOH2_Gain123_address;
1393 else if (AOHNumber == 10)
1394 address = PortCardSettingNames::k_bpix_AOH2_Gain456_address;
1395 else if (AOHNumber == 11)
1396 address = PortCardSettingNames::k_bpix_AOH2_Gain456_address;
1397 else if (AOHNumber == 12)
1398 address = PortCardSettingNames::k_bpix_AOH2_Gain456_address;
1399 else if (AOHNumber == 13)
1400 address = PortCardSettingNames::k_bpix_AOH3_Gain123_address;
1401 else if (AOHNumber == 14)
1402 address = PortCardSettingNames::k_bpix_AOH3_Gain123_address;
1403 else if (AOHNumber == 15)
1404 address = PortCardSettingNames::k_bpix_AOH3_Gain123_address;
1405 else if (AOHNumber == 16)
1406 address = PortCardSettingNames::k_bpix_AOH3_Gain456_address;
1407 else if (AOHNumber == 17)
1408 address = PortCardSettingNames::k_bpix_AOH3_Gain456_address;
1409 else if (AOHNumber == 18)
1410 address = PortCardSettingNames::k_bpix_AOH3_Gain456_address;
1411 else if (AOHNumber == 19)
1412 address = PortCardSettingNames::k_bpix_AOH4_Gain123_address;
1413 else if (AOHNumber == 20)
1414 address = PortCardSettingNames::k_bpix_AOH4_Gain123_address;
1415 else if (AOHNumber == 21)
1416 address = PortCardSettingNames::k_bpix_AOH4_Gain123_address;
1417 else if (AOHNumber == 22)
1418 address = PortCardSettingNames::k_bpix_AOH4_Gain456_address;
1419 else if (AOHNumber == 23)
1420 address = PortCardSettingNames::k_bpix_AOH4_Gain456_address;
1421 else if (AOHNumber == 24)
1422 address = PortCardSettingNames::k_bpix_AOH4_Gain456_address;
1423 else {
1424 std::cout << __LINE__ << "]\t" << mthn
1425 << "ERROR: For bpix, AOH number must be in the range 1-24, but the given AOH number was " << AOHNumber
1426 << "." << std::endl;
1427 assert(0);
1428 }
1429 } else
1430 assert(0);
1431
1432 return address;
1433 }
1434
1435 unsigned int PixelPortCardConfig::getAOHGain(unsigned int AOHNumber) const {
1436 const unsigned int address = AOHGainAddressFromAOHNumber(AOHNumber);
1437 const unsigned int threeGainsValue = getdeviceValuesForAddress(address);
1438
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);
1445
1446 assert(0);
1447 }
1448
1449 void PixelPortCardConfig::writeXMLHeader(pos::PixelConfigKey key,
1450 int version,
1451 std::string path,
1452 std::ofstream *outstream,
1453 std::ofstream *out1stream,
1454 std::ofstream *out2stream) const {
1455 std::string mthn = "[PixelPortCardConfig::writeXMLHeader()]\t\t\t ";
1456 std::stringstream fullPath;
1457 fullPath << path << "/Pixel_PortCardSettings_" << PixelTimeFormatter::getmSecTime() << ".xml";
1458 std::cout << __LINE__ << "]\t" << mthn << "Writing to: " << fullPath.str() << std::endl;
1459
1460 outstream->open(fullPath.str().c_str());
1461
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;
1472 *outstream << " <RUN_BEGIN_TIMESTAMP>" << pos::PixelTimeFormatter::getTime() << "</RUN_BEGIN_TIMESTAMP>"
1473 << 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;
1487 }
1488
1489
1490 void PixelPortCardConfig::writeXML(std::ofstream *outstream,
1491 std::ofstream *out1stream,
1492 std::ofstream *out2stream) const {
1493 std::string mthn = "[PixelPortCardConfig::writeXML()]\t\t\t ";
1494
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;
1502
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;
1507
1508
1509 if ((type_ == "fpix" && deviceAddress == k_fpix_AOH_Gain123_address) ||
1510 (type_ == "fpix" && deviceAddress == k_fpix_AOH_Gain456_address) ||
1511 (type_ == "bpix" && deviceAddress == k_bpix_AOH1_Gain123_address) ||
1512 (type_ == "bpix" && deviceAddress == k_bpix_AOH1_Gain456_address) ||
1513 (type_ == "bpix" && deviceAddress == k_bpix_AOH2_Gain123_address) ||
1514 (type_ == "bpix" && deviceAddress == k_bpix_AOH2_Gain456_address) ||
1515 (type_ == "bpix" && deviceAddress == k_bpix_AOH3_Gain123_address) ||
1516 (type_ == "bpix" && deviceAddress == k_bpix_AOH3_Gain456_address) ||
1517 (type_ == "bpix" && deviceAddress == k_bpix_AOH4_Gain123_address) ||
1518 (type_ == "bpix" && deviceAddress == k_bpix_AOH4_Gain456_address)) {
1519 std::string whichAOHString;
1520 unsigned int zeroOrThree;
1521 if (type_ == "fpix" && deviceAddress == k_fpix_AOH_Gain123_address) {
1522 whichAOHString = "";
1523 zeroOrThree = 0;
1524 } else if (type_ == "fpix" && deviceAddress == k_fpix_AOH_Gain456_address) {
1525 whichAOHString = "";
1526 zeroOrThree = 3;
1527 } else if (type_ == "bpix" && deviceAddress == k_bpix_AOH1_Gain123_address) {
1528 whichAOHString = "1";
1529 zeroOrThree = 0;
1530 } else if (type_ == "bpix" && deviceAddress == k_bpix_AOH1_Gain456_address) {
1531 whichAOHString = "1";
1532 zeroOrThree = 3;
1533 } else if (type_ == "bpix" && deviceAddress == k_bpix_AOH2_Gain123_address) {
1534 whichAOHString = "2";
1535 zeroOrThree = 0;
1536 } else if (type_ == "bpix" && deviceAddress == k_bpix_AOH2_Gain456_address) {
1537 whichAOHString = "2";
1538 zeroOrThree = 3;
1539 } else if (type_ == "bpix" && deviceAddress == k_bpix_AOH3_Gain123_address) {
1540 whichAOHString = "3";
1541 zeroOrThree = 0;
1542 } else if (type_ == "bpix" && deviceAddress == k_bpix_AOH3_Gain456_address) {
1543 whichAOHString = "3";
1544 zeroOrThree = 3;
1545 } else if (type_ == "bpix" && deviceAddress == k_bpix_AOH4_Gain123_address) {
1546 whichAOHString = "4";
1547 zeroOrThree = 0;
1548 } else if (type_ == "bpix" && deviceAddress == k_bpix_AOH4_Gain456_address) {
1549 whichAOHString = "4";
1550 zeroOrThree = 3;
1551 } else
1552 assert(0);
1553
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;
1563 continue;
1564 }
1565
1566
1567
1568 std::string settingName = "";
1569 for (std::map<std::string, unsigned int>::const_iterator nameToAddress_itr = nameToAddress_.begin();
1570 nameToAddress_itr != nameToAddress_.end();
1571 ++nameToAddress_itr) {
1572 if (nameToAddress_itr->second == deviceAddress) {
1573 settingName = nameToAddress_itr->first;
1574 break;
1575 }
1576 }
1577 for (std::map<std::string, std::string>::const_iterator nameDBtoFileConversion_itr =
1578 nameDBtoFileConversion_.begin();
1579 nameDBtoFileConversion_itr != nameDBtoFileConversion_.end();
1580 ++nameDBtoFileConversion_itr) {
1581 if (nameDBtoFileConversion_itr->second.find(settingName) != std::string::npos) {
1582 settingName = nameDBtoFileConversion_itr->first;
1583 break;
1584 }
1585 }
1586
1587
1588 if (settingName == k_PLL_CTR2) {
1589 if (found_PLL_CTR2 && last_PLL_CTR2_value == device_.at(i).second)
1590 continue;
1591 found_PLL_CTR2 = true;
1592 last_PLL_CTR2_value = device_.at(i).second;
1593 }
1594 if (found_PLL_CTR2 && settingName == k_PLL_CTR4or5)
1595 {
1596 if ((last_PLL_CTR2_value & 0x20) == 0x0)
1597 settingName = k_PLL_CTR4;
1598 else
1599 settingName = k_PLL_CTR5;
1600 }
1601
1602
1603 if (settingName.empty())
1604 *outstream << device_.at(i).first;
1605 else
1606 *outstream << " <" << settingName << ">";
1607
1608 *outstream << device_.at(i).second << "</" << settingName << ">" << std::endl;
1609 }
1610
1611 *outstream << " </DATA>" << std::endl;
1612 }
1613
1614 void PixelPortCardConfig::writeXMLTrailer(std::ofstream *outstream,
1615 std::ofstream *out1stream,
1616 std::ofstream *out2stream) const {
1617 std::string mthn = "[PixelPortCardConfig::writeXMLTrailer()]\t\t\t ";
1618
1619 *outstream << " </DATA_SET>" << std::endl;
1620 *outstream << "</ROOT> " << std::endl;
1621
1622 outstream->close();
1623 }