CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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

Definition at line 70 of file PixelDataFormatter.h.

Definition at line 65 of file PixelDataFormatter.h.

Definition at line 69 of file PixelDataFormatter.h.

Definition at line 67 of file PixelDataFormatter.h.

Definition at line 63 of file PixelDataFormatter.h.

Definition at line 68 of file PixelDataFormatter.h.

Definition at line 64 of file PixelDataFormatter.h.

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

Definition at line 71 of file PixelDataFormatter.h.

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

Definition at line 72 of file PixelDataFormatter.h.

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

Definition at line 66 of file PixelDataFormatter.h.

Constructor & Destructor Documentation

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),
31  theCablingTree_(map),
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

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

Definition at line 316 of file PixelDataFormatter.cc.

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

318  {
319  LogDebug("PixelDataFormatter") << print(digi);
320 
321  DetectorIndex detector = {detId, digi.row(), digi.column()};
322  ElectronicIndex cabling;
323  int fedId = theFrameReverter_->toCabling(cabling, detector);
324  if (fedId < 0)
325  return fedId;
326 
327  Word32 word = (cabling.link << LINK_shift) | (cabling.roc << ROC_shift) | (cabling.dcol << DCOL_shift) |
328  (cabling.pxid << PXID_shift) | (digi.adc() << ADC_shift);
329  words[fedId].push_back(word);
330  theWordCounter_++;
331 
332  return fedId;
333 }
int row() const
Definition: PixelDigi.h:54
constexpr uint32_t DCOL_shift
constexpr uint32_t PXID_shift
constexpr uint32_t ROC_shift
constexpr uint32_t ADC_shift
int toCabling(sipixelobjects::ElectronicIndex &cabling, const sipixelobjects::DetectorIndex &detector) const
uint64_t word
const SiPixelFrameReverter * theFrameReverter_
cms_uint32_t Word32
std::string print(const PixelDigi &digi) const
unsigned short adc() const
Definition: PixelDigi.h:64
constexpr uint32_t LINK_shift
int column() const
Definition: PixelDigi.h:57
#define LogDebug(id)
int PixelDataFormatter::digi2wordPhase1Layer1 ( cms_uint32_t  detId,
const PixelDigi digi,
FEDWordsMap words 
) const
private

Definition at line 334 of file PixelDataFormatter.cc.

References PixelDigi::adc(), sipixelconstants::ADC_shift, cuy::col, sipixelconstants::phase1layer1::COL_shift, PixelDigi::column(), sipixelobjects::ElectronicIndex::dcol, l1tstage2_dqm_sourceclient-live_cfg::fedId, sipixelobjects::ElectronicIndex::link, sipixelconstants::LINK_shift, LogDebug, phase1PixelTopology::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().

336  {
337  LogDebug("PixelDataFormatter") << print(digi);
338 
339  DetectorIndex detector = {detId, digi.row(), digi.column()};
340  ElectronicIndex cabling;
341  int fedId = theFrameReverter_->toCabling(cabling, detector);
342  if (fedId < 0)
343  return fedId;
344 
345  int col = ((cabling.dcol) * 2) + ((cabling.pxid) % 2);
346  int row = LocalPixel::numRowsInRoc - ((cabling.pxid) / 2);
347 
348  Word32 word = (cabling.link << LINK_shift) | (cabling.roc << ROC_shift) | (col << COL_shift) | (row << ROW_shift) |
349  (digi.adc() << ADC_shift);
350  words[fedId].push_back(word);
351  theWordCounter_++;
352 
353  return fedId;
354 }
int row() const
Definition: PixelDigi.h:54
constexpr uint16_t numRowsInRoc
constexpr uint32_t ROC_shift
constexpr uint32_t ADC_shift
int toCabling(sipixelobjects::ElectronicIndex &cabling, const sipixelobjects::DetectorIndex &detector) const
uint64_t word
const SiPixelFrameReverter * theFrameReverter_
cms_uint32_t Word32
std::string print(const PixelDigi &digi) const
unsigned short adc() const
Definition: PixelDigi.h:64
constexpr uint32_t LINK_shift
int column() const
Definition: PixelDigi.h:57
int col
Definition: cuy.py:1009
#define LogDebug(id)
cms_uint32_t PixelDataFormatter::errorDetId ( const SiPixelFrameConverter converter,
int  fedId,
int  errorType,
const Word32 word 
) const
private

