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;
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;
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;
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)
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();
285 while (kit != theSet.end()) {
286 const pair<int, int>& kchip_fiber = (*kit);
289 cout <<
"KCHIP : " << kchip_fiber.first <<
" FIBER: " << kchip_fiber.second << endl;
293 word1 = (0 <<
sKFLAG1) | (0xf <<
sKFLAG2) | (((kchip_fiber.first << 2) | 0x02) <<
sKID);
300 words.push_back(
word);
302 vector<Word64>&
data = map_data[kchip_fiber.first];
307 for (
unsigned int id = 0;
id <
data.size(); ++
id) {
310 words.push_back(
data[
id]);
318 int dataSize = (words.size() + 8) *
sizeof(
Word64);
320 vector<Word64> DCCwords;
325 DCCwords.push_back(
word);
330 DCCwords.push_back(
word);
335 DCCwords.push_back(
word);
337 for (
int iopto = 0; iopto < 3; ++iopto) {
343 for (ich = 0; ich < 4; ++ich) {
344 int chStatus = (optorx_ch_counts[iopto][ich + 8] > 0) ? 0xe : 0xd;
346 word2 |= (chStatus << (ich * 4));
349 for (ich = 0; ich < 8; ++ich) {
350 int chStatus = (optorx_ch_counts[iopto][ich] > 0) ? 0xe : 0xd;
352 word1 |= (chStatus << (ich * 4));
358 DCCwords.push_back(
word);
372 for (
unsigned int i = 0;
i < DCCwords.size(); ++
i) {
374 cout <<
"DCC : " <<
print(DCCwords[
i]) << endl;
380 for (
unsigned int i = 0;
i < words.size(); ++
i) {
387 dataSize /
sizeof(
Word64),
const ESDetId & id() const
std::string fullPath() const
T getUntrackedParameter(std::string const &, T const &) const
int adc() const
get the ADC sample (singed 16 bits)
const ESSample & sample(int i) 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.
unsigned short compute_crc(unsigned char *buffer, unsigned int bufSize)
ALPAKA_FN_ACC ALPAKA_FN_INLINE uint32_t ix(uint32_t id)
bool operator()(const pair< int, int > s1, const pair< int, int > s2) const
char data[epos_bytes_allocation]
ALPAKA_FN_ACC ALPAKA_FN_INLINE uint32_t iy(uint32_t id)