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

◆ BadChannels

Definition at line 68 of file PixelDataFormatter.h.

◆ Collection

Definition at line 59 of file PixelDataFormatter.h.

◆ DetBadChannels

Definition at line 67 of file PixelDataFormatter.h.

◆ DetDigis

Definition at line 62 of file PixelDataFormatter.h.

◆ DetErrors

Definition at line 65 of file PixelDataFormatter.h.

◆ Digis

Definition at line 63 of file PixelDataFormatter.h.

◆ Errors

Definition at line 66 of file PixelDataFormatter.h.

◆ Range

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

Definition at line 64 of file PixelDataFormatter.h.

◆ RawData

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

Definition at line 61 of file PixelDataFormatter.h.

◆ Word32

Definition at line 70 of file PixelDataFormatter.h.

◆ Word64

Definition at line 71 of file PixelDataFormatter.h.

Constructor & Destructor Documentation

◆ PixelDataFormatter()

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

Definition at line 57 of file PixelDataFormatter.cc.

58  : theDigiCounter(0),
59  theWordCounter(0),
61  badPixelInfo(nullptr),
62  modulesToUnpack(nullptr),
63  phase1(phase) {
64  int s32 = sizeof(Word32);
65  int s64 = sizeof(Word64);
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";
71  }
72  includeErrors = false;
73  useQualityInfo = false;
74  allDetDigis = 0;
75  hasDetDigis = 0;
76 
77  ADC_shift = 0;
78  PXID_shift = ADC_shift + ADC_bits;
79  DCOL_shift = PXID_shift + PXID_bits;
80  ROC_shift = DCOL_shift + DCOL_bits;
81 
82  if (phase1) { // for phase 1
83  LINK_shift = ROC_shift + ROC_bits1;
84  LINK_mask = ~(~PixelDataFormatter::Word32(0) << LINK_bits1);
85  ROC_mask = ~(~PixelDataFormatter::Word32(0) << ROC_bits1);
86  // special for layer 1 ROC
87  ROW_shift = ADC_shift + ADC_bits;
88  COL_shift = ROW_shift + ROW_bits1_l1;
89  COL_mask = ~(~PixelDataFormatter::Word32(0) << COL_bits1_l1);
90  ROW_mask = ~(~PixelDataFormatter::Word32(0) << ROW_bits1_l1);
91  maxROCIndex = 8;
92 
93  } else { // for phase 0
94  LINK_shift = ROC_shift + ROC_bits;
95  LINK_mask = ~(~PixelDataFormatter::Word32(0) << LINK_bits);
96  ROC_mask = ~(~PixelDataFormatter::Word32(0) << ROC_bits);
97  maxROCIndex = 25;
98  }
99 
100  DCOL_mask = ~(~PixelDataFormatter::Word32(0) << DCOL_bits);
101  PXID_mask = ~(~PixelDataFormatter::Word32(0) << PXID_bits);
102  ADC_mask = ~(~PixelDataFormatter::Word32(0) << ADC_bits);
103 
104  if (phase1) {
105  errorcheck = std::unique_ptr<ErrorCheckerBase>(new ErrorChecker());
106  } else {
107  errorcheck = std::unique_ptr<ErrorCheckerBase>(new ErrorCheckerPhase0());
108  }
109 }

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.

Member Function Documentation

◆ checkError()

int PixelDataFormatter::checkError ( const Word32 data) const
private

◆ digi2word()

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

Definition at line 405 of file PixelDataFormatter.cc.

407  {
408  LogDebug("PixelDataFormatter")
409  // <<" detId: " << detId
410  << print(digi);
411 
412  DetectorIndex detector = {detId, digi.row(), digi.column()};
413  ElectronicIndex cabling;
414  int fedId = theFrameReverter->toCabling(cabling, detector);
415  if (fedId < 0)
416  return fedId;
417 
418  //if(DANEK) cout<<" digi2raw "<<detId<<" "<<digi.column()<<" "<<digi.row()<<" "<<digi.adc()<<" "
419  // <<cabling.link<<" "<<cabling.roc<<" "<<cabling.dcol<<" "<<cabling.pxid<<endl;
420 
421  Word32 word = (cabling.link << LINK_shift) | (cabling.roc << ROC_shift) | (cabling.dcol << DCOL_shift) |
422  (cabling.pxid << PXID_shift) | (digi.adc() << ADC_shift);
423  words[fedId].push_back(word);
424  theWordCounter++;
425 
426  return fedId;
427 }

References PixelDigi::adc(), ADC_shift, PixelDigi::column(), sipixelobjects::ElectronicIndex::dcol, DCOL_shift, hgcalTestNeighbor_cfi::detector, l1tstage2_dqm_sourceclient-live_cfg::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().

◆ digi2wordPhase1Layer1()

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

Definition at line 428 of file PixelDataFormatter.cc.

