CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
HcalUnpacker Class Reference

#include <HcalUnpacker.h>

Classes

struct  Collections
 

Public Member Functions

 HcalUnpacker (int sourceIdOffset, int beg, int end)
 for normal data More...
 
 HcalUnpacker (int sourceIdOffset)
 For histograms, no begin and end. More...
 
void setExpectedOrbitMessageTime (int time)
 
void setMode (int mode)
 
void unpack (const FEDRawData &raw, const HcalElectronicsMap &emap, std::vector< HcalHistogramDigi > &histoDigis)
 
void unpack (const FEDRawData &raw, const HcalElectronicsMap &emap, Collections &conts, HcalUnpackerReport &report, bool silent=false)
 

Private Member Functions

void printInvalidDataMessage (const std::string &coll_type, int default_ns, int conflict_ns, bool extended=false)
 
void unpackUMNio (const FEDRawData &raw, int slot, Collections &colls)
 
void unpackUTCA (const FEDRawData &raw, const HcalElectronicsMap &emap, Collections &conts, HcalUnpackerReport &report, bool silent=false)
 
void unpackVME (const FEDRawData &raw, const HcalElectronicsMap &emap, Collections &conts, HcalUnpackerReport &report, bool silent=false)
 

Private Attributes

int endSample_
 last sample from fed raw data to copy (if present) More...
 
int expectedOrbitMessageTime_
 Expected orbit bunch time (needed to evaluate time differences) More...
 
int mode_
 
int nPrinted_
 
int sourceIdOffset_
 number to subtract from the source id to get the dcc id More...
 
int startSample_
 first sample from fed raw data to copy More...
 
std::set< HcalElectronicsIdunknownIds_
 
std::set< HcalElectronicsIdunknownIdsTrig_
 Recorded to limit number of times a log message is generated. More...
 

Detailed Description

Definition at line 21 of file HcalUnpacker.h.

Constructor & Destructor Documentation

HcalUnpacker::HcalUnpacker ( int  sourceIdOffset,
int  beg,
int  end 
)
inline

for normal data

Definition at line 44 of file HcalUnpacker.h.

45  : sourceIdOffset_(sourceIdOffset),
46  startSample_(beg),
47  endSample_(end),
49  mode_(0),
50  nPrinted_(0) {}
int sourceIdOffset_
number to subtract from the source id to get the dcc id
Definition: HcalUnpacker.h:83
int endSample_
last sample from fed raw data to copy (if present)
Definition: HcalUnpacker.h:85
int startSample_
first sample from fed raw data to copy
Definition: HcalUnpacker.h:84
int expectedOrbitMessageTime_
Expected orbit bunch time (needed to evaluate time differences)
Definition: HcalUnpacker.h:86
#define end
Definition: vmac.h:39
HcalUnpacker::HcalUnpacker ( int  sourceIdOffset)
inline

For histograms, no begin and end.

Definition at line 52 of file HcalUnpacker.h.

53  : sourceIdOffset_(sourceIdOffset),
54  startSample_(-1),
55  endSample_(-1),
57  mode_(0),
58  nPrinted_(0) {}
int sourceIdOffset_
number to subtract from the source id to get the dcc id
Definition: HcalUnpacker.h:83
int endSample_
last sample from fed raw data to copy (if present)
Definition: HcalUnpacker.h:85
int startSample_
first sample from fed raw data to copy
Definition: HcalUnpacker.h:84
int expectedOrbitMessageTime_
Expected orbit bunch time (needed to evaluate time differences)
Definition: HcalUnpacker.h:86

Member Function Documentation

void HcalUnpacker::printInvalidDataMessage ( const std::string &  coll_type,
int  default_ns,
int  conflict_ns,
bool  extended = false 
)
private

Definition at line 1070 of file HcalUnpacker.cc.

References constexpr, and MessageLogger_cff::limit.

Referenced by setMode().

1073  {
1074  nPrinted_++;
1075 
1076  constexpr int limit = 2; //print up to limit-1 messages
1077  if (nPrinted_ >= limit) {
1078  if (nPrinted_ == limit)
1079  edm::LogInfo("Invalid Data") << "Suppressing further error messages";
1080 
1081  return;
1082  }
1083 
1084  std::stringstream message;
1085 
1086  message << "The default " << coll_type << " Collection has " << default_ns
1087  << " samples per digi, while the current data has " << conflict_ns
1088  << "! This data cannot be included with the default collection.";
1089 
1090  if (extended) {
1091  message << "\nIn order to store this data in the event, it must have a unique tag. "
1092  << "To accomplish this, provide two lists to HcalRawToDigi \n"
1093  << "1) that specifies the number of samples and "
1094  << "2) that gives tags with which these data are saved.\n"
1095  << "For example in this case you might add \n"
1096  << "process.hcalDigis.save" << coll_type << "DataNSamples = cms.untracked.vint32( " << conflict_ns
1097  << ") \nprocess.hcalDigis.save" << coll_type << "DataTags = cms.untracked.vstring( \"MYDATA\" )";
1098  }
1099 
1100  edm::LogWarning("Invalid Data") << message.str();
1101 }
#define constexpr
void HcalUnpacker::setExpectedOrbitMessageTime ( int  time)
inline

Definition at line 59 of file HcalUnpacker.h.

References expectedOrbitMessageTime_, edmIntegrityCheck::report, CastorRawToDigi_cfi::silent, ntuplemaker::time, and unpack().

Referenced by HcalRawToDigi::HcalRawToDigi().

int expectedOrbitMessageTime_
Expected orbit bunch time (needed to evaluate time differences)
Definition: HcalUnpacker.h:86
void HcalUnpacker::setMode ( int  mode)
inline
void HcalUnpacker::unpack ( const FEDRawData raw,
const HcalElectronicsMap emap,
std::vector< HcalHistogramDigi > &  histoDigis 
)

Definition at line 991 of file HcalUnpacker.cc.

References HcalHTRData::check(), FEDRawData::data(), DetId::det(), runTauDisplay::eid, f, benchmark_cfg::fc, HcalHistogramDigi::getArray(), HcalHTRData::getHistogramFibers(), HcalDCCHeader::getSourceId(), HcalDCCHeader::getSpigotData(), HcalDCCHeader::getSpigotPresent(), HcalHTRData::getSubmodule(), DetId::Hcal, HcalHTRData::isHistogramEvent(), HcalElectronicsMap::lookup(), DetId::null(), HcalElectronicsId::setHTR(), FEDRawData::size(), HcalDCCHeader::SPIGOT_COUNT, DetId::subdetId(), and HcalHTRData::unpackHistogram().

Referenced by HcalHistogramRawToDigi::produce(), HcalRawToDigi::produce(), and setExpectedOrbitMessageTime().

