CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
PixelDataFormatter Class Reference

#include <PixelDataFormatter.h>

Public Types

typedef std::map< cms_uint32_t, DetBadChannelsBadChannels
 
typedef edm::DetSetVector< PixelDigiCollection
 
typedef std::vector< PixelFEDChannelDetBadChannels
 
typedef std::vector< PixelDigiDetDigis
 
typedef std::vector< SiPixelRawDataErrorDetErrors
 
typedef std::map< cms_uint32_t, DetDigisDigis
 
typedef std::map< cms_uint32_t, DetErrorsErrors
 
typedef std::pair< DetDigis::const_iterator, DetDigis::const_iterator > Range
 
typedef std::map< int, FEDRawDataRawData
 
typedef cms_uint32_t Word32
 
typedef cms_uint64_t Word64
 

Public Member Functions

void formatRawData (unsigned int lvl1_ID, RawData &fedRawData, const Digis &digis, const BadChannels &badChannels)
 
void interpretRawData (bool &errorsInEvent, int fedId, const FEDRawData &data, Collection &digis, Errors &errors)
 
cms_uint32_t linkId (cms_uint32_t word32)
 
int nDigis () const
 
int nWords () const
 
void passFrameReverter (const SiPixelFrameReverter *reverter)
 
 PixelDataFormatter (const SiPixelFedCabling *map, bool phase1=false)
 
void setErrorStatus (bool ErrorStatus)
 
void setModulesToUnpack (const std::set< unsigned int > *moduleIds)
 
void setQualityStatus (bool QualityStatus, const SiPixelQuality *QualityInfo)
 

Private Member Functions

int checkError (const Word32 &data) const
 
int digi2word (cms_uint32_t detId, const PixelDigi &digi, std::map< int, std::vector< Word32 > > &words) const
 
int digi2wordPhase1Layer1 (cms_uint32_t detId, const PixelDigi &digi, std::map< int, std::vector< Word32 > > &words) const
 
cms_uint32_t errorDetId (const SiPixelFrameConverter *converter, int fedId, int errorType, const Word32 &word) const
 
std::string print (const PixelDigi &digi) const
 
std::string print (const Word64 &word) const
 
int word2digi (const int fedId, const SiPixelFrameConverter *converter, const bool includeError, const bool useQuality, const Word32 &word, Digis &digis) const
 

Private Attributes

Word32 ADC_mask
 
int ADC_shift
 
int allDetDigis
 
const SiPixelQualitybadPixelInfo
 
Word32 COL_mask
 
int COL_shift
 
Word32 DCOL_mask
 
int DCOL_shift
 
bool debug
 
std::unique_ptr< ErrorCheckerBaseerrorcheck
 
int hasDetDigis
 
bool includeErrors
 
Word32 LINK_mask
 
int LINK_shift
 
int maxROCIndex
 
const std::set< unsigned int > * modulesToUnpack
 
bool phase1
 
Word32 PXID_mask
 
int PXID_shift
 
Word32 ROC_mask
 
int ROC_shift
 
Word32 ROW_mask
 
int ROW_shift
 
SiPixelFedCabling const * theCablingTree
 
int theDigiCounter
 
const SiPixelFrameRevertertheFrameReverter
 
int theWordCounter
 
bool useQualityInfo
 

Detailed Description

Transforms Pixel raw data of a given FED to orca digi and vice versa.

FED OUTPUT DATA FORMAT 6/02, d.k. (11/02 updated for 100*150 pixels)

The output is transmitted through a 64 bit S-link connection. The packet format is defined by the CMS RU group to be : 1st packet header, 64 bits, includes a 6 bit FED id. 2nd packet header, 64 bits. .......................... (detector data) packet trailer, 64 bits. of the 64 bit pixel data records consists of 2 32 bit words. Each 32 bit word includes data from 1 pixel, the bit fields are the following:

6 bit link ID (max 36) - this defines the input link within 1 FED. 5 bit ROC ID (max 24) - this defines the readout chip within one link. 5 bit DCOL ID (max 26) - this defines the double column index with 1 chip. 8 bit pixel ID (max 180) - this defines the pixel address within 1 DCOL. 8 bit ADC vales - this has the charge amplitude.

So, 1 pixel occupies 4 bytes. If the number of pixels is odd, one extra 32 bit word is added (value 0) to fill all 64 bits.

The PixelDataFormatter interpret/format ONLY detector data words (not FED headers or trailer, which are treated elsewhere).

Definition at line 57 of file PixelDataFormatter.h.

Member Typedef Documentation

Definition at line 70 of file PixelDataFormatter.h.

Definition at line 61 of file PixelDataFormatter.h.

Definition at line 69 of file PixelDataFormatter.h.

Definition at line 64 of file PixelDataFormatter.h.

Definition at line 67 of file PixelDataFormatter.h.

Definition at line 65 of file PixelDataFormatter.h.

Definition at line 68 of file PixelDataFormatter.h.

typedef std::pair<DetDigis::const_iterator, DetDigis::const_iterator> PixelDataFormatter::Range

Definition at line 66 of file PixelDataFormatter.h.