430  {
431  LogDebug("PixelDataFormatter")
432  // <<" detId: " << detId
433  << print(digi);
434 
435  DetectorIndex detector = {detId, digi.row(), digi.column()};
436  ElectronicIndex cabling;
437  int fedId = theFrameReverter->toCabling(cabling, detector);
438  if (fedId < 0)
439  return fedId;
440 
441  int col = ((cabling.dcol) * 2) + ((cabling.pxid) % 2);
442  int row = LocalPixel::numRowsInRoc - ((cabling.pxid) / 2);
443 
444  //if(DANEK) cout<<" layer 1: digi2raw "<<detId<<" "<<digi.column()<<" "<<digi.row()<<" "<<digi.adc()<<" "
445  // <<cabling.link<<" "<<cabling.roc<<" "<<cabling.dcol<<" "<<cabling.pxid<<" "
446  // <<col<<" "<<row<<endl;
447 
448  Word32 word = (cabling.link << LINK_shift) | (cabling.roc << ROC_shift) | (col << COL_shift) | (row << ROW_shift) |
449  (digi.adc() << ADC_shift);
450  words[fedId].push_back(word);
451  theWordCounter++;
452 
453  return fedId;
454 }

References PixelDigi::adc(), ADC_shift, cuy::col, COL_shift, PixelDigi::column(), sipixelobjects::ElectronicIndex::dcol, hgcalTestNeighbor_cfi::detector, l1tstage2_dqm_sourceclient-live_cfg::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().

◆ errorDetId()

cms_uint32_t PixelDataFormatter::errorDetId ( const SiPixelFrameConverter converter,
int  fedId,
int  errorType,
const Word32 word 
) const
private

◆ formatRawData()

void PixelDataFormatter::formatRawData ( unsigned int  lvl1_ID,
RawData fedRawData,
const Digis digis,
const BadChannels badChannels 
)

Definition at line 301 of file PixelDataFormatter.cc.

304  {
305  std::map<int, vector<Word32> > words;
306 
307  // translate digis into 32-bit raw words and store in map indexed by Fed
308  for (Digis::const_iterator im = digis.begin(); im != digis.end(); im++) {
309  allDetDigis++;
310  cms_uint32_t rawId = im->first;
311  int layer = 0;
312  bool barrel = PixelModuleName::isBarrel(rawId);
313  if (barrel)
314  layer = PixelROC::bpixLayerPhase1(rawId);
315  //if(DANEK) cout<<" layer "<<layer<<" "<<phase1<<endl;
316 
317  BadChannels::const_iterator detBadChannels = badChannels.find(rawId);
318 
319  hasDetDigis++;
320  const DetDigis& detDigis = im->second;
321  for (DetDigis::const_iterator it = detDigis.begin(); it != detDigis.end(); it++) {
322  theDigiCounter++;
323  const PixelDigi& digi = (*it);
324  int fedId = 0;
325 
326  if (layer == 1 && phase1)
327  fedId = digi2wordPhase1Layer1(rawId, digi, words);
328  else
329  fedId = digi2word(rawId, digi, words);
330 
331  if (fedId < 0) {
332  LogError("FormatDataException") << " digi2word returns error #" << fedId << " Ndigis: " << theDigiCounter
333  << endl
334  << " detector: " << rawId << endl
335  << print(digi) << endl;
336  } else if (detBadChannels != badChannels.end()) {
337  auto badChannel =
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()));
340  });
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;
345  }
346  } // if (fedId)
347  } // for (DetDigis
348  } // for (Digis
349  LogTrace(" allDetDigis/hasDetDigis : ") << allDetDigis << "/" << hasDetDigis;
350 
351  // fill FED error 25 words
352  for (const auto& detBadChannels : badChannels) {
353  for (const auto& badChannel : detBadChannels.second) {
354  unsigned int FEDError25 = 25;
355  Word32 word = (badChannel.link << LINK_shift) | (FEDError25 << ROC_shift);
356  words[badChannel.fed].push_back(word);
357  theWordCounter++;
358  }
359  }
360 
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;
364  // since raw words are written in the form of 64-bit packets
365  // add extra 32-bit word to make number of words even if necessary
366  if (words.find(fedId)->second.size() % 2 != 0)
367  words[fedId].push_back(Word32(0));
368 
369  // size in Bytes; create output structure
370  int dataSize = words.find(fedId)->second.size() * sizeof(Word32);
371  int nHeaders = 1;
372  int nTrailers = 1;
373  dataSize += (nHeaders + nTrailers) * sizeof(Word64);
374  FEDRawData* rawData = new FEDRawData(dataSize);
375 
376  // get begining of data;
377  Word64* word = reinterpret_cast<Word64*>(rawData->data());
378 
379  // write one header
380  FEDHeader::set(reinterpret_cast<unsigned char*>(word), 0, lvl1_ID, 0, fedId);
381  word++;
382 
383  // write data
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];
387  LogDebug("PixelDataFormatter") << print(*word);
388  word++;
389  }
390 
391  // write one trailer
392  FEDTrailer::set(reinterpret_cast<unsigned char*>(word), dataSize / sizeof(Word64), 0, 0, 0);
393  word++;
394 
395  // check memory
396  if (word != reinterpret_cast<Word64*>(rawData->data() + dataSize)) {
397  string s = "** PROBLEM in PixelDataFormatter !!!";
398  throw cms::Exception(s);
399  } // if (word !=
401  delete rawData;
402  } // for (RI feddata
403 }

