CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 //====================================================================================
67  fecnumber_ = aROC.fecnumber_;
68  mfec_ = aROC.mfec_;
71  hubaddress_ = aROC.hubaddress_;
72  rocid_ = aROC.rocid_;
73  fednumber_ = aROC.fednumber_;
74  fedchannel_ = aROC.fedchannel_;
76 
77  return *this;
78 }
79 
80 //====================================================================================
81 // Added by Dario
83  std::string mthn = "[PixelHdwAddress::setAddress()]\t\t\t ";
84  if (what == "fecnumber") {
85  fecnumber_ = value;
86  } else if (what == "mfec") {
87  mfec_ = value;
88  } else if (what == "mfecchannel") {
90  } else if (what == "portaddress") {
92  } else if (what == "hubaddress") {
94  } else if (what == "rocid") {
95  rocid_ = value;
96  } else if (what == "fednumber") {
97  fednumber_ = value;
98  } else if (what == "fedchannel") {
100  } else if (what == "fedrocnumber") {
102  } else {
103  std::cout << __LINE__ << "]\t" << mthn << "Could not set a value for " << what << " (invalid keyword)" << std::endl;
104  assert(0);
105  }
106 }
107 
108 //====================================================================================
109 void PixelHdwAddress::compare(std::string what, bool& changed, unsigned int newValue, unsigned int& oldValue) {
110  std::string mthn = "[PixelHdwAddress::compare()]\t\t\t ";
111  changed = false;
112  oldValue = 0;
113 
114  if (what == "fecnumber") {
115  if (fecnumber_ != newValue) {
116  changed = true;
117  oldValue = fecnumber_;
118  return;
119  }
120  } else if (what == "mfec") {
121  if (mfec_ != newValue) {
122  changed = true;
123  oldValue = mfec_;
124  return;
125  }
126  } else if (what == "mfecchannel") {
127  if (mfecchannel_ != newValue) {
128  changed = true;
129  oldValue = mfecchannel_;
130  return;
131  }
132  } else if (what == "portaddress") {
133  if (portaddress_ != newValue) {
134  changed = true;
135  oldValue = portaddress_;
136  return;
137  }
138  } else if (what == "hubaddress") {
139  if (hubaddress_ != newValue) {
140  changed = true;
141  oldValue = hubaddress_;
142  return;
143  }
144  } else if (what == "rocid") {
145  if (rocid_ != newValue) {
146  changed = true;
147  oldValue = rocid_;
148  return;
149  }
150  } else if (what == "fednumber") {
151  if (fednumber_ != newValue) {
152  changed = true;
153  oldValue = fednumber_;
154  return;
155  }
156  } else if (what == "fedchannel") {
157  if (fedchannel_ != newValue) {
158  changed = true;
159  oldValue = fedchannel_;
160  return;
161  }
162  } else if (what == "fedrocnumber") {
163  if (fedrocnumber_ != newValue) {
164  changed = true;
165  oldValue = fedrocnumber_;
166  return;
167  }
168  } else {
169  std::cout << __LINE__ << "]\t" << mthn << "Could not compare value for " << what << " (invalid keyword)"
170  << std::endl;
171  assert(0);
172  }
173 }
174 
175 //====================================================================================
176 bool PixelHdwAddress::operator()(const PixelHdwAddress& roc1, const PixelHdwAddress& roc2) const {
177  if (roc1.fednumber_ < roc2.fednumber_)
178  return true;
179  if (roc1.fednumber_ > roc2.fednumber_)
180  return false;
181  if (roc1.fedchannel_ < roc2.fedchannel_)
182  return true;
183  if (roc1.fedchannel_ > roc2.fedchannel_)
184  return false;
185 
186  return (roc1.fedrocnumber_ < roc2.fedrocnumber_);
187 }
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_
const PixelHdwAddress & operator=(const PixelHdwAddress &aROC)
unsigned int mfecchannel_
unsigned int portaddress_
void setAddress(std::string what, int value)
Store mfec, mfecchannel etc.
unsigned int fedchannel_
unsigned int fecnumber_
tuple cout
Definition: gather_cfg.py:144
void compare(std::string what, bool &changed, unsigned int newValue, unsigned int &oldValue)
unsigned int fedrocnumber_