993  {
994  // get the DCC header
995  const HcalDCCHeader* dccHeader = (const HcalDCCHeader*)(raw.data());
996  int dccid = dccHeader->getSourceId() - sourceIdOffset_;
997 
998  // check the summary status
999 
1000  // walk through the HTR data...
1001  HcalHTRData htr;
1002  for (int spigot = 0; spigot < HcalDCCHeader::SPIGOT_COUNT; spigot++) {
1003  if (!dccHeader->getSpigotPresent(spigot))
1004  continue;
1005 
1006  int retval = dccHeader->getSpigotData(spigot, htr, raw.size());
1007  // check
1008  if (retval || !htr.check()) {
1009  edm::LogWarning("Invalid Data") << "Invalid HTR data observed on spigot " << spigot << " of DCC with source id "
1010  << dccHeader->getSourceId();
1011  continue;
1012  }
1013  if (!htr.isHistogramEvent()) {
1014  edm::LogWarning("Invalid Data") << "Non-histogram data passed to histogram unpacker on spigot " << spigot
1015  << " of DCC with source id " << dccHeader->getSourceId();
1016  continue;
1017  }
1018 
1019  unsigned int smid = htr.getSubmodule();
1020  int htr_tb = smid & 0x1;
1021  int htr_slot = (smid >> 1) & 0x1F;
1022  int htr_cr = (smid >> 6) & 0x1F;
1023 
1024  // find out the fibers
1025  int f[2], fc;
1026  htr.getHistogramFibers(f[0], f[1]);
1027 
1028  for (int nf = 0; nf < 2; nf++) {
1029  if (f[nf] < 0 || (nf == 1 && f[0] == f[1]))
1030  continue; // skip if invalid or the same
1031  for (fc = 0; fc <= 2; fc++) {
1032  HcalElectronicsId eid(fc, f[nf], spigot, dccid);
1033  eid.setHTR(htr_cr, htr_slot, htr_tb);
1034  DetId did = emap.lookup(eid);
1035 
1036  if (did.null() || did.det() != DetId::Hcal || did.subdetId() == 0) {
1037  if (unknownIds_.find(eid) == unknownIds_.end()) {
1038  edm::LogWarning("HCAL") << "HcalHistogramUnpacker: No match found for electronics id :" << eid;
1039  unknownIds_.insert(eid);
1040  }
1041  continue;
1042  }
1043  histoDigis.push_back(HcalHistogramDigi(HcalDetId(did))); // add it!
1044  HcalHistogramDigi& digi = histoDigis.back();
1045 
1046  // unpack the four capids
1047  for (int capid = 0; capid < 4; capid++)
1048  htr.unpackHistogram(f[nf], fc, capid, digi.getArray(capid));
1049  }
1050  }
1051  }
1052 }
std::set< HcalElectronicsId > unknownIds_
Definition: HcalUnpacker.h:88
int sourceIdOffset_
number to subtract from the source id to get the dcc id
Definition: HcalUnpacker.h:83
bool check() const
Check for a good event Requires a minimum length, matching wordcount and length, not an empty event...
Definition: HcalHTRData.cc:63
constexpr bool null() const
is this a null id ?
Definition: DetId.h:59
void getHistogramFibers(int &a, int &b) const
Get the fiber numbers for the data present in this event (only in histogram mode!) ...
Definition: HcalHTRData.cc:435
int getSpigotData(int nspigot, HcalHTRData &decodeTool, int validSize) const
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
bool unpackHistogram(int fiber, int fiberchan, int capid, unsigned short *histogram) const
Unpack special histogramming mode data.
Definition: HcalHTRData.cc:464
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
double f[11][100]
bool getSpigotPresent(unsigned int nspigot) const
Read the "PRESENT" bit for this spigot.
int getSourceId() const
Definition: HcalDCCHeader.h:32
Definition: DetId.h:17
static const int SPIGOT_COUNT
Definition: HcalDCCHeader.h:19
uint16_t * getArray(int capid)
get the array for the specified capid
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
unsigned int getSubmodule() const
Get the HTR submodule number.
Definition: HcalHTRData.cc:355
Readout chain identification for Hcal.
const DetId lookup(HcalElectronicsId fId) const
lookup the logical detid associated with the given electronics id
bool isHistogramEvent() const
Is this event a histogram event? (do not call standard unpack in this case!!!!!)
Definition: HcalHTRData.cc:409
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
void HcalUnpacker::unpack ( const FEDRawData raw,
const HcalElectronicsMap emap,
Collections conts,
HcalUnpackerReport report,
bool  silent = false 
)

Definition at line 208 of file HcalUnpacker.cc.

References HcalDCCHeader::BOEshouldBeZeroAlways(), FEDRawData::data(), and FEDRawData::size().

212  {
213  if (raw.size() < 16) {
214  if (!silent)
215  edm::LogWarning("Invalid Data") << "Empty/invalid data, size = " << raw.size();
216  return;
217  }
218 
219  // get the DCC header
220  const HcalDCCHeader* dccHeader = (const HcalDCCHeader*)(raw.data());
221 
222  if (dccHeader->BOEshouldBeZeroAlways() == 0) // also includes uTCA before the common AMC13XG firmware
223  unpackVME(raw, emap, colls, report, silent);
224  else
225  unpackUTCA(raw, emap, colls, report, silent);
226 }
void unpackUTCA(const FEDRawData &raw, const HcalElectronicsMap &emap, Collections &conts, HcalUnpackerReport &report, bool silent=false)
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
void unpackVME(const FEDRawData &raw, const HcalElectronicsMap &emap, Collections &conts, HcalUnpackerReport &report, bool silent=false)
short BOEshouldBeZeroAlways() const
Definition: HcalDCCHeader.h:50
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
void HcalUnpacker::unpackUMNio ( const FEDRawData raw,
int  slot,
Collections colls 
)
private

Definition at line 1054 of file HcalUnpacker.cc.

References hcal::AMC13Header::AMCPayload(), hcal::AMC13Header::AMCSize(), hcal::AMC13Header::AMCSlot(), FEDRawData::data(), data, hcal::AMC13Header::NAMC(), and HcalUnpacker::Collections::umnio.

Referenced by setMode().

1054  {
1055  const hcal::AMC13Header* amc13 = (const hcal::AMC13Header*)(raw.data());
1056  int namc = amc13->NAMC();
1057  //Find AMC corresponding to uMNio slot
1058  for (int iamc = 0; iamc < namc; iamc++) {
1059  if (amc13->AMCSlot(iamc) == slot)
1060  namc = iamc;
1061  }
1062  if (namc == amc13->NAMC()) {
1063  return;
1064  }
1065  const uint16_t* data = (const uint16_t*)(amc13->AMCPayload(namc));
1066  size_t nwords = amc13->AMCSize(namc) * (sizeof(uint64_t) / sizeof(uint16_t));
1067  *(colls.umnio) = HcalUMNioDigi(data, nwords);
1068 }
int AMCSize(int i) const
Definition: AMC13Header.h:37
unsigned long long uint64_t
Definition: Time.h:13
int NAMC() const
Definition: AMC13Header.h:25
int AMCSlot(int i) const
Definition: AMC13Header.h:33
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
const uint64_t * AMCPayload(int i) const
Definition: AMC13Header.cc:4
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
void HcalUnpacker::unpackUTCA ( const FEDRawData raw,
const HcalElectronicsMap emap,
Collections conts,
HcalUnpackerReport report,
bool  silent = false 
)
private

Definition at line 683 of file HcalUnpacker.cc.

