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" ;
132 if (nWords==0)
return;
137 const Word64* trailer =
reinterpret_cast<const Word64*
>(rawData.
data())+(nWords-1);
142 bool moreHeaders =
true;
143 while (moreHeaders) {
147 moreHeaders = headerStatus;
151 bool moreTrailers =
true;
153 while (moreTrailers) {
157 moreTrailers = trailerStatus;
162 LogTrace(
"")<<
"data words: "<< (trailer-header-1);
174 for (
auto word = bw; word < ew; ++word) {
184 if ( (nlink!=link) | (nroc!=roc) ) {
185 link = nlink; roc=nroc;
187 if (skipROC)
continue;
188 rocp = converter.
toRoc(link,roc);
190 errorsInEvent =
true;
195 auto rawId = rocp->
rawId();
197 if(barrel) layer = PixelROC::bpixLayerPhase1(rawId);
206 if (skipROC)
continue;
209 if (skipROC)
continue;
212 if ( (*detDigis).empty() ) (*detDigis).
data.reserve(32);
216 if unlikely(skipROC || !rocp)
continue;
219 std::unique_ptr<LocalPixel>
local;
231 LogDebug(
"PixelDataFormatter::interpretRawData")
233 errorsInEvent =
true;
237 local = std::make_unique<LocalPixel>(localCR);
250 LogDebug(
"PixelDataFormatter::interpretRawData")
252 errorsInEvent =
true;
256 local = std::make_unique<LocalPixel>(localDP);
261 (*detDigis).data.emplace_back(global.row, global.col, adc);
263 LogTrace(
"") << (*detDigis).data.back();
286 std::map<int, vector<Word32> > words;
289 for (Digis::const_iterator im = digis.begin(); im != digis.end(); im++) {
294 if(barrel) layer = PixelROC::bpixLayerPhase1(rawId);
298 const DetDigis & detDigis = im->second;
299 for (DetDigis::const_iterator it = detDigis.begin(); it != detDigis.end(); it++) {
305 else status =
digi2word( rawId, digi, words);
309 <<
" digi2word returns error #"<<status
311 <<
" detector: "<<rawId<< endl
312 <<
print(digi) <<endl;
318 typedef std::map<int, vector<Word32> >::const_iterator RI;
319 for (RI feddata = words.begin(); feddata != words.end(); feddata++) {
320 int fedId = feddata->first;
323 if (words.find(fedId)->second.size() %2 != 0) words[fedId].push_back(
Word32(0) );
326 int dataSize = words.find(fedId)->second.size() *
sizeof(
Word32);
329 dataSize += (nHeaders+nTrailers)*
sizeof(
Word64);
336 FEDHeader::set( reinterpret_cast<unsigned char*>(word), 0, lvl1_ID, 0, fedId);
340 unsigned int nWord32InFed = words.find(fedId)->second.size();
341 for (
unsigned int i=0;
i < nWord32InFed;
i+=2) {
342 *word = (
Word64(words.find(fedId)->second[
i]) << 32 ) | words.find(fedId)->second[
i+1];
352 if (word != reinterpret_cast<Word64* >(rawData->
data()+dataSize)) {
353 string s =
"** PROBLEM in PixelDataFormatter !!!";
356 fedRawData[
fedId] = *rawData;
362 std::map<
int, vector<Word32> > & words)
const 371 if (fedId<0)
return fedId;
382 words[
fedId].push_back(word);
388 std::map<
int, vector<Word32> > & words)
const 397 if (fedId<0)
return fedId;
400 int row = LocalPixel::numRowsInRoc - ((cabling.
pxid)/2);
412 words[
fedId].push_back(word);
424 if (word == 0 )
return 0;
437 <<
" rocRow: "<<local.
rocRow()<<
", rocCol:"<<local.
rocCol()
438 <<
" (dcol: "<<cabling.
dcol<<
", pxid:"<<cabling.
pxid<<
"), adc:"<<
adc;
441 if (!converter)
return 0;
445 if (status)
return status;
452 static_cast<unsigned int>(cabling.
link),
453 static_cast<unsigned int>(cabling.
roc)};
457 if (badROC)
return 0;
462 digis[detIdx.
rawId].emplace_back(detIdx.
row, detIdx.
col, adc);
473 str <<
" DIGI: row: " << digi.
row() <<
", col: " << digi.
column() <<
", adc: " << digi.
adc();
480 str <<
"word64: " <<
reinterpret_cast<const bitset<64>&
> (word);
int adc(sample_type sample)
get the ADC sample (12 bits)
bool checkTrailer(bool &errorsInEvent, int fedId, int nWords, const Word64 *trailer, Errors &errors)
bool IsRocBad(const uint32_t &detid, const short &rocNb) const
static void set(unsigned char *trailer, int evt_lgth, int crc, int evt_stat, int tts, bool T=false)
Set all fields in the trailer.
size_t size() const
Lenght of the data buffer in bytes.
identify pixel inside single ROC
bool checkROC(bool &errorsInEvent, int fedId, const SiPixelFrameConverter *converter, const SiPixelFedCabling *theCablingTree, Word32 &errorWord, Errors &errors)
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)
bool checkCRC(bool &errorsInEvent, int fedId, const Word64 *trailer, Errors &errors)
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
void setErrorStatus(bool ErrorStatus)
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
void conversionError(int fedId, const SiPixelFrameConverter *converter, int status, Word32 &errorWord, Errors &errors)
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
bool checkHeader(bool &errorsInEvent, int fedId, const Word64 *header, Errors &errors)