#include <CastorCtdcUnpacker.h>
Public Member Functions | |
CastorCtdcUnpacker (int sourceIdOffset, int beg, int end) | |
for normal data | |
void | unpack (const FEDRawData &raw, const CastorElectronicsMap &emap, CastorRawCollections &conts, HcalUnpackerReport &report) |
Private Attributes | |
int | endSample_ |
last sample from fed raw data to copy (if present) | |
int | sourceIdOffset_ |
number to subtract from the source id to get the dcc id | |
int | startSample_ |
first sample from fed raw data to copy | |
std::set< CastorElectronicsId > | unknownIds_ |
std::set< CastorElectronicsId > | unknownIdsTrig_ |
Recorded to limit number of times a log message is generated. |
Definition at line 14 of file CastorCtdcUnpacker.h.
CastorCtdcUnpacker::CastorCtdcUnpacker | ( | int | sourceIdOffset, |
int | beg, | ||
int | end | ||
) |
for normal data
Definition at line 12 of file CastorCtdcUnpacker.cc.
References end, endSample_, CastorDataFrame::MAXSAMPLES, and startSample_.
: sourceIdOffset_(sourceIdOffset) { if ( beg >= 0 && beg <= CastorDataFrame::MAXSAMPLES -1 ) { startSample_ = beg; } else { startSample_ = 0; } if ( end >= 0 && end <= CastorDataFrame::MAXSAMPLES -1 && end >= beg ) { endSample_ = end; } else { endSample_ = CastorDataFrame::MAXSAMPLES -1; } }
void CastorCtdcUnpacker::unpack | ( | const FEDRawData & | raw, |
const CastorElectronicsMap & | emap, | ||
CastorRawCollections & | conts, | ||
HcalUnpackerReport & | report | ||
) |
work through all channels
Definition at line 27 of file CastorCtdcUnpacker.cc.
References CastorRawCollections::castorCont, CastorCORData::CHANNELS_PER_SPIGOT, CastorCORData::check(), HcalUnpackerReport::countSpigotFormatError(), HcalUnpackerReport::countUnmappedDigi(), FEDRawData::data(), endSample_, newFWLiteAna::found, CastorCORData::getNPS(), CastorCTDCHeader::getSourceId(), CastorCTDCHeader::getSpigotData(), CastorCTDCHeader::getSpigotPresent(), CastorCORData::isHistogramEvent(), CastorElectronicsMap::lookup(), CastorCORData::MAXIMUM_SAMPLES_PER_CHANNEL, compare_using_db::sample, CastorDataFrame::setPresamples(), CastorDataFrame::setSample(), CastorDataFrame::setSize(), FEDRawData::size(), sourceIdOffset_, CastorCTDCHeader::SPIGOT_COUNT, startSample_, unknownIds_, and CastorCORData::unpack().
Referenced by CastorRawToDigi::produce().
{ if (raw.size()<16) { edm::LogWarning("Invalid Data") << "Empty/invalid DCC data, size = " << raw.size(); return; } // get the CTDC header const CastorCTDCHeader* ctdcHeader=(const CastorCTDCHeader*)(raw.data()); int ctdcid=ctdcHeader->getSourceId()-sourceIdOffset_; // space for unpacked data from one COR std::vector<unsigned short> precdata(CastorCORData::CHANNELS_PER_SPIGOT*CastorCORData::MAXIMUM_SAMPLES_PER_CHANNEL); std::vector<unsigned short> trigdata(CastorCORData::CHANNELS_PER_SPIGOT*CastorCORData::MAXIMUM_SAMPLES_PER_CHANNEL); std::vector<unsigned char> preclen(CastorCORData::CHANNELS_PER_SPIGOT); std::vector<unsigned char> triglen(CastorCORData::CHANNELS_PER_SPIGOT); // walk through the COR data... CastorCORData cor; for (int spigot=0; spigot<CastorCTDCHeader::SPIGOT_COUNT; spigot++) { if (!ctdcHeader->getSpigotPresent(spigot)) continue; int retval=ctdcHeader->getSpigotData(spigot,cor,raw.size()); if (retval!=0) { if (retval==-1) { edm::LogWarning("Invalid Data") << "Invalid COR data (data beyond payload size) observed on spigot " << spigot << " of CTDC with source id " << ctdcHeader->getSourceId(); report.countSpigotFormatError(); } continue; } // check if (!cor.check()) { edm::LogWarning("Invalid Data") << "Invalid COR data observed on spigot " << spigot << " of CTDC with source id " << ctdcHeader->getSourceId(); report.countSpigotFormatError(); continue; } if (cor.isHistogramEvent()) { edm::LogWarning("Invalid Data") << "Histogram data passed to non-histogram unpacker on spigot " << spigot << " of CTDC with source id " << ctdcHeader->getSourceId(); continue; } // calculate "real" number of presamples int nps=cor.getNPS()-startSample_; // new: do not use get pointers .. instead make use of CastorCORData::unpack cor.unpack(&(preclen[0]),&(precdata[0]), &(triglen[0]),&(trigdata[0])); int ichan; for ( ichan = 0; ichan<CastorCORData::CHANNELS_PER_SPIGOT; ichan++) { if ( preclen[ichan] == 0 || preclen[ichan] & 0xc0 ) continue; int fiber = ichan/3; int fiberchan = ichan%3; // lookup the right channel CastorElectronicsId partialEid(fiberchan,fiber+1,spigot,ctdcid); // does this partial id exist? CastorElectronicsId eid; HcalGenericDetId did; bool found; found = emap.lookup(partialEid,eid,did); if (found) { CastorDataFrame digi = CastorDataFrame(HcalCastorDetId(did)); // set parameters - presamples digi.setPresamples(nps); int ntaken = 0; for ( int sample = startSample_; sample <= endSample_; sample++ ) { digi.setSample(ntaken,precdata[ichan*CastorCORData::MAXIMUM_SAMPLES_PER_CHANNEL+sample]); ntaken++; } digi.setSize(ntaken); colls.castorCont->push_back(digi); } else { report.countUnmappedDigi(); if (unknownIds_.find(partialEid)==unknownIds_.end()) { edm::LogWarning("CASTOR") << "CastorCtdcUnpacker: No match found for electronics partialEid :" << partialEid; unknownIds_.insert(partialEid); } } } } }
int CastorCtdcUnpacker::endSample_ [private] |
last sample from fed raw data to copy (if present)
Definition at line 23 of file CastorCtdcUnpacker.h.
Referenced by CastorCtdcUnpacker(), and unpack().
int CastorCtdcUnpacker::sourceIdOffset_ [private] |
number to subtract from the source id to get the dcc id
Definition at line 21 of file CastorCtdcUnpacker.h.
Referenced by unpack().
int CastorCtdcUnpacker::startSample_ [private] |
first sample from fed raw data to copy
Definition at line 22 of file CastorCtdcUnpacker.h.
Referenced by CastorCtdcUnpacker(), and unpack().
std::set<CastorElectronicsId> CastorCtdcUnpacker::unknownIds_ [private] |
Definition at line 24 of file CastorCtdcUnpacker.h.
Referenced by unpack().
std::set<CastorElectronicsId> CastorCtdcUnpacker::unknownIdsTrig_ [private] |
Recorded to limit number of times a log message is generated.
Definition at line 24 of file CastorCtdcUnpacker.h.