Referenced by unpackFEDErrors().

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

Definition at line 213 of file PixelDataFormatter.cc.

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

216  {
217  std::map<int, vector<Word32> > words;
218 
219  // translate digis into 32-bit raw words and store in map indexed by Fed
220  for (Digis::const_iterator im = digis.begin(); im != digis.end(); im++) {
221  allDetDigis_++;
222  cms_uint32_t rawId = im->first;
223  int layer = 0;
224  bool barrel = PixelModuleName::isBarrel(rawId);
225  if (barrel)
226  layer = PixelROC::bpixLayerPhase1(rawId);
227 
228  BadChannels::const_iterator detBadChannels = badChannels.find(rawId);
229 
230  hasDetDigis_++;
231  const DetDigis& detDigis = im->second;
232  for (DetDigis::const_iterator it = detDigis.begin(); it != detDigis.end(); it++) {
233  theDigiCounter_++;
234  const PixelDigi& digi = (*it);
235  int fedId = 0;
236 
237  if (layer == 1 && phase1_)
238  fedId = digi2wordPhase1Layer1(rawId, digi, words);
239  else
240  fedId = digi2word(rawId, digi, words);
241 
242  if (fedId < 0) {
243  LogError("FormatDataException") << " digi2word returns error #" << fedId << " Ndigis: " << theDigiCounter_
244  << endl
245  << " detector: " << rawId << endl
246  << print(digi) << endl;
247  } else if (detBadChannels != badChannels.end()) {
248  auto badChannel =
249  std::find_if(detBadChannels->second.begin(), detBadChannels->second.end(), [&](const PixelFEDChannel& ch) {
250  return (int(ch.fed) == fedId && ch.link == getLink(words[fedId].back()));
251  });
252  if (badChannel != detBadChannels->second.end()) {
253  LogError("FormatDataException") << " while marked bad, found digi for FED " << fedId << " Link "
254  << getLink(words[fedId].back()) << " on module " << rawId << endl
255  << print(digi) << endl;
256  }
257  } // if (fedId)
258  } // for (DetDigis
259  } // for (Digis
260  LogTrace(" allDetDigis_/hasDetDigis_ : ") << allDetDigis_ << "/" << hasDetDigis_;
261 
262  // fill FED error 25 words
263  for (const auto& detBadChannels : badChannels) {
264  for (const auto& badChannel : detBadChannels.second) {
265  unsigned int FEDError25 = 25;
266  Word32 word = (badChannel.link << LINK_shift) | (FEDError25 << ROC_shift);
267  words[badChannel.fed].push_back(word);
268  theWordCounter_++;
269  }
270  }
271 
272  typedef std::map<int, vector<Word32> >::const_iterator RI;
273  for (RI feddata = words.begin(); feddata != words.end(); feddata++) {
274  int fedId = feddata->first;
275  // since raw words are written in the form of 64-bit packets
276  // add extra 32-bit word to make number of words even if necessary
277  if (words.find(fedId)->second.size() % 2 != 0)
278  words[fedId].push_back(Word32(0));
279 
280  // size in Bytes; create output structure
281  int dataSize = words.find(fedId)->second.size() * sizeof(Word32);
282  int nHeaders = 1;
283  int nTrailers = 1;
284  dataSize += (nHeaders + nTrailers) * sizeof(Word64);
285  FEDRawData* rawData = new FEDRawData(dataSize);
286 
287  // get begining of data;
288  Word64* word = reinterpret_cast<Word64*>(rawData->data());
289 
290  // write one header
291  FEDHeader::set(reinterpret_cast<unsigned char*>(word), 0, lvl1_ID, 0, fedId);
292  word++;
293 
294  // write data
295  unsigned int nWord32InFed = words.find(fedId)->second.size();
296  for (unsigned int i = 0; i < nWord32InFed; i += 2) {
297  *word = (Word64(words.find(fedId)->second[i + 1]) << 32) | words.find(fedId)->second[i];
298  LogDebug("PixelDataFormatter") << print(*word);
299  word++;
300  }
301 
302  // write one trailer
303  FEDTrailer::set(reinterpret_cast<unsigned char*>(word), dataSize / sizeof(Word64), 0, 0, 0);
304  word++;
305 
306  // check memory
307  if (word != reinterpret_cast<Word64*>(rawData->data() + dataSize)) {
308  string s = "** PROBLEM in PixelDataFormatter !!!";
309  throw cms::Exception(s);
310  } // if (word !=
311  fedRawData[fedId] = *rawData;
312  delete rawData;
313  } // for (RI feddata
314 }
constexpr uint32_t ROC_shift
Log< level::Error, false > LogError
std::vector< PixelDigi > DetDigis
#define LogTrace(id)
constexpr std::array< uint8_t, layerIndexSize > layer
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
std::string print(const PixelDigi &digi) const
constexpr uint32_t getLink(uint32_t ww)
unsigned int cms_uint32_t
Definition: typedefs.h:15
virtual bool isBarrel() const
true for barrel modules
uint64_t Word64
constexpr uint32_t LINK_shift
int digi2word(cms_uint32_t detId, const PixelDigi &digi, FEDWordsMap &words) const
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
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
int digi2wordPhase1Layer1(cms_uint32_t detId, const PixelDigi &digi, FEDWordsMap &words) const
cms_uint64_t Word64
#define LogDebug(id)
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, FEDRawData::data(), edm::DetSet< T >::data, errorcheck_, 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(), PixelModuleName::isBarrel(), SiPixelQuality::IsRocBad(), phase1PixelTopology::layer, LIKELY, MainPageGenerator::link, LogDebug, LogTrace, maxROCIndex_, modulesToUnpack_, nWords(), phase1_, print(), PixelMapPlotter::roc, sipixelobjects::GlobalPixel::row, FEDRawData::size(), theCablingTree_, theWordCounter_, SiPixelFrameConverter::toRoc(), 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  PixelROC const* rocp = nullptr;
115  bool skipROC = false;
116  edm::DetSet<PixelDigi>* detDigis = nullptr;
117 
118  const Word32* bw = (const Word32*)(header + 1);
119  const Word32* ew = (const Word32*)(trailer);
120  if (*(ew - 1) == 0) {
121  ew--;
122  theWordCounter_--;
123  }
124  for (auto word = bw; word < ew; ++word) {
125  LogTrace("") << "DATA: " << print(*word);
126 
127  auto ww = *word;
128  if UNLIKELY (ww == 0) {
129  theWordCounter_--;
130  continue;
131  }
132  int nlink = getLink(ww);
133  int nroc = getROC(ww);
134 
135  if ((nlink != link) | (nroc != roc)) { // new roc
136  link = nlink;
137  roc = nroc;
138  skipROC = LIKELY(roc < maxROCIndex_)
139  ? false
140  : !errorcheck_->checkROC(errorsInEvent, fedId, &converter, theCablingTree_, ww, errors);
141  if (skipROC)
142  continue;
143  rocp = converter.toRoc(link, roc);
144  if UNLIKELY (!rocp) {
145  errorsInEvent = true;
146  errorcheck_->conversionError(fedId, &converter, 2, ww, errors);
147  skipROC = true;
148  continue;
149  }
150  auto rawId = rocp->rawId();
151  bool barrel = PixelModuleName::isBarrel(rawId);
152  if (barrel)
153  layer = PixelROC::bpixLayerPhase1(rawId);
154  else
155  layer = 0;
156 
157  if (useQualityInfo_ & (nullptr != badPixelInfo_)) {
158  short rocInDet = (short)rocp->idInDetUnit();
159  skipROC = badPixelInfo_->IsRocBad(rawId, rocInDet);
160  if (skipROC)
161  continue;
162  }
163  skipROC = modulesToUnpack_ && (modulesToUnpack_->find(rawId) == modulesToUnpack_->end());
164  if (skipROC)
165  continue;
166 
167  detDigis = &digis.find_or_insert(rawId);
168  if ((*detDigis).empty())
169  (*detDigis).data.reserve(32); // avoid the first relocations
170  }
171 
172  // skip is roc to be skipped ot invalid
173  if UNLIKELY (skipROC || !rocp)
174  continue;
175 
176  int adc = getADC(ww);
177  std::unique_ptr<LocalPixel> local;
178 
179  if (phase1_ && layer == 1) { // special case for layer 1ROC
180  // for l1 roc use the roc column and row index instead of dcol and pixel index.
181  int col = getCol(ww);
182  int row = getRow(ww);
183 
184  LocalPixel::RocRowCol localCR = {row, col}; // build pixel
185  if UNLIKELY (!localCR.valid()) {
186  LogDebug("PixelDataFormatter::interpretRawData") << "status #3";
187  errorsInEvent = true;
188  errorcheck_->conversionError(fedId, &converter, 3, ww, errors);
189  continue;
190  }
191  local = std::make_unique<LocalPixel>(localCR); // local pixel coordinate
192 
193  } else { // phase0 and phase1 except bpix layer 1
194  int dcol = getDCol(ww);
195  int pxid = getPxId(ww);
196  LocalPixel::DcolPxid localDP = {dcol, pxid};
197 
198  if UNLIKELY (!localDP.valid()) {
199  LogDebug("PixelDataFormatter::interpretRawData") << "status #3";
200  errorsInEvent = true;
201  errorcheck_->conversionError(fedId, &converter, 3, ww, errors);
202  continue;
203  }
204  local = std::make_unique<LocalPixel>(localDP); // local pixel coordinate
205  }
206 
207  GlobalPixel global = rocp->toGlobal(*local); // global pixel coordinate (in module)
208  (*detDigis).data.emplace_back(global.row, global.col, adc);
209  LogTrace("") << (*detDigis).data.back();
210  }
211 }
constexpr uint32_t getRow(uint32_t ww)
constexpr uint32_t getCol(uint32_t ww)
#define LIKELY(x)
Definition: Likely.h:20
bool IsRocBad(const uint32_t &detid, const short &rocNb) const
std::unique_ptr< T, impl::DeviceDeleter > unique_ptr
identify pixel inside single ROC
Definition: LocalPixel.h:7
const ModuleIDSet * modulesToUnpack_
#define LogTrace(id)
constexpr std::array< uint8_t, layerIndexSize > layer
global coordinates (row and column in DetUnit, as in PixelDigi)
Definition: GlobalPixel.h:6
constexpr uint32_t getPxId(uint32_t ww)
uint64_t word
constexpr uint32_t getDCol(uint32_t ww)
cms_uint32_t Word32
if(conf_.getParameter< bool >("UseStripCablingDB"))
constexpr uint32_t getADC(uint32_t ww)
std::string print(const PixelDigi &digi) const
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)
virtual bool isBarrel() const
true for barrel modules
uint64_t Word64
std::unique_ptr< ErrorCheckerBase > errorcheck_
SiPixelFedCablingTree const * theCablingTree_
const SiPixelQuality * badPixelInfo_
row and collumn in ROC representation
Definition: LocalPixel.h:13
#define UNLIKELY(x)
Definition: Likely.h:21
int col
Definition: cuy.py:1009
uint16_t *__restrict__ uint16_t const *__restrict__ adc
cms_uint64_t Word64
#define LogDebug(id)
int PixelDataFormatter::nDigis ( ) const
inline