typedef std::map<int, FEDRawData> PixelDataFormatter::RawData

Definition at line 63 of file PixelDataFormatter.h.

Definition at line 72 of file PixelDataFormatter.h.

Definition at line 73 of file PixelDataFormatter.h.

Constructor & Destructor Documentation

PixelDataFormatter::PixelDataFormatter ( const SiPixelFedCabling map,
bool  phase1 = false 
)

Definition at line 57 of file PixelDataFormatter.cc.

References ADC_mask, ADC_shift, allDetDigis, COL_mask, COL_shift, DCOL_mask, DCOL_shift, errorcheck, hasDetDigis, includeErrors, LINK_mask, LINK_shift, maxROCIndex, phase1, PXID_mask, PXID_shift, ROC_mask, ROC_shift, ROW_mask, ROW_shift, and useQualityInfo.

59 {
60  int s32 = sizeof(Word32);
61  int s64 = sizeof(Word64);
62  int s8 = sizeof(char);
63  if ( s8 != 1 || s32 != 4*s8 || s64 != 2*s32) {
64  LogError("UnexpectedSizes")
65  <<" unexpected sizes: "
66  <<" size of char is: " << s8
67  <<", size of Word32 is: " << s32
68  <<", size of Word64 is: " << s64
69  <<", send exception" ;
70  }
71  includeErrors = false;
72  useQualityInfo = false;
73  allDetDigis = 0;
74  hasDetDigis = 0;
75 
76  ADC_shift = 0;
77  PXID_shift = ADC_shift + ADC_bits;
78  DCOL_shift = PXID_shift + PXID_bits;
79  ROC_shift = DCOL_shift + DCOL_bits;
80 
81  if(phase1) { // for phase 1
82  LINK_shift = ROC_shift + ROC_bits1;
83  LINK_mask = ~(~PixelDataFormatter::Word32(0) << LINK_bits1);
84  ROC_mask = ~(~PixelDataFormatter::Word32(0) << ROC_bits1);
85  // special for layer 1 ROC
86  ROW_shift = ADC_shift + ADC_bits;
87  COL_shift = ROW_shift + ROW_bits1_l1;
88  COL_mask = ~(~PixelDataFormatter::Word32(0) << COL_bits1_l1);
89  ROW_mask = ~(~PixelDataFormatter::Word32(0) << ROW_bits1_l1);
90  maxROCIndex=8;
91 
92  } else { // for phase 0
93  LINK_shift = ROC_shift + ROC_bits;
94  LINK_mask = ~(~PixelDataFormatter::Word32(0) << LINK_bits);
95  ROC_mask = ~(~PixelDataFormatter::Word32(0) << ROC_bits);
96  maxROCIndex=25;
97  }
98 
99  DCOL_mask = ~(~PixelDataFormatter::Word32(0) << DCOL_bits);
100  PXID_mask = ~(~PixelDataFormatter::Word32(0) << PXID_bits);
101  ADC_mask = ~(~PixelDataFormatter::Word32(0) << ADC_bits);
102 
103  if (phase1) {
104  errorcheck=std::unique_ptr<ErrorCheckerBase>(new ErrorChecker());
105  } else {
106  errorcheck=std::unique_ptr<ErrorCheckerBase>(new ErrorCheckerPhase0());
107  }
108 }
const std::set< unsigned int > * modulesToUnpack
const SiPixelQuality * badPixelInfo
std::unique_ptr< ErrorCheckerBase > errorcheck
SiPixelFedCabling const * theCablingTree

Member Function Documentation

int PixelDataFormatter::checkError ( const Word32 data) const
private
int PixelDataFormatter::digi2word ( cms_uint32_t  detId,
const PixelDigi digi,
std::map< int, std::vector< Word32 > > &  words 
) const
private

Definition at line 390 of file PixelDataFormatter.cc.

References PixelDigi::adc(), ADC_shift, PixelDigi::column(), sipixelobjects::ElectronicIndex::dcol, DCOL_shift, gamEcalExtractorBlocks_cff::detector, l1t::stage2::layer2::fedId, sipixelobjects::ElectronicIndex::link, LINK_shift, LogDebug, print(), sipixelobjects::ElectronicIndex::pxid, PXID_shift, sipixelobjects::ElectronicIndex::roc, ROC_shift, PixelDigi::row(), theFrameReverter, theWordCounter, and SiPixelFrameReverter::toCabling().

Referenced by formatRawData().

