32 : m_WordCounter(0), m_DigiCounter(0) {
35 int s8 =
sizeof(char);
36 if (s8 != 1 || s32 != 4 * s8 || s64 != 2 * s32) {
37 LogError(
"UnexpectedSizes") <<
" unexpected sizes: "
38 <<
" size of char is: " << s8 <<
", size of Word32 is: " << s32
39 <<
", size of Word64 is: " << s64 <<
", send exception";
46 std::vector<PPSStripIndex> iDdet2fed) {
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) {
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);
93 words[
fedId].push_back(buf);
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);
129 FEDHeader::set(reinterpret_cast<unsigned char *>(word), 0, lvl1_ID, 0, fedId, 3);
133 unsigned int nWord16InFed = words16.find(fedId)->second.size();
134 for (
unsigned int i = 0;
i < nWord16InFed;
i += 4) {
135 *word = (
Word64(words16.find(fedId)->second[
i + 3]) << 48) | (
Word64(words16.find(fedId)->second[
i + 2]) << 32) |
136 (
Word64(words16.find(fedId)->second[
i + 1]) << 16) | words16.find(fedId)->second[
i];
145 if (word != reinterpret_cast<Word64 *>(rawData.data() + dataSize)) {
146 string s =
"** PROBLEM in CTPPSTotemDataFormatter !!!";
149 fedRawData[
fedId] = rawData;
Detector ID class for TOTEM Si strip detectors.
Log< level::Error, false > LogError
const uint16_t range(const Frame &aFrame)
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 long long uint64_t
static word calculateCRC(word crc_in, word dato)
internaly used to check CRC