Definition at line 81 of file PixelDataFormatter.h.

References theDigiCounter_.

81 { return theDigiCounter_; }
int PixelDataFormatter::nWords ( ) const
inline

Definition at line 82 of file PixelDataFormatter.h.

References theWordCounter_.

Referenced by interpretRawData().

82 { return theWordCounter_; }
void PixelDataFormatter::passFrameReverter ( const SiPixelFrameReverter reverter)

Definition at line 69 of file PixelDataFormatter.cc.

References theFrameReverter_.

69 { theFrameReverter_ = reverter; }
const SiPixelFrameReverter * theFrameReverter_
std::string PixelDataFormatter::print ( const PixelDigi digi) const
private

Definition at line 356 of file PixelDataFormatter.cc.

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

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

356  {
357  ostringstream str;
358  str << " DIGI: row: " << digi.row() << ", col: " << digi.column() << ", adc: " << digi.adc();
359  return str.str();
360 }
int row() const
Definition: PixelDigi.h:54
unsigned short adc() const
Definition: PixelDigi.h:64
int column() const
Definition: PixelDigi.h:57
#define str(s)
std::string PixelDataFormatter::print ( const Word64 word) const
private

Definition at line 362 of file PixelDataFormatter.cc.

References str.

362  {
363  ostringstream str;
364  str << "word64: " << reinterpret_cast<const bitset<64>&>(word);
365  return str.str();
366 }
uint64_t word
#define str(s)
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_
void PixelDataFormatter::setModulesToUnpack ( const ModuleIDSet moduleIds)