392 {
393  LogDebug("PixelDataFormatter")
394 // <<" detId: " << detId
395  <<print(digi);
396 
397  DetectorIndex detector = {detId, digi.row(), digi.column()};
398  ElectronicIndex cabling;
399  int fedId = theFrameReverter->toCabling(cabling, detector);
400  if (fedId<0) return fedId;
401 
402  //if(DANEK) cout<<" digi2raw "<<detId<<" "<<digi.column()<<" "<<digi.row()<<" "<<digi.adc()<<" "
403  // <<cabling.link<<" "<<cabling.roc<<" "<<cabling.dcol<<" "<<cabling.pxid<<endl;
404 
405  Word32 word =
406  (cabling.link << LINK_shift)
407  | (cabling.roc << ROC_shift)
408  | (cabling.dcol << DCOL_shift)
409  | (cabling.pxid << PXID_shift)
410  | (digi.adc() << ADC_shift);
411  words[fedId].push_back(word);
412  theWordCounter++;
413 
414  return fedId;
415 }
#define LogDebug(id)
int row() const
Definition: PixelDigi.h:56
int toCabling(sipixelobjects::ElectronicIndex &cabling, const sipixelobjects::DetectorIndex &detector) const
std::string print(const PixelDigi &digi) const
unsigned short adc() const
Definition: PixelDigi.h:59
const SiPixelFrameReverter * theFrameReverter
int column() const
Definition: PixelDigi.h:57
int PixelDataFormatter::digi2wordPhase1Layer1 ( cms_uint32_t  detId,
const PixelDigi digi,
std::map< int, std::vector< Word32 > > &  words 
) const
private

Definition at line 416 of file PixelDataFormatter.cc.

References PixelDigi::adc(), ADC_shift, cuy::col, COL_shift, PixelDigi::column(), sipixelobjects::ElectronicIndex::dcol, gamEcalExtractorBlocks_cff::detector, l1t::stage2::layer2::fedId, sipixelobjects::ElectronicIndex::link, LINK_shift, LogDebug, phase1PixelTopology::numRowsInRoc, print(), sipixelobjects::ElectronicIndex::pxid, sipixelobjects::ElectronicIndex::roc, ROC_shift, PixelDigi::row(), ROW_shift, theFrameReverter, theWordCounter, and SiPixelFrameReverter::toCabling().

Referenced by formatRawData().

418 {
419  LogDebug("PixelDataFormatter")
420 // <<" detId: " << detId
421  <<print(digi);
422 
423  DetectorIndex detector = {detId, digi.row(), digi.column()};
424  ElectronicIndex cabling;
425  int fedId = theFrameReverter->toCabling(cabling, detector);
426  if (fedId<0) return fedId;
427 
428  int col = ((cabling.dcol)*2) + ((cabling.pxid)%2);
429  int row = LocalPixel::numRowsInRoc - ((cabling.pxid)/2);
430 
431  //if(DANEK) cout<<" layer 1: digi2raw "<<detId<<" "<<digi.column()<<" "<<digi.row()<<" "<<digi.adc()<<" "
432  // <<cabling.link<<" "<<cabling.roc<<" "<<cabling.dcol<<" "<<cabling.pxid<<" "
433  // <<col<<" "<<row<<endl;
434 
435  Word32 word =
436  (cabling.link << LINK_shift)
437  | (cabling.roc << ROC_shift)
438  | (col << COL_shift)
439  | (row << ROW_shift)
440  | (digi.adc() << ADC_shift);
441  words[fedId].push_back(word);
442  theWordCounter++;
443 
444  return fedId;
445 }
#define LogDebug(id)
int row() const
Definition: PixelDigi.h:56
constexpr uint16_t numRowsInRoc
int toCabling(sipixelobjects::ElectronicIndex &cabling, const sipixelobjects::DetectorIndex &detector) const
std::string print(const PixelDigi &digi) const
unsigned short adc() const
Definition: PixelDigi.h:59
const SiPixelFrameReverter * theFrameReverter
col
Definition: cuy.py:1010
int column() const
Definition: PixelDigi.h:57
cms_uint32_t PixelDataFormatter::errorDetId ( const SiPixelFrameConverter converter,
int  fedId,
int  errorType,
const Word32 word 
) const
private
void PixelDataFormatter::formatRawData ( unsigned int  lvl1_ID,
RawData fedRawData,
const Digis digis,
const BadChannels badChannels 
)

Definition at line 289 of file PixelDataFormatter.cc.

References allDetDigis, Reference_intrackfit_cff::barrel, FEDRawData::data(), digi2word(), digi2wordPhase1Layer1(), Exception, l1t::stage2::layer2::fedId, hasDetDigis, mps_fire::i, PixelModuleName::isBarrel(), LINK_shift, linkId(), LogDebug, LogTrace, phase1, print(), ROC_shift, alignCSCRings::s, FEDHeader::set(), FEDTrailer::set(), theDigiCounter, and theWordCounter.

Referenced by nWords().

