#include <CastorUnpacker.h>
Public Member Functions | |
CastorUnpacker (int sourceIdOffset, int beg, int end) | |
for normal data | |
void | setExpectedOrbitMessageTime (int time) |
void | unpack (const FEDRawData &raw, const CastorElectronicsMap &emap, CastorRawCollections &conts, HcalUnpackerReport &report, bool silent=false) |
For histograms, no begin and end. | |
Private Attributes | |
int | endSample_ |
last sample from fed raw data to copy (if present) | |
int | expectedOrbitMessageTime_ |
Expected orbit bunch time (needed to evaluate time differences) | |
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 15 of file CastorUnpacker.h.
CastorUnpacker::CastorUnpacker | ( | int | sourceIdOffset, |
int | beg, | ||
int | end | ||
) |
for normal data
Definition at line 51 of file CastorUnpacker.cc.
References end, endSample_, CastorDataFrame::MAXSAMPLES, and startSample_.
: sourceIdOffset_(sourceIdOffset) , expectedOrbitMessageTime_(-1) { 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 CastorUnpacker::setExpectedOrbitMessageTime | ( | int | time | ) | [inline] |
Definition at line 20 of file CastorUnpacker.h.
References expectedOrbitMessageTime_, and cond::rpcobgas::time.
Referenced by CastorRawToDigi::beginRun(), and CastorRawToDigi::CastorRawToDigi().
void CastorUnpacker::unpack | ( | const FEDRawData & | raw, |
const CastorElectronicsMap & | emap, | ||
CastorRawCollections & | conts, | ||
HcalUnpackerReport & | report, | ||
bool | silent = false |
||
) |
For histograms, no begin and end.
work through the samples
work through the samples
Definition at line 66 of file CastorUnpacker.cc.
References CastorRawCollections::castorCont, HcalHTRData::check(), HcalUnpackerReport::countSpigotFormatError(), HcalUnpackerReport::countUnmappedDigi(), FEDRawData::data(), HcalHTRData::dataPointers(), endSample_, expectedOrbitMessageTime_, HcalQIESample::fiber(), HcalQIESample::fiberAndChan(), HcalQIESample::fiberChan(), HcalHTRData::getFirmwareFlavor(), HcalHTRData::getFormatVersion(), HcalHTRData::getNPS(), HcalDCCHeader::getSourceId(), HcalDCCHeader::getSpigotCRCError(), HcalDCCHeader::getSpigotData(), HcalDCCHeader::getSpigotPresent(), HcalHTRData::getSubmodule(), HcalHTRData::isHistogramEvent(), isTPGSOI(), HcalHTRData::isUnsuppressed(), LogDebug, CastorElectronicsMap::lookup(), HcalCastorDetId::module(), DetId::null(), HcalTriggerPrimitiveSample::raw(), HcalQIESample::raw(), HcalCastorDetId::sector(), CastorElectronicsId::setHTR(), FEDRawData::size(), HcalTriggerPrimitiveSample::slb(), HcalTriggerPrimitiveSample::slbAndChan(), HcalTriggerPrimitiveSample::slbChan(), sourceIdOffset_, HcalDCCHeader::SPIGOT_COUNT, startSample_, CastorRawCollections::tpCont, CastorRawCollections::ttp, unknownIds_, HcalTTPUnpacker::unpack(), TrackValidation_HighPurity_cff::valid, HcalHTRData::wasMarkAndPassZSTP(), and HcalCastorDetId::zside().
Referenced by CastorRawToDigi::produce().
{ if (raw.size()<16) { if (!silent) edm::LogWarning("Invalid Data") << "Empty/invalid DCC data, size = " << raw.size(); return; } // get the DCC header const HcalDCCHeader* dccHeader=(const HcalDCCHeader*)(raw.data()); int dccid=dccHeader->getSourceId()-sourceIdOffset_; // check the summary status // walk through the HTR data... HcalHTRData htr; const unsigned short* daq_first, *daq_last, *tp_first, *tp_last; const HcalQIESample* qie_begin, *qie_end, *qie_work; const HcalTriggerPrimitiveSample *tp_begin, *tp_end, *tp_work; for (int spigot=0; spigot<HcalDCCHeader::SPIGOT_COUNT; spigot++) { if (!dccHeader->getSpigotPresent(spigot)) continue; int retval=dccHeader->getSpigotData(spigot,htr,raw.size()); if (retval!=0) { if (retval==-1) { if (!silent) edm::LogWarning("Invalid Data") << "Invalid HTR data (data beyond payload size) observed on spigot " << spigot << " of DCC with source id " << dccHeader->getSourceId(); report.countSpigotFormatError(); } continue; } // check if (dccHeader->getSpigotCRCError(spigot)) { if (!silent) edm::LogWarning("Invalid Data") << "CRC Error on HTR data observed on spigot " << spigot << " of DCC with source id " << dccHeader->getSourceId(); report.countSpigotFormatError(); continue; } if (!htr.check()) { if (!silent) edm::LogWarning("Invalid Data") << "Invalid HTR data observed on spigot " << spigot << " of DCC with source id " << dccHeader->getSourceId(); report.countSpigotFormatError(); continue; } if (htr.isHistogramEvent()) { if (!silent) edm::LogWarning("Invalid Data") << "Histogram data passed to non-histogram unpacker on spigot " << spigot << " of DCC with source id " << dccHeader->getSourceId(); continue; } if ((htr.getFirmwareFlavor()&0xE0)==0x80) { // some kind of TTP data if (colls.ttp!=0) { HcalTTPUnpacker ttpUnpack; colls.ttp->push_back(HcalTTPDigi()); ttpUnpack.unpack(htr,colls.ttp->back()); } else { LogDebug("CastorUnpackerHcalTechTrigProcessor") << "Skipping data on spigot " << spigot << " of DCC with source id " << dccHeader->getSourceId() << " which is from the TechTrigProcessor (use separate unpacker!)"; } continue; } if (htr.getFirmwareFlavor()>=0x80) { if (!silent) edm::LogWarning("CastorUnpacker") << "Skipping data on spigot " << spigot << " of DCC with source id " << dccHeader->getSourceId() << " which is of unknown flavor " << htr.getFirmwareFlavor(); continue; } // calculate "real" number of presamples int nps=htr.getNPS()-startSample_; // get pointers htr.dataPointers(&daq_first,&daq_last,&tp_first,&tp_last); unsigned int smid=htr.getSubmodule(); int htr_tb=smid&0x1; int htr_slot=(smid>>1)&0x1F; int htr_cr=(smid>>6)&0x1F; tp_begin=(HcalTriggerPrimitiveSample*)tp_first; tp_end=(HcalTriggerPrimitiveSample*)(tp_last+1); // one beyond last.. int currFiberChan=0x3F; // invalid fiber+channel... int ncurr=0; bool valid=false; bool tpgSOIbitInUse=htr.getFormatVersion()>=3; // version 3 and later // bool isHOtpg=htr.getFormatVersion()>=3 && htr.getFirmwareFlavor()==0; // HO is flavor zero int npre=0; /* Unpack the trigger primitives */ // lookup the right channel bool dotp = true; CastorElectronicsId eid(0,1,spigot,dccid); eid.setHTR(htr_cr,htr_slot,htr_tb); DetId did=emap.lookup(eid); if ( did.null() ) dotp = false; HcalCastorDetId id1(did); HcalCastorDetId id((id1.zside()==0),id1.sector(),1); if ( id1.module() > 12 ) dotp = false; if ( dotp ) { // std::cout << " tp_first="<< tp_first << " tp_last="<< tp_last<< " tb="<<htr_tb<<" slot="<<htr_slot<<" crate="<<htr_cr<<" dccid="<< dccid<< std::endl; // regular TPs (not HO) for (tp_work=tp_begin; tp_work!=tp_end; tp_work++) { // std::cout << "raw=0x"<<std::hex<< tp_work->raw()<<std::dec <<std::endl; if (tp_work->raw()==0xFFFF) continue; // filler word if (tp_work->slbAndChan()!=currFiberChan) { // start new set npre=0; currFiberChan=tp_work->slbAndChan(); // std::cout<< " NEW SET "<<std::endl; //HcalElectronicsId eid(tp_work->slbChan(),tp_work->slb(),spigot,dccid,htr_cr,htr_slot,htr_tb); //DetId did=emap.lookupTrigger(eid); //if (did.null()) { //report.countUnmappedTPDigi(eid); //if (unknownIdsTrig_.find(eid)==unknownIdsTrig_.end()) { //if (!silent) edm::LogWarning("HCAL") << "HcalUnpacker: No trigger primitive match found for electronics id :" << eid; //unknownIdsTrig_.insert(eid); //} //valid=false; //continue; //} else if (did==HcalTrigTowerDetId::Undefined || //(did.det()==DetId::Hcal && did.subdetId()==0)) { //valid=false; //continue; //} colls.tpCont->push_back(CastorTriggerPrimitiveDigi(id)); // set the various bits if (!tpgSOIbitInUse) colls.tpCont->back().setPresamples(nps); colls.tpCont->back().setZSInfo(htr.isUnsuppressed(),htr.wasMarkAndPassZSTP(tp_work->slb(),tp_work->slbChan())); // no hits recorded for current ncurr=0; valid=true; } // add the word (if within settings or recent firmware [recent firmware ignores startSample/endSample]) if (valid && ((tpgSOIbitInUse && ncurr<10) || (ncurr>=startSample_ && ncurr<=endSample_))) { colls.tpCont->back().setSample(colls.tpCont->back().size(),*tp_work); colls.tpCont->back().setSize(colls.tpCont->back().size()+1); } // set presamples,if SOI if (valid && tpgSOIbitInUse && isTPGSOI(*tp_work)) { colls.tpCont->back().setPresamples(ncurr); } ncurr++; npre++; } } qie_begin=(HcalQIESample*)daq_first; qie_end=(HcalQIESample*)(daq_last+1); // one beyond last.. currFiberChan=0x3F; // invalid fiber+channel... ncurr=0; valid=false; for (qie_work=qie_begin; qie_work!=qie_end; ) { if (qie_work->raw()==0xFFFF) { qie_work++; continue; // filler word } // always at the beginning ... currFiberChan=qie_work->fiberAndChan(); // lookup the right channel CastorElectronicsId eid(qie_work->fiberChan(),qie_work->fiber(),spigot,dccid); eid.setHTR(htr_cr,htr_slot,htr_tb); DetId did=emap.lookup(eid); if (!did.null()) { colls.castorCont->push_back(CastorDataFrame(HcalCastorDetId(did))); qie_work=CastorUnpacker_impl::unpack<CastorDataFrame>(qie_work, qie_end, colls.castorCont->back(), nps, eid, startSample_, endSample_, expectedOrbitMessageTime_, htr); } else { report.countUnmappedDigi(); if (unknownIds_.find(eid)==unknownIds_.end()) { if (!silent) edm::LogWarning("CASTOR") << "CastorUnpacker: No match found for electronics id :" << eid; unknownIds_.insert(eid); } for (int fiberC=qie_work->fiberAndChan(); qie_work!=qie_end && qie_work->fiberAndChan()==fiberC; qie_work++); } } } }
int CastorUnpacker::endSample_ [private] |
last sample from fed raw data to copy (if present)
Definition at line 27 of file CastorUnpacker.h.
Referenced by CastorUnpacker(), and unpack().
int CastorUnpacker::expectedOrbitMessageTime_ [private] |
Expected orbit bunch time (needed to evaluate time differences)
Definition at line 28 of file CastorUnpacker.h.
Referenced by setExpectedOrbitMessageTime(), and unpack().
int CastorUnpacker::sourceIdOffset_ [private] |
number to subtract from the source id to get the dcc id
Definition at line 25 of file CastorUnpacker.h.
Referenced by unpack().
int CastorUnpacker::startSample_ [private] |
first sample from fed raw data to copy
Definition at line 26 of file CastorUnpacker.h.
Referenced by CastorUnpacker(), and unpack().
std::set<CastorElectronicsId> CastorUnpacker::unknownIds_ [private] |
Definition at line 29 of file CastorUnpacker.h.
Referenced by unpack().
std::set<CastorElectronicsId> CastorUnpacker::unknownIdsTrig_ [private] |
Recorded to limit number of times a log message is generated.
Definition at line 29 of file CastorUnpacker.h.