CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 
27 
28 //====================================================================================
29 PixelHdwAddress::PixelHdwAddress(int fecnumber, int mfec, int mfecchannel,
30  int hubaddress, int portaddress, int rocid,
31  int fednumber, int fedchannel,
32  int fedrocnumber):
33  fecnumber_(fecnumber),
34  mfec_(mfec),
35  mfecchannel_(mfecchannel),
36  portaddress_(portaddress),
37  hubaddress_(hubaddress),
38  rocid_(rocid),
39  fednumber_(fednumber),
40  fedchannel_(fedchannel),
41  fedrocnumber_(fedrocnumber)
42 {
43  //std::cout << "Created PixelHdwAddress:"<<std::endl;
44  //std::cout << *this << std::endl;
45 }
46 
47 //====================================================================================
48 std::ostream& pos::operator<<(std::ostream& s, const PixelHdwAddress& pixelroc){
49 
50  s<< "[PixelHdwAddress::operator<<]" <<std::endl;
51  s<< "fecnumber :" << pixelroc.fecnumber_ <<std::endl;
52  s<< "mfec :" << pixelroc.mfec_ <<std::endl;
53  s<< "mfecchannel :" << pixelroc.mfecchannel_ <<std::endl;
54  s<< "portaddress :" << pixelroc.portaddress_ <<std::endl;
55  s<< "hubaddress :" << pixelroc.hubaddress_ <<std::endl;
56  s<< "rocid :" << pixelroc.rocid_ <<std::endl;
57  s<< "fednumber :" << pixelroc.fednumber_ <<std::endl;
58  s<< "fedchannel :" << pixelroc.fedchannel_ <<std::endl;
59  s<< "fedrocnumber:" << pixelroc.fedrocnumber_ <<std::endl;
60 
61  return s;
62 }
63 
64 //====================================================================================
66 
67  fecnumber_ = aROC.fecnumber_ ;
68  mfec_ = aROC.mfec_ ;
69  mfecchannel_ = aROC.mfecchannel_ ;
70  portaddress_ = aROC.portaddress_ ;
71  hubaddress_ = aROC.hubaddress_ ;
72  rocid_ = aROC.rocid_ ;
73  fednumber_ = aROC.fednumber_ ;
74  fedchannel_ = aROC.fedchannel_ ;
76 
77  return *this;
78 
79 }
80 
81 //====================================================================================
82 // Added by Dario
83 void PixelHdwAddress::setAddress(std::string what, int value)
84 {
85  std::string mthn = "[PixelHdwAddress::setAddress()]\t\t\t " ;
86  if( what == "fecnumber" )
87  {
88  fecnumber_ = value;
89  } else if( what == "mfec" ) {
90  mfec_ = value ;
91  } else if( what == "mfecchannel" ) {
93  } else if( what == "portaddress" ) {
95  } else if( what == "hubaddress" ) {
96  hubaddress_ = value ;
97  } else if( what == "rocid" ) {
98  rocid_ = value ;
99  } else if( what == "fednumber" ) {
100  fednumber_ = value ;
101  } else if( what == "fedchannel" ) {
102  fedchannel_ = value ;
103  } else if( what == "fedrocnumber") {
104  fedrocnumber_ = value ;
105  } else {
106  std::cout << __LINE__ << "]\t" << mthn << "Could not set a value for " << what
107  << " (invalid keyword)" << std::endl ;
108  assert(0) ;
109  }
110 }
111 
112 //====================================================================================
113 void PixelHdwAddress::compare(std::string what, bool &changed, unsigned int newValue, unsigned int &oldValue)
114 {
115  std::string mthn = "[PixelHdwAddress::compare()]\t\t\t " ;
116  changed = false ;
117  oldValue = 0 ;
118 
119  if( what == "fecnumber" )
120  {
121  if( fecnumber_ != newValue) {changed = true; oldValue = fecnumber_; return ;}
122  } else if( what == "mfec" ) {
123  if( mfec_ != newValue) {changed = true; oldValue = mfec_; return ;}
124  } else if( what == "mfecchannel" ) {
125  if( mfecchannel_ != newValue) {changed = true; oldValue = mfecchannel_; return ;}
126  } else if( what == "portaddress" ) {
127  if( portaddress_ != newValue) {changed = true; oldValue = portaddress_; return ;}
128  } else if( what == "hubaddress" ) {
129  if( hubaddress_ != newValue) {changed = true; oldValue = hubaddress_; return ;}
130  } else if( what == "rocid" ) {
131  if( rocid_ != newValue) {changed = true; oldValue = rocid_; return ;}
132  } else if( what == "fednumber" ) {
133  if( fednumber_ != newValue) {changed = true; oldValue = fednumber_; return ;}
134  } else if( what == "fedchannel" ) {
135  if( fedchannel_ != newValue) {changed = true; oldValue = fedchannel_; return ;}
136  } else if( what == "fedrocnumber") {
137  if( fedrocnumber_ != newValue) {changed = true; oldValue = fedrocnumber_; return ;}
138  } else {
139  std::cout << __LINE__ << "]\t" << mthn << "Could not compare value for " << what
140  << " (invalid keyword)" << std::endl ;
141  assert(0) ;
142  }
143 }
144 
145 //====================================================================================
146 bool PixelHdwAddress::operator()(const PixelHdwAddress& roc1, const PixelHdwAddress& roc2) const{
147 
148  if (roc1.fednumber_ < roc2.fednumber_ ) return true;
149  if (roc1.fednumber_ > roc2.fednumber_ ) return false;
150  if (roc1.fedchannel_ < roc2.fedchannel_) return true;
151  if (roc1.fedchannel_ > roc2.fedchannel_) return false;
152 
153  return (roc1.fedrocnumber_<roc2.fedrocnumber_);
154 
155 }
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)
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:121
void compare(std::string what, bool &changed, unsigned int newValue, unsigned int &oldValue)
unsigned int fedrocnumber_