290 {
291  std::map<int, vector<Word32> > words;
292 
293  // translate digis into 32-bit raw words and store in map indexed by Fed
294  for (Digis::const_iterator im = digis.begin(); im != digis.end(); im++) {
295  allDetDigis++;
296  cms_uint32_t rawId = im->first;
297  int layer=0;
298  bool barrel = PixelModuleName::isBarrel(rawId);
299  if(barrel) layer = PixelROC::bpixLayerPhase1(rawId);
300  //if(DANEK) cout<<" layer "<<layer<<" "<<phase1<<endl;
301 
302  BadChannels::const_iterator detBadChannels=badChannels.find(rawId);
303 
304  hasDetDigis++;
305  const DetDigis & detDigis = im->second;
306  for (DetDigis::const_iterator it = detDigis.begin(); it != detDigis.end(); it++) {
307  theDigiCounter++;
308  const PixelDigi & digi = (*it);
309  int fedId=0;
310 
311  if(layer==1 && phase1) fedId = digi2wordPhase1Layer1( rawId, digi, words);
312  else fedId = digi2word( rawId, digi, words);
313 
314  if (fedId<0) {
315  LogError("FormatDataException")
316  <<" digi2word returns error #"<<fedId
317  <<" Ndigis: "<<theDigiCounter << endl
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(),
323  [&] (const PixelFEDChannel& ch) {
324  return (int(ch.fed)==fedId && ch.link==linkId(words[fedId].back()));
325  });
326  if (badChannel!=detBadChannels->second.end()) {
327  LogError("FormatDataException")
328  <<" while marked bad, found digi for FED "<<fedId<<" Link "<<linkId(words[fedId].back())
329  <<" on module "<<rawId<< endl
330  << print(digi) <<endl;
331  }
332  } // if (fedId)
333  } // for (DetDigis
334  } // for (Digis
335  LogTrace(" allDetDigis/hasDetDigis : ") << allDetDigis<<"/"<<hasDetDigis;
336 
337  // fill FED error 25 words
338  for(const auto& detBadChannels: badChannels) {
339  for(const auto& badChannel: detBadChannels.second) {
340  unsigned int FEDError25=25;
341  Word32 word = (badChannel.link << LINK_shift) | (FEDError25 << ROC_shift);
342  words[badChannel.fed].push_back(word);
343  theWordCounter++;
344  }
345  }
346 
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;
350  // since raw words are written in the form of 64-bit packets
351  // add extra 32-bit word to make number of words even if necessary
352  if (words.find(fedId)->second.size() %2 != 0) words[fedId].push_back( Word32(0) );
353 
354  // size in Bytes; create output structure
355  int dataSize = words.find(fedId)->second.size() * sizeof(Word32);
356  int nHeaders = 1;
357  int nTrailers = 1;
358  dataSize += (nHeaders+nTrailers)*sizeof(Word64);
359  FEDRawData * rawData = new FEDRawData(dataSize);
360 
361  // get begining of data;
362  Word64 * word = reinterpret_cast<Word64* >(rawData->data());
363 
364  // write one header
365  FEDHeader::set( reinterpret_cast<unsigned char*>(word), 0, lvl1_ID, 0, fedId);
366  word++;
367 
368  // write data
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];
372  LogDebug("PixelDataFormatter") << print(*word);
373  word++;
374  }
375 
376  // write one trailer
377  FEDTrailer::set( reinterpret_cast<unsigned char*>(word), dataSize/sizeof(Word64), 0,0,0);
378  word++;
379 
380  // check memory
381  if (word != reinterpret_cast<Word64* >(rawData->data()+dataSize)) {
382  string s = "** PROBLEM in PixelDataFormatter !!!";
383  throw cms::Exception(s);
384  } // if (word !=
385  fedRawData[fedId] = *rawData;
386  delete rawData;
387  } // for (RI feddata
388 }
#define LogDebug(id)
int digi2wordPhase1Layer1(cms_uint32_t detId, const PixelDigi &digi, std::map< int, std::vector< Word32 > > &words) const
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.
Definition: FEDTrailer.cc:60
std::string print(const PixelDigi &digi) const
uint64_t Word64
unsigned int cms_uint32_t
Definition: typedefs.h:15
#define LogTrace(id)
virtual bool isBarrel() const
true for barrel modules
std::vector< PixelDigi > DetDigis
int digi2word(cms_uint32_t detId, const PixelDigi &digi, std::map< int, std::vector< Word32 > > &words) const
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
cms_uint32_t linkId(cms_uint32_t word32)
static void set(unsigned char *header, uint8_t triggerType, uint32_t lvl1ID, uint16_t bxID, uint16_t sourceID, uint8_t version=0, bool moreHeaders=false)
Set all fields in the header.
Definition: FEDHeader.cc:47
void PixelDataFormatter::interpretRawData ( bool &  errorsInEvent,
int  fedId,
const FEDRawData data,
Collection digis,
Errors errors 
)

Definition at line 132 of file PixelDataFormatter.cc.

References ecalMGPA::adc(), ADC_mask, ADC_shift, badPixelInfo, Reference_intrackfit_cff::barrel, cuy::col, COL_mask, COL_shift, FEDRawData::data(), edm::DetSet< T >::data, DCOL_mask, DCOL_shift, errorcheck, edm::DetSetVector< T >::find_or_insert(), RecoTauValidation_cfi::header, sipixelobjects::PixelROC::idInDetUnit(), PixelModuleName::isBarrel(), SiPixelQuality::IsRocBad(), LIKELY, LINK_mask, LINK_shift, DTRecHitClients_cfi::local, LogDebug, LogTrace, maxROCIndex, modulesToUnpack, nWords(), phase1, print(), PXID_mask, PXID_shift, sipixelobjects::PixelROC::rawId(), ROC_mask, ROC_shift, ROW_mask, ROW_shift, FEDRawData::size(), theCablingTree, theWordCounter, sipixelobjects::PixelROC::toGlobal(), SiPixelFrameConverter::toRoc(), UNLIKELY, useQualityInfo, sipixelobjects::LocalPixel::RocRowCol::valid(), and sipixelobjects::LocalPixel::DcolPxid::valid().

