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};
195 int numberOfStrips = 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();
239 int sistrip = detId.
strip();
240 if (siz == 1 && sip == 1 && siy <= 20)
241 sistrip = 33 - sistrip;
242 if (siz == 1 && sip == 2 && six > 20)
243 sistrip = 33 - sistrip;
244 if (siz == -1 && sip == 1 && siy > 20)
245 sistrip = 33 - sistrip;
246 if (siz == -1 && sip == 2 && six <= 20)
247 sistrip = 33 - sistrip;
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) {
273 cout <<
"OPTORX: " <<
print(word) << endl;
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);
300 cout <<
"KCHIP : " <<
print(word) << endl;
302 words.push_back(word);
304 vector<Word64>&
data = map_data[kchip_fiber.first];
307 sort(data.begin(), data.end(),
ltstrip);
309 for (
unsigned int id = 0;
id < data.size(); ++
id) {
311 cout <<
"Data : " <<
print(data[
id]) << endl;
312 words.push_back(data[
id]);
321 int dataSize = (words.size() + 8) *
sizeof(
Word64);
323 vector<Word64> DCCwords;
326 word1 = (numberOfStrips <<
sDEL) | (0xff <<
sDERR);
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);
366 fedRawData.
resize(dataSize);
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),
T getUntrackedParameter(std::string const &, T const &) const
uint16_t *__restrict__ id
const ESDetId & id() const
static void set(unsigned char *trailer, uint32_t lenght, uint16_t crc, uint8_t evt_stat, uint8_t tts, bool moreTrailers=false)
Set all fields in the trailer.
void resize(size_t newsize)
unsigned short compute_crc(unsigned char *buffer, unsigned int bufSize)
const ESSample & sample(int i) const
bool operator()(const pair< int, int > s1, const pair< int, int > s2) const
char data[epos_bytes_allocation]
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
std::string fullPath() const
int adc() const
get the ADC sample (singed 16 bits)