66 int s8 =
sizeof(char);
67 if (s8 != 1 || s32 != 4 * s8 || s64 != 2 * s32) {
68 LogError(
"UnexpectedSizes") <<
" unexpected sizes: " 69 <<
" size of char is: " << s8 <<
", size of Word32 is: " << s32
70 <<
", size of Word64 is: " << s64 <<
", send exception";
136 const Word64* trailer =
reinterpret_cast<const Word64*
>(rawData.
data()) + (nWords - 1);
137 if (!
errorcheck->checkCRC(errorsInEvent, fedId, trailer, errors))
143 bool moreHeaders =
true;
144 while (moreHeaders) {
147 bool headerStatus =
errorcheck->checkHeader(errorsInEvent, fedId, header, errors);
148 moreHeaders = headerStatus;
152 bool moreTrailers =
true;
154 while (moreTrailers) {
157 bool trailerStatus =
errorcheck->checkTrailer(errorsInEvent, fedId, nWords, trailer, errors);
158 moreTrailers = trailerStatus;
163 LogTrace(
"") <<
"data words: " << (trailer - header - 1);
169 bool skipROC =
false;
174 if (*(ew - 1) == 0) {
192 if ((nlink != link) | (nroc !=
roc)) {
200 rocp = converter.
toRoc(link, roc);
203 errorsInEvent =
true;
204 errorcheck->conversionError(fedId, &converter, 2, ww, errors);
208 auto rawId = rocp->
rawId();
211 layer = PixelROC::bpixLayerPhase1(rawId);
229 if ((*detDigis).empty())
230 (*detDigis).
data.reserve(32);
235 UNLIKELY(skipROC || !rocp)
continue;
238 std::unique_ptr<LocalPixel>
local;
240 if (
phase1 && layer == 1) {
251 LogDebug(
"PixelDataFormatter::interpretRawData") <<
"status #3";
252 errorsInEvent =
true;
253 errorcheck->conversionError(fedId, &converter, 3, ww, errors);
256 local = std::make_unique<LocalPixel>(localCR);
270 LogDebug(
"PixelDataFormatter::interpretRawData") <<
"status #3";
271 errorsInEvent =
true;
272 errorcheck->conversionError(fedId, &converter, 3, ww, errors);
275 local = std::make_unique<LocalPixel>(localDP);
280 (*detDigis).data.emplace_back(global.row, global.col, adc);
282 LogTrace(
"") << (*detDigis).data.back();
305 std::map<int, vector<Word32> > words;
308 for (Digis::const_iterator im = digis.begin(); im != digis.end(); im++) {
314 layer = PixelROC::bpixLayerPhase1(rawId);
317 BadChannels::const_iterator detBadChannels = badChannels.find(rawId);
320 const DetDigis& detDigis = im->second;
321 for (DetDigis::const_iterator it = detDigis.begin(); it != detDigis.end(); it++) {
334 <<
" detector: " << rawId << endl
335 <<
print(digi) << endl;
336 }
else if (detBadChannels != badChannels.end()) {
338 std::find_if(detBadChannels->second.begin(), detBadChannels->second.end(), [&](
const PixelFEDChannel& ch) {
339 return (
int(ch.fed) == fedId && ch.link ==
linkId(words[fedId].back()));
341 if (badChannel != detBadChannels->second.end()) {
342 LogError(
"FormatDataException") <<
" while marked bad, found digi for FED " << fedId <<
" Link " 343 <<
linkId(words[fedId].back()) <<
" on module " << rawId << endl
344 <<
print(digi) << endl;
352 for (
const auto& detBadChannels : badChannels) {
353 for (
const auto& badChannel : detBadChannels.second) {
354 unsigned int FEDError25 = 25;
356 words[badChannel.fed].push_back(word);
361 typedef std::map<int, vector<Word32> >::const_iterator RI;
362 for (RI feddata = words.begin(); feddata != words.end(); feddata++) {
363 int fedId = feddata->first;
366 if (words.find(fedId)->second.size() % 2 != 0)
367 words[fedId].push_back(
Word32(0));
370 int dataSize = words.find(fedId)->second.size() *
sizeof(
Word32);
373 dataSize += (nHeaders + nTrailers) *
sizeof(
Word64);
380 FEDHeader::set(reinterpret_cast<unsigned char*>(word), 0, lvl1_ID, 0, fedId);
384 unsigned int nWord32InFed = words.find(fedId)->second.size();
385 for (
unsigned int i = 0;
i < nWord32InFed;
i += 2) {
386 *word = (
Word64(words.find(fedId)->second[
i + 1]) << 32) | words.find(fedId)->second[
i];
396 if (word != reinterpret_cast<Word64*>(rawData->
data() + dataSize)) {
397 string s =
"** PROBLEM in PixelDataFormatter !!!";
407 std::map<
int, vector<Word32> >& words)
const {
423 words[
fedId].push_back(word);
430 std::map<
int, vector<Word32> >& words)
const {
441 int col = ((cabling.
dcol) * 2) + ((cabling.
pxid) % 2);
450 words[
fedId].push_back(word);
462 Digis& digis)
const {
477 LogTrace(
"") <<
" link: " << cabling.
link <<
", roc: " << cabling.
roc <<
" rocRow: " << local.
rocRow()
478 <<
", rocCol:" << local.
rocCol() <<
" (dcol: " << cabling.
dcol <<
", pxid:" << cabling.
pxid 495 static_cast<unsigned int>(cabling.
link),
496 static_cast<unsigned int>(cabling.
roc)};
507 digis[detIdx.
rawId].emplace_back(detIdx.
row, detIdx.
col, adc);
518 str <<
" DIGI: row: " << digi.
row() <<
", col: " << digi.
column() <<
", adc: " << digi.
adc();
524 str <<
"word64: " <<
reinterpret_cast<const bitset<64>&
>(
word);
constexpr uint16_t numRowsInRoc
bool IsRocBad(const uint32_t &detid, const short &rocNb) const
size_t size() const
Lenght of the data buffer in bytes.
identify pixel inside single ROC
int toCabling(sipixelobjects::ElectronicIndex &cabling, const sipixelobjects::DetectorIndex &detector) const
reference find_or_insert(det_id_type id)
global coordinates (row and column in DetUnit, as in PixelDigi)
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 int idInDetUnit() const
id of this ROC in DetUnit etermined by token path
uint32_t rawId() const
return the DetUnit to which this ROC belongs to.
unsigned short adc() const
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
unsigned int cms_uint32_t
double collumn and pixel ID in double collumn representation
virtual bool isBarrel() const
true for barrel modules
virtual const sipixelobjects::PixelROC * findItem(const sipixelobjects::CablingPathToDetUnit &) const =0
row and collumn in ROC representation
sipixelobjects::PixelROC const * toRoc(int link, int roc) const
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
int toDetector(const sipixelobjects::ElectronicIndex &cabling, sipixelobjects::DetectorIndex &detector) const
GlobalPixel toGlobal(const LocalPixel &loc) const