References allDetDigis, Reference_intrackfit_cff::barrel, digi2word(), digi2wordPhase1Layer1(), Exception, l1tstage2_dqm_sourceclient-live_cfg::fedId, l1t_dqm_sourceclient-live_cfg::fedRawData, hasDetDigis, mps_fire::i, PixelModuleName::isBarrel(), LINK_shift, linkId(), LogDebug, LogTrace, phase1, print(), l1tstage2_dqm_sourceclient-live_cfg::rawData, ROC_shift, alignCSCRings::s, FEDHeader::set(), FEDTrailer::set(), theDigiCounter, and theWordCounter.

◆ interpretRawData()

void PixelDataFormatter::interpretRawData ( bool &  errorsInEvent,
int  fedId,
const FEDRawData data,
Collection digis,
Errors errors 
)

Definition at line 125 of file PixelDataFormatter.cc.

126  {
127  using namespace sipixelobjects;
128 
129  int nWords = rawData.size() / sizeof(Word64);
130  if (nWords == 0)
131  return;
132 
134 
135  // check CRC bit
136  const Word64* trailer = reinterpret_cast<const Word64*>(rawData.data()) + (nWords - 1);
137  if (!errorcheck->checkCRC(errorsInEvent, fedId, trailer, errors))
138  return;
139 
140  // check headers
141  const Word64* header = reinterpret_cast<const Word64*>(rawData.data());
142  header--;
143  bool moreHeaders = true;
144  while (moreHeaders) {
145  header++;
146  LogTrace("") << "HEADER: " << print(*header);
147  bool headerStatus = errorcheck->checkHeader(errorsInEvent, fedId, header, errors);
148  moreHeaders = headerStatus;
149  }
150 
151  // check trailers
152  bool moreTrailers = true;
153  trailer++;
154  while (moreTrailers) {
155  trailer--;
156  LogTrace("") << "TRAILER: " << print(*trailer);
157  bool trailerStatus = errorcheck->checkTrailer(errorsInEvent, fedId, nWords, trailer, errors);
158  moreTrailers = trailerStatus;
159  }
160 
161  // data words
162  theWordCounter += 2 * (nWords - 2);
163  LogTrace("") << "data words: " << (trailer - header - 1);
164 
165  int link = -1;
166  int roc = -1;
167  int layer = 0;
168  PixelROC const* rocp = nullptr;
169  bool skipROC = false;
170  edm::DetSet<PixelDigi>* detDigis = nullptr;
171 
172  const Word32* bw = (const Word32*)(header + 1);
173  const Word32* ew = (const Word32*)(trailer);
174  if (*(ew - 1) == 0) {
175  ew--;
176  theWordCounter--;
177  }
178  for (auto word = bw; word < ew; ++word) {
179  LogTrace("") << "DATA: " << print(*word);
180 
181  auto ww = *word;
182  if
183  UNLIKELY(ww == 0) {
184  theWordCounter--;
185  continue;
186  }
187  int nlink = (ww >> LINK_shift) & LINK_mask;
188  int nroc = (ww >> ROC_shift) & ROC_mask;
189 
190  //if(DANEK) cout<<" fed, link, roc "<<fedId<<" "<<nlink<<" "<<nroc<<endl;
191 
192  if ((nlink != link) | (nroc != roc)) { // new roc
193  link = nlink;
194  roc = nroc;
195  skipROC = LIKELY(roc < maxROCIndex)
196  ? false
197  : !errorcheck->checkROC(errorsInEvent, fedId, &converter, theCablingTree, ww, errors);
198  if (skipROC)
199  continue;
200  rocp = converter.toRoc(link, roc);
201  if
202  UNLIKELY(!rocp) {
203  errorsInEvent = true;
204  errorcheck->conversionError(fedId, &converter, 2, ww, errors);
205  skipROC = true;
206  continue;
207  }
208  auto rawId = rocp->rawId();
209  bool barrel = PixelModuleName::isBarrel(rawId);
210  if (barrel)
211  layer = PixelROC::bpixLayerPhase1(rawId);
212  else
213  layer = 0;
214 
215  //if(DANEK) cout<<" rocp "<<rocp->print()<<" layer "<<rocp->bpixLayerPhase1(rawId)<<" "
216  // <<layer<<" phase1 "<<phase1<<" rawid "<<rawId<<endl;
217 
218  if (useQualityInfo & (nullptr != badPixelInfo)) {
219  short rocInDet = (short)rocp->idInDetUnit();
220  skipROC = badPixelInfo->IsRocBad(rawId, rocInDet);
221  if (skipROC)
222  continue;
223  }
224  skipROC = modulesToUnpack && (modulesToUnpack->find(rawId) == modulesToUnpack->end());
225  if (skipROC)
226  continue;
227 
228  detDigis = &digis.find_or_insert(rawId);
229  if ((*detDigis).empty())
230  (*detDigis).data.reserve(32); // avoid the first relocations
231  }
232 
233  // skip is roc to be skipped ot invalid
234  if
235  UNLIKELY(skipROC || !rocp) continue;
236 
237  int adc = (ww >> ADC_shift) & ADC_mask;
238  std::unique_ptr<LocalPixel> local;
239 
240  if (phase1 && layer == 1) { // special case for layer 1ROC
241  // for l1 roc use the roc column and row index instead of dcol and pixel index.
242  int col = (ww >> COL_shift) & COL_mask;
243  int row = (ww >> ROW_shift) & ROW_mask;
244  //if(DANEK) cout<<" layer 1: raw2digi "<<link<<" "<<roc<<" "
245  // <<col<<" "<<row<<" "<<adc<<endl;
246 
247  LocalPixel::RocRowCol localCR = {row, col}; // build pixel
248  //if(DANEK)cout<<localCR.rocCol<<" "<<localCR.rocRow<<endl;
249  if
250  UNLIKELY(!localCR.valid()) {
251  LogDebug("PixelDataFormatter::interpretRawData") << "status #3";
252  errorsInEvent = true;
253  errorcheck->conversionError(fedId, &converter, 3, ww, errors);
254  continue;
255  }
256  local = std::make_unique<LocalPixel>(localCR); // local pixel coordinate
257  //if(DANEK) cout<<local->dcol()<<" "<<local->pxid()<<" "<<local->rocCol()<<" "<<local->rocRow()<<endl;
258 
259  } else { // phase0 and phase1 except bpix layer 1
260  int dcol = (ww >> DCOL_shift) & DCOL_mask;
261  int pxid = (ww >> PXID_shift) & PXID_mask;
262  //if(DANEK) cout<<" raw2digi "<<link<<" "<<roc<<" "
263  //<<dcol<<" "<<pxid<<" "<<adc<<" "<<layer<<endl;
264 
265  LocalPixel::DcolPxid localDP = {dcol, pxid};
266  //if(DANEK) cout<<localDP.dcol<<" "<<localDP.pxid<<endl;
267 
268  if
269  UNLIKELY(!localDP.valid()) {
270  LogDebug("PixelDataFormatter::interpretRawData") << "status #3";
271  errorsInEvent = true;
272  errorcheck->conversionError(fedId, &converter, 3, ww, errors);
273  continue;
274  }
275  local = std::make_unique<LocalPixel>(localDP); // local pixel coordinate
276  //if(DANEK) cout<<local->dcol()<<" "<<local->pxid()<<" "<<local->rocCol()<<" "<<local->rocRow()<<endl;
277  }
278 
279  GlobalPixel global = rocp->toGlobal(*local); // global pixel coordinate (in module)
280  (*detDigis).data.emplace_back(global.row, global.col, adc);
281  //if(DANEK) cout<<global.row<<" "<<global.col<<" "<<adc<<endl;
282  LogTrace("") << (*detDigis).data.back();
283  }
284 }

