58 : theDigiCounter(0), theWordCounter(0), theCablingTree(map), badPixelInfo(
nullptr), modulesToUnpack(
nullptr), phase1(phase)
62 int s8 =
sizeof(char);
63 if ( s8 != 1 || s32 != 4*s8 || s64 != 2*s32) {
65 <<
" unexpected sizes: " 66 <<
" size of char is: " << s8
67 <<
", size of Word32 is: " << s32
68 <<
", size of Word64 is: " << s64
69 <<
", send exception" ;
137 if (nWords==0)
return;
142 const Word64* trailer =
reinterpret_cast<const Word64*
>(rawData.
data())+(nWords-1);
143 if(!
errorcheck->checkCRC(errorsInEvent, fedId, trailer, errors))
return;
147 bool moreHeaders =
true;
148 while (moreHeaders) {
151 bool headerStatus =
errorcheck->checkHeader(errorsInEvent, fedId, header, errors);
152 moreHeaders = headerStatus;
156 bool moreTrailers =
true;
158 while (moreTrailers) {
161 bool trailerStatus =
errorcheck->checkTrailer(errorsInEvent, fedId, nWords, trailer, errors);
162 moreTrailers = trailerStatus;
167 LogTrace(
"")<<
"data words: "<< (trailer-header-1);
179 for (
auto word = bw; word < ew; ++word) {
189 if ( (nlink!=link) | (nroc!=roc) ) {
190 link = nlink; roc=nroc;
192 if (skipROC)
continue;
193 rocp = converter.
toRoc(link,roc);
195 errorsInEvent =
true;
196 errorcheck->conversionError(fedId, &converter, 2, ww, errors);
200 auto rawId = rocp->
rawId();
202 if(barrel) layer = PixelROC::bpixLayerPhase1(rawId);
211 if (skipROC)
continue;
214 if (skipROC)
continue;
217 if ( (*detDigis).empty() ) (*detDigis).
data.reserve(32);
221 if UNLIKELY(skipROC || !rocp)
continue;
224 std::unique_ptr<LocalPixel>
local;
236 LogDebug(
"PixelDataFormatter::interpretRawData")
238 errorsInEvent =
true;
239 errorcheck->conversionError(fedId, &converter, 3, ww, errors);
242 local = std::make_unique<LocalPixel>(localCR);
255 LogDebug(
"PixelDataFormatter::interpretRawData")
257 errorsInEvent =
true;
258 errorcheck->conversionError(fedId, &converter, 3, ww, errors);
261 local = std::make_unique<LocalPixel>(localDP);
266 (*detDigis).data.emplace_back(global.row, global.col, adc);
268 LogTrace(
"") << (*detDigis).data.back();
291 std::map<int, vector<Word32> > words;
294 for (Digis::const_iterator im = digis.begin(); im != digis.end(); im++) {
299 if(barrel) layer = PixelROC::bpixLayerPhase1(rawId);
302 BadChannels::const_iterator detBadChannels=badChannels.find(rawId);
305 const DetDigis & detDigis = im->second;
306 for (DetDigis::const_iterator it = detDigis.begin(); it != detDigis.end(); it++) {
312 else fedId =
digi2word( rawId, digi, words);
316 <<
" digi2word returns error #"<<fedId
318 <<
" detector: "<<rawId<< endl
319 <<
print(digi) <<endl;
320 }
else if (detBadChannels!=badChannels.end()) {
321 auto badChannel=std::find_if(detBadChannels->second.begin(),
322 detBadChannels->second.end(),
324 return (
int(ch.fed)==fedId && ch.link==
linkId(words[fedId].back()));
326 if (badChannel!=detBadChannels->second.end()) {
328 <<
" while marked bad, found digi for FED "<<fedId<<
" Link "<<
linkId(words[fedId].back())
329 <<
" on module "<<rawId<< endl
330 <<
print(digi) <<endl;
338 for(
const auto& detBadChannels: badChannels) {
339 for(
const auto& badChannel: detBadChannels.second) {
340 unsigned int FEDError25=25;
342 words[badChannel.fed].push_back(word);
347 typedef std::map<int, vector<Word32> >::const_iterator RI;
348 for (RI feddata = words.begin(); feddata != words.end(); feddata++) {
349 int fedId = feddata->first;
352 if (words.find(fedId)->second.size() %2 != 0) words[fedId].push_back(
Word32(0) );
355 int dataSize = words.find(fedId)->second.size() *
sizeof(
Word32);
358 dataSize += (nHeaders+nTrailers)*
sizeof(
Word64);
365 FEDHeader::set( reinterpret_cast<unsigned char*>(word), 0, lvl1_ID, 0, fedId);
369 unsigned int nWord32InFed = words.find(fedId)->second.size();
370 for (
unsigned int i=0;
i < nWord32InFed;
i+=2) {
371 *word = (
Word64(words.find(fedId)->second[
i+1]) << 32 ) | words.find(fedId)->second[
i];
381 if (word != reinterpret_cast<Word64* >(rawData->
data()+dataSize)) {
382 string s =
"** PROBLEM in PixelDataFormatter !!!";
385 fedRawData[
fedId] = *rawData;
391 std::map<
int, vector<Word32> > & words)
const 400 if (fedId<0)
return fedId;
411 words[
fedId].push_back(word);
417 std::map<
int, vector<Word32> > & words)
const 426 if (fedId<0)
return fedId;
441 words[
fedId].push_back(word);
453 if (word == 0 )
return 0;
466 <<
" rocRow: "<<local.
rocRow()<<
", rocCol:"<<local.
rocCol()
467 <<
" (dcol: "<<cabling.
dcol<<
", pxid:"<<cabling.
pxid<<
"), adc:"<<
adc;
470 if (!converter)
return 0;
474 if (status)
return status;
481 static_cast<unsigned int>(cabling.
link),
482 static_cast<unsigned int>(cabling.
roc)};
486 if (badROC)
return 0;
491 digis[detIdx.
rawId].emplace_back(detIdx.
row, detIdx.
col, adc);
502 str <<
" DIGI: row: " << digi.
row() <<
", col: " << digi.
column() <<
", adc: " << digi.
adc();
509 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