File indexing completed on 2024-04-06 11:58:15
0001
0002
0003
0004
0005
0006
0007 #include "CalibFormats/SiPixelObjects/interface/PixelHdwAddress.h"
0008 #include <string>
0009 #include <cassert>
0010 #include <ostream>
0011 #include <iostream>
0012
0013 using namespace pos;
0014
0015
0016 PixelHdwAddress::PixelHdwAddress()
0017 : mfec_(0),
0018 mfecchannel_(0),
0019 portaddress_(0),
0020 hubaddress_(0),
0021 rocid_(0),
0022 fednumber_(0),
0023 fedchannel_(0),
0024 fedrocnumber_(0) {}
0025
0026
0027 PixelHdwAddress::PixelHdwAddress(int fecnumber,
0028 int mfec,
0029 int mfecchannel,
0030 int hubaddress,
0031 int portaddress,
0032 int rocid,
0033 int fednumber,
0034 int fedchannel,
0035 int fedrocnumber)
0036 : fecnumber_(fecnumber),
0037 mfec_(mfec),
0038 mfecchannel_(mfecchannel),
0039 portaddress_(portaddress),
0040 hubaddress_(hubaddress),
0041 rocid_(rocid),
0042 fednumber_(fednumber),
0043 fedchannel_(fedchannel),
0044 fedrocnumber_(fedrocnumber) {
0045
0046
0047 }
0048
0049
0050 std::ostream& pos::operator<<(std::ostream& s, const PixelHdwAddress& pixelroc) {
0051 s << "[PixelHdwAddress::operator<<]" << std::endl;
0052 s << "fecnumber :" << pixelroc.fecnumber_ << std::endl;
0053 s << "mfec :" << pixelroc.mfec_ << std::endl;
0054 s << "mfecchannel :" << pixelroc.mfecchannel_ << std::endl;
0055 s << "portaddress :" << pixelroc.portaddress_ << std::endl;
0056 s << "hubaddress :" << pixelroc.hubaddress_ << std::endl;
0057 s << "rocid :" << pixelroc.rocid_ << std::endl;
0058 s << "fednumber :" << pixelroc.fednumber_ << std::endl;
0059 s << "fedchannel :" << pixelroc.fedchannel_ << std::endl;
0060 s << "fedrocnumber:" << pixelroc.fedrocnumber_ << std::endl;
0061
0062 return s;
0063 }
0064
0065
0066
0067 void PixelHdwAddress::setAddress(std::string what, int value) {
0068 std::string mthn = "[PixelHdwAddress::setAddress()]\t\t\t ";
0069 if (what == "fecnumber") {
0070 fecnumber_ = value;
0071 } else if (what == "mfec") {
0072 mfec_ = value;
0073 } else if (what == "mfecchannel") {
0074 mfecchannel_ = value;
0075 } else if (what == "portaddress") {
0076 portaddress_ = value;
0077 } else if (what == "hubaddress") {
0078 hubaddress_ = value;
0079 } else if (what == "rocid") {
0080 rocid_ = value;
0081 } else if (what == "fednumber") {
0082 fednumber_ = value;
0083 } else if (what == "fedchannel") {
0084 fedchannel_ = value;
0085 } else if (what == "fedrocnumber") {
0086 fedrocnumber_ = value;
0087 } else {
0088 std::cout << __LINE__ << "]\t" << mthn << "Could not set a value for " << what << " (invalid keyword)" << std::endl;
0089 assert(0);
0090 }
0091 }
0092
0093
0094 void PixelHdwAddress::compare(std::string what, bool& changed, unsigned int newValue, unsigned int& oldValue) {
0095 std::string mthn = "[PixelHdwAddress::compare()]\t\t\t ";
0096 changed = false;
0097 oldValue = 0;
0098
0099 if (what == "fecnumber") {
0100 if (fecnumber_ != newValue) {
0101 changed = true;
0102 oldValue = fecnumber_;
0103 return;
0104 }
0105 } else if (what == "mfec") {
0106 if (mfec_ != newValue) {
0107 changed = true;
0108 oldValue = mfec_;
0109 return;
0110 }
0111 } else if (what == "mfecchannel") {
0112 if (mfecchannel_ != newValue) {
0113 changed = true;
0114 oldValue = mfecchannel_;
0115 return;
0116 }
0117 } else if (what == "portaddress") {
0118 if (portaddress_ != newValue) {
0119 changed = true;
0120 oldValue = portaddress_;
0121 return;
0122 }
0123 } else if (what == "hubaddress") {
0124 if (hubaddress_ != newValue) {
0125 changed = true;
0126 oldValue = hubaddress_;
0127 return;
0128 }
0129 } else if (what == "rocid") {
0130 if (rocid_ != newValue) {
0131 changed = true;
0132 oldValue = rocid_;
0133 return;
0134 }
0135 } else if (what == "fednumber") {
0136 if (fednumber_ != newValue) {
0137 changed = true;
0138 oldValue = fednumber_;
0139 return;
0140 }
0141 } else if (what == "fedchannel") {
0142 if (fedchannel_ != newValue) {
0143 changed = true;
0144 oldValue = fedchannel_;
0145 return;
0146 }
0147 } else if (what == "fedrocnumber") {
0148 if (fedrocnumber_ != newValue) {
0149 changed = true;
0150 oldValue = fedrocnumber_;
0151 return;
0152 }
0153 } else {
0154 std::cout << __LINE__ << "]\t" << mthn << "Could not compare value for " << what << " (invalid keyword)"
0155 << std::endl;
0156 assert(0);
0157 }
0158 }
0159
0160
0161 bool PixelHdwAddress::operator()(const PixelHdwAddress& roc1, const PixelHdwAddress& roc2) const {
0162 if (roc1.fednumber_ < roc2.fednumber_)
0163 return true;
0164 if (roc1.fednumber_ > roc2.fednumber_)
0165 return false;
0166 if (roc1.fedchannel_ < roc2.fedchannel_)
0167 return true;
0168 if (roc1.fedchannel_ > roc2.fedchannel_)
0169 return false;
0170
0171 return (roc1.fedrocnumber_ < roc2.fedrocnumber_);
0172 }