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