Definition at line 67 of file PixelDataFormatter.cc.

References modulesToUnpack_.

67 { modulesToUnpack_ = moduleIds; }
const ModuleIDSet * modulesToUnpack_
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_
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 368 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(), sipixelobjects::PixelROC::idInDetUnit(), edmNew::DetSetVector< T >::insert(), sipixelobjects::PixelFEDCabling::link(), MainPageGenerator::link, phase1_, edm::EDCollection< T >::push_back(), PixelMapPlotter::roc, PixelFEDChannel::roc_first, PixelFEDChannel::roc_last, and theCablingTree_.

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

Member Data Documentation

int PixelDataFormatter::allDetDigis_
private

Definition at line 108 of file PixelDataFormatter.h.

Referenced by formatRawData(), and PixelDataFormatter().

const SiPixelQuality* PixelDataFormatter::badPixelInfo_
private

Definition at line 103 of file PixelDataFormatter.h.

Referenced by interpretRawData(), and setQualityStatus().

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

Definition at line 110 of file PixelDataFormatter.h.

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

int PixelDataFormatter::hasDetDigis_
private

Definition at line 109 of file PixelDataFormatter.h.

Referenced by formatRawData(), and PixelDataFormatter().

bool PixelDataFormatter::includeErrors_
private

Definition at line 106 of file PixelDataFormatter.h.

Referenced by PixelDataFormatter(), and setErrorStatus().

int PixelDataFormatter::maxROCIndex_
private

Definition at line 112 of file PixelDataFormatter.h.

Referenced by interpretRawData(), and PixelDataFormatter().

const ModuleIDSet* PixelDataFormatter::modulesToUnpack_
private

Definition at line 104 of file PixelDataFormatter.h.

Referenced by interpretRawData(), and setModulesToUnpack().

bool PixelDataFormatter::phase1_
private
SiPixelFedCablingTree const* PixelDataFormatter::theCablingTree_
private

Definition at line 101 of file PixelDataFormatter.h.

Referenced by interpretRawData(), and unpackFEDErrors().

int PixelDataFormatter::theDigiCounter_
mutableprivate

Definition at line 98 of file PixelDataFormatter.h.

Referenced by formatRawData(), and nDigis().

const SiPixelFrameReverter* PixelDataFormatter::theFrameReverter_
private

Definition at line 102 of file PixelDataFormatter.h.

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

int PixelDataFormatter::theWordCounter_
mutableprivate
bool PixelDataFormatter::useQualityInfo_
private

Definition at line 107 of file PixelDataFormatter.h.

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