20 constexpr
int m_LINK_bits = 6;
21 constexpr
int m_ROC_bits = 5;
22 constexpr
int m_DCOL_bits = 5;
23 constexpr
int m_PXID_bits = 8;
24 constexpr
int m_COL_bits = 6;
25 constexpr
int m_ROW_bits = 7;
26 constexpr
int m_ADC_bits = 8;
27 constexpr
int min_Dcol = 0;
28 constexpr
int max_Dcol = 25;
29 constexpr
int min_Pixid = 2;
30 constexpr
int max_Pixid = 161;
31 constexpr
int min_COL = 0;
32 constexpr
int max_COL = 51;
33 constexpr
int min_ROW = 0;
34 constexpr
int max_ROW = 79;
35 constexpr
int maxRocIndex = 3;
36 constexpr
int maxLinkIndex = 49;
41 : m_WordCounter(0), m_Mapping(
mapping) {
44 int s8 =
sizeof(char);
45 if (s8 != 1 || s32 != 4 * s8 || s64 != 2 * s32) {
46 LogError(
"UnexpectedSizes") <<
" unexpected sizes: " 47 <<
" size of char is: " << s8 <<
", size of Word32 is: " << s32
48 <<
", size of Word64 is: " << s64 <<
", send exception";
92 bool moreHeaders =
true;
97 moreHeaders = headerStatus;
101 bool moreTrailers =
true;
103 while (moreTrailers) {
107 moreTrailers = trailerStatus;
117 bool skipROC =
false;
123 if (*(ew - 1) == 0) {
139 int convroc = nroc - 1;
142 std::map<CTPPSPixelFramePosition, CTPPSPixelROCInfo>::const_iterator mit;
146 if (nlink >= maxLinkIndex) {
148 }
else if ((nroc - 1) >= maxRocIndex) {
160 if ((nlink !=
link) | (nroc !=
roc)) {
168 auto rawId = rocp.
rawId();
171 if ((*detDigis).empty())
172 (*detDigis).
data.reserve(32);
182 if (!
isRun3 && (dcol < min_Dcol || dcol > max_Dcol || pxid < min_Pixid || pxid > max_Pixid)) {
184 <<
" unphysical dcol and/or pxid " 185 <<
" nllink=" << nlink <<
" nroc=" << nroc <<
" adc=" <<
adc <<
" dcol=" << dcol <<
" pxid=" << pxid;
191 if (
isRun3 && (col < min_COL || col > max_COL || row < min_ROW || row > max_ROW)) {
193 <<
" unphysical col and/or row " 194 <<
" nllink=" << nlink <<
" nroc=" << nroc <<
" adc=" <<
adc <<
" col=" <<
col <<
" row=" << row;
201 std::pair<int, int> rocPixel;
202 std::pair<int, int> modPixel;
205 rocPixel = std::make_pair(row,
col);
208 rocPixel = std::make_pair(dcol, pxid);
215 (*detDigis).data.emplace_back(modPixel.first, modPixel.second,
adc);
220 unsigned int lvl1_ID,
223 std::vector<PPSPixelIndex> iDdet2fed) {
224 std::map<int, vector<Word32> > words;
228 for (
auto const& im : digis) {
232 const DetDigis& detDigis = im.second;
233 for (
auto const& it : detDigis) {
234 int nroc = 999, nlink = 999;
235 int rocPixelRow = -1, rocPixelColumn = -1, rocID = -1;
236 int modulePixelColumn = it.column();
237 int modulePixelRow = it.row();
241 const int pxid = 2 * (ROCSizeInX - rocPixelRow) + (rocPixelColumn % 2);
243 unsigned int urocID = rocID;
246 auto range = std::equal_range(iDdet2fed.begin(), iDdet2fed.end(), myTest,
compare);
248 auto i =
range.first - iDdet2fed.begin();
249 nlink = iDdet2fed.at(
i).fedch;
250 nroc = iDdet2fed.at(
i).rocch + 1;
258 words[iDdet2fed.at(
i).fedid].push_back(
word);
264 words[iDdet2fed.at(
i).fedid].push_back(
word);
274 for (
auto const& feddata : words) {
275 int fedId = feddata.first;
279 if (words.find(
fedId)->second.size() % 2 != 0)
280 words[
fedId].emplace_back(0);
283 size_t dataSize = words.find(
fedId)->second.size() *
sizeof(
Word32);
286 dataSize += (nHeaders + nTrailers) *
sizeof(
Word64);
298 unsigned int nWord32InFed = words.find(
fedId)->second.size();
299 for (
unsigned int i = 0;
i < nWord32InFed;
i += 2) {
310 if (
word != reinterpret_cast<Word64*>(
rawData.data() + dataSize)) {
312 string s =
"** PROBLEM in CTPPSPixelDataFormatter !!!";
313 LogError(
"CTPPSPixelDataFormatter") <<
"** PROBLEM in CTPPSPixelDataFormatter!!!";
321 std::ostringstream
str;
322 str <<
"word64: " <<
reinterpret_cast<const std::bitset<64>&
>(
word);
Contains mappind data related to a ROC.
bool checkHeader(bool &errorsInEvent, int fedId, const Word64 *header, Errors &errors) const
bool checkCRC(bool &errorsInEvent, int fedId, const Word64 *trailer, Errors &errors) const
bool checkTrailer(bool &errorsInEvent, int fedId, unsigned int nWords, const Word64 *trailer, Errors &errors) const
Log< level::Error, false > LogError
bool checkROC(bool &errorsInEvent, int fedId, uint32_t iD, const Word32 &errorWord, Errors &errors) const
reference find_or_insert(det_id_type id)
uint32_t iD
the symbolic id
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.
int transformToROC(const int col, const int row, int &rocId, int &colROC, int &rowROC) const
uint32_t rawId() const
return the DetUnit to which this ROC belongs to.
unsigned int cms_uint32_t
void setErrorStatus(bool errorStatus)
void conversionError(int fedId, uint32_t iD, const State &state, const Word32 &errorWord, Errors &errors) const
static constexpr Word32 dummyDetId
std::pair< int, int > toGlobalfromDcol(const std::pair< int, int > &rocPixel) const
static int DColumn(const int colROC)
uint16_t *__restrict__ uint16_t const *__restrict__ adc
std::pair< int, int > toGlobal(const std::pair< int, int > &rocPixel) const