47 std::map<int, vector<std::array<uint16_t, 12>>> words;
48 for (
auto const &itDig : digis) {
50 uint32_t
rawId = itDig.first;
51 const DetDigis &detDigis = itDig.second;
52 std::array<uint16_t, 12>
buf, bufCRC;
53 std::map<uint32_t, vector<int>> mapIdCh;
54 for (
auto const &
it : detDigis) {
57 int nStrip =
it.stripNumber();
58 int chipPosition = nStrip / nCH;
59 int channel = nStrip - chipPosition * nCH;
60 uint32_t newrawId =
rawId + 8192 * chipPosition;
61 mapIdCh[newrawId].push_back(channel);
63 for (
auto &pId : mapIdCh) {
64 PPSStripIndex myTest = {pId.first, 0, 0, 0, 0};
67 auto range = std::equal_range(iDdet2fed.begin(), iDdet2fed.end(), myTest,
compare);
69 auto i =
range.first - iDdet2fed.begin();
70 for (
int b = 0;
b < 12;
b++) {
75 for (
auto &ch : pId.second) {
76 int chInWord = ch / 16;
77 buf[9 - chInWord] |= (1 << (ch % 16));
78 bufCRC[chInWord + 1] =
buf[9 - chInWord];
80 fedId = iDdet2fed.at(
i).fedid;
81 int idxInFiber = iDdet2fed.at(
i).idxinfiber;
82 int gohId = iDdet2fed.at(
i).gohid;
83 unsigned int hFlag = 0x90;
84 buf[0] = (hFlag << 8) | (gohId << 4) | (idxInFiber << 0);
85 buf[1] = (pId.first >> 15);
88 for (
int i = 11;
i >= 1;
i--)
91 buf[11] = (15 << 12) | (0 << 8) | (12 << 0);
98 typedef std::map<int, vector<std::array<uint16_t, 12>>>::const_iterator RI;
99 std::map<int, vector<uint16_t>> words16;
100 for (
auto &itFed : words) {
101 int fedId = itFed.first;
102 int wordsS = words.find(
fedId)->second.size();
104 words16[
fedId].emplace_back(0);
105 words16[
fedId].emplace_back(0);
107 for (
int k = 0;
k < wordsS;
k++) {
108 for (
int b = 0;
b < 12;
b++) {
109 words16[
fedId].push_back(words.find(
fedId)->second.at(
k)[
b]);
114 while (words16.find(
fedId)->second.size() % 4 != 0)
115 words16[
fedId].emplace_back(0);
118 auto dataSize = (words16.find(
fedId)->second.size()) *
sizeof(
Word16);
121 dataSize += (nHeaders + nTrailers) *
sizeof(
Word64);
133 unsigned int nWord16InFed = words16.find(
fedId)->second.size();
134 for (
unsigned int i = 0;
i < nWord16InFed;
i += 4) {
145 if (
word != reinterpret_cast<Word64 *>(
rawData.data() + dataSize)) {
146 string s =
"** PROBLEM in CTPPSTotemDataFormatter !!!";
Detector ID class for TOTEM Si strip detectors.
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.
static word calculateCRC(word crc_in, word dato)
internaly used to check CRC