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) {
140 int convroc = nroc - 1;
144 std::map<CTPPSPixelFramePosition, CTPPSPixelROCInfo>::const_iterator mit;
152 if ((nlink !=
link) | (nroc !=
roc)) {
156 if ((
roc - 1) < maxRocIndex) {
167 if (nlink >= maxLinkIndex) {
169 edm::LogError(
"CTPPSPixelDataFormatter") <<
" Invalid linkId ";
170 }
else if ((nroc - 1) >= maxRocIndex) {
173 <<
" Invalid ROC Id " << convroc <<
" in nlink " << nlink <<
" of FED " <<
fedId <<
" in DetId " << iD;
176 edm::LogError(
"CTPPSPixelDataFormatter") <<
" Error unknown ";
181 if (rocp.
rawId() == 0) {
186 auto rawId = rocp.
rawId();
189 if ((*detDigis).empty())
190 (*detDigis).
data.reserve(32);
193 if (skipROC || rocp.
rawId() == 0)
203 if (!
isRun3 && (dcol < min_Dcol || dcol > max_Dcol || pxid < min_Pixid || pxid > max_Pixid)) {
205 <<
" unphysical dcol and/or pxid " 206 <<
"fedId=" <<
fedId <<
" nllink=" << nlink <<
" convroc=" << convroc <<
" adc=" <<
adc <<
" dcol=" << dcol
207 <<
" pxid=" << pxid <<
" detId=" << iD;
213 if (
isRun3 && (col < min_COL || col > max_COL || row < min_ROW || row > max_ROW)) {
214 edm::LogError(
"CTPPSPixelDataFormatter") <<
" unphysical col and/or row " 215 <<
"fedId=" <<
fedId <<
" nllink=" << nlink <<
" convroc=" << convroc
216 <<
" adc=" <<
adc <<
" col=" <<
col <<
" row=" << row <<
" detId=" << iD;
222 std::pair<int, int> rocPixel;
223 std::pair<int, int> modPixel;
226 rocPixel = std::make_pair(row,
col);
229 rocPixel = std::make_pair(dcol, pxid);
236 (*detDigis).data.emplace_back(modPixel.first, modPixel.second,
adc);
241 unsigned int lvl1_ID,
244 std::vector<PPSPixelIndex> iDdet2fed) {
245 std::map<int, vector<Word32> > words;
249 for (
auto const& im : digis) {
253 const DetDigis& detDigis = im.second;
254 for (
auto const& it : detDigis) {
255 int nroc = 999, nlink = 999;
256 int rocPixelRow = -1, rocPixelColumn = -1, rocID = -1;
257 int modulePixelColumn = it.column();
258 int modulePixelRow = it.row();
264 unsigned int urocID = rocID;
267 auto range = std::equal_range(iDdet2fed.begin(), iDdet2fed.end(), myTest,
compare);
269 auto i =
range.first - iDdet2fed.begin();
270 nlink = iDdet2fed.at(
i).fedch;
271 nroc = iDdet2fed.at(
i).rocch + 1;
279 words[iDdet2fed.at(
i).fedid].push_back(
word);
285 words[iDdet2fed.at(
i).fedid].push_back(
word);
295 for (
auto const& feddata : words) {
296 int fedId = feddata.first;
300 if (words.find(
fedId)->second.size() % 2 != 0)
301 words[
fedId].emplace_back(0);
304 size_t dataSize = words.find(
fedId)->second.size() *
sizeof(
Word32);
307 dataSize += (nHeaders + nTrailers) *
sizeof(
Word64);
319 unsigned int nWord32InFed = words.find(
fedId)->second.size();
320 for (
unsigned int i = 0;
i < nWord32InFed;
i += 2) {
331 if (
word != reinterpret_cast<Word64*>(
rawData.data() + dataSize)) {
333 string s =
"** PROBLEM in CTPPSPixelDataFormatter !!!";
334 LogError(
"CTPPSPixelDataFormatter") <<
"** PROBLEM in CTPPSPixelDataFormatter!!!";
342 std::ostringstream
str;
343 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
void setParameters(uint32_t du, int idInDU, int idLk)
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