References ecalMGPA::adc(), ADC_mask, ADC_shift, badPixelInfo, Reference_intrackfit_cff::barrel, sipixelobjects::GlobalPixel::col, cuy::col, COL_mask, COL_shift, edm::DetSet< T >::data, DCOL_mask, DCOL_shift, errorcheck, funct::false, l1tstage2_dqm_sourceclient-live_cfg::fedId, edm::DetSetVector< T >::find_or_insert(), RecoTauValidation_cfi::header, sipixelobjects::PixelROC::idInDetUnit(), PixelModuleName::isBarrel(), SiPixelQuality::IsRocBad(), LIKELY, MainPageGenerator::link, LINK_mask, LINK_shift, DTRecHitClients_cfi::local, LogDebug, LogTrace, maxROCIndex, modulesToUnpack, nWords(), phase1, print(), PXID_mask, PXID_shift, l1tstage2_dqm_sourceclient-live_cfg::rawData, sipixelobjects::PixelROC::rawId(), PixelMapPlotter::roc, ROC_mask, ROC_shift, sipixelobjects::GlobalPixel::row, ROW_mask, ROW_shift, theCablingTree, theWordCounter, sipixelobjects::PixelROC::toGlobal(), UNLIKELY, useQualityInfo, sipixelobjects::LocalPixel::RocRowCol::valid(), and sipixelobjects::LocalPixel::DcolPxid::valid().

◆ linkId()

cms_uint32_t PixelDataFormatter::linkId ( cms_uint32_t  word32)
inline

Definition at line 87 of file PixelDataFormatter.h.

87 { return (word32 >> LINK_shift) & LINK_mask; }

References LINK_mask, and LINK_shift.

Referenced by formatRawData().

◆ nDigis()

int PixelDataFormatter::nDigis ( ) const
inline

Definition at line 80 of file PixelDataFormatter.h.

80 { return theDigiCounter; }

References theDigiCounter.

◆ nWords()

int PixelDataFormatter::nWords ( ) const
inline

Definition at line 81 of file PixelDataFormatter.h.

81 { return theWordCounter; }

References theWordCounter.

Referenced by interpretRawData().

◆ passFrameReverter()