Referenced by nWords().

133 {
134  using namespace sipixelobjects;
135 
136  int nWords = rawData.size()/sizeof(Word64);
137  if (nWords==0) return;
138 
140 
141  // check CRC bit
142  const Word64* trailer = reinterpret_cast<const Word64* >(rawData.data())+(nWords-1);
143  if(!errorcheck->checkCRC(errorsInEvent, fedId, trailer, errors)) return;
144 
145  // check headers
146  const Word64* header = reinterpret_cast<const Word64* >(rawData.data()); header--;
147  bool moreHeaders = true;
148  while (moreHeaders) {
149  header++;
150  LogTrace("")<<"HEADER: " << print(*header);
151  bool headerStatus = errorcheck->checkHeader(errorsInEvent, fedId, header, errors);
152  moreHeaders = headerStatus;
153  }
154 
155  // check trailers
156  bool moreTrailers = true;
157  trailer++;
158  while (moreTrailers) {
159  trailer--;
160  LogTrace("")<<"TRAILER: " << print(*trailer);
161  bool trailerStatus = errorcheck->checkTrailer(errorsInEvent, fedId, nWords, trailer, errors);
162  moreTrailers = trailerStatus;
163  }
164 
165  // data words
166  theWordCounter += 2*(nWords-2);
167  LogTrace("")<<"data words: "<< (trailer-header-1);
168 
169  int link = -1;
170  int roc = -1;
171  int layer = 0;
172  PixelROC const * rocp=nullptr;
173  bool skipROC=false;
174  edm::DetSet<PixelDigi> * detDigis=nullptr;
175 
176  const Word32 * bw =(const Word32 *)(header+1);
177  const Word32 * ew =(const Word32 *)(trailer);
178  if ( *(ew-1) == 0 ) { ew--; theWordCounter--;}
179  for (auto word = bw; word < ew; ++word) {
180  LogTrace("")<<"DATA: " << print(*word);
181 
182  auto ww = *word;
183  if UNLIKELY(ww==0) { theWordCounter--; continue;}
184  int nlink = (ww >> LINK_shift) & LINK_mask;
185  int nroc = (ww >> ROC_shift) & ROC_mask;
186 
187  //if(DANEK) cout<<" fed, link, roc "<<fedId<<" "<<nlink<<" "<<nroc<<endl;
188 
189  if ( (nlink!=link) | (nroc!=roc) ) { // new roc
190  link = nlink; roc=nroc;
191  skipROC = LIKELY(roc<maxROCIndex) ? false : !errorcheck->checkROC(errorsInEvent, fedId, &converter, theCablingTree, ww, errors);
192  if (skipROC) continue;
193  rocp = converter.toRoc(link,roc);
194  if UNLIKELY(!rocp) {
195  errorsInEvent = true;
196  errorcheck->conversionError(fedId, &converter, 2, ww, errors);
197  skipROC=true;
198  continue;
199  }
200  auto rawId = rocp->rawId();
201  bool barrel = PixelModuleName::isBarrel(rawId);
202  if(barrel) layer = PixelROC::bpixLayerPhase1(rawId);
203  else layer=0;
204 
205  //if(DANEK) cout<<" rocp "<<rocp->print()<<" layer "<<rocp->bpixLayerPhase1(rawId)<<" "
206  // <<layer<<" phase1 "<<phase1<<" rawid "<<rawId<<endl;
207 
208  if (useQualityInfo&(nullptr!=badPixelInfo)) {
209  short rocInDet = (short) rocp->idInDetUnit();
210  skipROC = badPixelInfo->IsRocBad(rawId, rocInDet);
211  if (skipROC) continue;
212  }
213  skipROC= modulesToUnpack && ( modulesToUnpack->find(rawId) == modulesToUnpack->end());
214  if (skipROC) continue;
215 
216  detDigis = &digis.find_or_insert(rawId);
217  if ( (*detDigis).empty() ) (*detDigis).data.reserve(32); // avoid the first relocations
218  }
219 
220  // skip is roc to be skipped ot invalid
221  if UNLIKELY(skipROC || !rocp) continue;
222 
223  int adc = (ww >> ADC_shift) & ADC_mask;
224  std::unique_ptr<LocalPixel> local;
225 
226  if(phase1 && layer==1) { // special case for layer 1ROC
227  // for l1 roc use the roc column and row index instead of dcol and pixel index.
228  int col = (ww >> COL_shift) & COL_mask;
229  int row = (ww >> ROW_shift) & ROW_mask;
230  //if(DANEK) cout<<" layer 1: raw2digi "<<link<<" "<<roc<<" "
231  // <<col<<" "<<row<<" "<<adc<<endl;
232 
233  LocalPixel::RocRowCol localCR = { row, col }; // build pixel
234  //if(DANEK)cout<<localCR.rocCol<<" "<<localCR.rocRow<<endl;
235  if UNLIKELY(!localCR.valid()) {
236  LogDebug("PixelDataFormatter::interpretRawData")
237  << "status #3";
238  errorsInEvent = true;
239  errorcheck->conversionError(fedId, &converter, 3, ww, errors);
240  continue;
241  }
242  local = std::make_unique<LocalPixel>(localCR); // local pixel coordinate
243  //if(DANEK) cout<<local->dcol()<<" "<<local->pxid()<<" "<<local->rocCol()<<" "<<local->rocRow()<<endl;
244 
245  } else { // phase0 and phase1 except bpix layer 1
246  int dcol = (ww >> DCOL_shift) & DCOL_mask;
247  int pxid = (ww >> PXID_shift) & PXID_mask;
248  //if(DANEK) cout<<" raw2digi "<<link<<" "<<roc<<" "
249  //<<dcol<<" "<<pxid<<" "<<adc<<" "<<layer<<endl;
250 
251  LocalPixel::DcolPxid localDP = { dcol, pxid };
252  //if(DANEK) cout<<localDP.dcol<<" "<<localDP.pxid<<endl;
253 
254  if UNLIKELY(!localDP.valid()) {
255  LogDebug("PixelDataFormatter::interpretRawData")
256  << "status #3";
257  errorsInEvent = true;
258  errorcheck->conversionError(fedId, &converter, 3, ww, errors);
259  continue;
260  }
261  local = std::make_unique<LocalPixel>(localDP); // local pixel coordinate
262  //if(DANEK) cout<<local->dcol()<<" "<<local->pxid()<<" "<<local->rocCol()<<" "<<local->rocRow()<<endl;
263  }
264 
265  GlobalPixel global = rocp->toGlobal( *local ); // global pixel coordinate (in module)
266  (*detDigis).data.emplace_back(global.row, global.col, adc);
267  //if(DANEK) cout<<global.row<<" "<<global.col<<" "<<adc<<endl;
268  LogTrace("") << (*detDigis).data.back();
269  }
270 
271 }
#define LogDebug(id)
#define LIKELY(x)
Definition: Likely.h:20
bool IsRocBad(const uint32_t &detid, const short &rocNb) const
identify pixel inside single ROC
Definition: LocalPixel.h:7
global coordinates (row and column in DetUnit, as in PixelDigi)
Definition: GlobalPixel.h:6
unsigned int idInDetUnit() const
id of this ROC in DetUnit etermined by token path
Definition: PixelROC.h:40
uint32_t rawId() const
return the DetUnit to which this ROC belongs to.
Definition: PixelROC.h:37
std::string print(const PixelDigi &digi) const
uint64_t Word64
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
const std::set< unsigned int > * modulesToUnpack
const SiPixelQuality * badPixelInfo
#define LogTrace(id)
double collumn and pixel ID in double collumn representation
Definition: LocalPixel.h:22
virtual bool isBarrel() const
true for barrel modules
row and collumn in ROC representation
Definition: LocalPixel.h:15
collection_type data
Definition: DetSet.h:80
std::unique_ptr< ErrorCheckerBase > errorcheck
col
Definition: cuy.py:1010
Definition: errors.py:1
#define UNLIKELY(x)
Definition: Likely.h:21
SiPixelFedCabling const * theCablingTree
GlobalPixel toGlobal(const LocalPixel &loc) const
Definition: PixelROC.h:59
cms_uint32_t PixelDataFormatter::linkId ( cms_uint32_t  word32)
inline

