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

using BadChannels = std::map< cms_uint32_t, DetBadChannels >
 
using Collection = edm::DetSetVector< PixelDigi >
 
using DetBadChannels = std::vector< PixelFEDChannel >
 
using DetDigis = std::vector< PixelDigi >
 
using DetErrors = std::vector< SiPixelRawDataError >
 
using Digis = std::map< cms_uint32_t, DetDigis >
 
using Errors = std::map< cms_uint32_t, DetErrors >
 
using FEDWordsMap = std::map< int, std::vector< Word32 > >
 
using ModuleIDSet = std::set< unsigned int >
 
using RawData = std::map< int, FEDRawData >
 

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)
 
int nDigis () const
 
int nWords () const
 
void passFrameReverter (const SiPixelFrameReverter *reverter)
 
 PixelDataFormatter (const SiPixelFedCablingTree *map, bool phase1_=false)
 
void setErrorStatus (bool ErrorStatus)
 
void setModulesToUnpack (const ModuleIDSet *moduleIds)
 
void setQualityStatus (bool QualityStatus, const SiPixelQuality *QualityInfo)
 
void unpackFEDErrors (Errors const &errors, std::vector< int > const &tkerrorlist, std::vector< int > const &usererrorlist, edm::DetSetVector< SiPixelRawDataError > &errorcollection, DetIdCollection &tkerror_detidcollection, DetIdCollection &usererror_detidcollection, edmNew::DetSetVector< PixelFEDChannel > &disabled_channelcollection, DetErrors &nodeterrors)
 

Private Member Functions

int checkError (const Word32 &data) const
 
int digi2word (cms_uint32_t detId, const PixelDigi &digi, FEDWordsMap &words) const
 