References HcalDataFrameContainer< Digi >::addDataFrame(), hcal::AMC13Header::AMCCRCOk(), hcal::AMC13Header::AMCDataPresent(), hcal::AMC13Header::AMCEnabled(), hcal::AMC13Header::AMCId(), hcal::AMC13Header::AMCPayload(), hcal::AMC13Header::AMCSegmented(), hcal::AMC13Header::AMCSize(), hcal::AMC13Header::AMCSlot(), HcalUnpacker::Collections::calibCont, HcalCalibDetId::calibFlavor(), DetId::Calo, HcalUHTRData::const_iterator::channelid(), HcalUnpackerReport::countSpigotFormatError(), HcalUnpackerReport::countUnmappedDigi(), HcalUnpackerReport::countUnmappedTPDigi(), gather_cfg::cout, FEDRawData::data(), DetId::det(), runTauDisplay::eid, HcalUHTRData::const_iterator::flavor(), HcalUnpacker::Collections::hbheCont, DetId::Hcal, HcalBarrel, HcalCalibration, HcalEmpty, HcalEndcap, HcalForward, HcalOther, HcalOuter, HcalUnpacker::Collections::hfCont, HcalUnpacker::Collections::hoCont, mps_fire::i, triggerObjects_cff::id, HcalUHTRData::const_iterator::isHeader(), dqmiolumiharvest::j, HcalElectronicsMap::lookup(), HcalElectronicsMap::lookupTrigger(), hcal::AMC13Header::NAMC(), DetId::null(), HcalUnpacker::Collections::qie10, HcalUnpacker::Collections::qie10Addtl, HcalUnpacker::Collections::qie10Lasermon, HcalUnpacker::Collections::qie10ZDC, HcalUnpacker::Collections::qie11, HcalUnpacker::Collections::qie11Addtl, HcalUHTRData::const_iterator::raw(), HcalDataFrameContainer< Digi >::samples(), HcalUHTRData::const_iterator::soi(), hcal::AMC13Header::sourceId(), HcalOtherDetId::subdet(), HcalZDCDetId::SubdetectorId, DetId::subdetId(), HcalUHTRData::const_iterator::technicalDataType(), HcalUnpacker::Collections::tpCont, HcalTrigTowerDetId::Undefined, HcalUHTRData::const_iterator::value(), and HcalUnpacker::Collections::zdcCont.

Referenced by setMode().