Definition at line 89 of file PixelDataFormatter.h.

References LINK_mask, and LINK_shift.

Referenced by formatRawData().

89 { return (word32 >> LINK_shift) & LINK_mask; }
int PixelDataFormatter::nDigis ( ) const
inline

Definition at line 82 of file PixelDataFormatter.h.

References theDigiCounter.

82 { return theDigiCounter; }
int PixelDataFormatter::nWords ( ) const
inline
void PixelDataFormatter::passFrameReverter ( const SiPixelFrameReverter reverter)

Definition at line 127 of file PixelDataFormatter.cc.

References theFrameReverter.

Referenced by SiPixelDigiToRaw::produce().

128 {
129  theFrameReverter = reverter;
130 }
const SiPixelFrameReverter * theFrameReverter
std::string PixelDataFormatter::print ( const PixelDigi digi) const
private

Definition at line 499 of file PixelDataFormatter.cc.

References PixelDigi::adc(), PixelDigi::column(), PixelDigi::row(), and str.

Referenced by digi2word(), digi2wordPhase1Layer1(), formatRawData(), and interpretRawData().

500 {
501  ostringstream str;
502  str << " DIGI: row: " << digi.row() <<", col: " << digi.column() <<", adc: " << digi.adc();
503  return str.str();
504 }
int row() const
Definition: PixelDigi.h:56
unsigned short adc() const
Definition: PixelDigi.h:59
int column() const
Definition: PixelDigi.h:57
#define str(s)
std::string PixelDataFormatter::print ( const Word64 word) const
private

