24 using namespace sipixelobjects;
33 constexpr int PXID_shift = ADC_shift + ADC_bits;
34 constexpr int DCOL_shift = PXID_shift + PXID_bits;
35 constexpr int ROC_shift = DCOL_shift + DCOL_bits;
36 constexpr int LINK_shift = ROC_shift + ROC_bits;
47 : theDigiCounter(0), theWordCounter(0), theCablingTree(map), badPixelInfo(0), modulesToUnpack(0)
51 int s8 =
sizeof(
char);
52 if ( s8 != 1 || s32 != 4*s8 || s64 != 2*s32) {
54 <<
" unexpected sizes: "
55 <<
" size of char is: " << s8
56 <<
", size of Word32 is: " << s32
57 <<
", size of Word64 is: " << s64
58 <<
", send exception" ;
90 using namespace sipixelobjects;
102 const Word64* header =
reinterpret_cast<const Word64*
>(rawData.
data()); header--;
103 bool moreHeaders =
true;
104 while (moreHeaders) {
108 moreHeaders = headerStatus;
112 bool moreTrailers =
true;
114 while (moreTrailers) {
118 moreTrailers = trailerStatus;
123 LogTrace(
"")<<
"data words: "<< (trailer-header-1);
134 for (
auto word = bw; word < ew; ++word) {
140 int nlink = (ww >> LINK_shift) & LINK_mask;
141 int nroc = (ww >> ROC_shift) & ROC_mask;
143 if ( (nlink!=
link) | (nroc!=roc) ) {
144 link = nlink; roc=nroc;
146 if (skipROC)
continue;
149 errorsInEvent =
true;
154 auto rawId = rocp->rawId();
157 short rocInDet = (short) rocp->idInDetUnit();
159 if (skipROC)
continue;
162 if (skipROC)
continue;
165 if ( (*detDigis).empty() ) (*detDigis).
data.reserve(32);
170 int dcol = (ww >> DCOL_shift) & DCOL_mask;
171 int pxid = (ww >> PXID_shift) & PXID_mask;
172 int adc = (ww >> ADC_shift) & ADC_mask;
176 LogDebug(
"PixelDataFormatter::interpretRawData")
178 errorsInEvent =
true;
184 (*detDigis).data.emplace_back(global.
row, global.
col, adc);
186 LogTrace(
"") << (*detDigis).data.back();
192 for (
int i=0;
i<
N; ++
i) {
194 int dcol = (ww >> DCOL_shift) & DCOL_mask;
195 int pxid = (ww >> PXID_shift) & PXID_mask;
201 row[
i]=global.
row; col[
i]=global.
col;
210 std::map<int, vector<Word32> > words;
213 for (Digis::const_iterator im = digis.begin(); im != digis.end(); im++) {
217 const DetDigis & detDigis = im->second;
218 for (DetDigis::const_iterator it = detDigis.begin(); it != detDigis.end(); it++) {
224 <<
" digi2word returns error #"<<status
226 <<
" detector: "<<rawId<< endl
227 <<
print(digi) <<endl;
233 typedef std::map<int, vector<Word32> >::const_iterator RI;
234 for (RI feddata = words.begin(); feddata != words.end(); feddata++) {
235 int fedId = feddata->first;
238 if (words.find(fedId)->second.size() %2 != 0) words[fedId].push_back(
Word32(0) );
241 int dataSize = words.find(fedId)->second.size() *
sizeof(
Word32);
244 dataSize += (nHeaders+nTrailers)*
sizeof(
Word64);
251 FEDHeader::set( reinterpret_cast<unsigned char*>(word), 0, lvl1_ID, 0, fedId);
255 unsigned int nWord32InFed = words.find(fedId)->second.size();
256 for (
unsigned int i=0;
i < nWord32InFed;
i+=2) {
257 *word = (
Word64(words.find(fedId)->second[
i]) << 32 ) | words.find(fedId)->second[
i+1];
267 if (word != reinterpret_cast<Word64* >(rawData->
data()+dataSize)) {
268 string s =
"** PROBLEM in PixelDataFormatter !!!";
271 fedRawData[fedId] = *rawData;
277 std::map<
int, vector<Word32> > & words)
const
286 if (fedId<0)
return fedId;
289 (cabling.
link << LINK_shift)
290 | (cabling.
roc << ROC_shift)
291 | (cabling.
dcol << DCOL_shift)
292 | (cabling.
pxid << PXID_shift)
293 | (digi.
adc() << ADC_shift);
294 words[fedId].push_back(word);
306 if (word == 0 )
return 0;
309 cabling.
dcol = (word >> DCOL_shift) & DCOL_mask;
310 cabling.
pxid = (word >> PXID_shift) & PXID_mask;
311 cabling.
link = (word >> LINK_shift) & LINK_mask;
312 cabling.
roc = (word >> ROC_shift) & ROC_mask;
313 int adc = (word >> ADC_shift) & ADC_mask;
319 <<
" rocRow: "<<local.
rocRow()<<
", rocCol:"<<local.
rocCol()
320 <<
" (dcol: "<<cabling.
dcol<<
", pxid:"<<cabling.
pxid<<
"), adc:"<<
adc;
323 if (!converter)
return 0;
327 if (status)
return status;
334 static_cast<unsigned int>(cabling.
link),
335 static_cast<unsigned int>(cabling.
roc)};
339 if (badROC)
return 0;
344 digis[detIdx.
rawId].emplace_back(detIdx.
row, detIdx.
col, adc);
355 str <<
" DIGI: row: " << digi.
row() <<
", col: " << digi.
column() <<
", adc: " << digi.
adc();
362 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)
virtual const sipixelobjects::PixelROC * findItem(const sipixelobjects::CablingPathToDetUnit &) const =0
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
int toCabling(sipixelobjects::ElectronicIndex &cabling, const sipixelobjects::DetectorIndex &detector) const
reference find_or_insert(det_id_type id)
bool checkROC(bool &errorsInEvent, int fedId, const SiPixelFrameConverter *converter, Word32 &errorWord, Errors &errors)
global coordinates (row and column in DetUnit, as in PixelDigi)
std::string link(std::string &nm, std::string &ns)
tuple path
else: Piece not in the list, fine.
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
unsigned short adc() const
void setErrorStatus(bool ErrorStatus)
unsigned int cms_uint32_t
double collumn and pixel ID in double collumn representation
void conversionError(int fedId, const SiPixelFrameConverter *converter, int status, Word32 &errorWord, Errors &errors)
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)