int digi2wordPhase1Layer1 (cms_uint32_t detId, const PixelDigi &digi, FEDWordsMap &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
 

Private Attributes

int allDetDigis_
 
const SiPixelQualitybadPixelInfo_
 
std::unique_ptr< ErrorCheckerBaseerrorcheck_
 
int hasDetDigis_
 
bool includeErrors_
 
int maxROCIndex_
 
const ModuleIDSetmodulesToUnpack_
 
bool phase1_
 
SiPixelFedCablingTree 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 61 of file PixelDataFormatter.h.

Member Typedef Documentation

◆ BadChannels

Definition at line 70 of file PixelDataFormatter.h.

◆ Collection

Definition at line 65 of file PixelDataFormatter.h.

◆ DetBadChannels

Definition at line 69 of file PixelDataFormatter.h.

◆ DetDigis

Definition at line 67 of file PixelDataFormatter.h.

◆ DetErrors

Definition at line 63 of file PixelDataFormatter.h.

◆ Digis

Definition at line 68 of file PixelDataFormatter.h.

◆ Errors

Definition at line 64 of file PixelDataFormatter.h.

◆ FEDWordsMap

using PixelDataFormatter::FEDWordsMap = std::map<int, std::vector<Word32> >

Definition at line 71 of file PixelDataFormatter.h.

◆ ModuleIDSet

using PixelDataFormatter::ModuleIDSet = std::set<unsigned int>

Definition at line 72 of file PixelDataFormatter.h.

◆ RawData

using PixelDataFormatter::RawData = std::map<int, FEDRawData>

Definition at line 66 of file PixelDataFormatter.h.

Constructor & Destructor Documentation

◆ PixelDataFormatter()

PixelDataFormatter::PixelDataFormatter ( const SiPixelFedCablingTree map,
bool  phase1_ = false 
)

Definition at line 28 of file PixelDataFormatter.cc.

References allDetDigis_, errorcheck_, hasDetDigis_, includeErrors_, maxROCIndex_, phase1_, and useQualityInfo_.

29  : theDigiCounter_(0),
30  theWordCounter_(0),
32  badPixelInfo_(nullptr),
33  modulesToUnpack_(nullptr),
34  phase1_(phase) {
35  int s32 = sizeof(Word32);
36  int s64 = sizeof(Word64);
37  int s8 = sizeof(char);
38  if (s8 != 1 || s32 != 4 * s8 || s64 != 2 * s32) {
39  LogError("UnexpectedSizes") << " unexpected sizes: "
40  << " size of char is: " << s8 << ", size of Word32 is: " << s32
41  << ", size of Word64 is: " << s64 << ", send exception";
42  }
43  includeErrors_ = false;
44  useQualityInfo_ = false;
45  allDetDigis_ = 0;
46  hasDetDigis_ = 0;
47 
48  if (phase1_) {
49  maxROCIndex_ = 8;
50  errorcheck_ = std::unique_ptr<ErrorCheckerBase>(new ErrorChecker());
51  } else {
52  maxROCIndex_ = 25;
53  errorcheck_ = std::unique_ptr<ErrorCheckerBase>(new ErrorCheckerPhase0());
54  }
55 }
Log< level::Error, false > LogError
const ModuleIDSet * modulesToUnpack_
cms_uint32_t Word32
uint64_t Word64
std::unique_ptr< ErrorCheckerBase > errorcheck_
SiPixelFedCablingTree const * theCablingTree_
const SiPixelQuality * badPixelInfo_

Member Function Documentation

◆ checkError()

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

◆ digi2word()

int PixelDataFormatter::digi2word ( cms_uint32_t  detId,
const PixelDigi digi,
FEDWordsMap words 
) const
private

Definition at line 327 of file PixelDataFormatter.cc.

References PixelDigi::adc(), sipixelconstants::ADC_shift, PixelDigi::column(), sipixelobjects::ElectronicIndex::dcol, sipixelconstants::DCOL_shift, hgcalTestNeighbor_cfi::detector, hcalRecHitTable_cff::detId, l1tstage2_dqm_sourceclient-live_cfg::fedId, sipixelobjects::ElectronicIndex::link, sipixelconstants::LINK_shift, LogDebug, print(), sipixelobjects::ElectronicIndex::pxid, sipixelconstants::PXID_shift, sipixelobjects::ElectronicIndex::roc, sipixelconstants::ROC_shift, PixelDigi::row(), theFrameReverter_, theWordCounter_, and SiPixelFrameReverter::toCabling().

Referenced by formatRawData().

329  {
330  LogDebug("PixelDataFormatter") << print(digi);
331 
332  DetectorIndex detector = {detId, digi.row(), digi.column()};
333  ElectronicIndex cabling;
334  int fedId = theFrameReverter_->toCabling(cabling, detector);
335  if (fedId < 0)
336  return fedId;
337 
338  Word32 word = (cabling.link << LINK_shift) | (cabling.roc << ROC_shift) | (cabling.dcol << DCOL_shift) |
339  (cabling.pxid << PXID_shift) | (digi.adc() << ADC_shift);
340  words[fedId].push_back(word);
341  theWordCounter_++;
342 
343  return fedId;
344 }
std::string print(const PixelDigi &digi) const
int toCabling(sipixelobjects::ElectronicIndex &cabling, const sipixelobjects::DetectorIndex &detector) const
constexpr uint32_t DCOL_shift
constexpr uint32_t PXID_shift
constexpr uint32_t ROC_shift
constexpr uint32_t ADC_shift
unsigned short adc() const
Definition: PixelDigi.h:64
uint64_t word
const SiPixelFrameReverter * theFrameReverter_
cms_uint32_t Word32
int column() const
Definition: PixelDigi.h:57
constexpr uint32_t LINK_shift
int row() const
Definition: PixelDigi.h:54
#define LogDebug(id)

◆ digi2wordPhase1Layer1()

int PixelDataFormatter::digi2wordPhase1Layer1 ( cms_uint32_t  detId,
const PixelDigi digi,
FEDWordsMap words 
) const
private

Definition at line 345 of file PixelDataFormatter.cc.

References PixelDigi::adc(), sipixelconstants::ADC_shift, cuy::col, sipixelconstants::phase1layer1::COL_shift, PixelDigi::column(), sipixelobjects::ElectronicIndex::dcol, hgcalTestNeighbor_cfi::detector, hcalRecHitTable_cff::detId, l1tstage2_dqm_sourceclient-live_cfg::fedId, sipixelobjects::ElectronicIndex::link, sipixelconstants::LINK_shift, LogDebug, pixelgpudetails::numRowsInRoc, print(), sipixelobjects::ElectronicIndex::pxid, sipixelobjects::ElectronicIndex::roc, sipixelconstants::ROC_shift, PixelDigi::row(), sipixelconstants::phase1layer1::ROW_shift, theFrameReverter_, theWordCounter_, and SiPixelFrameReverter::toCabling().

Referenced by formatRawData().

347  {
348  LogDebug("PixelDataFormatter") << print(digi);
349 
350  DetectorIndex detector = {detId, digi.row(), digi.column()};
351  ElectronicIndex cabling;
352  int fedId = theFrameReverter_->toCabling(cabling, detector);
353  if (fedId < 0)
354  return fedId;
355 
356  int col = ((cabling.dcol) * 2) + ((cabling.pxid) % 2);
357  int row = LocalPixel::numRowsInRoc - ((cabling.pxid) / 2);
358 
359  Word32 word = (cabling.link << LINK_shift) | (cabling.roc << ROC_shift) | (col << COL_shift) | (row << ROW_shift) |
360  (digi.adc() << ADC_shift);
361  words[fedId].push_back(word);
362  theWordCounter_++;
363 
364  return fedId;
365 }
std::string print(const PixelDigi &digi) const
int toCabling(sipixelobjects::ElectronicIndex &cabling, const sipixelobjects::DetectorIndex &detector) const
constexpr uint32_t ROC_shift
constexpr uint32_t ADC_shift
unsigned short adc() const
Definition: PixelDigi.h:64
uint64_t word
const SiPixelFrameReverter * theFrameReverter_
cms_uint32_t Word32
int column() const
Definition: PixelDigi.h:57
constexpr uint32_t LINK_shift
col
Definition: cuy.py:1009
int row() const
Definition: PixelDigi.h:54
#define LogDebug(id)

◆ errorDetId()

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

Referenced by unpackFEDErrors().

◆ formatRawData()

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

Definition at line 224 of file PixelDataFormatter.cc.

References allDetDigis_, Reference_intrackfit_cff::barrel, digi2word(), digi2wordPhase1Layer1(), Exception, l1tstage2_dqm_sourceclient-live_cfg::fedId, l1t_dqm_sourceclient-live_cfg::fedRawData, sipixelconstants::functions::getLink(), hasDetDigis_, mps_fire::i, PixelModuleName::isBarrel(), nano_mu_digi_cff::layer, sipixelconstants::LINK_shift, LogDebug, LogTrace, phase1_, print(), push_back(), l1tstage2_dqm_sourceclient-live_cfg::rawData, nano_mu_digi_cff::rawId, sipixelconstants::ROC_shift, alignCSCRings::s, FEDHeader::set(), FEDTrailer::set(), theDigiCounter_, and theWordCounter_.

227  {
228  std::map<int, vector<Word32> > words;
229 
230  // translate digis into 32-bit raw words and store in map indexed by Fed
231  for (Digis::const_iterator im = digis.begin(); im != digis.end(); im++) {
232  allDetDigis_++;
233  cms_uint32_t rawId = im->first;
234  int layer = 0;
236  if (barrel)
237  layer = PixelROC::bpixLayerPhase1(rawId);
238 
239  BadChannels::const_iterator detBadChannels = badChannels.find(rawId);
240 
241  hasDetDigis_++;
242  const DetDigis& detDigis = im->second;
243  for (DetDigis::const_iterator it = detDigis.begin(); it != detDigis.end(); it++) {
244  theDigiCounter_++;
245  const PixelDigi& digi = (*it);
246  int fedId = 0;
247 
248  if (layer == 1 && phase1_)
249  fedId = digi2wordPhase1Layer1(rawId, digi, words);
250  else
251  fedId = digi2word(rawId, digi, words);
252 
253  if (fedId < 0) {
254  LogError("FormatDataException") << " digi2word returns error #" << fedId << " Ndigis: " << theDigiCounter_
255  << endl
256  << " detector: " << rawId << endl
257  << print(digi) << endl;
258  } else if (detBadChannels != badChannels.end()) {
259  auto badChannel =
260  std::find_if(detBadChannels->second.begin(), detBadChannels->second.end(), [&](const PixelFEDChannel& ch) {
261  return (int(ch.fed) == fedId && ch.link == getLink(words[fedId].back()));
262  });
263  if (badChannel != detBadChannels->second.end()) {
264  LogError("FormatDataException") << " while marked bad, found digi for FED " << fedId << " Link "
265  << getLink(words[fedId].back()) << " on module " << rawId << endl
266  << print(digi) << endl;
267  }
268  } // if (fedId)
269  } // for (DetDigis
270  } // for (Digis
271  LogTrace(" allDetDigis_/hasDetDigis_ : ") << allDetDigis_ << "/" << hasDetDigis_;
272 
273  // fill FED error 25 words
274  for (const auto& detBadChannels : badChannels) {
275  for (const auto& badChannel : detBadChannels.second) {
276  unsigned int FEDError25 = 25;
277  Word32 word = (badChannel.link << LINK_shift) | (FEDError25 << ROC_shift);
278  words[badChannel.fed].push_back(word);
279  theWordCounter_++;
280  }
281  }
282 
283  typedef std::map<int, vector<Word32> >::const_iterator RI;
284  for (RI feddata = words.begin(); feddata != words.end(); feddata++) {
285  int fedId = feddata->first;
286  // since raw words are written in the form of 64-bit packets
287  // add extra 32-bit word to make number of words even if necessary
288  if (words.find(fedId)->second.size() % 2 != 0)
289  words[fedId].push_back(Word32(0));
290 
291  // size in Bytes; create output structure
292  int dataSize = words.find(fedId)->second.size() * sizeof(Word32);
293  int nHeaders = 1;
294  int nTrailers = 1;
295  dataSize += (nHeaders + nTrailers) * sizeof(Word64);
296  FEDRawData* rawData = new FEDRawData(dataSize);
297 
298  // get begining of data;
299  Word64* word = reinterpret_cast<Word64*>(rawData->data());
300 
301  // write one header
302  FEDHeader::set(reinterpret_cast<unsigned char*>(word), 0, lvl1_ID, 0, fedId);
303  word++;
304 
305  // write data
306  unsigned int nWord32InFed = words.find(fedId)->second.size();
307  for (unsigned int i = 0; i < nWord32InFed; i += 2) {
308  *word = (Word64(words.find(fedId)->second[i + 1]) << 32) | words.find(fedId)->second[i];
309  LogDebug("PixelDataFormatter") << print(*word);
310  word++;
311  }
312 
313  // write one trailer
314  FEDTrailer::set(reinterpret_cast<unsigned char*>(word), dataSize / sizeof(Word64), 0, 0, 0);
315  word++;
316 
317  // check memory
318  if (word != reinterpret_cast<Word64*>(rawData->data() + dataSize)) {
319  string s = "** PROBLEM in PixelDataFormatter !!!";
320  throw cms::Exception(s);
321  } // if (word !=
323  delete rawData;
324  } // for (RI feddata
325 }
std::string print(const PixelDigi &digi) const
int digi2word(cms_uint32_t detId, const PixelDigi &digi, FEDWordsMap &words) const
int digi2wordPhase1Layer1(cms_uint32_t detId, const PixelDigi &digi, FEDWordsMap &words) const
constexpr uint32_t ROC_shift
Log< level::Error, false > LogError
std::vector< PixelDigi > DetDigis
#define LogTrace(id)
uint64_t word
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
cms_uint32_t Word32
constexpr uint32_t getLink(uint32_t ww)
unsigned int cms_uint32_t
Definition: typedefs.h:15
uint64_t Word64
constexpr uint32_t LINK_shift
virtual bool isBarrel() const
true for barrel modules
deadvectors [0] push_back({0.0175431, 0.538005, 6.80997, 13.29})
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
cms_uint64_t Word64
#define LogDebug(id)

◆ interpretRawData()

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

Definition at line 71 of file PixelDataFormatter.cc.

References gpuClustering::adc, badPixelInfo_, Reference_intrackfit_cff::barrel, sipixelobjects::GlobalPixel::col, cuy::col, edm::DetSet< T >::data, errorcheck_, funct::false, l1tstage2_dqm_sourceclient-live_cfg::fedId, edm::DetSetVector< T >::find_or_insert(), sipixelconstants::functions::getADC(), sipixelconstants::functions::getCol(), sipixelconstants::functions::getDCol(), sipixelconstants::functions::getLink(), sipixelconstants::functions::getPxId(), sipixelconstants::functions::getROC(), sipixelconstants::functions::getRow(), RecoTauValidation_cfi::header, sipixelobjects::PixelROC::idInDetUnit(), PixelModuleName::isBarrel(), SiPixelQuality::IsRocBad(), nano_mu_digi_cff::layer, LIKELY, DTRecHitClients_cfi::local, LogDebug, LogTrace, maxROCIndex_, modulesToUnpack_, nWords(), phase1_, print(), l1tstage2_dqm_sourceclient-live_cfg::rawData, sipixelobjects::PixelROC::rawId(), nano_mu_digi_cff::rawId, PixelMapPlotter::roc, sipixelobjects::GlobalPixel::row, theCablingTree_, theWordCounter_, sipixelobjects::PixelROC::toGlobal(), UNLIKELY, useQualityInfo_, sipixelobjects::LocalPixel::RocRowCol::valid(), and sipixelobjects::LocalPixel::DcolPxid::valid().

72  {
73  using namespace sipixelobjects;
74 
75  int nWords = rawData.size() / sizeof(Word64);
76  if (nWords == 0)
77  return;
78 
80 
81  // check CRC bit
82  const Word64* trailer = reinterpret_cast<const Word64*>(rawData.data()) + (nWords - 1);
83  if (!errorcheck_->checkCRC(errorsInEvent, fedId, trailer, errors))
84  return;
85 
86  // check headers
87  const Word64* header = reinterpret_cast<const Word64*>(rawData.data());
88  header--;
89  bool moreHeaders = true;
90  while (moreHeaders) {
91  header++;
92  LogTrace("") << "HEADER: " << print(*header);
93  bool headerStatus = errorcheck_->checkHeader(errorsInEvent, fedId, header, errors);
94  moreHeaders = headerStatus;
95  }
96 
97  // check trailers
98  bool moreTrailers = true;
99  trailer++;
100  while (moreTrailers) {
101  trailer--;
102  LogTrace("") << "TRAILER: " << print(*trailer);
103  bool trailerStatus = errorcheck_->checkTrailer(errorsInEvent, fedId, nWords, trailer, errors);
104  moreTrailers = trailerStatus;
105  }
106 
107  // data words
108  theWordCounter_ += 2 * (nWords - 2);
109  LogTrace("") << "data words: " << (trailer - header - 1);
110 
111  int link = -1;
112  int roc = -1;
113  int layer = 0;
114  unsigned int rawId = 0;
115  unsigned int nrawId = 0;
116  PixelROC const* rocp = nullptr;
117  bool skipROC = false;
118  edm::DetSet<PixelDigi>* detDigis = nullptr;
119 
120  const Word32* bw = (const Word32*)(header + 1);
121  const Word32* ew = (const Word32*)(trailer);
122  if (*(ew - 1) == 0) {
123  ew--;
124  theWordCounter_--;
125  }
126  for (auto word = bw; word < ew; ++word) {
127  LogTrace("") << "DATA: " << print(*word);
128 
129  auto ww = *word;
130  if UNLIKELY (ww == 0) {
131  theWordCounter_--;
132  continue;
133  }
134  int nlink = getLink(ww);
135  int nroc = getROC(ww);
136 
137  if ((nlink != link) | (nroc != roc)) { // new roc
138  link = nlink;
139  roc = nroc;
140  skipROC = LIKELY(roc < maxROCIndex_)
141  ? false
142  : !errorcheck_->checkROC(errorsInEvent, fedId, &converter, theCablingTree_, ww, errors);
143  if (skipROC)
144  continue;
145  rocp = converter.toRoc(link, roc);
146  if UNLIKELY (!rocp) {
147  errorsInEvent = true;
148  errorcheck_->conversionError(fedId, &converter, 2, ww, errors);
149  skipROC = true;
150  continue;
151  }
152  rawId = rocp->rawId();
154  if (barrel)
155  layer = PixelROC::bpixLayerPhase1(rawId);
156  else
157  layer = 0;
158 
159  if (useQualityInfo_ & (nullptr != badPixelInfo_)) {
160  short rocInDet = (short)rocp->idInDetUnit();
161  skipROC = badPixelInfo_->IsRocBad(rawId, rocInDet);
162  if (skipROC)
163  continue;
164  }
165  skipROC = modulesToUnpack_ && (modulesToUnpack_->find(rawId) == modulesToUnpack_->end());
166  if (skipROC)
167  continue;
168  }
169 
170  // skip is roc to be skipped ot invalid
171  if UNLIKELY (skipROC || !rocp)
172  continue;
173 
174  int adc = getADC(ww);
175  std::unique_ptr<LocalPixel> local;
176 
177  if (phase1_ && layer == 1) { // special case for layer 1ROC
178  // for l1 roc use the roc column and row index instead of dcol and pixel index.
179  int col = getCol(ww);
180  int row = getRow(ww);
181 
182  LocalPixel::RocRowCol localCR = {row, col}; // build pixel
183  if UNLIKELY (!localCR.valid()) {
184  LogDebug("PixelDataFormatter::interpretRawData") << "status #3";
185  errorsInEvent = true;
186  errorcheck_->conversionError(fedId, &converter, 3, ww, errors);
187  continue;
188  }
189  local = std::make_unique<LocalPixel>(localCR); // local pixel coordinate
190 
191  } else { // phase0 and phase1 except bpix layer 1
192  int dcol = getDCol(ww);
193  int pxid = getPxId(ww);
194  LocalPixel::DcolPxid localDP = {dcol, pxid};
195 
196  if UNLIKELY (!localDP.valid()) {
197  LogDebug("PixelDataFormatter::interpretRawData") << "status #3";
198  errorsInEvent = true;
199  errorcheck_->conversionError(fedId, &converter, 3, ww, errors);
200  continue;
201  }
202  local = std::make_unique<LocalPixel>(localDP); // local pixel coordinate
203  }
204 
205  if (nrawId != rawId) {
206  nrawId = rawId;
207  detDigis = &digis.find_or_insert(rawId);
208  if ((*detDigis).empty()) {
209  (*detDigis).data.reserve(32); // avoid the first relocations
210  }
211  }
212 
213  if (detDigis) {
214  GlobalPixel global = rocp->toGlobal(*local); // global pixel coordinate (in module)
215  (*detDigis).data.emplace_back(global.row, global.col, adc);
216  LogTrace("") << (*detDigis).data.back();
217  } else {
218  LogError("NullPointerException") << "@SUB=PixelDataFormatter::interpretRawData"
219  << "DetSet pointer not set. This is not supposed to happen.";
220  }
221  }
222 }
std::string print(const PixelDigi &digi) const
constexpr uint32_t getRow(uint32_t ww)
bool IsRocBad(const uint32_t &detid, const short &rocNb) const
constexpr uint32_t getCol(uint32_t ww)
#define LIKELY(x)
Definition: Likely.h:20
Log< level::Error, false > LogError
const ModuleIDSet * modulesToUnpack_
#define LogTrace(id)
global coordinates (row and column in DetUnit, as in PixelDigi)
Definition: GlobalPixel.h:6
constexpr uint32_t getPxId(uint32_t ww)
uint64_t word
GlobalPixel toGlobal(const LocalPixel &loc) const
Definition: PixelROC.h:55
constexpr uint32_t getDCol(uint32_t ww)
cms_uint32_t Word32
constexpr uint32_t getADC(uint32_t ww)
constexpr uint32_t getLink(uint32_t ww)
double collumn and pixel ID in double collumn representation
Definition: LocalPixel.h:19
constexpr uint32_t getROC(uint32_t ww)
uint64_t Word64
virtual bool isBarrel() const
true for barrel modules
std::unique_ptr< ErrorCheckerBase > errorcheck_
SiPixelFedCablingTree const * theCablingTree_
const SiPixelQuality * badPixelInfo_
row and collumn in ROC representation
Definition: LocalPixel.h:13
collection_type data
Definition: DetSet.h:80
col
Definition: cuy.py:1009
Definition: errors.py:1
#define UNLIKELY(x)
Definition: Likely.h:21
uint32_t rawId() const
return the DetUnit to which this ROC belongs to.
Definition: PixelROC.h:34
unsigned int idInDetUnit() const
id of this ROC in DetUnit etermined by token path
Definition: PixelROC.h:37
uint16_t *__restrict__ uint16_t const *__restrict__ adc
cms_uint64_t Word64
#define LogDebug(id)

◆ nDigis()

int PixelDataFormatter::nDigis ( ) const
inline

Definition at line 81 of file PixelDataFormatter.h.

References theDigiCounter_.

81 { return theDigiCounter_; }

◆ nWords()

int PixelDataFormatter::nWords ( ) const
inline

Definition at line 82 of file PixelDataFormatter.h.

References theWordCounter_.

Referenced by interpretRawData().

82 { return theWordCounter_; }

◆ passFrameReverter()

void PixelDataFormatter::passFrameReverter ( const SiPixelFrameReverter reverter)

Definition at line 69 of file PixelDataFormatter.cc.

References theFrameReverter_.

Referenced by SiPixelDigiToRaw::produce().

69 { theFrameReverter_ = reverter; }
const SiPixelFrameReverter * theFrameReverter_

◆ print() [1/2]

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

Definition at line 367 of file PixelDataFormatter.cc.

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

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

367  {
368  ostringstream str;
369  str << " DIGI: row: " << digi.row() << ", col: " << digi.column() << ", adc: " << digi.adc();
370  return str.str();
371 }
unsigned short adc() const
Definition: PixelDigi.h:64
int column() const
Definition: PixelDigi.h:57
int row() const
Definition: PixelDigi.h:54
#define str(s)

◆ print() [2/2]

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

Definition at line 373 of file PixelDataFormatter.cc.

References str.

373  {
374  ostringstream str;
375  str << "word64: " << reinterpret_cast<const bitset<64>&>(word);
376  return str.str();
377 }
uint64_t word
#define str(s)

◆ setErrorStatus()

void PixelDataFormatter::setErrorStatus ( bool  ErrorStatus)

Definition at line 57 of file PixelDataFormatter.cc.

References errorcheck_, and includeErrors_.

Referenced by SiPixelRawToDigi::produce().

57  {
58  includeErrors_ = ErrorStatus;
59  errorcheck_->setErrorStatus(includeErrors_);
60 }
std::unique_ptr< ErrorCheckerBase > errorcheck_

◆ setModulesToUnpack()

void PixelDataFormatter::setModulesToUnpack ( const ModuleIDSet moduleIds)

Definition at line 67 of file PixelDataFormatter.cc.

References modulesToUnpack_.

67 { modulesToUnpack_ = moduleIds; }
const ModuleIDSet * modulesToUnpack_

◆ setQualityStatus()

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

Definition at line 62 of file PixelDataFormatter.cc.

References badPixelInfo_, and useQualityInfo_.

62  {
63  useQualityInfo_ = QualityStatus;
64  badPixelInfo_ = QualityInfo;
65 }
const SiPixelQuality * badPixelInfo_

◆ unpackFEDErrors()

void PixelDataFormatter::unpackFEDErrors ( PixelDataFormatter::Errors const &  errors,
std::vector< int > const &  tkerrorlist,
std::vector< int > const &  usererrorlist,
edm::DetSetVector< SiPixelRawDataError > &  errorcollection,
DetIdCollection tkerror_detidcollection,
DetIdCollection usererror_detidcollection,
edmNew::DetSetVector< PixelFEDChannel > &  disabled_channelcollection,
DetErrors nodeterrors 
)

Definition at line 379 of file PixelDataFormatter.cc.

References edm::DetSet< T >::data, sipixelconstants::dummyDetId, errorDetId(), SiPixelFedCablingTree::fed(), l1tstage2_dqm_sourceclient-live_cfg::fedId, spr::find(), edm::DetSetVector< T >::find_or_insert(), sipixelconstants::functions::getLink(), sipixelobjects::PixelFEDCabling::id(), edmNew::DetSetVector< T >::insert(), sipixelobjects::PixelFEDCabling::link(), phase1_, edm::EDCollection< T >::push_back(), PixelMapPlotter::roc, PixelFEDChannel::roc_first, PixelFEDChannel::roc_last, and theCablingTree_.

386  {
387  const uint32_t dummyDetId = 0xffffffff;
388  for (const auto& [errorDetId, rawErrorsVec] : errors) {
389  if (errorDetId == dummyDetId) { // errors given dummy detId must be sorted by Fed
390  nodeterrors.insert(nodeterrors.end(), rawErrorsVec.begin(), rawErrorsVec.end());
391  } else {
392  edm::DetSet<SiPixelRawDataError>& errorDetSet = errorcollection.find_or_insert(errorDetId);
393  errorDetSet.data.insert(errorDetSet.data.end(), rawErrorsVec.begin(), rawErrorsVec.end());
394  // Fill detid of the detectors where there is error AND the error number is listed
395  // in the configurable error list in the job option cfi.
396  // Code needs to be here, because there can be a set of errors for each
397  // entry in the for loop over PixelDataFormatter::Errors
398 
399  std::vector<PixelFEDChannel> disabledChannelsDetSet;
400 
401  for (auto const& aPixelError : errorDetSet) {
402  // For the time being, we extend the error handling functionality with ErrorType 25
403  // In the future, we should sort out how the usage of tkerrorlist can be generalized
404  if (phase1_ && aPixelError.getType() == 25) {
405  int fedId = aPixelError.getFedId();
407  if (fed) {
408  cms_uint32_t linkId = getLink(aPixelError.getWord32());
409  const sipixelobjects::PixelFEDLink* link = fed->link(linkId);
410  if (link) {
411  // The "offline" 0..15 numbering is fixed by definition, also, the FrameConversion depends on it
412  // in contrast, the ROC-in-channel numbering is determined by hardware --> better to use the "offline" scheme
413  PixelFEDChannel ch = {fed->id(), linkId, 25, 0};
414  for (unsigned int iRoc = 1; iRoc <= link->numberOfROCs(); iRoc++) {
415  const sipixelobjects::PixelROC* roc = link->roc(iRoc);
416  if (roc->idInDetUnit() < ch.roc_first)
417  ch.roc_first = roc->idInDetUnit();
418  if (roc->idInDetUnit() > ch.roc_last)
419  ch.roc_last = roc->idInDetUnit();
420  }
421  disabledChannelsDetSet.push_back(ch);
422  }
423  }
424  } else {
425  // fill list of detIds to be turned off by tracking
426  if (!tkerrorlist.empty()) {
427  auto it_find = std::find(tkerrorlist.begin(), tkerrorlist.end(), aPixelError.getType());
428  if (it_find != tkerrorlist.end()) {
429  tkerror_detidcollection.push_back(errorDetId);
430  }
431  }
432  }
433 
434  // fill list of detIds with errors to be studied
435  if (!usererrorlist.empty()) {
436  auto it_find = std::find(usererrorlist.begin(), usererrorlist.end(), aPixelError.getType());
437  if (it_find != usererrorlist.end()) {
438  usererror_detidcollection.push_back(errorDetId);
439  }
440  }
441 
442  } // loop on DetSet of errors
443 
444  if (!disabledChannelsDetSet.empty()) {
445  disabled_channelcollection.insert(errorDetId, disabledChannelsDetSet.data(), disabledChannelsDetSet.size());
446  }
447 
448  } // if error assigned to a real DetId
449  } // loop on errors in event for this FED
450 }
constexpr cms_uint32_t dummyDetId
const PixelFEDLink * link(unsigned int id) const
return link identified by id. Link id&#39;s are ranged [1, numberOfLinks]
cms_uint32_t errorDetId(const SiPixelFrameConverter *converter, int fedId, int errorType, const Word32 &word) const
void push_back(T const &t)
Definition: EDCollection.h:61
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
unsigned int roc_last
reference find_or_insert(det_id_type id)
Definition: DetSetVector.h:234
constexpr uint32_t getLink(uint32_t ww)
unsigned int cms_uint32_t
Definition: typedefs.h:15
DetSet insert(id_type iid, data_type const *idata, size_type isize)
const PixelFEDCabling * fed(unsigned int idFed) const
get fed identified by its id
SiPixelFedCablingTree const * theCablingTree_
unsigned int roc_first
collection_type data
Definition: DetSet.h:80
Definition: errors.py:1

Member Data Documentation

◆ allDetDigis_

int PixelDataFormatter::allDetDigis_
private

Definition at line 108 of file PixelDataFormatter.h.

Referenced by formatRawData(), and PixelDataFormatter().

◆ badPixelInfo_

const SiPixelQuality* PixelDataFormatter::badPixelInfo_
private

Definition at line 103 of file PixelDataFormatter.h.

Referenced by interpretRawData(), and setQualityStatus().

◆ errorcheck_

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

Definition at line 110 of file PixelDataFormatter.h.

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

◆ hasDetDigis_

int PixelDataFormatter::hasDetDigis_
private

Definition at line 109 of file PixelDataFormatter.h.

Referenced by formatRawData(), and PixelDataFormatter().

◆ includeErrors_

bool PixelDataFormatter::includeErrors_
private

Definition at line 106 of file PixelDataFormatter.h.

Referenced by PixelDataFormatter(), and setErrorStatus().

◆ maxROCIndex_

int PixelDataFormatter::maxROCIndex_
private

Definition at line 112 of file PixelDataFormatter.h.

Referenced by interpretRawData(), and PixelDataFormatter().

◆ modulesToUnpack_

const ModuleIDSet* PixelDataFormatter::modulesToUnpack_
private

Definition at line 104 of file PixelDataFormatter.h.

Referenced by interpretRawData(), and setModulesToUnpack().

◆ phase1_

bool PixelDataFormatter::phase1_
private

◆ theCablingTree_

SiPixelFedCablingTree const* PixelDataFormatter::theCablingTree_
private

Definition at line 101 of file PixelDataFormatter.h.

Referenced by interpretRawData(), and unpackFEDErrors().

◆ theDigiCounter_

int PixelDataFormatter::theDigiCounter_
mutableprivate

Definition at line 98 of file PixelDataFormatter.h.

Referenced by formatRawData(), and nDigis().

◆ theFrameReverter_

const SiPixelFrameReverter* PixelDataFormatter::theFrameReverter_
private

Definition at line 102 of file PixelDataFormatter.h.

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

◆ theWordCounter_

int PixelDataFormatter::theWordCounter_
mutableprivate

◆ useQualityInfo_

bool PixelDataFormatter::useQualityInfo_
private

Definition at line 107 of file PixelDataFormatter.h.

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