void PixelDataFormatter::passFrameReverter ( const SiPixelFrameReverter reverter)

Definition at line 123 of file PixelDataFormatter.cc.

123 { theFrameReverter = reverter; }

References theFrameReverter.

Referenced by SiPixelDigiToRaw::produce().

◆ print() [1/2]

std::string PixelDataFormatter::print ( const PixelDigi digi) const
private

Definition at line 516 of file PixelDataFormatter.cc.

516  {
517  ostringstream str;
518  str << " DIGI: row: " << digi.row() << ", col: " << digi.column() << ", adc: " << digi.adc();
519  return str.str();
520 }

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

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

◆ print() [2/2]

std::string PixelDataFormatter::print ( const Word64 word) const
private

Definition at line 522 of file PixelDataFormatter.cc.

522  {
523  ostringstream str;
524  str << "word64: " << reinterpret_cast<const bitset<64>&>(word);
525  return str.str();
526 }

References str.

◆ setErrorStatus()

void PixelDataFormatter::setErrorStatus ( bool  ErrorStatus)

Definition at line 111 of file PixelDataFormatter.cc.

111  {
112  includeErrors = ErrorStatus;
113  errorcheck->setErrorStatus(includeErrors);
114 }

References errorcheck, and includeErrors.

Referenced by SiPixelRawToDigi::produce().

◆ setModulesToUnpack()

void PixelDataFormatter::setModulesToUnpack ( const std::set< unsigned int > *  moduleIds)

Definition at line 121 of file PixelDataFormatter.cc.

121 { modulesToUnpack = moduleIds; }

References modulesToUnpack.

◆ setQualityStatus()

void PixelDataFormatter::setQualityStatus ( bool  QualityStatus,
const SiPixelQuality QualityInfo 
)

Definition at line 116 of file PixelDataFormatter.cc.

116  {
117  useQualityInfo = QualityStatus;
118  badPixelInfo = QualityInfo;
119 }

References badPixelInfo, and useQualityInfo.

◆ word2digi()

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 457 of file PixelDataFormatter.cc.

462  {
463  // do not interpret false digis
464  if (word == 0)
465  return 0;
466 
467  ElectronicIndex cabling;
468  cabling.dcol = (word >> DCOL_shift) & DCOL_mask;
469  cabling.pxid = (word >> PXID_shift) & PXID_mask;
470  cabling.link = (word >> LINK_shift) & LINK_mask;
471  cabling.roc = (word >> ROC_shift) & ROC_mask;
472  int adc = (word >> ADC_shift) & ADC_mask;
473 
474  if (debug) {
475  LocalPixel::DcolPxid pixel = {cabling.dcol, cabling.pxid};
477  LogTrace("") << " link: " << cabling.link << ", roc: " << cabling.roc << " rocRow: " << local.rocRow()
478  << ", rocCol:" << local.rocCol() << " (dcol: " << cabling.dcol << ", pxid:" << cabling.pxid
479  << "), adc:" << adc;
480  }
481 
482  if (!converter)
483  return 0;
484 
485  DetectorIndex detIdx;
486  int status = converter->toDetector(cabling, detIdx);
487  if (status)
488  return status;
489 
490  // exclude ROC(raw) based on bad ROC list bad in SiPixelQuality
491  // enable: process.siPixelDigis.UseQualityInfo = True
492  // 20-10-2010 A.Y.
493  if (useQuality && badPixelInfo) {
494  CablingPathToDetUnit path = {static_cast<unsigned int>(fedId),
495  static_cast<unsigned int>(cabling.link),
496  static_cast<unsigned int>(cabling.roc)};
498  short rocInDet = (short)roc->idInDetUnit();
499  bool badROC = badPixelInfo->IsRocBad(detIdx.rawId, rocInDet);
500  if (badROC)
501  return 0;
502  }
503 
504  if (modulesToUnpack && modulesToUnpack->find(detIdx.rawId) == modulesToUnpack->end())
505  return 0;
506 
507  digis[detIdx.rawId].emplace_back(detIdx.row, detIdx.col, adc);
508 
509  theDigiCounter++;
510 
511  if (debug)
512  LogTrace("") << digis[detIdx.rawId].back();
513  return 0;
514 }

References ecalMGPA::adc(), ADC_mask, ADC_shift, badPixelInfo, sipixelobjects::DetectorIndex::col, sipixelobjects::ElectronicIndex::dcol, DCOL_mask, DCOL_shift, debug, l1tstage2_dqm_sourceclient-live_cfg::fedId, SiPixelFedCabling::findItem(), SiPixelQuality::IsRocBad(), sipixelobjects::ElectronicIndex::link, LINK_mask, LINK_shift, DTRecHitClients_cfi::local, LogTrace, modulesToUnpack, castor_dqm_sourceclient_file_cfg::path, muonClassificationByHits_cfi::pixel, sipixelobjects::ElectronicIndex::pxid, PXID_mask, PXID_shift, sipixelobjects::DetectorIndex::rawId, sipixelobjects::ElectronicIndex::roc, PixelMapPlotter::roc, ROC_mask, ROC_shift, sipixelobjects::DetectorIndex::row, mps_update::status, theCablingTree, theDigiCounter, and bysipixelclustmulteventfilter_cfi::useQuality.