Definition at line 506 of file PixelDataFormatter.cc.

References str.

507 {
508  ostringstream str;
509  str <<"word64: " << reinterpret_cast<const bitset<64>&> (word);
510  return str.str();
511 }
#define str(s)
void PixelDataFormatter::setErrorStatus ( bool  ErrorStatus)

Definition at line 110 of file PixelDataFormatter.cc.

References errorcheck, and includeErrors.

Referenced by SiPixelRawToDigi::produce().

111 {
112  includeErrors = ErrorStatus;
113  errorcheck->setErrorStatus(includeErrors);
114 }
std::unique_ptr< ErrorCheckerBase > errorcheck
void PixelDataFormatter::setModulesToUnpack ( const std::set< unsigned int > *  moduleIds)

Definition at line 122 of file PixelDataFormatter.cc.

References modulesToUnpack.

123 {
124  modulesToUnpack = moduleIds;
125 }
const std::set< unsigned int > * modulesToUnpack
void PixelDataFormatter::setQualityStatus ( bool  QualityStatus,
const SiPixelQuality QualityInfo 
)

Definition at line 116 of file PixelDataFormatter.cc.

References badPixelInfo, and useQualityInfo.

117 {
118  useQualityInfo = QualityStatus;
119  badPixelInfo = QualityInfo;
120 }
const SiPixelQuality * badPixelInfo
int PixelDataFormatter::word2digi ( const int  fedId,
const SiPixelFrameConverter converter,
const bool  includeError,
const bool  useQuality,
const Word32 word,
Digis digis 
) const
private

Definition at line 449 of file PixelDataFormatter.cc.

References ecalMGPA::adc(), ADC_mask, ADC_shift, badPixelInfo, sipixelobjects::DetectorIndex::col, sipixelobjects::ElectronicIndex::dcol, DCOL_mask, DCOL_shift, debug, l1t::stage2::layer2::fedId, SiPixelFedCabling::findItem(), sipixelobjects::PixelROC::idInDetUnit(), SiPixelQuality::IsRocBad(), sipixelobjects::ElectronicIndex::link, LINK_mask, LINK_shift, DTRecHitClients_cfi::local, LogTrace, modulesToUnpack, callgraph::path, digitizers_cfi::pixel, sipixelobjects::ElectronicIndex::pxid, PXID_mask, PXID_shift, sipixelobjects::DetectorIndex::rawId, sipixelobjects::ElectronicIndex::roc, ROC_mask, ROC_shift, sipixelobjects::LocalPixel::rocCol(), sipixelobjects::LocalPixel::rocRow(), sipixelobjects::DetectorIndex::row, mps_update::status, theCablingTree, theDigiCounter, and SiPixelFrameConverter::toDetector().

451 {
452  // do not interpret false digis
453  if (word == 0 ) return 0;
454 
455  ElectronicIndex cabling;
456  cabling.dcol = (word >> DCOL_shift) & DCOL_mask;
457  cabling.pxid = (word >> PXID_shift) & PXID_mask;
458  cabling.link = (word >> LINK_shift) & LINK_mask;
459  cabling.roc = (word >> ROC_shift) & ROC_mask;
460  int adc = (word >> ADC_shift) & ADC_mask;
461 
462  if (debug) {
463  LocalPixel::DcolPxid pixel = {cabling.dcol,cabling.pxid};
464  LocalPixel local(pixel);
465  LogTrace("")<<" link: "<<cabling.link<<", roc: "<<cabling.roc
466  <<" rocRow: "<<local.rocRow()<<", rocCol:"<<local.rocCol()
467  <<" (dcol: "<<cabling.dcol<<", pxid:"<<cabling.pxid<<"), adc:"<<adc;
468  }
469 
470  if (!converter) return 0;
471 
472  DetectorIndex detIdx;
473  int status = converter->toDetector(cabling, detIdx);
474  if (status) return status;
475 
476  // exclude ROC(raw) based on bad ROC list bad in SiPixelQuality
477  // enable: process.siPixelDigis.UseQualityInfo = True
478  // 20-10-2010 A.Y.
479  if (useQuality&&badPixelInfo) {
480  CablingPathToDetUnit path = {static_cast<unsigned int>(fedId),
481  static_cast<unsigned int>(cabling.link),
482  static_cast<unsigned int>(cabling.roc)};
483  const PixelROC * roc = theCablingTree->findItem(path);
484  short rocInDet = (short) roc->idInDetUnit();
485  bool badROC = badPixelInfo->IsRocBad(detIdx.rawId, rocInDet);
486  if (badROC) return 0;
487  }
488 
489  if (modulesToUnpack && modulesToUnpack->find(detIdx.rawId) == modulesToUnpack->end()) return 0;
490 
491  digis[detIdx.rawId].emplace_back(detIdx.row, detIdx.col, adc);
492 
493  theDigiCounter++;
494 
495  if (debug) LogTrace("") << digis[detIdx.rawId].back();
496  return 0;
497 }
bool IsRocBad(const uint32_t &detid, const short &rocNb) const
identify pixel inside single ROC
Definition: LocalPixel.h:7
unsigned int idInDetUnit() const
id of this ROC in DetUnit etermined by token path
Definition: PixelROC.h:40
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
const std::set< unsigned int > * modulesToUnpack
const SiPixelQuality * badPixelInfo
#define LogTrace(id)
double collumn and pixel ID in double collumn representation
Definition: LocalPixel.h:22
virtual const sipixelobjects::PixelROC * findItem(const sipixelobjects::CablingPathToDetUnit &) const =0
int toDetector(const sipixelobjects::ElectronicIndex &cabling, sipixelobjects::DetectorIndex &detector) const
SiPixelFedCabling const * theCablingTree

