CMS 3D CMS Logo

SiStripRawToDigiUnpacker.cc
Go to the documentation of this file.
15 #include <iostream>
16 #include <sstream>
17 #include <iomanip>
18 #include <boost/format.hpp>
19 #include <ext/algorithm>
21 
22 namespace sistrip {
23 
24  RawToDigiUnpacker::RawToDigiUnpacker(int16_t appended_bytes,
25  int16_t fed_buffer_dump_freq,
26  int16_t fed_event_dump_freq,
27  int16_t trigger_fed_id,
28  bool using_fed_key,
29  bool unpack_bad_channels,
30  bool mark_missing_feds,
31  const uint32_t errorThreshold)
32  : headerBytes_(appended_bytes),
33  fedBufferDumpFreq_(fed_buffer_dump_freq),
34  fedEventDumpFreq_(fed_event_dump_freq),
35  triggerFedId_(trigger_fed_id),
36  useFedKey_(using_fed_key),
37  unpackBadChannels_(unpack_bad_channels),
38  markMissingFeds_(mark_missing_feds),
39  event_(0),
40  once_(true),
41  first_(true),
42  useDaqRegister_(false),
43  quiet_(true),
44  extractCm_(false),
45  doFullCorruptBufferChecks_(false),
46  doAPVEmulatorCheck_(true),
47  errorThreshold_(errorThreshold),
48  warnings_(sistrip::mlRawToDigi_, "[sistrip::RawToDigiUnpacker::createDigis]", edm::isDebugEnabled()) {
49  if (edm::isDebugEnabled()) {
50  LogTrace("SiStripRawToDigi") << "[sistrip::RawToDigiUnpacker::" << __func__ << "]"
51  << " Constructing object...";
52  }
53  if (unpackBadChannels_) {
54  edm::LogWarning("SiStripRawToDigi")
55  << "Warning: Unpacking of bad channels enabled. Only enable this if you know what you are doing. "
56  << std::endl;
57  }
58  }
59 
61  if (edm::isDebugEnabled()) {
62  LogTrace("SiStripRawToDigi") << "[sistrip::RawToDigiUnpacker::" << __func__ << "]"
63  << " Destructing object...";
64  }
65  }
66 
67  namespace {
68 
69  edm::RunningAverage localRA(10000);
70 
71  void maskFED(DetIdCollection& maskedModules, SiStripFedCabling::ConnsConstIterRange fedConnections) {
72  maskedModules.reserve(maskedModules.size() + fedConnections.size());
73  for (const auto& conn : fedConnections) {
74  if (conn.detId() && (conn.detId() != sistrip::invalid32_)) {
75  maskedModules.push_back(conn.detId()); //@@ Possible multiple entries (ok for Giovanni)
76  }
77  }
78  }
79  } // namespace
80 
82  const FEDRawDataCollection& buffers,
84  RawDigis& scope_mode,
85  RawDigis& virgin_raw,
86  RawDigis& proc_raw,
87  Digis& zero_suppr,
88  DetIdCollection& detids,
89  RawDigis& cm_values) {
90  // Clear done at the end
91  assert(zs_work_digis_.empty());
92  zs_work_digis_.reserve(localRA.upper());
93  // Reserve space in bad module list
94  detids.reserve(100);
95 
96  // Check if FEDs found in cabling map and event data
97  if (cabling.fedIds().empty()) {
98  warnings_.add("No FEDs found in cabling map!");
99  if (edm::isDebugEnabled()) {
100  // Check which FED ids have non-zero size buffers
101  std::vector<uint16_t> feds;
102  for (uint16_t ifed = FEDNumbering::MINSiStripFEDID; ifed < FEDNumbering::MAXSiStripFEDID; ifed++) {
103  if (ifed != triggerFedId_ && buffers.FEDData(static_cast<int>(ifed)).size()) {
104  feds.push_back(ifed);
105  }
106  }
107  LogTrace("SiStripRawToDigi") << "[sistrip::RawToDigiUnpacker::" << __func__ << "]"
108  << " Found " << feds.size() << " FED buffers with non-zero size!";
109  }
110  }
111 
112  // Flag for EventSummary update using DAQ register
113  bool first_fed = true;
114 
115  // Retrieve FED ids from cabling map and iterate through
116  std::vector<uint16_t>::const_iterator ifed = cabling.fedIds().begin();
117  for (; ifed != cabling.fedIds().end(); ifed++) {
118  // ignore trigger FED
119  if (*ifed == triggerFedId_) {
120  continue;
121  }
122 
123  // Retrieve FED raw data for given FED
124  const FEDRawData& input = buffers.FEDData(static_cast<int>(*ifed));
125 
126  // Some debug on FED buffer size
127  if (edm::isDebugEnabled()) {
128  if (first_ && input.data()) {
129  std::stringstream ss;
130  ss << "[sistrip::RawToDigiUnpacker::" << __func__ << "]"
131  << " Found FED id " << std::setw(4) << std::setfill(' ') << *ifed << " in FEDRawDataCollection"
132  << " with non-zero pointer 0x" << std::hex << std::setw(8) << std::setfill('0')
133  << reinterpret_cast<const uint32_t*>(input.data()) << std::dec << " and size " << std::setw(5)
134  << std::setfill(' ') << input.size() << " chars";
135  LogTrace("SiStripRawToDigi") << ss.str();
136  }
137  }
138 
139  // Dump of FEDRawData to stdout
140  if (edm::isDebugEnabled()) {
142  std::stringstream ss;
143  dumpRawData(*ifed, input, ss);
145  }
146  }
147 
148  // get the cabling connections for this FED
149  auto conns = cabling.fedConnections(*ifed);
150  // check FEDRawData pointer, size, and more
151  const auto st_buffer = preconstructCheckFEDBuffer(input);
152  // construct FEDBuffer
153  if (FEDBufferStatusCode::SUCCESS != st_buffer) {
154  if (FEDBufferStatusCode::BUFFER_NULL == st_buffer) {
155  warnings_.add("NULL pointer to FEDRawData for FED", (boost::format("id %1%") % *ifed).str());
156  } else if (!input.size()) {
157  warnings_.add("FEDRawData has zero size for FED", (boost::format("id %1%") % *ifed).str());
158  } else {
159  warnings_.add("Exception caught when creating FEDBuffer object for FED",
160  (boost::format("id %1%: %2%") % *ifed % st_buffer).str());
161  }
162  // FED buffer is bad and should not be unpacked. Skip this FED and mark all modules as bad.
163  maskFED(detids, conns);
164  continue;
165  }
167  const auto st_chan = buffer.findChannels();
168  if (FEDBufferStatusCode::SUCCESS != st_chan) {
169  warnings_.add("Exception caught when creating FEDBuffer object for FED",
170  (boost::format("id %1%: %2%") % *ifed % st_chan).str());
171  maskFED(detids, conns);
172  continue;
173  }
174  buffer.setLegacyMode(legacy_);
175  if ((!buffer.doChecks(true)) && (!unpackBadChannels_ || !buffer.checkNoFEOverflows())) {
176  warnings_.add("Exception caught when creating FEDBuffer object for FED",
177  (boost::format("id %1%: FED Buffer check fails for FED ID %1%.") % *ifed).str());
178  maskFED(detids, conns);
179  continue;
180  }
181  if (doFullCorruptBufferChecks_ && !buffer.doCorruptBufferChecks()) {
182  warnings_.add("Exception caught when creating FEDBuffer object for FED",
183  (boost::format("id %1%: FED corrupt buffer check fails for FED ID %1%.") % *ifed).str());
184  maskFED(detids, conns);
185  continue;
186  }
187 
188  // Check if EventSummary ("trigger FED info") needs updating
189  if (first_fed && useDaqRegister_) {
191  first_fed = false;
192  }
193 
194  // Check to see if EventSummary info is set
195  if (!quiet_ && !summary.isSet()) {
196  warnings_.add(
197  "EventSummary is not set correctly! Missing information from both \"trigger FED\" and \"DAQ registers\"!");
198  }
199 
200  // Check to see if event is to be analyzed according to EventSummary
201  if (!summary.valid()) {
202  if (edm::isDebugEnabled()) {
203  LogTrace("SiStripRawToDigi") << "[sistrip::RawToDigiUnpacker::" << __func__ << "]"
204  << " EventSummary is not valid: skipping...";
205  }
206  continue;
207  }
208 
210  const sistrip::FEDReadoutMode mode = buffer.readoutMode();
211  const sistrip::FEDLegacyReadoutMode lmode =
212  (legacy_) ? buffer.legacyReadoutMode() : sistrip::READOUT_MODE_LEGACY_INVALID;
213 
214  // Retrive run type
215  const sistrip::RunType runType_ = summary.runType();
216  if (runType_ == sistrip::APV_LATENCY || runType_ == sistrip::FINE_DELAY) {
217  useFedKey_ = false;
218  }
219 
220  // Dump of FED buffer
221  if (edm::isDebugEnabled()) {
223  std::stringstream ss;
224  buffer.dump(ss);
226  }
227  }
228 
229  // Iterate through FED channels, extract payload and create Digis
230  std::vector<FedChannelConnection>::const_iterator iconn = conns.begin();
231  for (; iconn != conns.end(); iconn++) {
233  uint16_t chan = iconn->fedCh();
234 
235  // Check if fed connection is valid
236  if (!iconn->isConnected()) {
237  continue;
238  }
239 
240  // Check DetId is valid (if to be used as key)
241  if (!useFedKey_ && (!iconn->detId() || iconn->detId() == sistrip::invalid32_)) {
242  continue;
243  }
244 
245  // Check FED channel
246  if (!buffer.channelGood(iconn->fedCh(), doAPVEmulatorCheck_)) {
247  if (!unpackBadChannels_ || !(buffer.fePresent(iconn->fedCh() / FEDCH_PER_FEUNIT) &&
248  buffer.feEnabled(iconn->fedCh() / FEDCH_PER_FEUNIT))) {
249  detids.push_back(iconn->detId()); //@@ Possible multiple entries (ok for Giovanni)
250  continue;
251  }
252  }
253 
254  // Determine whether FED key is inferred from cabling or channel loop
255  const uint32_t fed_key =
256  (summary.runType() == sistrip::FED_CABLING)
257  ? ((*ifed & sistrip::invalid_) << 16) | (chan & sistrip::invalid_)
258  : ((iconn->fedId() & sistrip::invalid_) << 16) | (iconn->fedCh() & sistrip::invalid_);
259 
260  // Determine whether DetId or FED key should be used to index digi containers
261  const uint32_t key = (useFedKey_ || (!legacy_ && mode == sistrip::READOUT_MODE_SCOPE) ||
263  ? fed_key
264  : iconn->detId();
265 
266  // Determine APV std::pair number (needed only when using DetId)
267  const uint16_t ipair = (useFedKey_ || (!legacy_ && mode == sistrip::READOUT_MODE_SCOPE) ||
269  ? 0
270  : iconn->apvPairNumber();
271 
272  const auto& fedChannel = buffer.channel(iconn->fedCh());
273 
274 #ifdef EDM_ML_DEBUG
275  std::stringstream smode;
276  if (!legacy_)
277  smode << mode;
278  else
279  smode << lmode;
280  LogDebug("SiStripRawToDigi") << "Unpacking FED " << *ifed << " channel " << iconn->fedCh()
281  << ((!legacy_) ? " " : " legacy ") << "data in mode " << smode.str()
282  << " for module " << iconn->detId() << " pair " << ipair;
283 #endif
285  Registry regItem(key, 0, zs_work_digis_.size(), 0);
286  const auto isNonLite = fedchannelunpacker::isNonLiteZS(mode, legacy_, lmode);
287  const uint8_t pCode = (isNonLite ? buffer.packetCode(legacy_, iconn->fedCh()) : 0);
288  if (isNonLite)
289  LogDebug("SiStripRawToDigi") << "Non-lite zero-suppressed mode. Packet code=0x" << std::hex
290  << uint16_t(pCode) << std::dec;
291  const auto st_ch = fedchannelunpacker::unpackZeroSuppressed(
292  fedChannel, std::back_inserter(zs_work_digis_), ipair * 256, isNonLite, mode, legacy_, lmode, pCode);
295  warnings_.add((boost::format("Invalid packet code %1$#x for zero-suppressed data") % uint16_t(pCode)).str(),
296  (boost::format("FED %1% channel %2%") % *ifed % iconn->fedCh()).str());
297  } else if (fedchannelunpacker::StatusCode::SUCCESS != st_ch) {
298  warnings_.add("Clusters are not ordered",
299  (boost::format("FED %1% channel %2%: %3%") % *ifed % iconn->fedCh() % toString(st_ch)).str());
300  detids.push_back(iconn->detId()); //@@ Possible multiple entries (ok for Giovanni)
301  continue;
302  }
303  if (regItem.index != zs_work_digis_.size()) {
304  regItem.length = zs_work_digis_.size() - regItem.index;
305  regItem.first = zs_work_digis_[regItem.index].strip();
306  zs_work_registry_.push_back(regItem);
307  }
308  // Common mode values
309  if (isNonLite && extractCm_) {
310  if ((pCode == PACKET_CODE_ZERO_SUPPRESSED) || (pCode == PACKET_CODE_ZERO_SUPPRESSED10) ||
312  Registry regItem2(key, 2 * ipair, cm_work_digis_.size(), 2);
313  cm_work_digis_.push_back(SiStripRawDigi(fedChannel.cmMedian(0)));
314  cm_work_digis_.push_back(SiStripRawDigi(fedChannel.cmMedian(1)));
315  cm_work_registry_.push_back(regItem2);
316  } else {
317  detids.push_back(iconn->detId()); //@@ Possible multiple entries (ok for Giovanni)
318  warnings_.add("Problem extracting common modes",
319  (boost::format("FED %1% channel %2%:\n Request for CM median from channel with non-ZS "
320  "packet code. Packet code is %3%.") %
321  *ifed % iconn->fedCh() % pCode)
322  .str());
323  }
324  }
325  } else {
328  Registry regItem(key, 256 * ipair, virgin_work_digis_.size(), 0);
329  LogDebug("SiStripRawToDigi") << "Virgin raw packet code: 0x" << std::hex
330  << uint16_t(buffer.packetCode(legacy_)) << " 0x"
331  << uint16_t(fedChannel.packetCode()) << std::dec;
333  fedChannel, std::back_inserter(virgin_work_digis_), buffer.packetCode(legacy_));
334  if (regItem.index != virgin_work_digis_.size()) {
335  regItem.length = virgin_work_digis_.size() - regItem.index;
336  virgin_work_registry_.push_back(regItem);
337  }
338  } else if (fedchannelunpacker::isProcessedRaw(mode, legacy_, lmode)) {
339  Registry regItem(key, 256 * ipair, proc_work_digis_.size(), 0);
340  st_ch = fedchannelunpacker::unpackProcessedRaw(fedChannel, std::back_inserter(proc_work_digis_));
341  if (regItem.index != proc_work_digis_.size()) {
342  regItem.length = proc_work_digis_.size() - regItem.index;
343  proc_work_registry_.push_back(regItem);
344  }
345  } else if (fedchannelunpacker::isScopeMode(mode, legacy_, lmode)) {
346  Registry regItem(key, 0, scope_work_digis_.size(), 0);
347  st_ch = fedchannelunpacker::unpackScope(fedChannel, std::back_inserter(scope_work_digis_));
348  if (regItem.index != scope_work_digis_.size()) {
349  regItem.length = scope_work_digis_.size() - regItem.index;
350  scope_work_registry_.push_back(regItem);
351  }
352  } else { // Unknown readout mode! => assume scope mode
353  warnings_.add((boost::format("Unknown FED readout mode (%1%)! Assuming SCOPE MODE...") % mode).str());
354  Registry regItem(key, 0, scope_work_digis_.size(), 0);
355  st_ch = fedchannelunpacker::unpackScope(fedChannel, std::back_inserter(scope_work_digis_));
356  if (regItem.index != scope_work_digis_.size()) {
357  regItem.length = scope_work_digis_.size() - regItem.index;
358  scope_work_registry_.push_back(regItem);
359  if (edm::isDebugEnabled()) {
360  std::stringstream ss;
361  ss << "Extracted " << regItem.length
362  << " SCOPE MODE digis (samples[0] = " << scope_work_digis_[regItem.index] << ") from FED id/ch "
363  << iconn->fedId() << "/" << iconn->fedCh();
364  LogTrace("SiStripRawToDigi") << ss.str();
365  }
366  } else {
367  warnings_.add("No SM digis found!");
368  }
369  }
371  warnings_.add(toString(st_ch), (boost::format("FED %1% channel %2%:") % *ifed % iconn->fedCh()).str());
372  }
373  }
374  } // channel loop
375  } // fed loop
376 
377  // bad channels warning
378  unsigned int detIdsSize = detids.size();
379  if (edm::isDebugEnabled() && detIdsSize) {
380  std::ostringstream ss;
381  ss << "[sistrip::RawToDigiUnpacker::" << __func__ << "]"
382  << " Problems were found in data and " << detIdsSize << " channels could not be unpacked. "
383  << "See output of FED Hardware monitoring for more information. ";
385  }
386  if ((errorThreshold_ != 0) && (detIdsSize > errorThreshold_)) {
387  edm::LogError("TooManyErrors") << "Total number of errors = " << detIdsSize;
388  }
389 
390  // update DetSetVectors
391  update(scope_mode, virgin_raw, proc_raw, zero_suppr, cm_values);
392 
393  // increment event counter
394  event_++;
395 
396  // no longer first event!
397  if (first_) {
398  first_ = false;
399  }
400 
401  // final cleanup, just in case
403  }
404 
406  RawDigis& scope_mode, RawDigis& virgin_raw, RawDigis& proc_raw, Digis& zero_suppr, RawDigis& common_mode) {
407  if (!zs_work_registry_.empty()) {
408  std::sort(zs_work_registry_.begin(), zs_work_registry_.end());
409  std::vector<edm::DetSet<SiStripDigi> > sorted_and_merged;
410  sorted_and_merged.reserve(std::min(zs_work_registry_.size(), size_t(17000)));
411 
412  bool errorInData = false;
413  std::vector<Registry>::iterator it = zs_work_registry_.begin(), it2 = it + 1, end = zs_work_registry_.end();
414  while (it < end) {
415  sorted_and_merged.push_back(edm::DetSet<SiStripDigi>(it->detid));
416  std::vector<SiStripDigi>& digis = sorted_and_merged.back().data;
417  // first count how many digis we have
418  size_t len = it->length;
419  for (it2 = it + 1; (it2 != end) && (it2->detid == it->detid); ++it2) {
420  len += it2->length;
421  }
422  // reserve memory
423  digis.reserve(len);
424  // push them in
425  for (it2 = it + 0; (it2 != end) && (it2->detid == it->detid); ++it2) {
426  digis.insert(digis.end(), &zs_work_digis_[it2->index], &zs_work_digis_[it2->index + it2->length]);
427  }
428  it = it2;
429  }
430 
431  // check sorting
432  if (!__gnu_cxx::is_sorted(sorted_and_merged.begin(), sorted_and_merged.end())) {
433  // this is an error in the code: i DID sort it already!
434  throw cms::Exception("Bug Found")
435  << "Container must be already sorted!\nat " << __FILE__ << ", line " << __LINE__ << "\n";
436  }
437 
438  std::vector<edm::DetSet<SiStripDigi> >::iterator iii = sorted_and_merged.begin();
439  std::vector<edm::DetSet<SiStripDigi> >::iterator jjj = sorted_and_merged.end();
440  for (; iii != jjj; ++iii) {
441  if (!__gnu_cxx::is_sorted(iii->begin(), iii->end())) {
442  // this might be an error in the data, if the raws from one FED are not sorted
443  iii->clear();
444  errorInData = true;
445  }
446  }
447 
448  // output error
449  if (errorInData)
450  edm::LogWarning("CorruptData")
451  << "Some modules contained corrupted ZS raw data, and have been skipped in unpacking\n";
452 
453  // make output DetSetVector
454  edm::DetSetVector<SiStripDigi> zero_suppr_dsv(sorted_and_merged, true);
455  zero_suppr.swap(zero_suppr_dsv);
456  }
457 
458  // Populate final DetSetVector container with VR data
459  if (!virgin_work_registry_.empty()) {
460  std::sort(virgin_work_registry_.begin(), virgin_work_registry_.end());
461 
462  std::vector<edm::DetSet<SiStripRawDigi> > sorted_and_merged;
463  sorted_and_merged.reserve(std::min(virgin_work_registry_.size(), size_t(17000)));
464 
465  bool errorInData = false;
466  std::vector<Registry>::iterator it = virgin_work_registry_.begin(), it2, end = virgin_work_registry_.end();
467  while (it < end) {
468  sorted_and_merged.push_back(edm::DetSet<SiStripRawDigi>(it->detid));
469  std::vector<SiStripRawDigi>& digis = sorted_and_merged.back().data;
470 
471  bool isDetOk = true;
472  // first count how many digis we have
473  int maxFirstStrip = it->first;
474  for (it2 = it + 1; (it2 != end) && (it2->detid == it->detid); ++it2) {
475  // duplicated APV or data corruption. DO NOT 'break' here!
476  if (it2->first <= maxFirstStrip) {
477  isDetOk = false;
478  continue;
479  }
480  maxFirstStrip = it2->first;
481  }
482  if (!isDetOk) {
483  errorInData = true;
484  it = it2;
485  continue;
486  } // skip whole det
487 
488  // make room for 256 * (max_apv_pair + 1) Raw Digis
489  digis.resize(maxFirstStrip + 256);
490  // push them in
491  for (it2 = it + 0; (it2 != end) && (it2->detid == it->detid); ++it2) {
492  // data corruption. DO NOT 'break' here
493  if (it->length != 256) {
494  isDetOk = false;
495  continue;
496  }
497  std::copy(&virgin_work_digis_[it2->index], &virgin_work_digis_[it2->index + it2->length], &digis[it2->first]);
498  }
499  if (!isDetOk) {
500  errorInData = true;
501  digis.clear();
502  it = it2;
503  continue;
504  } // skip whole det
505  it = it2;
506  }
507 
508  // output error
509  if (errorInData)
510  edm::LogWarning("CorruptData")
511  << "Some modules contained corrupted virgin raw data, and have been skipped in unpacking\n";
512 
513  // check sorting
514  if (!__gnu_cxx::is_sorted(sorted_and_merged.begin(), sorted_and_merged.end())) {
515  // this is an error in the code: i DID sort it already!
516  throw cms::Exception("Bug Found")
517  << "Container must be already sorted!\nat " << __FILE__ << ", line " << __LINE__ << "\n";
518  }
519 
520  // make output DetSetVector
521  edm::DetSetVector<SiStripRawDigi> virgin_raw_dsv(sorted_and_merged, true);
522  virgin_raw.swap(virgin_raw_dsv);
523  }
524 
525  // Populate final DetSetVector container with VR data
526  if (!proc_work_registry_.empty()) {
527  std::sort(proc_work_registry_.begin(), proc_work_registry_.end());
528 
529  std::vector<edm::DetSet<SiStripRawDigi> > sorted_and_merged;
530  sorted_and_merged.reserve(std::min(proc_work_registry_.size(), size_t(17000)));
531 
532  bool errorInData = false;
533  std::vector<Registry>::iterator it = proc_work_registry_.begin(), it2, end = proc_work_registry_.end();
534  while (it < end) {
535  sorted_and_merged.push_back(edm::DetSet<SiStripRawDigi>(it->detid));
536  std::vector<SiStripRawDigi>& digis = sorted_and_merged.back().data;
537 
538  bool isDetOk = true;
539  // first count how many digis we have
540  int maxFirstStrip = it->first;
541  for (it2 = it + 1; (it2 != end) && (it2->detid == it->detid); ++it2) {
542  // duplicated APV or data corruption. DO NOT 'break' here!
543  if (it2->first <= maxFirstStrip) {
544  isDetOk = false;
545  continue;
546  }
547  maxFirstStrip = it2->first;
548  }
549  // skip whole det
550  if (!isDetOk) {
551  errorInData = true;
552  it = it2;
553  continue;
554  }
555 
556  // make room for 256 * (max_apv_pair + 1) Raw Digis
557  digis.resize(maxFirstStrip + 256);
558  // push them in
559  for (it2 = it + 0; (it2 != end) && (it2->detid == it->detid); ++it2) {
560  // data corruption. DO NOT 'break' here
561  if (it->length != 256) {
562  isDetOk = false;
563  continue;
564  }
565  std::copy(&proc_work_digis_[it2->index], &proc_work_digis_[it2->index + it2->length], &digis[it2->first]);
566  }
567  // skip whole det
568  if (!isDetOk) {
569  errorInData = true;
570  digis.clear();
571  it = it2;
572  continue;
573  }
574  it = it2;
575  }
576 
577  // output error
578  if (errorInData)
579  edm::LogWarning("CorruptData")
580  << "Some modules contained corrupted proc raw data, and have been skipped in unpacking\n";
581 
582  // check sorting
583  if (!__gnu_cxx::is_sorted(sorted_and_merged.begin(), sorted_and_merged.end())) {
584  // this is an error in the code: i DID sort it already!
585  throw cms::Exception("Bug Found")
586  << "Container must be already sorted!\nat " << __FILE__ << ", line " << __LINE__ << "\n";
587  }
588 
589  // make output DetSetVector
590  edm::DetSetVector<SiStripRawDigi> proc_raw_dsv(sorted_and_merged, true);
591  proc_raw.swap(proc_raw_dsv);
592  }
593 
594  // Populate final DetSetVector container with SM data
595  if (!scope_work_registry_.empty()) {
596  std::sort(scope_work_registry_.begin(), scope_work_registry_.end());
597 
598  std::vector<edm::DetSet<SiStripRawDigi> > sorted_and_merged;
599  sorted_and_merged.reserve(scope_work_registry_.size());
600 
601  bool errorInData = false;
602  std::vector<Registry>::iterator it, end;
603  for (it = scope_work_registry_.begin(), end = scope_work_registry_.end(); it != end; ++it) {
604  sorted_and_merged.push_back(edm::DetSet<SiStripRawDigi>(it->detid));
605  std::vector<SiStripRawDigi>& digis = sorted_and_merged.back().data;
606  digis.insert(digis.end(), &scope_work_digis_[it->index], &scope_work_digis_[it->index + it->length]);
607 
608  if ((it + 1 != end) && (it->detid == (it + 1)->detid)) {
609  errorInData = true;
610  // let's skip *all* the detsets for that key, as we don't know which is the correct one!
611  do {
612  ++it;
613  } while ((it + 1 != end) && (it->detid == (it + 1)->detid));
614  }
615  }
616 
617  // output error
618  if (errorInData)
619  edm::LogWarning("CorruptData")
620  << "Some fed keys contained corrupted scope mode data, and have been skipped in unpacking\n";
621 
622  // check sorting
623  if (!__gnu_cxx::is_sorted(sorted_and_merged.begin(), sorted_and_merged.end())) {
624  // this is an error in the code: i DID sort it already!
625  throw cms::Exception("Bug Found")
626  << "Container must be already sorted!\nat " << __FILE__ << ", line " << __LINE__ << "\n";
627  }
628 
629  // make output DetSetVector
630  edm::DetSetVector<SiStripRawDigi> scope_mode_dsv(sorted_and_merged, true);
631  scope_mode.swap(scope_mode_dsv);
632  }
633 
634  // Populate DetSetVector with Common Mode values
635  if (extractCm_) {
636  // Populate final DetSetVector container with VR data
637  if (!cm_work_registry_.empty()) {
638  std::sort(cm_work_registry_.begin(), cm_work_registry_.end());
639 
640  std::vector<edm::DetSet<SiStripRawDigi> > sorted_and_merged;
641  sorted_and_merged.reserve(std::min(cm_work_registry_.size(), size_t(17000)));
642 
643  bool errorInData = false;
644  std::vector<Registry>::iterator it = cm_work_registry_.begin(), it2, end = cm_work_registry_.end();
645  while (it < end) {
646  sorted_and_merged.push_back(edm::DetSet<SiStripRawDigi>(it->detid));
647  std::vector<SiStripRawDigi>& digis = sorted_and_merged.back().data;
648 
649  bool isDetOk = true;
650  // first count how many digis we have
651  int maxFirstStrip = it->first;
652  for (it2 = it + 1; (it2 != end) && (it2->detid == it->detid); ++it2) {
653  // duplicated APV or data corruption. DO NOT 'break' here!
654  if (it2->first <= maxFirstStrip) {
655  isDetOk = false;
656  continue;
657  }
658  maxFirstStrip = it2->first;
659  }
660  if (!isDetOk) {
661  errorInData = true;
662  it = it2;
663  continue;
664  } // skip whole det
665 
666  // make room for 2 * (max_apv_pair + 1) Common mode values
667  digis.resize(maxFirstStrip + 2);
668  // push them in
669  for (it2 = it + 0; (it2 != end) && (it2->detid == it->detid); ++it2) {
670  // data corruption. DO NOT 'break' here
671  if (it->length != 2) {
672  isDetOk = false;
673  continue;
674  }
675  std::copy(&cm_work_digis_[it2->index], &cm_work_digis_[it2->index + it2->length], &digis[it2->first]);
676  }
677  if (!isDetOk) {
678  errorInData = true;
679  digis.clear();
680  it = it2;
681  continue;
682  } // skip whole det
683  it = it2;
684  }
685 
686  // output error
687  if (errorInData)
688  edm::LogWarning("CorruptData")
689  << "Some modules contained corrupted common mode data, and have been skipped in unpacking\n";
690 
691  // check sorting
692  if (!__gnu_cxx::is_sorted(sorted_and_merged.begin(), sorted_and_merged.end())) {
693  // this is an error in the code: i DID sort it already!
694  throw cms::Exception("Bug Found")
695  << "Container must be already sorted!\nat " << __FILE__ << ", line " << __LINE__ << "\n";
696  }
697 
698  // make output DetSetVector
699  edm::DetSetVector<SiStripRawDigi> common_mode_dsv(sorted_and_merged, true);
700  common_mode.swap(common_mode_dsv);
701  }
702  }
703  }
704 
706  // Clear working areas and registries
707 
708  localRA.update(zs_work_digis_.size());
709  zs_work_registry_.clear();
710  zs_work_digis_.clear();
711  zs_work_digis_.shrink_to_fit();
712  assert(zs_work_digis_.capacity() == 0);
713  virgin_work_registry_.clear();
714  virgin_work_digis_.clear();
715  proc_work_registry_.clear();
716  proc_work_digis_.clear();
717  scope_work_registry_.clear();
718  scope_work_digis_.clear();
719  cm_work_registry_.clear();
720  cm_work_digis_.clear();
721  }
722 
725  const uint32_t& event) {
726  // Pointer to data (recast as 32-bit words) and number of 32-bit words
727  const uint32_t* data_u32 = nullptr;
728  uint32_t size_u32 = 0;
729 
730  // Search mode
731  if (triggerFedId_ < 0) {
732  uint16_t ifed = 0;
733  while (triggerFedId_ < 0 && ifed < 1 + FEDNumbering::lastFEDId()) {
734  const FEDRawData& trigger_fed = buffers.FEDData(ifed);
735  if (trigger_fed.data() && trigger_fed.size()) {
736  const uint8_t* temp = trigger_fed.data();
737  data_u32 = reinterpret_cast<const uint32_t*>(temp) + FEDHeader::length / sizeof(uint32_t) + 1;
738  size_u32 = trigger_fed.size() / sizeof(uint32_t) - FEDHeader::length / sizeof(uint32_t) - 1;
739  const FEDTrailer fedTrailer(temp + trigger_fed.size() - FEDTrailer::length);
740  if (fedTrailer.conscheck() == 0xDEADFACE) {
741  triggerFedId_ = ifed;
742  if (edm::isDebugEnabled()) {
743  std::stringstream ss;
744  ss << "[sistrip::RawToDigiUnpacker::" << __func__ << "]"
745  << " Search mode for 'trigger FED' activated!"
746  << " Found 'trigger FED' info with id " << triggerFedId_;
747  LogTrace("SiStripRawToDigi") << ss.str();
748  }
749  }
750  }
751  ifed++;
752  }
753  if (triggerFedId_ < 0) {
754  triggerFedId_ = 0;
755  if (edm::isDebugEnabled()) {
756  std::stringstream ss;
757  ss << "[sistrip::RawToDigiUnpacker::" << __func__ << "]"
758  << " Search mode for 'trigger FED' activated!"
759  << " 'Trigger FED' info not found!";
761  }
762  }
763  }
764 
765  // "Trigger FED" id given in .cfg file
766  else if (triggerFedId_ > 0) {
767  const FEDRawData& trigger_fed = buffers.FEDData(triggerFedId_);
768  if (trigger_fed.data() && trigger_fed.size()) {
769  const uint8_t* temp = trigger_fed.data();
770  data_u32 = reinterpret_cast<const uint32_t*>(temp) + FEDHeader::length / sizeof(uint32_t) + 1;
771  size_u32 = trigger_fed.size() / sizeof(uint32_t) - FEDHeader::length / sizeof(uint32_t) - 1;
772  const FEDTrailer fedTrailer(temp + trigger_fed.size() - FEDTrailer::length);
773  if (fedTrailer.conscheck() != 0xDEADFACE) {
774  if (edm::isDebugEnabled()) {
775  edm::LogWarning(sistrip::mlRawToDigi_) << "[sistrip::RawToDigiUnpacker::" << __func__ << "]"
776  << " Unexpected stamp found in DAQ trailer (ie, not 0xDEADFACE)!"
777  << " Buffer appears not to contain 'trigger FED' data!";
778  }
779  triggerFedId_ = 0;
780  }
781  }
782 
783  } else {
784  triggerFedId_ = 0;
785  data_u32 = nullptr;
786  size_u32 = 0;
787  }
788 
789  // Populate summary object with commissioning information
790  if (triggerFedId_ > 0) {
791  // Some checks
792  if (!data_u32) {
793  if (edm::isDebugEnabled()) {
794  std::stringstream ss;
795  ss << "[sistrip::RawToDigiUnpacker::" << __func__ << "]"
796  << " NULL pointer to 'trigger FED' data";
798  }
799  return;
800  }
801  if (size_u32 < sizeof(TFHeaderDescription) / sizeof(uint32_t)) {
802  if (edm::isDebugEnabled()) {
803  std::stringstream ss;
804  ss << "[sistrip::RawToDigiUnpacker::" << __func__ << "]"
805  << " Unexpected 'Trigger FED' data size [32-bit words]: " << size_u32;
807  }
808  return;
809  }
810 
811  // Write event-specific data to event
812  const TFHeaderDescription* header = (const TFHeaderDescription*)data_u32;
813  summary.event(static_cast<uint32_t>(header->getFedEventNumber()));
814  summary.bx(static_cast<uint32_t>(header->getBunchCrossing()));
815 
816  // Write commissioning information to event
817  uint32_t hsize = sizeof(TFHeaderDescription) / sizeof(uint32_t);
818  const uint32_t* head = &data_u32[hsize];
819  summary.commissioningInfo(head, event);
820  summary.triggerFed(triggerFedId_);
821  }
822 
823  // Some debug
824  if (summary.isSet() && once_) {
825  if (edm::isDebugEnabled()) {
826  std::stringstream ss;
827  ss << "[sistrip::RawToDigiUnpacker::" << __func__ << "]"
828  << " EventSummary built from \"trigger FED\":" << std::endl
829  << summary;
830  LogTrace("SiStripRawToDigi") << ss.str();
831  }
832  once_ = false;
833  }
834  }
835 
837  // Check size of input buffer
838  if (input.size() < 24) {
839  output.resize(input.size()); // Return UNadjusted buffer start position and size
840  memcpy(output.data(), input.data(), input.size());
841  if (edm::isDebugEnabled()) {
842  std::stringstream ss;
843  ss << "[sistrip::RawToDigiUnpacker::" << __func__ << "] "
844  << "Input FEDRawData with FED id " << fed_id << " has size " << input.size();
846  }
847  return;
848  }
849 
850  // Iterator through buffer to find DAQ header
851  bool found = false;
852  uint16_t ichar = 0;
853  while (ichar < input.size() - 16 && !found) {
854  uint16_t offset =
855  headerBytes_ < 0 ? ichar : headerBytes_; // Negative value means use "search mode" to find DAQ header
856  const uint32_t* input_u32 = reinterpret_cast<const uint32_t*>(input.data() + offset);
857  const uint32_t* fed_trailer = reinterpret_cast<const uint32_t*>(input.data() + input.size() - 8);
858 
859  // see info on FED 32-bit swapping at end-of-file
860 
861  bool old_vme_header = (input_u32[0] & 0xF0000000) == 0x50000000 && (fed_trailer[0] & 0xF0000000) == 0xA0000000 &&
862  ((fed_trailer[0] & 0x00FFFFFF) * 0x8) == (input.size() - offset);
863 
864  bool old_slink_header = (input_u32[1] & 0xF0000000) == 0x50000000 &&
865  (fed_trailer[1] & 0xF0000000) == 0xA0000000 &&
866  ((fed_trailer[1] & 0x00FFFFFF) * 0x8) == (input.size() - offset);
867 
868  bool old_slink_payload = (input_u32[3] & 0xFF000000) == 0xED000000;
869 
870  bool new_buffer_format = (input_u32[2] & 0xFF000000) == 0xC5000000;
871 
872  if (old_vme_header) {
873  // Found DAQ header at byte position 'offset'
874  found = true;
875  output.resize(input.size() - offset);
876  memcpy(output.data(), // target
877  input.data() + offset, // source
878  input.size() - offset); // nbytes
879  if (headerBytes_ < 0) {
880  if (edm::isDebugEnabled()) {
881  std::stringstream ss;
882  ss << "[sistrip::RawToDigiUnpacker::" << __func__ << "]"
883  << " Buffer for FED id " << fed_id << " has been found at byte position " << offset << " with a size of "
884  << input.size() - offset << " bytes."
885  << " Adjust the configurable 'AppendedBytes' to " << offset;
886  LogTrace("SiStripRawToDigi") << ss.str();
887  }
888  }
889 
890  } else if (old_slink_header) {
891  if (old_slink_payload) {
892  // Found DAQ header (with MSB and LSB 32-bit words swapped) at byte position 'offset'
893  found = true;
894  output.resize(input.size() - offset);
895  uint32_t* output_u32 = reinterpret_cast<uint32_t*>(output.data());
896  uint16_t iter = offset;
897  while (iter < output.size() / sizeof(uint32_t)) {
898  output_u32[iter] = input_u32[iter + 1];
899  output_u32[iter + 1] = input_u32[iter];
900  iter += 2;
901  }
902  if (headerBytes_ < 0) {
903  if (edm::isDebugEnabled()) {
904  std::stringstream ss;
905  ss << "[sistrip::RawToDigiUnpacker::" << __func__ << "]"
906  << " Buffer (with MSB and LSB 32-bit words swapped) for FED id " << fed_id
907  << " has been found at byte position " << offset << " with a size of " << output.size() << " bytes."
908  << " Adjust the configurable 'AppendedBytes' to " << offset;
909  LogTrace("SiStripRawToDigi") << ss.str();
910  }
911  }
912 
913  } else if (new_buffer_format) {
914  // Found DAQ header at byte position 'offset'
915  found = true;
916  output.resize(input.size() - offset);
917  memcpy(output.data(), // target
918  input.data() + offset, // source
919  input.size() - offset); // nbytes
920  if (headerBytes_ < 0) {
921  if (edm::isDebugEnabled()) {
922  std::stringstream ss;
923  ss << "[sistrip::RawToDigiUnpacker::" << __func__ << "]"
924  << " Buffer for FED id " << fed_id << " has been found at byte position " << offset
925  << " with a size of " << input.size() - offset << " bytes."
926  << " Adjust the configurable 'AppendedBytes' to " << offset;
927  LogTrace("SiStripRawToDigi") << ss.str();
928  }
929  }
930 
931  } else {
932  headerBytes_ < 0 ? found = false : found = true;
933  }
934  } else {
935  headerBytes_ < 0 ? found = false : found = true;
936  }
937  ichar++;
938  }
939 
940  // Check size of output buffer
941  if (output.size() == 0) {
942  // Did not find DAQ header after search => return buffer with null size
943  output.resize(0); //@@ NULL SIZE
944  memcpy(output.data(), input.data(), 0); //@@ NULL SIZE
945  if (edm::isDebugEnabled()) {
946  std::stringstream ss;
947  if (headerBytes_ < 0) {
948  ss << "[sistrip::RawToDigiUnpacker::" << __func__ << "]"
949  << " DAQ header not found within buffer for FED id: " << fed_id;
950  } else {
951  const uint32_t* input_u32 = reinterpret_cast<const uint32_t*>(input.data());
952  ss << "[sistrip::RawToDigiUnpacker::" << __func__ << "]"
953  << " DAQ header not found at expected location for FED id: " << fed_id << std::endl
954  << " First 64-bit word of buffer is 0x" << std::hex << std::setfill('0') << std::setw(8) << input_u32[0]
955  << std::setfill('0') << std::setw(8) << input_u32[1] << std::dec << std::endl
956  << " Adjust 'AppendedBytes' configurable to '-1' to activate 'search mode'";
957  }
959  }
960 
961  } else if (output.size() < 24) { // Found DAQ header after search, but too few words
962 
963  if (edm::isDebugEnabled()) {
964  std::stringstream ss;
965  ss << "[sistrip::RawToDigiUnpacker::" << __func__ << "]"
966  << " Unexpected buffer size! FEDRawData with FED id " << fed_id << " has size " << output.size();
968  }
969  }
970  }
971 
973  summary.event(fed.daqHeader().l1ID());
974  summary.bx(fed.daqHeader().bxID());
975 
976  // Retrieve contents of DAQ registers
977 
978  sistrip::FEDDAQEventType readout_mode = fed.daqEventType();
979  uint32_t daq1 = sistrip::invalid32_;
980  uint32_t daq2 = sistrip::invalid32_;
981 
983  const sistrip::FEDFullDebugHeader* header = nullptr;
984  header = dynamic_cast<const sistrip::FEDFullDebugHeader*>(fed.feHeader());
985  daq1 = static_cast<uint32_t>(header->daqRegister());
986  daq2 = static_cast<uint32_t>(header->daqRegister2());
987  }
988 
989  // If FED DAQ registers contain info, update (and possibly overwrite) EventSummary
990  if (daq1 != 0 && daq1 != sistrip::invalid32_) {
991  summary.triggerFed(triggerFedId_);
992  summary.fedReadoutMode(readout_mode);
993  summary.commissioningInfo(daq1, daq2);
994 
995  if (summary.isSet() && once_) {
996  if (edm::isDebugEnabled()) {
997  std::stringstream ss;
998  ss << "[sistrip::RawToDigiUnpacker::" << __func__ << "]"
999  << " EventSummary built from FED DAQ registers:" << std::endl
1000  << summary;
1001  LogTrace("SiStripRawToDigi") << ss.str();
1002  }
1003  once_ = false;
1004  }
1005  }
1006  }
1007 
1008  void RawToDigiUnpacker::dumpRawData(uint16_t fed_id, const FEDRawData& buffer, std::stringstream& ss) {
1009  ss << "[sistrip::RawToDigiUnpacker::" << __func__ << "]"
1010  << " Dump of buffer for FED id " << fed_id << std::endl
1011  << " Buffer contains " << buffer.size() << " bytes (NB: payload is byte-swapped)" << std::endl;
1012 
1013  if (false) {
1014  const uint32_t* buffer_u32 = reinterpret_cast<const uint32_t*>(buffer.data());
1015  unsigned int empty = 0;
1016 
1017  ss << "Byte-> 4 5 6 7 0 1 2 3\n";
1018  for (uint32_t i = 0; i < buffer.size() / 8; i++) {
1019  unsigned int temp0 = buffer_u32[i * 2] & sistrip::invalid32_;
1020  unsigned int temp1 = buffer_u32[i * 2 + 1] & sistrip::invalid32_;
1021  if (!temp0 && !temp1) {
1022  empty++;
1023  } else {
1024  if (empty) {
1025  ss << " [ empty words ]" << std::endl;
1026  empty = 0;
1027  }
1028  ss << std::dec << std::setfill(' ') << std::setw(6) << i * 8 << ": " << std::hex << std::setfill('0')
1029  << std::setw(8) << temp0 << std::setfill('0') << std::setw(8) << temp1 << std::dec << std::endl;
1030  }
1031  }
1032 
1033  } else {
1034  ss << " Byte | <---- Byte order ----< | Byte" << std::endl;
1035  ss << " cntr | 7 6 5 4 3 2 1 0 | cntr" << std::endl;
1036  for (uint32_t i = 0; i < buffer.size() / 8; i++) {
1037  //if ( i>=20 && ((i+4)<(buffer.size()/8)) ) { continue; }
1038  uint16_t tmp0 = buffer.data()[i * 8 + 0] & 0xFF;
1039  uint16_t tmp1 = buffer.data()[i * 8 + 1] & 0xFF;
1040  uint16_t tmp2 = buffer.data()[i * 8 + 2] & 0xFF;
1041  uint16_t tmp3 = buffer.data()[i * 8 + 3] & 0xFF;
1042  uint16_t tmp4 = buffer.data()[i * 8 + 4] & 0xFF;
1043  uint16_t tmp5 = buffer.data()[i * 8 + 5] & 0xFF;
1044  uint16_t tmp6 = buffer.data()[i * 8 + 6] & 0xFF;
1045  uint16_t tmp7 = buffer.data()[i * 8 + 7] & 0xFF;
1046  // if ( !tmp0 && !tmp1 && !tmp2 && !tmp3 &&
1047  // !tmp4 && !tmp5 && !tmp6 && !tmp7 ) { empty++; }
1048  // else {
1049  // if ( empty ) {
1050  // ss << " [.."
1051  // << std::dec << std::setfill('.') << std::setw(4) << empty
1052  // << " null words....]" << std::endl;
1053  // empty = 0;
1054  // }
1055  ss << std::dec << std::setfill(' ') << std::setw(6) << i * 8 + 7 << " : " << std::hex << std::setfill('0')
1056  << std::setw(2) << tmp7 << " " << std::setfill('0') << std::setw(2) << tmp6 << " " << std::setfill('0')
1057  << std::setw(2) << tmp5 << " " << std::setfill('0') << std::setw(2) << tmp4 << " " << std::setfill('0')
1058  << std::setw(2) << tmp3 << " " << std::setfill('0') << std::setw(2) << tmp2 << " " << std::setfill('0')
1059  << std::setw(2) << tmp1 << " " << std::setfill('0') << std::setw(2) << tmp0 << std::dec << " :"
1060  << std::setfill(' ') << std::setw(6) << i * 8 << std::endl;
1061  // }
1062  }
1063  }
1064  ss << "[sistrip::RawToDigiUnpacker::" << __func__ << "]"
1065  << " End of FED buffer";
1066  }
1067 } // namespace sistrip
1068 
1069 /*
1070 
1071 Some info on FED buffer 32-bit word swapping.
1072 
1073 Table below indicates if data are swapped relative to the "old"
1074 VME format (as originally expected by the Fed9UEvent class).
1075 
1076 -------------------------------------------
1077 | SWAPPED? | DATA FORMAT |
1078 | (wrt "OLD") | OLD (0xED) | NEW (0xC5) |
1079 | | VME | SLINK | VME | SLINK |
1080 -------------------------------------------
1081 | DAQ HEADER | N | Y | Y | Y |
1082 | TRK HEADER | N | Y | N | N |
1083 | PAYLOAD | N | Y | N | N |
1084 | DAQ TRAILER | N | Y | Y | Y |
1085 -------------------------------------------
1086 
1087 So, in code, we check in code order of bytes in DAQ header/trailer only:
1088 -> if "old_vme_header", then old format read out via vme, so do nothing.
1089 -> else if "old_slink_header", then data may be wrapped, so check additionally the TRK header:
1090 ---> if "old_slink_payload", then old format read out via slink, so swap all data;
1091 ---> else if "new_buffer_format", then new format, handled internally by Fed9UEvent, so do nothing.
1092 
1093 Pattern matching to find DAQ and tracker headers, and DAQ trailer:
1094 DAQ header, 4 bits, in field |BOE_1| with value 0x5
1095 DAQ trailer, 4 bits, in field |EOE_1| with value 0xA
1096 TRK header, 8 bits, in field |Hdr format| with value 0xED or 0xC5
1097 
1098 -------------------------------------------------------------------------------------------
1099 | SWAPPED? | DATA FORMAT |
1100 | (wrt "OLD") | OLD (0xED) | NEW (0xC5) |
1101 | | VME | SLINK | VME | SLINK |
1102 -------------------------------------------------------------------------------------------
1103 | DAQ HEADER | ........5....... | 5............... | 5............... | 5............... |
1104 | TRK HEADER | ........ED...... | ED.............. | ........C5...... | ........C5...... |
1105 | PAYLOAD | ..........EA.... | ..EA............ | ..EA............ | ............EA.. |
1106 | DAQ TRAILER | ........A....... | A............... | A............... | A............... |
1107 -------------------------------------------------------------------------------------------
1108 
1109 */
RunningAverage.h
sistrip::RawToDigiUnpacker::scope_work_digis_
std::vector< SiStripRawDigi > scope_work_digis_
Definition: SiStripRawToDigiUnpacker.h:161
edm::EDCollection::push_back
void push_back(T const &t)
Definition: EDCollection.h:60
FEDNumbering.h
edm::DetSetVector< SiStripRawDigi >
l1tstage2emulator_dqm_sourceclient-live_cfg.feds
feds
Definition: l1tstage2emulator_dqm_sourceclient-live_cfg.py:146
sistrip::fedchannelunpacker::isVirginRaw
bool isVirginRaw(FEDReadoutMode mode, bool legacy=false, FEDLegacyReadoutMode lmode=READOUT_MODE_LEGACY_INVALID)
Definition: SiStripFEDBuffer.h:382
sistrip::fedchannelunpacker::StatusCode::SUCCESS
sistrip::RawToDigiUnpacker::proc_work_digis_
std::vector< SiStripRawDigi > proc_work_digis_
Definition: SiStripRawToDigiUnpacker.h:162
mps_fire.i
i
Definition: mps_fire.py:355
input
static const std::string input
Definition: EdmProvDump.cc:48
MessageLogger.h
funct::false
false
Definition: Factorize.h:34
sistrip::RawToDigiUnpacker::errorThreshold_
uint32_t errorThreshold_
Definition: SiStripRawToDigiUnpacker.h:149
sistrip::mlRawToDigi_
static const char mlRawToDigi_[]
Definition: ConstantsForLogger.h:25
sistrip::invalid32_
static const uint32_t invalid32_
Definition: Constants.h:15
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
sistrip::fedchannelunpacker::isNonLiteZS
bool isNonLiteZS(FEDReadoutMode mode, bool legacy=false, FEDLegacyReadoutMode lmode=READOUT_MODE_LEGACY_INVALID)
Definition: SiStripFEDBuffer.h:375
sistrip::RawToDigiUnpacker::doFullCorruptBufferChecks_
bool doFullCorruptBufferChecks_
Definition: SiStripRawToDigiUnpacker.h:146
edm::DetSet< SiStripDigi >
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:32
FEDNumbering::lastFEDId
static constexpr int lastFEDId()
Definition: FEDNumbering.h:19
min
T min(T a, T b)
Definition: MathUtil.h:58
sistrip::toString
std::string toString(fedchannelunpacker::StatusCode status)
Definition: SiStripFEDBuffer.cc:412
FEDRawDataCollection
Definition: FEDRawDataCollection.h:18
sistrip::READOUT_MODE_SCOPE
Definition: SiStripFEDBufferComponents.h:47
edm
HLT enums.
Definition: AlignableModifier.h:19
SiStripRawDigi.h
SiStripRawToDigiUnpacker.h
ALCARECOPromptCalibProdSiPixelAli0T_cff.mode
mode
Definition: ALCARECOPromptCalibProdSiPixelAli0T_cff.py:96
SiStripFedCabling.h
sistrip::RawToDigiUnpacker::doAPVEmulatorCheck_
bool doAPVEmulatorCheck_
Definition: SiStripRawToDigiUnpacker.h:147
SiStripCommissioningClient_cfg.conn
conn
Definition: SiStripCommissioningClient_cfg.py:5
sistrip::RawToDigiUnpacker::cm_work_digis_
std::vector< SiStripRawDigi > cm_work_digis_
Definition: SiStripRawToDigiUnpacker.h:163
cms::cuda::assert
assert(be >=bs)
sistrip::WarningSummary::add
void add(const std::string &message, const std::string &details="")
Definition: WarningSummary.cc:6
sistrip::RawToDigiUnpacker::quiet_
bool quiet_
Definition: SiStripRawToDigiUnpacker.h:144
sistrip::fedchannelunpacker::unpackScope
StatusCode unpackScope(const FEDChannel &channel, OUT &&out)
Definition: SiStripFEDBuffer.h:401
sistrip::PACKET_CODE_ZERO_SUPPRESSED8_TOPBOT
static const uint8_t PACKET_CODE_ZERO_SUPPRESSED8_TOPBOT
Definition: SiStripFEDBufferComponents.h:91
sistrip::RunType
RunType
Definition: ConstantsForRunType.h:70
sistrip::PACKET_CODE_ZERO_SUPPRESSED
static const uint8_t PACKET_CODE_ZERO_SUPPRESSED
Definition: SiStripFEDBufferComponents.h:88
SiStripFedCabling::ConnsConstIterRange
boost::iterator_range< ConnsConstIter > ConnsConstIterRange
Definition: SiStripFedCabling.h:47
SiStripFedCabling
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses,...
Definition: SiStripFedCabling.h:25
sistrip::fedchannelunpacker::unpackProcessedRaw
StatusCode unpackProcessedRaw(const FEDChannel &channel, OUT &&out)
Definition: SiStripFEDBuffer.h:405
edm::DetSetVector::swap
void swap(DetSetVector &other)
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
sistrip::fedchannelunpacker::isProcessedRaw
bool isProcessedRaw(FEDReadoutMode mode, bool legacy=false, FEDLegacyReadoutMode lmode=READOUT_MODE_LEGACY_INVALID)
Definition: SiStripFEDBuffer.h:388
FEDRawData::data
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
end
#define end
Definition: vmac.h:39
sistrip::FEDDAQHeader::l1ID
uint32_t l1ID() const
Definition: SiStripFEDBufferComponents.h:1347
FEDRawData
Definition: FEDRawData.h:19
sistrip::RawToDigiUnpacker::unpackBadChannels_
bool unpackBadChannels_
Definition: SiStripRawToDigiUnpacker.h:136
sistrip::RawToDigiUnpacker::cm_work_registry_
std::vector< Registry > cm_work_registry_
Definition: SiStripRawToDigiUnpacker.h:156
sistrip::RawToDigiUnpacker::warnings_
WarningSummary warnings_
Definition: SiStripRawToDigiUnpacker.h:165
sistrip::FEDReadoutMode
FEDReadoutMode
Definition: SiStripFEDBufferComponents.h:45
edmScanValgrind.buffer
buffer
Definition: edmScanValgrind.py:171
sistrip::FINE_DELAY
Definition: ConstantsForRunType.h:85
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
SiStripRawDigi
A Digi for the silicon strip detector, containing only adc information, and suitable for storing raw ...
Definition: SiStripRawDigi.h:15
sistrip::FED_CABLING
Definition: ConstantsForRunType.h:81
sistrip::fedchannelunpacker::unpackZeroSuppressed
StatusCode unpackZeroSuppressed(const FEDChannel &channel, OUT &&out, uint16_t stripStart, bool isNonLite, FEDReadoutMode mode, bool legacy=false, FEDLegacyReadoutMode lmode=READOUT_MODE_LEGACY_INVALID, uint8_t packetCode=0)
Definition: SiStripFEDBuffer.h:435
sistrip::RawToDigiUnpacker::createDigis
void createDigis(const SiStripFedCabling &, const FEDRawDataCollection &, SiStripEventSummary &, RawDigis &scope_mode, RawDigis &virgin_raw, RawDigis &proc_raw, Digis &zero_suppr, DetIdCollection &, RawDigis &common_mode)
creates digis
Definition: SiStripRawToDigiUnpacker.cc:81
dqm-mbProfile.format
format
Definition: dqm-mbProfile.py:16
sistrip::FEDDAQEventType
FEDDAQEventType
Definition: SiStripFEDBufferComponents.h:95
SiStripDigi.h
str
#define str(s)
Definition: TestProcessor.cc:48
sistrip::PACKET_CODE_ZERO_SUPPRESSED10
static const uint8_t PACKET_CODE_ZERO_SUPPRESSED10
Definition: SiStripFEDBufferComponents.h:89
sistrip::RawToDigiUnpacker::headerBytes_
int16_t headerBytes_
configurables
Definition: SiStripRawToDigiUnpacker.h:131
sistrip::FEDBufferBase::daqHeader
FEDDAQHeader daqHeader() const
Definition: SiStripFEDBufferComponents.h:1401
sistrip::FEDBufferBase::daqEventType
FEDDAQEventType daqEventType() const
Definition: SiStripFEDBufferComponents.h:1409
sistrip::RawToDigiUnpacker::update
void update(RawDigis &scope_mode, RawDigis &virgin_raw, RawDigis &proc_raw, Digis &zero_suppr, RawDigis &common_mode)
fill DetSetVectors using registries
Definition: SiStripRawToDigiUnpacker.cc:405
sistrip::RawToDigiUnpacker::proc_work_registry_
std::vector< Registry > proc_work_registry_
Definition: SiStripRawToDigiUnpacker.h:155
FEDRawDataCollection::FEDData
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
Definition: FEDRawDataCollection.cc:19
sistrip::RawToDigiUnpacker::triggerFedId_
int16_t triggerFedId_
Definition: SiStripRawToDigiUnpacker.h:134
sistrip::fedchannelunpacker::isScopeMode
bool isScopeMode(FEDReadoutMode mode, bool legacy=false, FEDLegacyReadoutMode lmode=READOUT_MODE_LEGACY_INVALID)
Definition: SiStripFEDBuffer.h:394
sistrip::FEDLegacyReadoutMode
FEDLegacyReadoutMode
Definition: SiStripFEDBufferComponents.h:64
SiStripEventSummary.h
sistrip::RawToDigiUnpacker::zs_work_digis_
std::vector< SiStripDigi > zs_work_digis_
digi collections
Definition: SiStripRawToDigiUnpacker.h:159
edm::LogWarning
Definition: MessageLogger.h:141
sistrip::RawToDigiUnpacker::scope_work_registry_
std::vector< Registry > scope_work_registry_
Definition: SiStripRawToDigiUnpacker.h:154
sistrip::RawToDigiUnpacker::RawToDigiUnpacker
RawToDigiUnpacker()=delete
private default constructor
sistrip::RawToDigiUnpacker::virgin_work_registry_
std::vector< Registry > virgin_work_registry_
Definition: SiStripRawToDigiUnpacker.h:153
sistrip::FEDBufferBase::headerType
FEDHeaderType headerType() const
Definition: SiStripFEDBufferComponents.h:1427
funct::true
true
Definition: Factorize.h:173
FEDNumbering::MAXSiStripFEDID
Definition: FEDNumbering.h:30
SiStripConstants.h
sistrip::RawToDigiUnpacker::cleanupWorkVectors
void cleanupWorkVectors()
method to clear registries and digi collections
Definition: SiStripRawToDigiUnpacker.cc:705
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::LogError
Definition: MessageLogger.h:183
FEDTrailer
Definition: FEDTrailer.h:14
sistrip::RawToDigiUnpacker::triggerFed
void triggerFed(const FEDRawDataCollection &, SiStripEventSummary &, const uint32_t &event)
trigger info
Definition: SiStripRawToDigiUnpacker.cc:723
sistrip::HEADER_TYPE_FULL_DEBUG
Definition: SiStripFEDBufferComponents.h:39
sistrip::RawToDigiUnpacker::Registry
private class to register start and end index of digis in a collection
Definition: SiStripRawToDigiUnpacker.h:114
sistrip::RawToDigiUnpacker::zs_work_registry_
std::vector< Registry > zs_work_registry_
registries
Definition: SiStripRawToDigiUnpacker.h:152
sistrip::RawToDigiUnpacker::updateEventSummary
void updateEventSummary(const sistrip::FEDBuffer &, SiStripEventSummary &)
sets the SiStripEventSummary -> not yet implemented for FEDBuffer class
Definition: SiStripRawToDigiUnpacker.cc:972
sistrip::fedchannelunpacker::unpackVirginRaw
StatusCode unpackVirginRaw(const FEDChannel &channel, OUT &&out, uint8_t packetCode)
Definition: SiStripFEDBuffer.h:410
event_
void event_()
edmLumisInFiles.summary
summary
Definition: edmLumisInFiles.py:39
sistrip::FEDBufferStatusCode::SUCCESS
FEDRawDataCollection.h
edm::LogVerbatim
Definition: MessageLogger.h:297
edm::EDCollection::reserve
void reserve(size_type n)
Definition: EDCollection.h:92
sistrip::FEDFullDebugHeader
Definition: SiStripFEDBufferComponents.h:535
FEDHeader::length
static const uint32_t length
Definition: FEDHeader.h:54
sistrip::RawToDigiUnpacker::extractCm_
bool extractCm_
Definition: SiStripRawToDigiUnpacker.h:145
sistrip::invalid_
static const uint16_t invalid_
Definition: Constants.h:16
sistrip::FEDBuffer
Definition: SiStripFEDBuffer.h:24
edm::EDCollection< DetId >
FEDRawData::size
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
sistrip::RawToDigiUnpacker::locateStartOfFedBuffer
void locateStartOfFedBuffer(const uint16_t &fed_id, const FEDRawData &input, FEDRawData &output)
Removes any data appended prior to FED buffer and reorders 32-bit words if swapped.
Definition: SiStripRawToDigiUnpacker.cc:836
sistrip::RawToDigiUnpacker::first_
bool first_
Definition: SiStripRawToDigiUnpacker.h:142
sistrip::preconstructCheckFEDBuffer
FEDBufferStatusCode preconstructCheckFEDBuffer(const FEDRawData &fedBuffer, bool allowBadBuffer=false)
Definition: SiStripFEDBuffer.h:131
sistrip::RawToDigiUnpacker::fedEventDumpFreq_
int16_t fedEventDumpFreq_
Definition: SiStripRawToDigiUnpacker.h:133
TFHeaderDescription.h
sistrip::RawToDigiUnpacker::once_
bool once_
Definition: SiStripRawToDigiUnpacker.h:141
sistrip::READOUT_MODE_LEGACY_INVALID
Definition: SiStripFEDBufferComponents.h:65
sistrip::RawToDigiUnpacker::useFedKey_
bool useFedKey_
Definition: SiStripRawToDigiUnpacker.h:135
sistrip::fedchannelunpacker::StatusCode::BAD_PACKET_CODE
officialStyle.chan
chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, "NDC") lumi.SetBorderSize( 0 ) lumi....
Definition: officialStyle.py:106
FEDTrailer::length
static const uint32_t length
Definition: FEDTrailer.h:57
sistrip::APV_LATENCY
Definition: ConstantsForRunType.h:76
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
edm::EDCollection::size
size_type size() const
Definition: EDCollection.h:82
Exception
Definition: hltDiff.cc:246
sistrip::RawToDigiUnpacker::legacy_
bool legacy_
Definition: SiStripRawToDigiUnpacker.h:148
Exception.h
sistrip::RawToDigiUnpacker::dumpRawData
static void dumpRawData(uint16_t fed_id, const FEDRawData &, std::stringstream &)
dumps raw data to stdout (NB: payload is byte-swapped,headers/trailer are not).
Definition: SiStripRawToDigiUnpacker.cc:1008
RecoTauValidation_cfi.header
header
Definition: RecoTauValidation_cfi.py:292
SiStripFedCabling::fedIds
FedsConstIterRange fedIds() const
Definition: SiStripFedCabling.h:154
edm::isDebugEnabled
bool isDebugEnabled()
Definition: MessageLogger.cc:71
sistrip::FEDBufferStatusCode::BUFFER_NULL
sistrip::FEDCH_PER_FEUNIT
static const uint16_t FEDCH_PER_FEUNIT
Definition: ConstantsForHardwareSystems.h:28
sistrip::FEDBuffer::feHeader
const FEDFEHeader * feHeader() const
Definition: SiStripFEDBuffer.h:154
DetSet.h
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
sistrip
sistrip classes
Definition: SiStripQualityHelpers.h:14
sistrip::RawToDigiUnpacker::fedBufferDumpFreq_
int16_t fedBufferDumpFreq_
Definition: SiStripRawToDigiUnpacker.h:132
SiStripEventSummary
Definition: SiStripEventSummary.h:22
event
Definition: event.py:1
SiStripFedCabling::fedConnections
ConnsConstIterRange fedConnections(uint16_t fed_id) const
Definition: SiStripFedCabling.cc:160
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:78
sistrip::fedchannelunpacker::StatusCode::ZERO_PACKET_CODE
crabWrapper.key
key
Definition: crabWrapper.py:19
FEDHeader.h
sistrip::RawToDigiUnpacker::virgin_work_digis_
std::vector< SiStripRawDigi > virgin_work_digis_
Definition: SiStripRawToDigiUnpacker.h:160
TFHeaderDescription
Definition: TFHeaderDescription.h:10
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
sistrip::RawToDigiUnpacker::~RawToDigiUnpacker
~RawToDigiUnpacker()
default constructor
Definition: SiStripRawToDigiUnpacker.cc:60
sistrip::RawToDigiUnpacker::useDaqRegister_
bool useDaqRegister_
Definition: SiStripRawToDigiUnpacker.h:143
sistrip::READOUT_MODE_LEGACY_SCOPE
Definition: SiStripFEDBufferComponents.h:66
sistrip::RawToDigiUnpacker::event_
uint32_t event_
other values
Definition: SiStripRawToDigiUnpacker.h:140
sistrip::PACKET_CODE_ZERO_SUPPRESSED8_BOTBOT
static const uint8_t PACKET_CODE_ZERO_SUPPRESSED8_BOTBOT
Definition: SiStripFEDBufferComponents.h:90
sistrip::FEDDAQHeader::bxID
uint16_t bxID() const
Definition: SiStripFEDBufferComponents.h:1349
edm::RunningAverage
Definition: RunningAverage.h:17
sistrip::fedchannelunpacker::isZeroSuppressed
bool isZeroSuppressed(FEDReadoutMode mode, bool legacy=false, FEDLegacyReadoutMode lmode=READOUT_MODE_LEGACY_INVALID)
Definition: SiStripFEDBuffer.h:341
FEDNumbering::MINSiStripFEDID
Definition: FEDNumbering.h:29
FEDTrailer.h