Member Data Documentation

◆ ADC_mask

Word32 PixelDataFormatter::ADC_mask
private

Definition at line 108 of file PixelDataFormatter.h.

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

◆ ADC_shift

int PixelDataFormatter::ADC_shift
private

◆ allDetDigis

int PixelDataFormatter::allDetDigis
private

Definition at line 101 of file PixelDataFormatter.h.

Referenced by formatRawData(), and PixelDataFormatter().

◆ badPixelInfo

const SiPixelQuality* PixelDataFormatter::badPixelInfo
private

Definition at line 95 of file PixelDataFormatter.h.

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

◆ COL_mask

Word32 PixelDataFormatter::COL_mask
private

Definition at line 108 of file PixelDataFormatter.h.

Referenced by interpretRawData(), and PixelDataFormatter().

◆ COL_shift

int PixelDataFormatter::COL_shift
private

◆ DCOL_mask

Word32 PixelDataFormatter::DCOL_mask
private

Definition at line 108 of file PixelDataFormatter.h.

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

◆ DCOL_shift

int PixelDataFormatter::DCOL_shift
private

Definition at line 107 of file PixelDataFormatter.h.

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

◆ debug

bool PixelDataFormatter::debug
private

◆ errorcheck

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

Definition at line 103 of file PixelDataFormatter.h.

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

◆ hasDetDigis

int PixelDataFormatter::hasDetDigis
private

Definition at line 102 of file PixelDataFormatter.h.

Referenced by formatRawData(), and PixelDataFormatter().

◆ includeErrors

bool PixelDataFormatter::includeErrors
private

Definition at line 98 of file PixelDataFormatter.h.

Referenced by PixelDataFormatter(), and setErrorStatus().

◆ LINK_mask

Word32 PixelDataFormatter::LINK_mask
private

Definition at line 108 of file PixelDataFormatter.h.

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

◆ LINK_shift

int PixelDataFormatter::LINK_shift
private

◆ maxROCIndex

int PixelDataFormatter::maxROCIndex
private

Definition at line 109 of file PixelDataFormatter.h.

Referenced by interpretRawData(), and PixelDataFormatter().

◆ modulesToUnpack

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

Definition at line 96 of file PixelDataFormatter.h.

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

◆ phase1

bool PixelDataFormatter::phase1
private

Definition at line 110 of file PixelDataFormatter.h.

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

◆ PXID_mask

Word32 PixelDataFormatter::PXID_mask
private

Definition at line 108 of file PixelDataFormatter.h.

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

◆ PXID_shift

int PixelDataFormatter::PXID_shift
private

Definition at line 107 of file PixelDataFormatter.h.

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

◆ ROC_mask

Word32 PixelDataFormatter::ROC_mask
private

Definition at line 108 of file PixelDataFormatter.h.

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

◆ ROC_shift

int PixelDataFormatter::ROC_shift
private

◆ ROW_mask

Word32 PixelDataFormatter::ROW_mask
private

Definition at line 108 of file PixelDataFormatter.h.

Referenced by interpretRawData(), and PixelDataFormatter().

◆ ROW_shift

int PixelDataFormatter::ROW_shift
private

◆ theCablingTree

SiPixelFedCabling const* PixelDataFormatter::theCablingTree
private

Definition at line 93 of file PixelDataFormatter.h.

Referenced by interpretRawData(), and word2digi().

◆ theDigiCounter

int PixelDataFormatter::theDigiCounter
mutableprivate

Definition at line 90 of file PixelDataFormatter.h.

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

◆ theFrameReverter

const SiPixelFrameReverter* PixelDataFormatter::theFrameReverter
private

Definition at line 94 of file PixelDataFormatter.h.

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

◆ theWordCounter

int PixelDataFormatter::theWordCounter
mutableprivate

◆ useQualityInfo

bool PixelDataFormatter::useQualityInfo
private

Definition at line 99 of file PixelDataFormatter.h.

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