Member Data Documentation

Word32 PixelDataFormatter::ADC_mask
private

Definition at line 111 of file PixelDataFormatter.h.

Referenced by interpretRawData(), PixelDataFormatter(), and word2digi().

int PixelDataFormatter::ADC_shift
private
int PixelDataFormatter::allDetDigis
private

Definition at line 103 of file PixelDataFormatter.h.

Referenced by formatRawData(), and PixelDataFormatter().

const SiPixelQuality* PixelDataFormatter::badPixelInfo
private

Definition at line 97 of file PixelDataFormatter.h.

Referenced by interpretRawData(), setQualityStatus(), and word2digi().

Word32 PixelDataFormatter::COL_mask
private

Definition at line 111 of file PixelDataFormatter.h.

Referenced by interpretRawData(), and PixelDataFormatter().

int PixelDataFormatter::COL_shift
private
Word32 PixelDataFormatter::DCOL_mask
private

Definition at line 111 of file PixelDataFormatter.h.

Referenced by interpretRawData(), PixelDataFormatter(), and word2digi().

int PixelDataFormatter::DCOL_shift
private

Definition at line 109 of file PixelDataFormatter.h.

Referenced by digi2word(), interpretRawData(), PixelDataFormatter(), and word2digi().

bool PixelDataFormatter::debug
private
std::unique_ptr<ErrorCheckerBase> PixelDataFormatter::errorcheck
private

Definition at line 105 of file PixelDataFormatter.h.

Referenced by interpretRawData(), PixelDataFormatter(), and setErrorStatus().

int PixelDataFormatter::hasDetDigis
private

Definition at line 104 of file PixelDataFormatter.h.

Referenced by formatRawData(), and PixelDataFormatter().

bool PixelDataFormatter::includeErrors
private

Definition at line 100 of file PixelDataFormatter.h.

Referenced by PixelDataFormatter(), and setErrorStatus().

Word32 PixelDataFormatter::LINK_mask
private

Definition at line 111 of file PixelDataFormatter.h.

Referenced by interpretRawData(), linkId(), PixelDataFormatter(), and word2digi().

int PixelDataFormatter::LINK_shift
private
int PixelDataFormatter::maxROCIndex
private

Definition at line 113 of file PixelDataFormatter.h.

Referenced by interpretRawData(), and PixelDataFormatter().

const std::set<unsigned int>* PixelDataFormatter::modulesToUnpack
private

Definition at line 98 of file PixelDataFormatter.h.

Referenced by interpretRawData(), setModulesToUnpack(), and word2digi().

bool PixelDataFormatter::phase1
private

Definition at line 114 of file PixelDataFormatter.h.

Referenced by formatRawData(), interpretRawData(), and PixelDataFormatter().

Word32 PixelDataFormatter::PXID_mask
private

Definition at line 111 of file PixelDataFormatter.h.

Referenced by interpretRawData(), PixelDataFormatter(), and word2digi().

int PixelDataFormatter::PXID_shift
private

Definition at line 109 of file PixelDataFormatter.h.

Referenced by digi2word(), interpretRawData(), PixelDataFormatter(), and word2digi().

Word32 PixelDataFormatter::ROC_mask
private

Definition at line 111 of file PixelDataFormatter.h.

Referenced by interpretRawData(), PixelDataFormatter(), and word2digi().

int PixelDataFormatter::ROC_shift
private
Word32 PixelDataFormatter::ROW_mask
private

Definition at line 111 of file PixelDataFormatter.h.

Referenced by interpretRawData(), and PixelDataFormatter().

int PixelDataFormatter::ROW_shift
private
SiPixelFedCabling const* PixelDataFormatter::theCablingTree
private

Definition at line 95 of file PixelDataFormatter.h.

Referenced by interpretRawData(), and word2digi().

int PixelDataFormatter::theDigiCounter
mutableprivate

Definition at line 92 of file PixelDataFormatter.h.

Referenced by formatRawData(), nDigis(), and word2digi().

const SiPixelFrameReverter* PixelDataFormatter::theFrameReverter
private

Definition at line 96 of file PixelDataFormatter.h.

Referenced by digi2word(), digi2wordPhase1Layer1(), and passFrameReverter().

int PixelDataFormatter::theWordCounter
mutableprivate
bool PixelDataFormatter::useQualityInfo
private

Definition at line 101 of file PixelDataFormatter.h.

Referenced by interpretRawData(), PixelDataFormatter(), and setQualityStatus().