687  {
688  const hcal::AMC13Header* amc13 = (const hcal::AMC13Header*)(raw.data());
689 
690  // how many AMC in this packet
691  int namc = amc13->NAMC();
692  for (int iamc = 0; iamc < namc; iamc++) {
693  // if not enabled, ignore
694  if (!amc13->AMCEnabled(iamc))
695  continue;
696 
697  if (!amc13->AMCDataPresent(iamc)) {
698  if (!silent)
699  edm::LogWarning("Invalid Data") << "Missing data observed on iamc " << iamc << " of AMC13 with source id "
700  << amc13->sourceId();
701  report.countSpigotFormatError();
702  continue;
703  }
704  if (!amc13->AMCCRCOk(iamc)) {
705  if (!silent)
706  edm::LogWarning("Invalid Data") << "CRC Error on uHTR data observed on iamc " << iamc
707  << " of AMC13 with source id " << amc13->sourceId();
708  report.countSpigotFormatError();
709  // continue;
710  }
711  // this unpacker cannot handle segmented data!
712  if (amc13->AMCSegmented(iamc)) {
713  if (!silent)
714  edm::LogWarning("Invalid Data") << "Unpacker cannot handle segmented data observed on iamc " << iamc
715  << " of AMC13 with source id " << amc13->sourceId();
716  report.countSpigotFormatError();
717  continue;
718  }
719 
720  // ok, now we're work-able
721  int slot = amc13->AMCSlot(iamc);
722  int crate = amc13->AMCId(iamc) & 0xFF;
723 
724  HcalUHTRData uhtr(amc13->AMCPayload(iamc), amc13->AMCSize(iamc));
725  //Check to make sure uMNio is not unpacked here
726  if (uhtr.getFormatVersion() != 1) {
727  unpackUMNio(raw, slot, colls);
728  continue;
729  }
730 #ifdef DebugLog
731  //debug printouts
732  int nwords = uhtr.getRawLengthBytes() / 2;
733  for (int iw = 0; iw < nwords; iw++)
734  printf("%04d %04x\n", iw, uhtr.getRawData16()[iw]);
735 #endif
736 
737  //use uhtr presamples since amc header not properly packed in simulation
738  int nps = uhtr.presamples();
739 
740  HcalUHTRData::const_iterator i = uhtr.begin(), iend = uhtr.end();
741  while (i != iend) {
742 #ifdef DebugLog
743  std::cout << "This data is flavored:" << i.flavor() << std::endl;
744 #endif
745 
746  if (!i.isHeader()) {
747  ++i;
748 #ifdef DebugLog
749  std::cout << "its not a header" << std::endl;
750 #endif
751  continue;
752  }
754  if (i.flavor() == 1 || i.flavor() == 0 || i.flavor() == 3) {
755  int ifiber = ((i.channelid() >> 3) & 0x1F);
756  int ichan = (i.channelid() & 0x7);
757  HcalElectronicsId eid(crate, slot, ifiber, ichan, false);
758  DetId did = emap.lookup(eid);
759  // Count from current position to next header, or equal to end
760  const uint16_t* head_pos = i.raw();
761  int ns = 0;
762  for (++i; i != iend && !i.isHeader(); ++i) {
763  ns++;
764  }
765  // Check QEI11 container exists
766  if (colls.qie11 == nullptr) {
767  colls.qie11 = new QIE11DigiCollection(ns);
768  } else if (colls.qie11->samples() != ns) {
769  // if this sample type hasn't been requested to be saved
770  // warn the user to provide a configuration that prompts it to be saved
771  if (colls.qie11Addtl.find(ns) == colls.qie11Addtl.end()) {
772  printInvalidDataMessage("QIE11", colls.qie11->samples(), ns, true);
773  }
774  }
775 
776  // Insert data
778  if (!did.null()) { // unpack and store...
779  // only fill the default collection if we have the correct number of samples
780  if (colls.qie11->samples() == ns) {
781  colls.qie11->addDataFrame(did, head_pos);
782  }
783  // fill the additional qie11 collections
784  if (colls.qie11Addtl.find(ns) != colls.qie11Addtl.end()) {
785  colls.qie11Addtl[ns]->addDataFrame(did, head_pos);
786  }
787  } else {
788  report.countUnmappedDigi(eid);
789  if (unknownIds_.find(eid) == unknownIds_.end()) {
790  if (!silent)
791  edm::LogWarning("HCAL") << "HcalUnpacker: No match found for electronics id :" << eid;
792  unknownIds_.insert(eid);
793 #ifdef DebugLog
794  std::cout << "HcalUnpacker: No match found for electronics id :" << eid << std::endl;
795 #endif
796  }
797 #ifdef DebugLog
798  std::cout << "OH NO! detector id is null!" << std::endl;
799 #endif
800  }
801  } else if (i.flavor() == 2) {
803 
804  int ifiber = ((i.channelid() >> 3) & 0x1F);
805  int ichan = (i.channelid() & 0x7);
806  HcalElectronicsId eid(crate, slot, ifiber, ichan, false);
807  DetId did = emap.lookup(eid);
808 
809  // Count from current position to next header, or equal to end
810  const uint16_t* head_pos = i.raw();
811  int ns = 0;
812  for (++i; i != iend && !i.isHeader(); ++i) {
813  ns++;
814  }
815 
816  bool isZDC = (did.det() == DetId::Calo && did.subdetId() == HcalZDCDetId::SubdetectorId);
817  bool isLasmon = (did.det() == DetId::Hcal && (HcalSubdetector)did.subdetId() == HcalOther &&
818  HcalCalibDetId(did).calibFlavor() == 5);
819 
820  if (isZDC) {
821  if (colls.qie10ZDC == nullptr) {
822  colls.qie10ZDC = new QIE10DigiCollection(ns);
823  } else if (colls.qie10ZDC->samples() != ns) {
824  printInvalidDataMessage("QIE10ZDC", colls.qie10ZDC->samples(), ns, false);
825  }
826  } else if (isLasmon) {
827  if (colls.qie10Lasermon == nullptr) {
828  colls.qie10Lasermon = new QIE10DigiCollection(ns);
829  } else if (colls.qie10Lasermon->samples() != ns) {
830  printInvalidDataMessage("QIE10LASMON", colls.qie10Lasermon->samples(), ns, false);
831  }
832  } else { // these are the default qie10 channels
833  if (colls.qie10 == nullptr) {
834  colls.qie10 = new QIE10DigiCollection(ns);
835  } else if (colls.qie10->samples() != ns) {
836  // if this sample type hasn't been requested to be saved
837  // warn the user to provide a configuration that prompts it to be saved
838  if (colls.qie10Addtl.find(ns) == colls.qie10Addtl.end()) {
839  printInvalidDataMessage("QIE10", colls.qie10->samples(), ns, true);
840  }
841  }
842  }
843 
844  // Insert data
846  if (!did.null()) { // unpack and store...
847  // fill the additional qie10 collections
848  if (isZDC)
849  colls.qie10ZDC->addDataFrame(did, head_pos);
850  else if (isLasmon)
851  colls.qie10Lasermon->addDataFrame(did, head_pos);
852  else {
853  // only fill the default collection if we have the correct number of samples
854  if (colls.qie10->samples() == ns) {
855  colls.qie10->addDataFrame(did, head_pos);
856  }
857 
858  // fill the additional qie10 collections
859  if (colls.qie10Addtl.find(ns) != colls.qie10Addtl.end()) {
860  colls.qie10Addtl[ns]->addDataFrame(did, head_pos);
861  }
862  }
863  } else {
864  report.countUnmappedDigi(eid);
865  if (unknownIds_.find(eid) == unknownIds_.end()) {
866  if (!silent)
867  edm::LogWarning("HCAL") << "HcalUnpacker: No match found for electronics id :" << eid;
868  unknownIds_.insert(eid);
869 #ifdef DebugLog
870  std::cout << "HcalUnpacker: No match found for electronics id :" << eid << std::endl;
871 #endif
872  }
873 #ifdef DebugLog
874  std::cout << "OH NO! HcalUnpacker: No match found for electronics id :" << eid << std::endl;
875 #endif
876  }
877  } else if (i.flavor() == 5 || (i.flavor() == 7 && i.technicalDataType() == 15)) { // Old-style digis
878  int ifiber = ((i.channelid() >> 2) & 0x1F);
879  int ichan = (i.channelid() & 0x3);
880  HcalElectronicsId eid(crate, slot, ifiber, ichan, false);
881  DetId did = emap.lookup(eid);
882 
883  if (!did.null()) { // unpack and store...
884  if (did.det() == DetId::Calo && did.subdetId() == HcalZDCDetId::SubdetectorId) {
885  colls.zdcCont->push_back(ZDCDataFrame(HcalZDCDetId(did)));
886  HcalUnpacker_impl::unpack_compact<ZDCDataFrame>(
887  i, iend, colls.zdcCont->back(), nps, eid, startSample_, endSample_);
888  } else if (did.det() == DetId::Hcal) {
889  switch (((HcalSubdetector)did.subdetId())) {
890  case (HcalBarrel):
891  case (HcalEndcap): {
892  colls.hbheCont->push_back(HBHEDataFrame(HcalDetId(did)));
893  HcalUnpacker_impl::unpack_compact<HBHEDataFrame>(
894  i, iend, colls.hbheCont->back(), nps, eid, startSample_, endSample_);
895  } break;
896  case (HcalOuter): {
897  colls.hoCont->push_back(HODataFrame(HcalDetId(did)));
898  HcalUnpacker_impl::unpack_compact<HODataFrame>(
899  i, iend, colls.hoCont->back(), nps, eid, startSample_, endSample_);
900  } break;
901  case (HcalForward): {
902  colls.hfCont->push_back(HFDataFrame(HcalDetId(did)));
903  HcalUnpacker_impl::unpack_compact<HFDataFrame>(
904  i, iend, colls.hfCont->back(), nps, eid, startSample_, endSample_);
905  } break;
906  case (HcalOther): {
907  HcalOtherDetId odid(did);
908  if (odid.subdet() == HcalCalibration) {
909  colls.calibCont->push_back(HcalCalibDataFrame(HcalCalibDetId(did)));
910  HcalUnpacker_impl::unpack_compact<HcalCalibDataFrame>(
911  i, iend, colls.calibCont->back(), nps, eid, startSample_, endSample_);
912  }
913  } break;
914  case (HcalEmpty):
915  default: {
916  for (++i; i != iend && !i.isHeader(); ++i)
917  ;
918  } break;
919  }
920  }
921  } else {
922  report.countUnmappedDigi(eid);
923  if (unknownIds_.find(eid) == unknownIds_.end()) {
924  if (!silent)
925  edm::LogWarning("HCAL") << "HcalUnpacker: No match found for electronics id :" << eid;
926  unknownIds_.insert(eid);
927  }
928  for (++i; i != iend && !i.isHeader(); ++i)
929  ;
930  }
931  } else if (i.flavor() == 0x4) { // TP digis
932  int ilink = ((i.channelid() >> 4) & 0xF);
933  int itower = (i.channelid() & 0xF);
934  HcalElectronicsId eid(crate, slot, ilink, itower, true);
935  DetId did = emap.lookupTrigger(eid);
936 #ifdef DebugLog
937  std::cout << "Unpacking " << eid << " " << i.channelid() << std::endl;
938 #endif
939  if (did.null()) {
940  report.countUnmappedTPDigi(eid);
941  if (unknownIdsTrig_.find(eid) == unknownIdsTrig_.end()) {
942  if (!silent)
943  edm::LogWarning("HCAL") << "HcalUnpacker: No trigger primitive match found for electronics id :" << eid;
944  unknownIdsTrig_.insert(eid);
945  }
946  // Skip it
947  for (++i; i != iend && !i.isHeader(); ++i)
948  ;
949  } else if (did == HcalTrigTowerDetId::Undefined || (did.det() == DetId::Hcal && did.subdetId() == 0)) {
950  for (++i; i != iend && !i.isHeader(); ++i)
951  ;
952  } else {
953  HcalTrigTowerDetId id(did);
954 #ifdef DebugLog
955  std::cout << "Unpacking " << id << std::endl;
956 #endif
957  colls.tpCont->push_back(HcalTriggerPrimitiveDigi(id));
958  int j = 0;
959  for (++i; i != iend && !i.isHeader(); ++i) {
960  colls.tpCont->back().setSample(j, i.value());
961  if (i.soi())
962  colls.tpCont->back().setPresamples(j);
963  j++;
964  }
965  colls.tpCont->back().setSize(j);
966  }
967  } else {
968  // consume any not-understood channel data
969  for (++i; i != iend && !i.isHeader(); ++i)
970  ;
971  }
972  }
973  }
974 }
std::set< HcalElectronicsId > unknownIds_
Definition: HcalUnpacker.h:88
int endSample_
last sample from fed raw data to copy (if present)
Definition: HcalUnpacker.h:85
int startSample_
first sample from fed raw data to copy
Definition: HcalUnpacker.h:84
CalibDetType calibFlavor() const
get the flavor of this calibration detid
constexpr bool null() const
is this a null id ?
Definition: DetId.h:59
void printInvalidDataMessage(const std::string &coll_type, int default_ns, int conflict_ns, bool extended=false)
int AMCSize(int i) const
Definition: AMC13Header.h:37
HcalDataFrameContainer< QIE10DataFrame > QIE10DigiCollection
bool AMCDataPresent(int i) const
Definition: AMC13Header.h:47
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
HcalSubdetector
Definition: HcalAssistant.h:31
std::set< HcalElectronicsId > unknownIdsTrig_
Recorded to limit number of times a log message is generated.
Definition: HcalUnpacker.h:88
HcalDataFrameContainer< QIE11DataFrame > QIE11DigiCollection
Definition: DetId.h:17
static const int SubdetectorId
Definition: HcalZDCDetId.h:25
int sourceId() const
Definition: AMC13Header.h:15
static const HcalTrigTowerDetId Undefined
bool AMCSegmented(int i) const
Definition: AMC13Header.h:41
int NAMC() const
Definition: AMC13Header.h:25
int AMCSlot(int i) const
Definition: AMC13Header.h:33
const uint64_t * AMCPayload(int i) const
Definition: AMC13Header.cc:4
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
bool AMCCRCOk(int i) const
Definition: AMC13Header.h:45
const DetId lookupTrigger(HcalElectronicsId fId) const
brief lookup the trigger logical detid associated with the given electronics id
bool AMCEnabled(int i) const
Definition: AMC13Header.h:51
void unpackUMNio(const FEDRawData &raw, int slot, Collections &colls)
uint16_t AMCId(int i) const
Definition: AMC13Header.h:31
const uint16_t * raw() const
Definition: HcalUHTRData.h:71
Readout chain identification for Hcal.
const DetId lookup(HcalElectronicsId fId) const
lookup the logical detid associated with the given electronics id
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
void HcalUnpacker::unpackVME ( const FEDRawData raw,
const HcalElectronicsMap emap,
Collections conts,
HcalUnpackerReport report,
bool  silent = false 
)
private

