16 {
17 bool p_debug = (
log.level() <= MSG::DEBUG);
18
19 if (p_debug) {
20 log << MSG::DEBUG <<
"TgcByteStream::rdo2ByteStream" <<
endmsg;
21 }
22
23 ByteStream headerBS, statusBS, countersBS, dataBS, footerBS;
24 TGC_BYTESTREAM_FRAGMENTCOUNT counters[7] = {{0, 1}, {0, 2}, {0, 3}, {0, 4},
25 {0, 5}, {0, 8}, {0, 9}};
26 TGC_BYTESTREAM_LOCALSTATUS
ls;
27
28 if (p_debug) {
29 log << MSG::DEBUG <<
"Encoding " << rdo->
size() <<
" elements"
31 }
32
34 switch (raw->type()) {
38 {
39 TGC_BYTESTREAM_READOUTHIT roh;
40 roh.
channel = raw->channel() - 40;
41 roh.
sbId = raw->slbId();
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57 roh.
sbType = raw->slbType();
58
59
60
61
62
63
64
65
66
67
68
69
72 if (raw->slbId() % 2 == 0) {
73 roh.
sbId = raw->slbId() / 2;
74 } else {
75 roh.
sbId = (raw->slbId() + 15) / 2;
76 }
77 }
78
79 roh.
adj = raw->isAdjacent();
80 roh.
ldbId = raw->sswId();
84 dataBS.push_back(
toBS32(roh));
85 }
86 break;
91 TGC_BYTESTREAM_READOUTTRIPLETSTRIP rot;
92 rot.
phi = raw->position();
93 rot.
seg = raw->segment();
94 rot.
sbId = raw->slbId();
95 rot.
ldbId = raw->sswId();
99 dataBS.push_back(
toBS32(rot));
100 } else {
101 TGC_BYTESTREAM_READOUTTRACKLET rot;
102 rot.
rphi = raw->position();
103 rot.
subm = raw->subMatrix();
104 rot.
seg = raw->segment();
105 rot.
delta = raw->delta();
106 rot.
sbId = raw->slbId();
107 rot.
ldbId = raw->sswId();
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
126 dataBS.push_back(
toBS32(rot));
127 }
128 break;
132 if (raw->isStrip() == 1 && raw->sector() & 4) {
133 TGC_BYTESTREAM_HIPT_INNER hpt;
134 hpt.
inner = raw->inner();
135
136
137
138 hpt.
sector = raw->sector();
139
140 hpt.
strip = raw->isStrip();
142 dataBS.push_back(
toBS32(hpt));
143 } else {
144 TGC_BYTESTREAM_HIPT hpt;
145 hpt.
delta = raw->delta();
146 hpt.
sub = raw->hsub();
147 hpt.
hitId = raw->hitId();
148 hpt.
hipt = raw->isHipt();
149 hpt.
cand = raw->index();
150 hpt.
chip = raw->chip();
151 hpt.
sector = raw->sector();
152 hpt.
fwd = raw->isForward();
153 hpt.
strip = raw->isStrip();
155 dataBS.push_back(
toBS32(hpt));
156 }
157 break;
161 {
162 TGC_BYTESTREAM_SL sl;
165 sl.
veto = raw->isVeto();
167 sl.
sign = raw->isMuplus();
168 sl.
cand = raw->index();
169 sl.
sector = raw->sector();
170 sl.
fwd = raw->isForward();
173 dataBS.push_back(
toBS32(sl));
174 }
175 break;
176 default:
177 log << MSG::ERROR <<
"Invalid type " << raw->typeName()
179 break;
180 }
181 }
182
183 statusBS.push_back(
toBS32(ls));
184 statusBS.push_back(rdo->orbit());
185
186 for (int iCnt = 0; iCnt < 7; iCnt++) {
187 if (counters[iCnt].
count > 0) {
188 countersBS.push_back(
toBS32(counters[iCnt]));
189 }
190 }
191
192 bs.clear();
193 bs.insert(bs.end(), countersBS.begin(), countersBS.end());
194 bs.insert(bs.end(), dataBS.begin(), dataBS.end());
195
196 if (p_debug) {
197 log << MSG::DEBUG <<
"TgcByteStream::rdo2ByteStream done" <<
endmsg;
198 }
199}
unsigned bcBitmap(uint16_t bcTag)
std::vector< uint32_t > ByteStream