104 for (
int i = 0;
i < 2; ++
i)
105 for (
int j = 0;
j < 2; ++
j)
106 for (
int k = 0;
k < 40; ++
k)
107 for (
int m = 0;
m < 40;
m++) {
116 for (
int i = 0;
i < 56; ++
i) {
117 for (
int j = 0;
j < 3; ++
j)
121 for (
int i = 0;
i < 56; ++
i) {
122 for (
int j = 0;
j < 3; ++
j)
123 for (
int k = 0;
k < 12;
k++)
128 int nLines, iz, ip, ix, iy, fed, kchip, pace, bundle, fiber, optorx;
131 if (
file.is_open()) {
136 file >> iz >> ip >> ix >> iy >> fed >> kchip >> pace >> bundle >> fiber >> optorx;
138 fedId =
fedId_[(3 - iz) / 2 - 1][ip - 1][ix - 1][iy - 1] = fed;
139 kchipId_[(3 - iz) / 2 - 1][ip - 1][ix - 1][iy - 1] = kchip;
140 paceId_[(3 - iz) / 2 - 1][ip - 1][ix - 1][iy - 1] = pace - 1;
141 bundleId_[(3 - iz) / 2 - 1][ip - 1][ix - 1][iy - 1] = bundle;
142 fiberId_[(3 - iz) / 2 - 1][ip - 1][ix - 1][iy - 1] = fiber;
143 optoId_[(3 - iz) / 2 - 1][ip - 1][ix - 1][iy - 1] = optorx;
147 cout <<
"ESDataFormatterV4::ESDataFormatterV4 : fedId value : " <<
fedId
148 <<
" out of ES range, at lookup table line : " <<
i << endl;
149 }
else if (optorx < 1 || optorx > 3) {
151 cout <<
"ESDataFormatterV4::ESDataFormatterV4 : optorx value : " << optorx
152 <<
" out of ES range, at lookup table line : " <<
i << endl;
156 if (fiber > 0 && fiber < 13) {
160 cout <<
"ESDataFormatterV4::ESDataFormatterV4 : fiber value : " << fiber
161 <<
" out of ES range, at lookup table line : " <<
i << endl;
168 cout <<
"ESDataFormatterV4::ESDataFormatterV4 : Look up table file can not be found in "
178 bool operator()(
const pair<int, int> s1,
const pair<int, int>
s2)
const {
return (s1.second <
s2.second); }
188 return (val1 < val2);
192 int ts[3] = {0, 0, 0};
197 int optorx_ch_counts[3][12];
199 int kchip, pace, optorx, fiber;
200 map<int, vector<Word64> > map_data;
201 vector<Word64> words;
203 vector<Word32> testVector;
205 set<pair<int, int>,
ltfiber> set_of_kchip_fiber_in_optorx[3];
210 for (
int i = 0;
i < 3; ++
i)
211 for (
int j = 0;
j < 12; ++
j)
212 optorx_ch_counts[
i][
j] = 0;
217 cout <<
"ESDataFormatterV4::DigiToRaw : FEDID : " <<
fedId <<
" size of detDigis : " << detDigis.size() << endl;
220 for (DetDigis::const_iterator it = detDigis.begin(); it != detDigis.end(); ++it) {
224 for (
int is = 0; is < dataframe.
size(); ++is)
231 cout <<
"Si : " << detId.
zside() <<
" " << detId.
plane() <<
" " << detId.
six() <<
" " << detId.
siy() <<
" "
232 << detId.
strip() <<
" (" << kchip <<
"," << pace <<
") " << ts[0] <<
" " << ts[1] <<
" " << ts[2] << endl;
235 int siz = detId.
zside();
236 int sip = detId.
plane();
237 int six = detId.
six();
238 int siy = detId.
siy();
240 if (siz == 1 && sip == 1 && siy <= 20)
242 if (siz == 1 && sip == 2 && six > 20)
244 if (siz == -1 && sip == 1 && siy > 20)
246 if (siz == -1 && sip == 2 && six <= 20)
253 map_data[kchip].push_back(
word);
258 optorx_ch_counts[optorx - 1][fiber - 1]++;
260 set<pair<int, int>,
ltfiber>& theSet = set_of_kchip_fiber_in_optorx[optorx - 1];
261 theSet.insert(pair<int, int>(kchip, fiber));
267 for (
int iopto = 0; iopto < 3; ++iopto) {
274 words.push_back(
word);
276 set<pair<int, int>,
ltfiber>& theSet = set_of_kchip_fiber_in_optorx[iopto];
279 cout <<
"ESDataFormatterV4::DigiToRaw : FEDID : " <<
fedId <<
" size of set_of_kchip_fiber_in_optorx[" << iopto
280 <<
"] : " << theSet.size() << endl;
283 set<pair<int, int>,
ltfiber>::const_iterator kit = theSet.begin();
287 while (kit != theSet.end()) {
288 const pair<int, int>& kchip_fiber = (*kit);
291 cout <<
"KCHIP : " << kchip_fiber.first <<
" FIBER: " << kchip_fiber.second << endl;
295 word1 = (0 <<
sKFLAG1) | (0xf <<
sKFLAG2) | (((kchip_fiber.first << 2) | 0x02) <<
sKID);
302 words.push_back(
word);
304 vector<Word64>&
data = map_data[kchip_fiber.first];
309 for (
unsigned int id = 0;
id <
data.size(); ++
id) {
312 words.push_back(
data[
id]);
321 int dataSize = (words.size() + 8) *
sizeof(
Word64);
323 vector<Word64> DCCwords;
328 DCCwords.push_back(
word);
333 DCCwords.push_back(
word);
338 DCCwords.push_back(
word);
340 for (
int iopto = 0; iopto < 3; ++iopto) {
346 for (ich = 0; ich < 4; ++ich) {
347 int chStatus = (optorx_ch_counts[iopto][ich + 8] > 0) ? 0xe : 0xd;
349 word2 |= (chStatus << (ich * 4));
352 for (ich = 0; ich < 8; ++ich) {
353 int chStatus = (optorx_ch_counts[iopto][ich] > 0) ? 0xe : 0xd;
355 word1 |= (chStatus << (ich * 4));
361 DCCwords.push_back(
word);
375 for (
unsigned int i = 0;
i < DCCwords.size(); ++
i) {
377 cout <<
"DCC : " <<
print(DCCwords[
i]) << endl;
383 for (
unsigned int i = 0;
i < words.size(); ++
i) {
390 dataSize /
sizeof(
Word64),