work through the samples

branch point between 2006-2011 data format and 2012+ data format

work through the samples

Definition at line 232 of file HcalUnpacker.cc.

References HcalUnpacker::Collections::calibCont, DetId::Calo, HcalHTRData::check(), HOUnrolledTP::checked, HcalUnpackerReport::countBusySpigot(), HcalUnpackerReport::countEmptyEventSpigot(), HcalUnpackerReport::countOFWSpigot(), HcalUnpackerReport::countSpigotFormatError(), HcalUnpackerReport::countUnmappedDigi(), HcalUnpackerReport::countUnmappedTPDigi(), FEDRawData::data(), HcalHTRData::dataPointers(), DetId::det(), runTauDisplay::eid, benchmark_cfg::fc, HcalQIESample::fiber(), HcalQIESample::fiberAndChan(), HcalQIESample::fiberChan(), HcalHTRData::FORMAT_VERSION_COMPACT_DATA, HcalDCCHeader::getDCCDataFormatVersion(), HcalHTRData::getFirmwareFlavor(), HcalHTRData::getFormatVersion(), HcalHTRData::getNPS(), HcalDTCHeader::getSlotCRCError(), HcalDTCHeader::getSlotData(), HcalDTCHeader::getSlotPresent(), HcalDCCHeader::getSourceId(), HcalDTCHeader::getSourceId(), HcalDCCHeader::getSpigotCRCError(), HcalDCCHeader::getSpigotData(), HcalDCCHeader::getSpigotPresent(), HcalHTRData::getSubmodule(), HcalUnpacker::Collections::hbheCont, DetId::Hcal, HcalBarrel, HcalCalibration, HcalEmpty, HcalEndcap, HcalForward, HcalOther, HcalOuter, HcalUnpacker::Collections::hfCont, HcalUnpacker::Collections::hoCont, mps_fire::i, triggerObjects_cff::id, LEDCalibrationChannels::ieta, HcalDetId::ieta(), HOUnrolledTP::ieta, LEDCalibrationChannels::iphi, HcalDetId::iphi(), HOUnrolledTP::iphi, HcalHTRData::is_channel_header(), HcalHTRData::isBusy(), HcalHTRData::isEmptyEvent(), HcalHTRData::isHistogramEvent(), HcalHTRData::isOverflowWarning(), isTPGSOI(), HcalHTRData::isUnsuppressed(), linear(), LogDebug, HcalElectronicsMap::lookup(), HcalElectronicsMap::lookupTrigger(), HcalDTCHeader::MAXIMUM_SLOT, DetId::null(), HcalTriggerPrimitiveSample::raw(), HcalQIESample::raw(), EgammaValidation_cff::samples, HOUnrolledTP::samples, HOUnrolledTP::setbit(), HcalElectronicsId::setHTR(), FEDRawData::size(), slb(), slbAndChan(), slbChan(), HOUnrolledTP::soi, HcalDCCHeader::SPIGOT_COUNT, HcalOtherDetId::subdet(), HcalZDCDetId::SubdetectorId, DetId::subdetId(), HcalUnpacker::Collections::tpCont, HcalUnpacker::Collections::tphoCont, HcalUnpacker::Collections::ttp, HcalTrigTowerDetId::Undefined, HcalTTPUnpacker::unpack(), HcalHTRData::unpack_per_channel_header(), validateGeometry_cfg::valid, HOUnrolledTP::valid, HcalHTRData::wasMarkAndPassZSTP(), testProducerWithPsetDescEmpty_cfi::x1, and HcalUnpacker::Collections::zdcCont.

Referenced by setMode().