cms_uint32_t
unsigned int cms_uint32_t
Definition: typedefs.h:15
ecalMGPA::adc
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
Definition: EcalMGPASample.h:11
PixelDataFormatter::nWords
int nWords() const
Definition: PixelDataFormatter.h:81
ErrorCheckerPhase0
Definition: ErrorCheckerPhase0.h:11
mps_fire.i
i
Definition: mps_fire.py:355
Reference_intrackfit_cff.barrel
list barrel
Definition: Reference_intrackfit_cff.py:37
PixelDataFormatter::ADC_mask
Word32 ADC_mask
Definition: PixelDataFormatter.h:108
funct::false
false
Definition: Factorize.h:34
PixelFEDChannel
Definition: PixelFEDChannel.h:6
MainPageGenerator.link
link
Definition: MainPageGenerator.py:271
PixelDataFormatter::digi2word
int digi2word(cms_uint32_t detId, const PixelDigi &digi, std::map< int, std::vector< Word32 > > &words) const
Definition: PixelDataFormatter.cc:405
edm::DetSet
Definition: DetSet.h:23
mps_update.status
status
Definition: mps_update.py:69
converter
Definition: CandidateProducer.h:25
SiPixelFedCabling::findItem
virtual const sipixelobjects::PixelROC * findItem(const sipixelobjects::CablingPathToDetUnit &) const =0
PixelDataFormatter::DCOL_shift
int DCOL_shift
Definition: PixelDataFormatter.h:107
phase1PixelTopology::numRowsInRoc
constexpr uint16_t numRowsInRoc
Definition: phase1PixelTopology.h:8
PixelDataFormatter::theDigiCounter
int theDigiCounter
Definition: PixelDataFormatter.h:90
cuy.col
col
Definition: cuy.py:1010
l1tstage2_dqm_sourceclient-live_cfg.rawData
rawData
Definition: l1tstage2_dqm_sourceclient-live_cfg.py:162
PixelDigi
Definition: PixelDigi.h:14
sipixelobjects::LocalPixel::DcolPxid::valid
bool valid() const
Definition: LocalPixel.h:21
muonClassificationByHits_cfi.pixel
pixel
Definition: muonClassificationByHits_cfi.py:9
PixelDataFormatter::theFrameReverter
const SiPixelFrameReverter * theFrameReverter
Definition: PixelDataFormatter.h:94
sipixelobjects::GlobalPixel::row
int row
Definition: GlobalPixel.h:7
PixelDataFormatter::DetDigis
std::vector< PixelDigi > DetDigis
Definition: PixelDataFormatter.h:62
sipixelobjects::DetectorIndex::row
int row
Definition: DetectorIndex.h:8
sipixelobjects::ElectronicIndex::dcol
int dcol
Definition: ElectronicIndex.h:8
HLT_2018_cff.phase
phase
Definition: HLT_2018_cff.py:5346
PixelDataFormatter::hasDetDigis
int hasDetDigis
Definition: PixelDataFormatter.h:102
sipixelobjects::GlobalPixel::col
int col
Definition: GlobalPixel.h:8
PixelDataFormatter::ADC_shift
int ADC_shift
Definition: PixelDataFormatter.h:107
PixelDataFormatter::phase1
bool phase1
Definition: PixelDataFormatter.h:110
sipixelobjects::LocalPixel
identify pixel inside single ROC
Definition: LocalPixel.h:7
FEDRawData
Definition: FEDRawData.h:19
PixelDataFormatter
Definition: PixelDataFormatter.h:57
word
uint64_t word
Definition: CTPPSTotemDataFormatter.cc:29
PixelDataFormatter::errorcheck
std::unique_ptr< ErrorCheckerBase > errorcheck
Definition: PixelDataFormatter.h:103
UNLIKELY
#define UNLIKELY(x)
Definition: Likely.h:21
alignCSCRings.s
s
Definition: alignCSCRings.py:92
bysipixelclustmulteventfilter_cfi.useQuality
useQuality
Definition: bysipixelclustmulteventfilter_cfi.py:7
PixelDataFormatter::DCOL_mask
Word32 DCOL_mask
Definition: PixelDataFormatter.h:108
l1t_dqm_sourceclient-live_cfg.fedRawData
fedRawData
Definition: l1t_dqm_sourceclient-live_cfg.py:188
sipixelobjects::GlobalPixel
global coordinates (row and column in DetUnit, as in PixelDigi)
Definition: GlobalPixel.h:6
errors
Definition: errors.py:1
PixelDataFormatter::ROW_shift
int ROW_shift
Definition: PixelDataFormatter.h:107
sipixelobjects
Definition: CablingPathToDetUnit.h:4
sipixelobjects::CablingPathToDetUnit
Definition: CablingPathToDetUnit.h:5
PixelDataFormatter::useQualityInfo
bool useQualityInfo
Definition: PixelDataFormatter.h:99
str
#define str(s)
Definition: TestProcessor.cc:48
PixelDataFormatter::ROC_mask
Word32 ROC_mask
Definition: PixelDataFormatter.h:108
sipixelobjects::ElectronicIndex::pxid
int pxid
Definition: ElectronicIndex.h:9
PixelDataFormatter::badPixelInfo
const SiPixelQuality * badPixelInfo
Definition: PixelDataFormatter.h:95
PixelDataFormatter::LINK_mask
Word32 LINK_mask
Definition: PixelDataFormatter.h:108
sipixelobjects::PixelROC::rawId
uint32_t rawId() const
return the DetUnit to which this ROC belongs to.
Definition: PixelROC.h:34
sipixelobjects::ElectronicIndex
Definition: ElectronicIndex.h:5
sipixelobjects::ElectronicIndex::link
int link
Definition: ElectronicIndex.h:6
PixelDigi::column
int column() const
Definition: PixelDigi.h:55
SiPixelFrameReverter::toCabling
int toCabling(sipixelobjects::ElectronicIndex &cabling, const sipixelobjects::DetectorIndex &detector) const
Definition: SiPixelFrameReverter.cc:34
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::LogError
Definition: MessageLogger.h:183
sipixelobjects::LocalPixel::DcolPxid
double collumn and pixel ID in double collumn representation
Definition: LocalPixel.h:19
PixelDataFormatter::ROW_mask
Word32 ROW_mask
Definition: PixelDataFormatter.h:108
Word64
uint64_t Word64
Definition: RPCUnpackingModule.cc:38
PixelDataFormatter::maxROCIndex
int maxROCIndex
Definition: PixelDataFormatter.h:109
PixelDataFormatter::theWordCounter
int theWordCounter
Definition: PixelDataFormatter.h:91
PixelDataFormatter::print
std::string print(const PixelDigi &digi) const
Definition: PixelDataFormatter.cc:516
sipixelobjects::DetectorIndex::col
int col
Definition: DetectorIndex.h:9
PixelDataFormatter::PXID_mask
Word32 PXID_mask
Definition: PixelDataFormatter.h:108
SiPixelFrameConverter
Definition: SiPixelFrameConverter.h:15
sipixelobjects::PixelROC::toGlobal
GlobalPixel toGlobal(const LocalPixel &loc) const
Definition: PixelROC.h:55
l1tstage2_dqm_sourceclient-live_cfg.fedId
fedId
Definition: l1tstage2_dqm_sourceclient-live_cfg.py:88
FEDTrailer::set
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:31
PixelDataFormatter::linkId
cms_uint32_t linkId(cms_uint32_t word32)
Definition: PixelDataFormatter.h:87
PixelDataFormatter::LINK_shift
int LINK_shift
Definition: PixelDataFormatter.h:107
ErrorChecker
Definition: ErrorChecker.h:11
PixelDataFormatter::theCablingTree
SiPixelFedCabling const * theCablingTree
Definition: PixelDataFormatter.h:93
PixelDataFormatter::digi2wordPhase1Layer1
int digi2wordPhase1Layer1(cms_uint32_t detId, const PixelDigi &digi, std::map< int, std::vector< Word32 > > &words) const
Definition: PixelDataFormatter.cc:428
PixelModuleName::isBarrel
virtual bool isBarrel() const
true for barrel modules
Definition: PixelModuleName.h:20
PixelDataFormatter::debug
bool debug
Definition: PixelDataFormatter.h:100
sipixelobjects::PixelROC
Definition: PixelROC.h:23
PixelDigi::row
int row() const
Definition: PixelDigi.h:52
sipixelobjects::LocalPixel::RocRowCol
row and collumn in ROC representation
Definition: LocalPixel.h:13
PixelDataFormatter::COL_mask
Word32 COL_mask
Definition: PixelDataFormatter.h:108
LIKELY
#define LIKELY(x)
Definition: Likely.h:20
Exception
Definition: hltDiff.cc:246
PixelDigi::adc
unsigned short adc() const
Definition: PixelDigi.h:60
FEDHeader::set
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:25
PixelMapPlotter.roc
roc
Definition: PixelMapPlotter.py:498
edm::DetSet::data
collection_type data
Definition: DetSet.h:80
hgcalTestNeighbor_cfi.detector
detector
Definition: hgcalTestNeighbor_cfi.py:6
RecoTauValidation_cfi.header
header
Definition: RecoTauValidation_cfi.py:292
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
DTRecHitClients_cfi.local
local
Definition: DTRecHitClients_cfi.py:10
genParticles_cff.map
map
Definition: genParticles_cff.py:11
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
PixelDataFormatter::includeErrors
bool includeErrors
Definition: PixelDataFormatter.h:98
SiPixelQuality::IsRocBad
bool IsRocBad(const uint32_t &detid, const short &rocNb) const
Definition: SiPixelQuality.cc:111
sipixelobjects::LocalPixel::RocRowCol::valid
bool valid() const
Definition: LocalPixel.h:15
PixelDataFormatter::PXID_shift
int PXID_shift
Definition: PixelDataFormatter.h:107
PixelDataFormatter::Word32
cms_uint32_t Word32
Definition: PixelDataFormatter.h:70
PixelDataFormatter::allDetDigis
int allDetDigis
Definition: PixelDataFormatter.h:101
PixelDataFormatter::COL_shift
int COL_shift
Definition: PixelDataFormatter.h:107
sipixelobjects::PixelROC::idInDetUnit
unsigned int idInDetUnit() const
id of this ROC in DetUnit etermined by token path
Definition: PixelROC.h:37
sipixelobjects::DetectorIndex::rawId
uint32_t rawId
Definition: DetectorIndex.h:7
sipixelobjects::DetectorIndex
Definition: DetectorIndex.h:6
PixelDataFormatter::Word64
cms_uint64_t Word64
Definition: PixelDataFormatter.h:71
sipixelobjects::ElectronicIndex::roc
int roc
Definition: ElectronicIndex.h:7
PixelDataFormatter::modulesToUnpack
const std::set< unsigned int > * modulesToUnpack
Definition: PixelDataFormatter.h:96
PixelDataFormatter::ROC_shift
int ROC_shift
Definition: PixelDataFormatter.h:107