CMS 3D CMS Logo

PixelHdwAddress.cc
Go to the documentation of this file.
1 //
2 //
3 //
4 //
5 //
6 
8 #include <string>
9 #include <cassert>
10 #include <ostream>
11 #include <iostream>
12 
13 using namespace pos;
14 
15 //====================================================================================
17  : mfec_(0),
18  mfecchannel_(0),
19  portaddress_(0),
20  hubaddress_(0),
21  rocid_(0),
22  fednumber_(0),
23  fedchannel_(0),
24  fedrocnumber_(0) {}
25 
26 //====================================================================================
28  int mfec,
29  int mfecchannel,
30  int hubaddress,
31  int portaddress,
32  int rocid,
33  int fednumber,
34  int fedchannel,
35  int fedrocnumber)
36  : fecnumber_(fecnumber),
37  mfec_(mfec),
38  mfecchannel_(mfecchannel),
39  portaddress_(portaddress),
40  hubaddress_(hubaddress),
41  rocid_(rocid),
42  fednumber_(fednumber),
43  fedchannel_(fedchannel),
44  fedrocnumber_(fedrocnumber) {
45  //std::cout << "Created PixelHdwAddress:"<<std::endl;
46  //std::cout << *this << std::endl;
47 }
48 
49 //====================================================================================
50 std::ostream& pos::operator<<(std::ostream& s, const PixelHdwAddress& pixelroc) {
51  s << "[PixelHdwAddress::operator<<]" << std::endl;
52  s << "fecnumber :" << pixelroc.fecnumber_ << std::endl;
53  s << "mfec :" << pixelroc.mfec_ << std::endl;
54  s << "mfecchannel :" << pixelroc.mfecchannel_ << std::endl;
55  s << "portaddress :" << pixelroc.portaddress_ << std::endl;
56  s << "hubaddress :" << pixelroc.hubaddress_ << std::endl;
57  s << "rocid :" << pixelroc.rocid_ << std::endl;
58  s << "fednumber :" << pixelroc.fednumber_ << std::endl;
59  s << "fedchannel :" << pixelroc.fedchannel_ << std::endl;
60  s << "fedrocnumber:" << pixelroc.fedrocnumber_ << std::endl;
61 
62  return s;
63 }
64 
65 //====================================================================================
66 // Added by Dario
68  std::string mthn = "[PixelHdwAddress::setAddress()]\t\t\t ";
69  if (what == "fecnumber") {
70  fecnumber_ = value;
71  } else if (what == "mfec") {
72  mfec_ = value;
73  } else if (what == "mfecchannel") {
75  } else if (what == "portaddress") {
77  } else if (what == "hubaddress") {
79  } else if (what == "rocid") {
80  rocid_ = value;
81  } else if (what == "fednumber") {
82  fednumber_ = value;
83  } else if (what == "fedchannel") {
85  } else if (what == "fedrocnumber") {
87  } else {
88  std::cout << __LINE__ << "]\t" << mthn << "Could not set a value for " << what << " (invalid keyword)" << std::endl;
89  assert(0);
90  }
91 }
92 
93 //====================================================================================
94 void PixelHdwAddress::compare(std::string what, bool& changed, unsigned int newValue, unsigned int& oldValue) {
95  std::string mthn = "[PixelHdwAddress::compare()]\t\t\t ";
96  changed = false;
97  oldValue = 0;
98 
99  if (what == "fecnumber") {
100  if (fecnumber_ != newValue) {
101  changed = true;
102  oldValue = fecnumber_;
103  return;
104  }
105  } else if (what == "mfec") {
106  if (mfec_ != newValue) {
107  changed = true;
108  oldValue = mfec_;
109  return;
110  }
111  } else if (what == "mfecchannel") {
112  if (mfecchannel_ != newValue) {
113  changed = true;
114  oldValue = mfecchannel_;
115  return;
116  }
117  } else if (what == "portaddress") {
118  if (portaddress_ != newValue) {
119  changed = true;
120  oldValue = portaddress_;
121  return;
122  }
123  } else if (what == "hubaddress") {
124  if (hubaddress_ != newValue) {
125  changed = true;
126  oldValue = hubaddress_;
127  return;
128  }
129  } else if (what == "rocid") {
130  if (rocid_ != newValue) {
131  changed = true;
132  oldValue = rocid_;
133  return;
134  }
135  } else if (what == "fednumber") {
136  if (fednumber_ != newValue) {
137  changed = true;
138  oldValue = fednumber_;
139  return;
140  }
141  } else if (what == "fedchannel") {
142  if (fedchannel_ != newValue) {
143  changed = true;
144  oldValue = fedchannel_;
145  return;
146  }
147  } else if (what == "fedrocnumber") {
148  if (fedrocnumber_ != newValue) {
149  changed = true;
150  oldValue = fedrocnumber_;
151  return;
152  }
153  } else {
154  std::cout << __LINE__ << "]\t" << mthn << "Could not compare value for " << what << " (invalid keyword)"
155  << std::endl;
156  assert(0);
157  }
158 }
159 
160 //====================================================================================
161 bool PixelHdwAddress::operator()(const PixelHdwAddress& roc1, const PixelHdwAddress& roc2) const {
162  if (roc1.fednumber_ < roc2.fednumber_)
163  return true;
164  if (roc1.fednumber_ > roc2.fednumber_)
165  return false;
166  if (roc1.fedchannel_ < roc2.fedchannel_)
167  return true;
168  if (roc1.fedchannel_ > roc2.fedchannel_)
169  return false;
170 
171  return (roc1.fedrocnumber_ < roc2.fedrocnumber_);
172 }
unsigned int hubaddress_
bool operator()(const PixelHdwAddress &roc1, const PixelHdwAddress &roc2) const
Store mfec, mfecchannel etc.
std::ostream & operator<<(std::ostream &s, const PixelCalibConfiguration &calib)
assert(be >=bs)
unsigned int fednumber_
unsigned int mfecchannel_
unsigned int portaddress_
void setAddress(std::string what, int value)
Store mfec, mfecchannel etc.
Definition: value.py:1
unsigned int fedchannel_
unsigned int fecnumber_
void compare(std::string what, bool &changed, unsigned int newValue, unsigned int &oldValue)
unsigned int fedrocnumber_