236  {
237  // get the DCC header
238  const HcalDCCHeader* dccHeader = (const HcalDCCHeader*)(raw.data());
239  const HcalDTCHeader* dtcHeader = (const HcalDTCHeader*)(raw.data());
240  bool is_VME_DCC = (dccHeader->getDCCDataFormatVersion() < 0x10) || ((mode_ & 0x1) == 0);
241 
242  int dccid =
243  (is_VME_DCC) ? (dccHeader->getSourceId() - sourceIdOffset_) : (dtcHeader->getSourceId() - sourceIdOffset_);
244 
245  // check the summary status
246 
247  // walk through the HTR data. For the uTCA, use spigot=slot+1
248  HcalHTRData htr;
249  const unsigned short *daq_first, *daq_last, *tp_first, *tp_last;
250  const HcalQIESample *qie_begin, *qie_end, *qie_work;
251  const HcalTriggerPrimitiveSample *tp_begin, *tp_end, *tp_work;
252  for (int spigot = 0; spigot < HcalDCCHeader::SPIGOT_COUNT; spigot++) {
253  if (is_VME_DCC) {
254  if (!dccHeader->getSpigotPresent(spigot))
255  continue;
256 
257  int retval = dccHeader->getSpigotData(spigot, htr, raw.size());
258  if (retval != 0) {
259  if (retval == -1) {
260  if (!silent)
261  edm::LogWarning("Invalid Data") << "Invalid HTR data (data beyond payload size) observed on spigot "
262  << spigot << " of DCC with source id " << dccHeader->getSourceId();
263  report.countSpigotFormatError();
264  }
265  continue;
266  }
267  // check
268  if (dccHeader->getSpigotCRCError(spigot)) {
269  if (!silent)
270  edm::LogWarning("Invalid Data") << "CRC Error on HTR data observed on spigot " << spigot
271  << " of DCC with source id " << dccHeader->getSourceId();
272  report.countSpigotFormatError();
273  continue;
274  }
275  } else { // is_uTCA (!is_VME_DCC)
276  int slot = spigot + 1;
277  if (slot > HcalDTCHeader::MAXIMUM_SLOT)
278  continue;
279 
280  if (!dtcHeader->getSlotPresent(slot))
281  continue;
282 
283  int retval = dtcHeader->getSlotData(slot, htr, raw.size());
284  if (retval != 0) {
285  if (retval == -1) {
286  if (!silent)
287  edm::LogWarning("Invalid Data") << "Invalid uHTR data (data beyond payload size) observed on slot " << slot
288  << " of DTC with source id " << dtcHeader->getSourceId();
289  report.countSpigotFormatError();
290  }
291  continue;
292  }
293  // check
294  if (dtcHeader->getSlotCRCError(slot)) {
295  if (!silent)
296  edm::LogWarning("Invalid Data") << "CRC Error on uHTR data observed on slot " << slot
297  << " of DTC with source id " << dtcHeader->getSourceId();
298  report.countSpigotFormatError();
299  continue;
300  }
301  }
302 
303  // check for EE
304  if (htr.isEmptyEvent()) {
305  report.countEmptyEventSpigot();
306  }
307  if (htr.isOverflowWarning()) {
308  report.countOFWSpigot();
309  }
310  if (htr.isBusy()) {
311  report.countBusySpigot();
312  }
313  if (!htr.check()) {
314  if (!silent)
315  edm::LogWarning("Invalid Data") << "Invalid HTR data observed on spigot " << spigot << " of DCC with source id "
316  << dccHeader->getSourceId();
317  report.countSpigotFormatError();
318  continue;
319  }
320  if (htr.isHistogramEvent()) {
321  if (!silent)
322  edm::LogWarning("Invalid Data") << "Histogram data passed to non-histogram unpacker on spigot " << spigot
323  << " of DCC with source id " << dccHeader->getSourceId();
324  continue;
325  }
326  if ((htr.getFirmwareFlavor() & 0xE0) == 0x80) { // some kind of TTP data
327  if (colls.ttp != nullptr) {
328  HcalTTPUnpacker ttpUnpack;
329  colls.ttp->push_back(HcalTTPDigi());
330  ttpUnpack.unpack(htr, colls.ttp->back());
331  } else {
332  LogDebug("HcalTechTrigProcessor")
333  << "Skipping data on spigot " << spigot << " of DCC with source id " << dccHeader->getSourceId()
334  << " which is from the TechTrigProcessor (use separate unpacker!)";
335  }
336  continue;
337  }
338  if (htr.getFirmwareFlavor() >= 0x80) {
339  if (!silent)
340  edm::LogWarning("HcalUnpacker") << "Skipping data on spigot " << spigot << " of DCC with source id "
341  << dccHeader->getSourceId() << " which is of unknown flavor "
342  << htr.getFirmwareFlavor();
343  continue;
344  }
345 
346  // calculate "real" number of presamples
347  int nps = htr.getNPS() - startSample_;
348 
349  // get pointers
350  htr.dataPointers(&daq_first, &daq_last, &tp_first, &tp_last);
351  unsigned int smid = htr.getSubmodule();
352  int htr_tb = smid & 0x1;
353  int htr_slot = (smid >> 1) & 0x1F;
354  int htr_cr = (smid >> 6) & 0x1F;
355 
356  tp_begin = (const HcalTriggerPrimitiveSample*)tp_first;
357  tp_end = (const HcalTriggerPrimitiveSample*)(tp_last + 1); // one beyond last..
358 
360  int currFiberChan = 0x3F; // invalid fiber+channel...
361  int ncurr = 0;
362  bool valid = false;
363 
364  bool tpgSOIbitInUse = htr.getFormatVersion() >= 3; // version 3 and later
365  bool isHOtpg = htr.getFormatVersion() >= 3 && htr.getFirmwareFlavor() == 0; // HO is flavor zero
366  int npre = 0;
367  /*
368  Unpack the trigger primitives
369  */
370  if (isHOtpg) {
371  HOUnrolledTP unrolled[24];
372  for (tp_work = tp_begin; tp_work != tp_end; tp_work++) {
373  if (tp_work->raw() == 0xFFFF)
374  continue; // filler word
375  int sector = slbChan(tp_work->raw());
376  if (sector > 2)
377  continue;
378 
379  for (int ibit = 0; ibit < 8; ibit++) {
380  int linear = sector * 8 + ibit;
381  if (!unrolled[linear].checked) {
382  unrolled[linear].checked = true;
383  int fiber = (linear / 3) + 1;
384  int fc = (linear % 3);
385  // electronics id (use precision match for HO TP)
386  HcalElectronicsId eid(fc, fiber, spigot, dccid);
387  eid.setHTR(htr_cr, htr_slot, htr_tb);
388  DetId did = emap.lookup(eid);
389  if (!did.null()) {
390  if (did.det() == DetId::Hcal && ((HcalSubdetector)did.subdetId()) == HcalOuter) {
391  HcalDetId hid(did);
392  unrolled[linear].valid = true;
393  unrolled[linear].ieta = hid.ieta();
394  unrolled[linear].iphi = hid.iphi();
395  }
396  } else {
397  report.countUnmappedTPDigi(eid);
398  }
399  }
400  if (unrolled[linear].valid) {
401  if (isTPGSOI(*tp_work))
402  unrolled[linear].soi = unrolled[linear].samples;
403  if (tp_work->raw() & (1 << ibit))
404  unrolled[linear].setbit(unrolled[linear].samples);
405  unrolled[linear].samples++;
406  }
407  }
408  }
409  for (int i = 0; i < 24; i++) {
410  if (unrolled[i].valid)
411  colls.tphoCont->push_back(HOTriggerPrimitiveDigi(
412  unrolled[i].ieta, unrolled[i].iphi, unrolled[i].samples, unrolled[i].soi, unrolled[i].databits));
413  }
414  } else { // regular TPs (not HO)
415  for (tp_work = tp_begin; tp_work != tp_end; tp_work++) {
416  if (tp_work->raw() == 0xFFFF)
417  continue; // filler word
418  if (slbAndChan(tp_work->raw()) != currFiberChan) { // start new set
419  npre = 0;
420  currFiberChan = slbAndChan(tp_work->raw());
421  // lookup the right channel
422  HcalElectronicsId eid(slbChan(tp_work->raw()), slb(tp_work->raw()), spigot, dccid, htr_cr, htr_slot, htr_tb);
423  DetId did = emap.lookupTrigger(eid);
424  if (did.null()) {
425  report.countUnmappedTPDigi(eid);
426  if (unknownIdsTrig_.find(eid) == unknownIdsTrig_.end()) {
427  if (!silent)
428  edm::LogWarning("HCAL") << "HcalUnpacker: No trigger primitive match found for electronics id :" << eid;
429  unknownIdsTrig_.insert(eid);
430  }
431  valid = false;
432  continue;
433  } else if (did == HcalTrigTowerDetId::Undefined || (did.det() == DetId::Hcal && did.subdetId() == 0)) {
434  // known to be unmapped
435  valid = false;
436  continue;
437  }
438  HcalTrigTowerDetId id(did);
439  colls.tpCont->push_back(HcalTriggerPrimitiveDigi(id));
440  // set the various bits
441  if (!tpgSOIbitInUse)
442  colls.tpCont->back().setPresamples(nps);
443  colls.tpCont->back().setZSInfo(htr.isUnsuppressed(),
444  htr.wasMarkAndPassZSTP(slb(tp_work->raw()), slbChan(tp_work->raw())));
445 
446  // no hits recorded for current
447  ncurr = 0;
448  valid = true;
449  }
450  // add the word (if within settings or recent firmware [recent firmware ignores startSample/endSample])
451  if (valid && ((tpgSOIbitInUse && ncurr < 10) || (ncurr >= startSample_ && ncurr <= endSample_))) {
452  colls.tpCont->back().setSample(colls.tpCont->back().size(), *tp_work);
453  colls.tpCont->back().setSize(colls.tpCont->back().size() + 1);
454  }
455  // set presamples,if SOI
456  if (valid && tpgSOIbitInUse && isTPGSOI(*tp_work)) {
457  colls.tpCont->back().setPresamples(ncurr);
458  }
459  ncurr++;
460  npre++;
461  }
462  }
463 
466  qie_begin = (const HcalQIESample*)daq_first;
467  qie_end = (const HcalQIESample*)(daq_last + 1); // one beyond last..
468 
470 
471  for (qie_work = qie_begin; qie_work != qie_end;) {
472  if (qie_work->raw() == 0xFFFF) {
473  qie_work++;
474  continue; // filler word
475  }
476  // always at the beginning ...
477 
478  // lookup the right channel
479  HcalElectronicsId eid(qie_work->fiberChan(), qie_work->fiber(), spigot, dccid);
480  eid.setHTR(htr_cr, htr_slot, htr_tb);
481  DetId did = emap.lookup(eid);
482 
483  if (!did.null()) {
484  if (did.det() == DetId::Calo && did.subdetId() == HcalZDCDetId::SubdetectorId) {
485  colls.zdcCont->push_back(ZDCDataFrame(HcalZDCDetId(did)));
486  qie_work = HcalUnpacker_impl::unpack<ZDCDataFrame>(qie_work,
487  qie_end,
488  colls.zdcCont->back(),
489  nps,
490  eid,
491  startSample_,
492  endSample_,
494  htr);
495  } else if (did.det() == DetId::Hcal) {
496  switch (((HcalSubdetector)did.subdetId())) {
497  case (HcalBarrel):
498  case (HcalEndcap): {
499  colls.hbheCont->push_back(HBHEDataFrame(HcalDetId(did)));
500  qie_work = HcalUnpacker_impl::unpack<HBHEDataFrame>(qie_work,
501  qie_end,
502  colls.hbheCont->back(),
503  nps,
504  eid,
505  startSample_,
506  endSample_,
508  htr);
509  } break;
510  case (HcalOuter): {
511  colls.hoCont->push_back(HODataFrame(HcalDetId(did)));
512  qie_work = HcalUnpacker_impl::unpack<HODataFrame>(qie_work,
513  qie_end,
514  colls.hoCont->back(),
515  nps,
516  eid,
517  startSample_,
518  endSample_,
520  htr);
521  } break;
522  case (HcalForward): {
523  colls.hfCont->push_back(HFDataFrame(HcalDetId(did)));
524  qie_work = HcalUnpacker_impl::unpack<HFDataFrame>(qie_work,
525  qie_end,
526  colls.hfCont->back(),
527  nps,
528  eid,
529  startSample_,
530  endSample_,
532  htr);
533  } break;
534  case (HcalOther): {
535  HcalOtherDetId odid(did);
536  if (odid.subdet() == HcalCalibration) {
537  colls.calibCont->push_back(HcalCalibDataFrame(HcalCalibDetId(did)));
538  qie_work = HcalUnpacker_impl::unpack<HcalCalibDataFrame>(qie_work,
539  qie_end,
540  colls.calibCont->back(),
541  nps,
542  eid,
543  startSample_,
544  endSample_,
546  htr);
547  }
548  } break;
549  case (HcalEmpty):
550  default: {
551  for (int fiberC = qie_work->fiberAndChan(); qie_work != qie_end && qie_work->fiberAndChan() == fiberC;
552  qie_work++)
553  ;
554  } break;
555  }
556  }
557  } else {
558  report.countUnmappedDigi(eid);
559  if (unknownIds_.find(eid) == unknownIds_.end()) {
560  if (!silent)
561  edm::LogWarning("HCAL") << "HcalUnpacker: No match found for electronics id :" << eid;
562  unknownIds_.insert(eid);
563  }
564  for (int fiberC = qie_work->fiberAndChan(); qie_work != qie_end && qie_work->fiberAndChan() == fiberC;
565  qie_work++)
566  ;
567  }
568  }
569  } else {
570  // this is the branch for unpacking the compact data format with per-channel headers
571  const unsigned short* ptr_header = daq_first;
572  const unsigned short* ptr_end = daq_last + 1;
573  int flavor, error_flags, capid0, channelid;
574 
575  while (ptr_header != ptr_end) {
576  if (*ptr_header == 0xFFFF) { // impossible filler word
577  ptr_header++;
578  continue;
579  }
580  // unpack the header word
581  bool isheader = HcalHTRData::unpack_per_channel_header(*ptr_header, flavor, error_flags, capid0, channelid);
582  if (!isheader) {
583  ptr_header++;
584  continue;
585  }
586 
587  int fiberchan = channelid & 0x3;
588  int fiber = ((channelid >> 2) & 0x7) + 1;
589 
590  // lookup the right channel
591  HcalElectronicsId eid(fiberchan, fiber, spigot, dccid);
592  eid.setHTR(htr_cr, htr_slot, htr_tb);
593  DetId did = emap.lookup(eid);
594 
595  if (!did.null()) {
596  if (did.det() == DetId::Calo && did.subdetId() == HcalZDCDetId::SubdetectorId) {
597  colls.zdcCont->push_back(ZDCDataFrame(HcalZDCDetId(did)));
598  ptr_header = HcalUnpacker_impl::unpack_compact<ZDCDataFrame>(ptr_header,
599  ptr_end,
600  colls.zdcCont->back(),
601  nps,
602  eid,
603  startSample_,
604  endSample_,
606  htr);
607  } else if (did.det() == DetId::Hcal) {
608  switch (((HcalSubdetector)did.subdetId())) {
609  case (HcalBarrel):
610  case (HcalEndcap): {
611  colls.hbheCont->push_back(HBHEDataFrame(HcalDetId(did)));
612  ptr_header = HcalUnpacker_impl::unpack_compact<HBHEDataFrame>(ptr_header,
613  ptr_end,
614  colls.hbheCont->back(),
615  nps,
616  eid,
617  startSample_,
618  endSample_,
620  htr);
621  } break;
622  case (HcalOuter): {
623  colls.hoCont->push_back(HODataFrame(HcalDetId(did)));
624  ptr_header = HcalUnpacker_impl::unpack_compact<HODataFrame>(ptr_header,
625  ptr_end,
626  colls.hoCont->back(),
627  nps,
628  eid,
629  startSample_,
630  endSample_,
632  htr);
633  } break;
634  case (HcalForward): {
635  colls.hfCont->push_back(HFDataFrame(HcalDetId(did)));
636  ptr_header = HcalUnpacker_impl::unpack_compact<HFDataFrame>(ptr_header,
637  ptr_end,
638  colls.hfCont->back(),
639  nps,
640  eid,
641  startSample_,
642  endSample_,
644  htr);
645  } break;
646  case (HcalOther): {
647  HcalOtherDetId odid(did);
648  if (odid.subdet() == HcalCalibration) {
649  colls.calibCont->push_back(HcalCalibDataFrame(HcalCalibDetId(did)));
650  ptr_header = HcalUnpacker_impl::unpack_compact<HcalCalibDataFrame>(ptr_header,
651  ptr_end,
652  colls.calibCont->back(),
653  nps,
654  eid,
655  startSample_,
656  endSample_,
658  htr);
659  }
660  } break;
661  case (HcalEmpty):
662  default: {
663  for (ptr_header++; ptr_header != ptr_end && !HcalHTRData::is_channel_header(*ptr_header); ptr_header++)
664  ;
665  } break;
666  }
667  }
668  } else {
669  report.countUnmappedDigi(eid);
670  if (unknownIds_.find(eid) == unknownIds_.end()) {
671  if (!silent)
672  edm::LogWarning("HCAL") << "HcalUnpacker: No match found for electronics id :" << eid;
673  unknownIds_.insert(eid);
674  }
675  for (ptr_header++; ptr_header != ptr_end && !HcalHTRData::is_channel_header(*ptr_header); ptr_header++)
676  ;
677  }
678  }
679  }
680  }
681 }
#define LogDebug(id)
int getSourceId() const
Definition: HcalDTCHeader.h:35
std::set< HcalElectronicsId > unknownIds_
Definition: HcalUnpacker.h:88
int sourceIdOffset_
number to subtract from the source id to get the dcc id
Definition: HcalUnpacker.h:83
int endSample_
last sample from fed raw data to copy (if present)
Definition: HcalUnpacker.h:85
int startSample_
first sample from fed raw data to copy
Definition: HcalUnpacker.h:84
bool check() const
Check for a good event Requires a minimum length, matching wordcount and length, not an empty event...
Definition: HcalHTRData.cc:63
static int slbAndChan(uint16_t theSample)
constexpr bool null() const
is this a null id ?
Definition: DetId.h:59
bool getSpigotCRCError(unsigned int nspigot) const
Read the "CRC-Mismatch" bit for this spigot.
static bool isTPGSOI(const HcalTriggerPrimitiveSample &s)
constexpr int fiberChan() const
get the fiber channel number
Definition: HcalQIESample.h:55
static bool unpack_per_channel_header(unsigned short, int &flav, int &error_flags, int &capid0, int &channelid)
Unpack a per-channel header word (compact format)
Definition: HcalHTRData.cc:455
int getSpigotData(int nspigot, HcalHTRData &decodeTool, int validSize) const
int getFormatVersion() const
Get the version number of this event.
Definition: HcalHTRData.h:36
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
bool isUnsuppressed() const
Is this event an unsuppresed event?
Definition: HcalHTRData.cc:378
bool isOverflowWarning() const
Definition: HcalHTRData.cc:115
static bool is_channel_header(unsigned short value)
check top bit to see if this is a compact format channel header word
Definition: HcalHTRData.h:92
int expectedOrbitMessageTime_
Expected orbit bunch time (needed to evaluate time differences)
Definition: HcalUnpacker.h:86
bool isEmptyEvent() const
Definition: HcalHTRData.cc:107
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
HcalSubdetector
Definition: HcalAssistant.h:31
uint16_t raw() const
get the raw word
bool getSpigotPresent(unsigned int nspigot) const
Read the "PRESENT" bit for this spigot.
bool getSlotPresent(unsigned int nslot) const
Read the "PRESENT" bit for this slot.
Definition: HcalDTCHeader.h:85
std::set< HcalElectronicsId > unknownIdsTrig_
Recorded to limit number of times a log message is generated.
Definition: HcalUnpacker.h:88
int getSourceId() const
Definition: HcalDCCHeader.h:32
Definition: DetId.h:17
static const int SubdetectorId
Definition: HcalZDCDetId.h:25
static int slb(uint16_t theSample)
void dataPointers(const unsigned short **daq_first, const unsigned short **daq_last, const unsigned short **tp_first, const unsigned short **tp_last) const
Obtain the starting and ending pointers for external unpacking of the data.
Definition: HcalHTRData.cc:161
bool unpack(const HcalHTRData &data, HcalTTPDigi &digi)
void setbit(int i)
int getNPS() const
Get the number of presamples in daq data.
Definition: HcalHTRData.cc:426
static const HcalTrigTowerDetId Undefined
static const int FORMAT_VERSION_COMPACT_DATA
Definition: HcalHTRData.h:20
int getFirmwareFlavor() const
Get the HTR firmware flavor.
Definition: HcalHTRData.cc:433
static const int SPIGOT_COUNT
Definition: HcalDCCHeader.h:19
int getSlotData(int nslot, HcalHTRData &decodeTool, int validSize) const
bool wasMarkAndPassZSTP(int slb, int slbchan) const
Was this channel passed as part of Mark&Pass ZS?
Definition: HcalHTRData.cc:389
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
constexpr uint16_t raw() const
get the raw word
Definition: HcalQIESample.h:41
const DetId lookupTrigger(HcalElectronicsId fId) const
brief lookup the trigger logical detid associated with the given electronics id
short getDCCDataFormatVersion() const
Definition: HcalDCCHeader.h:59
unsigned int getSubmodule() const
Get the HTR submodule number.
Definition: HcalHTRData.cc:355
bool isBusy() const
Definition: HcalHTRData.cc:123
float linear(float x)
Readout chain identification for Hcal.
const DetId lookup(HcalElectronicsId fId) const
lookup the logical detid associated with the given electronics id
bool isHistogramEvent() const
Is this event a histogram event? (do not call standard unpack in this case!!!!!)
Definition: HcalHTRData.cc:409
static const int MAXIMUM_SLOT
Definition: HcalDTCHeader.h:22
bool getSlotCRCError(unsigned int nslot) const
Read the "CRC-Mismatch" bit for this slot.
Definition: HcalDTCHeader.h:93
static int slbChan(uint16_t theSample)
constexpr int fiber() const
get the fiber number
Definition: HcalQIESample.h:53
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46

Member Data Documentation

int HcalUnpacker::endSample_
private

last sample from fed raw data to copy (if present)

Definition at line 85 of file HcalUnpacker.h.

int HcalUnpacker::expectedOrbitMessageTime_
private

Expected orbit bunch time (needed to evaluate time differences)

Definition at line 86 of file HcalUnpacker.h.

Referenced by setExpectedOrbitMessageTime().

int HcalUnpacker::mode_
private

Definition at line 87 of file HcalUnpacker.h.

Referenced by setMode().

int HcalUnpacker::nPrinted_
private

Definition at line 91 of file HcalUnpacker.h.

int HcalUnpacker::sourceIdOffset_
private

number to subtract from the source id to get the dcc id

Definition at line 83 of file HcalUnpacker.h.

int HcalUnpacker::startSample_
private

first sample from fed raw data to copy

Definition at line 84 of file HcalUnpacker.h.

std::set<HcalElectronicsId> HcalUnpacker::unknownIds_
private

Definition at line 88 of file HcalUnpacker.h.

std::set<HcalElectronicsId> HcalUnpacker::unknownIdsTrig_
private

Recorded to limit number of times a log message is generated.

Definition at line 88 of file HcalUnpacker.h.