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 edm::LogError(
"CTPPSPixelDataFormatter") <<
" Invalid linkId ";
149 }
else if ((nroc - 1) >= maxRocIndex) {
154 iD = (*mit).second.iD;
157 <<
" Invalid ROC Id " << convroc <<
" in nlink " << nlink <<
" of FED " <<
fedId <<
" in DetId " << iD;
160 edm::LogError(
"CTPPSPixelDataFormatter") <<
" Error unknown ";
169 if ((nlink != link) | (nroc !=
roc)) {
177 auto rawId = rocp.
rawId();
180 if ((*detDigis).empty())
181 (*detDigis).
data.reserve(32);
191 if (!
isRun3 && (dcol < min_Dcol || dcol > max_Dcol || pxid < min_Pixid || pxid > max_Pixid)) {
193 <<
" unphysical dcol and/or pxid " 194 <<
"fedId=" <<
fedId <<
" nllink=" << nlink <<
" convroc=" << convroc <<
" adc=" <<
adc <<
" dcol=" << dcol
195 <<
" pxid=" << pxid <<
" detId=" << iD;
201 if (
isRun3 && (col < min_COL || col > max_COL || row < min_ROW || row > max_ROW)) {
202 edm::LogError(
"CTPPSPixelDataFormatter") <<
" unphysical col and/or row " 203 <<
"fedId=" <<
fedId <<
" nllink=" << nlink <<
" convroc=" << convroc
204 <<
" adc=" <<
adc <<
" col=" <<
col <<
" row=" << row <<
" detId=" << iD;
210 std::pair<int, int> rocPixel;
211 std::pair<int, int> modPixel;
214 rocPixel = std::make_pair(row,
col);
217 rocPixel = std::make_pair(dcol, pxid);
224 (*detDigis).data.emplace_back(modPixel.first, modPixel.second,
adc);
229 unsigned int lvl1_ID,
232 std::vector<PPSPixelIndex> iDdet2fed) {
233 std::map<int, vector<Word32> > words;
237 for (
auto const& im : digis) {
241 const DetDigis& detDigis = im.second;
242 for (
auto const& it : detDigis) {
243 int nroc = 999, nlink = 999;
244 int rocPixelRow = -1, rocPixelColumn = -1, rocID = -1;
245 int modulePixelColumn = it.column();
246 int modulePixelRow = it.row();
252 unsigned int urocID = rocID;
255 auto range = std::equal_range(iDdet2fed.begin(), iDdet2fed.end(), myTest,
compare);
257 auto i =
range.first - iDdet2fed.begin();
258 nlink = iDdet2fed.at(
i).fedch;
259 nroc = iDdet2fed.at(
i).rocch + 1;
267 words[iDdet2fed.at(
i).fedid].push_back(
word);
273 words[iDdet2fed.at(
i).fedid].push_back(
word);
283 for (
auto const& feddata : words) {
284 int fedId = feddata.first;
288 if (words.find(
fedId)->second.size() % 2 != 0)
289 words[
fedId].emplace_back(0);
292 size_t dataSize = words.find(
fedId)->second.size() *
sizeof(
Word32);
295 dataSize += (nHeaders + nTrailers) *
sizeof(
Word64);
307 unsigned int nWord32InFed = words.find(
fedId)->second.size();
308 for (
unsigned int i = 0;
i < nWord32InFed;
i += 2) {
319 if (
word != reinterpret_cast<Word64*>(
rawData.data() + dataSize)) {
321 string s =
"** PROBLEM in CTPPSPixelDataFormatter !!!";
322 LogError(
"CTPPSPixelDataFormatter") <<
"** PROBLEM in CTPPSPixelDataFormatter!!!";
330 std::ostringstream
str;
331 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