CMS 3D CMS Logo

Classes | Public Member Functions | Private Attributes

HcalUnpacker Class Reference

#include <HcalUnpacker.h>

List of all members.

Classes

struct  Collections

Public Member Functions

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

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 mode_
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< HcalElectronicsIdunknownIds_
std::set< HcalElectronicsIdunknownIdsTrig_
 Recorded to limit number of times a log message is generated.

Detailed Description

Definition at line 19 of file HcalUnpacker.h.


Constructor & Destructor Documentation

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

for normal data

Definition at line 35 of file HcalUnpacker.h.

HcalUnpacker::HcalUnpacker ( int  sourceIdOffset) [inline]

For histograms, no begin and end.

Definition at line 37 of file HcalUnpacker.h.

: sourceIdOffset_(sourceIdOffset), startSample_(-1), endSample_(-1),  expectedOrbitMessageTime_(-1), mode_(0) { }

Member Function Documentation

void HcalUnpacker::setExpectedOrbitMessageTime ( int  time) [inline]
void HcalUnpacker::setMode ( int  mode) [inline]

Definition at line 47 of file HcalUnpacker.h.

References alignBH_cfg::mode, and mode_.

Referenced by HcalRawToDigi::HcalRawToDigi().

{ mode_=mode; }
void HcalUnpacker::unpack ( const FEDRawData raw,
const HcalElectronicsMap emap,
std::vector< HFDataFrame > &  precision,
std::vector< HcalTriggerPrimitiveDigi > &  tp 
)

Definition at line 519 of file HcalUnpacker.cc.

References trackerHits::c, HcalUnpacker::Collections::hfCont, alignCSCRings::r, HcalUnpacker::Collections::tpCont, and unpack().

                                                                                                                                                           {
  Collections c;
  c.hfCont=&container;
  c.tpCont=&tp;
  HcalUnpackerReport r;
  unpack(raw,emap,c,r);
}
void HcalUnpacker::unpack ( const FEDRawData raw,
const HcalElectronicsMap emap,
std::vector< HODataFrame > &  precision,
std::vector< HcalTriggerPrimitiveDigi > &  tp 
)

Definition at line 511 of file HcalUnpacker.cc.

References trackerHits::c, HcalUnpacker::Collections::hoCont, alignCSCRings::r, HcalUnpacker::Collections::tpCont, and unpack().

                                                                                                                                                           {
  Collections c;
  c.hoCont=&container;
  c.tpCont=&tp;
  HcalUnpackerReport r;
  unpack(raw,emap,c,r);
}
void HcalUnpacker::unpack ( const FEDRawData raw,
const HcalElectronicsMap emap,
std::vector< HBHEDataFrame > &  precision,
std::vector< HcalTriggerPrimitiveDigi > &  tp 
)

Definition at line 503 of file HcalUnpacker.cc.

References trackerHits::c, HcalUnpacker::Collections::hbheCont, alignCSCRings::r, HcalUnpacker::Collections::tpCont, and unpack().

                                                                                                                                                             {
  Collections c;
  c.hbheCont=&container;
  c.tpCont=&tp;
  HcalUnpackerReport r;
  unpack(raw,emap,c,r);
}
void HcalUnpacker::unpack ( const FEDRawData raw,
const HcalElectronicsMap emap,
Collections conts,
HcalUnpackerReport report,
bool  silent = false 
)

work through the samples

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

work through the samples

Definition at line 129 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(), endSample_, expectedOrbitMessageTime_, 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(), HcalDTCHeader::getSourceId(), HcalDCCHeader::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, i, HOUnrolledTP::ieta, HcalDetId::ieta(), HOUnrolledTP::iphi, HcalDetId::iphi(), HcalHTRData::is_channel_header(), HcalHTRData::isBusy(), HcalHTRData::isEmptyEvent(), HcalHTRData::isHistogramEvent(), HcalHTRData::isOverflowWarning(), isTPGSOI(), HcalHTRData::isUnsuppressed(), LogDebug, HcalElectronicsMap::lookup(), HcalElectronicsMap::lookupTrigger(), HcalDTCHeader::MAXIMUM_SLOT, mode_, DetId::null(), HcalTriggerPrimitiveSample::raw(), HcalQIESample::raw(), HOUnrolledTP::samples, HOUnrolledTP::setbit(), HcalElectronicsId::setHTR(), FEDRawData::size(), HcalTriggerPrimitiveSample::slb(), HcalTriggerPrimitiveSample::slbAndChan(), HcalTriggerPrimitiveSample::slbChan(), HOUnrolledTP::soi, sourceIdOffset_, HcalDCCHeader::SPIGOT_COUNT, startSample_, HcalOtherDetId::subdet(), HcalZDCDetId::SubdetectorId, DetId::subdetId(), HcalUnpacker::Collections::tpCont, HcalUnpacker::Collections::tphoCont, HcalUnpacker::Collections::ttp, HcalTrigTowerDetId::Undefined, unknownIds_, unknownIdsTrig_, HcalTTPUnpacker::unpack(), HcalHTRData::unpack_per_channel_header(), HOUnrolledTP::valid, TrackValidation_HighPurity_cff::valid, HcalHTRData::wasMarkAndPassZSTP(), and HcalUnpacker::Collections::zdcCont.

                                                                                       {

  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());
  const HcalDTCHeader* dtcHeader=(const HcalDTCHeader*)(raw.data());
  bool is_VME_DCC=(dccHeader->getDCCDataFormatVersion()<0x10) || ((mode_&0x1)==0);
  
  int dccid=(is_VME_DCC)?(dccHeader->getSourceId()-sourceIdOffset_):(dtcHeader->getSourceId()-sourceIdOffset_);

  // check the summary status
  
  // walk through the HTR data.  For the uTCA, use spigot=slot+1
  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 (is_VME_DCC) {
      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;
      } 
    } else { // is_uTCA (!is_VME_DCC)
      int slot=spigot+1;
      if (slot>HcalDTCHeader::MAXIMUM_SLOT) continue;

      if (!dtcHeader->getSlotPresent(slot)) continue;

      int retval=dtcHeader->getSlotData(slot,htr,raw.size());
      if (retval!=0) {
        if (retval==-1) {
          if (!silent) edm::LogWarning("Invalid Data") << "Invalid uHTR data (data beyond payload size) observed on slot " << slot << " of DTC with source id " << dtcHeader->getSourceId();
          report.countSpigotFormatError();
        }
        continue;
      }
      // check
      if (dtcHeader->getSlotCRCError(slot)) {
        if (!silent) 
          edm::LogWarning("Invalid Data") << "CRC Error on uHTR data observed on slot " << slot << " of DTC with source id " << dtcHeader->getSourceId();
        report.countSpigotFormatError();
        continue;
      } 
    }


    // check for EE
    if (htr.isEmptyEvent()) {
      report.countEmptyEventSpigot();
    }
    if (htr.isOverflowWarning()) {
      report.countOFWSpigot();
    }
    if (htr.isBusy()) {
      report.countBusySpigot();
    }
    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("HcalTechTrigProcessor") << "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("HcalUnpacker") << "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
    */
    if (isHOtpg) {
      HOUnrolledTP unrolled[24];
      for (tp_work=tp_begin; tp_work!=tp_end; tp_work++) {
        if (tp_work->raw()==0xFFFF) continue; // filler word
        int sector=tp_work->slbChan();
        if (sector>2) continue;

        for (int ibit=0; ibit<8; ibit++) {
          int linear=sector*8+ibit; 
          if (!unrolled[linear].checked) {
            unrolled[linear].checked=true;
            int fiber=(linear/3)+1;
            int fc=(linear%3);
            // electronics id (use precision match for HO TP)
            HcalElectronicsId eid(fc,fiber,spigot,dccid);       
            eid.setHTR(htr_cr,htr_slot,htr_tb);
            DetId did=emap.lookup(eid);
            if (!did.null()) {
              if (did.det()==DetId::Hcal && ((HcalSubdetector)did.subdetId())==HcalOuter ) {
                HcalDetId hid(did);
                unrolled[linear].valid=true;
                unrolled[linear].ieta=hid.ieta();
                unrolled[linear].iphi=hid.iphi();
              }
            } else {
              report.countUnmappedTPDigi(eid);
            }
          }
          if (unrolled[linear].valid) {
            if (isTPGSOI(*tp_work)) unrolled[linear].soi=unrolled[linear].samples;
            if (tp_work->raw()&(1<<ibit)) unrolled[linear].setbit(unrolled[linear].samples);
            unrolled[linear].samples++;
          }
        }
      }
      for (int i=0; i<24; i++) {
        if (unrolled[i].valid) 
          colls.tphoCont->push_back(HOTriggerPrimitiveDigi(
                                                           unrolled[i].ieta,
                                                           unrolled[i].iphi,
                                                           unrolled[i].samples,
                                                           unrolled[i].soi,
                                                           unrolled[i].databits));
      }
    } else { // regular TPs (not HO)
      for (tp_work=tp_begin; tp_work!=tp_end; tp_work++) {
        if (tp_work->raw()==0xFFFF) continue; // filler word
        if (tp_work->slbAndChan()!=currFiberChan) { // start new set
          npre=0;
          currFiberChan=tp_work->slbAndChan();
          // lookup the right channel
          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)) {
            // known to be unmapped
            valid=false;
            continue;
          }
          HcalTrigTowerDetId id(did);
          colls.tpCont->push_back(HcalTriggerPrimitiveDigi(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++;
      }
    }

    if (htr.getFormatVersion() < HcalHTRData::FORMAT_VERSION_COMPACT_DATA) {
 
      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
        HcalElectronicsId 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()) {
          if (did.det()==DetId::Calo && did.subdetId()==HcalZDCDetId::SubdetectorId) {
            colls.zdcCont->push_back(ZDCDataFrame(HcalZDCDetId(did)));
            qie_work=HcalUnpacker_impl::unpack<ZDCDataFrame>(qie_work, qie_end, colls.zdcCont->back(), nps, eid, startSample_, endSample_, expectedOrbitMessageTime_, htr); 
          } else if (did.det()==DetId::Hcal) {
            switch (((HcalSubdetector)did.subdetId())) {
            case (HcalBarrel):
            case (HcalEndcap): {
              colls.hbheCont->push_back(HBHEDataFrame(HcalDetId(did)));
              qie_work=HcalUnpacker_impl::unpack<HBHEDataFrame>(qie_work, qie_end, colls.hbheCont->back(), nps, eid, startSample_, endSample_, expectedOrbitMessageTime_, htr);
            } break;
            case (HcalOuter): {
              colls.hoCont->push_back(HODataFrame(HcalDetId(did)));
              qie_work=HcalUnpacker_impl::unpack<HODataFrame>(qie_work, qie_end, colls.hoCont->back(), nps, eid, startSample_, endSample_, expectedOrbitMessageTime_, htr);
          } break;
            case (HcalForward): {
              colls.hfCont->push_back(HFDataFrame(HcalDetId(did)));
              qie_work=HcalUnpacker_impl::unpack<HFDataFrame>(qie_work, qie_end, colls.hfCont->back(), nps, eid, startSample_, endSample_, expectedOrbitMessageTime_, htr);
            } break;
            case (HcalOther) : {
              HcalOtherDetId odid(did);
              if (odid.subdet()==HcalCalibration) {
                colls.calibCont->push_back(HcalCalibDataFrame(HcalCalibDetId(did)));
                qie_work=HcalUnpacker_impl::unpack<HcalCalibDataFrame>(qie_work, qie_end, colls.calibCont->back(), nps, eid, startSample_, endSample_, expectedOrbitMessageTime_, htr); 
              }
            } break;
            case (HcalEmpty): 
            default: {
              for (int fiberC=qie_work->fiberAndChan();
                   qie_work!=qie_end && qie_work->fiberAndChan()==fiberC;
                   qie_work++);
            }
            break;
            }
          }
        } else {
          report.countUnmappedDigi(eid);
          if (unknownIds_.find(eid)==unknownIds_.end()) {
            if (!silent) edm::LogWarning("HCAL") << "HcalUnpacker: 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++);
        }
      }
    } else {
      // this is the branch for unpacking the compact data format with per-channel headers
      const unsigned short* ptr_header=daq_first;
      const unsigned short* ptr_end=daq_last+1;
      int flavor, error_flags, capid0, channelid;

      while (ptr_header!=ptr_end) {
        if (*ptr_header==0xFFFF) { // impossible filler word
          ptr_header++;
          continue;
        }
        // unpack the header word
        bool isheader=HcalHTRData::unpack_per_channel_header(*ptr_header,flavor,error_flags,capid0,channelid);
        if (!isheader) {
          ptr_header++;
          continue;
        }

        int fiberchan=channelid&0x3;
        int fiber=((channelid>>2)&0x7)+1;

        // lookup the right channel
        HcalElectronicsId eid(fiberchan,fiber,spigot,dccid);
        eid.setHTR(htr_cr,htr_slot,htr_tb);
        DetId did=emap.lookup(eid);
        
        if (!did.null()) {
          if (did.det()==DetId::Calo && did.subdetId()==HcalZDCDetId::SubdetectorId) {
            colls.zdcCont->push_back(ZDCDataFrame(HcalZDCDetId(did)));
            ptr_header=HcalUnpacker_impl::unpack_compact<ZDCDataFrame>(ptr_header, ptr_end, colls.zdcCont->back(), nps, eid, startSample_, endSample_, expectedOrbitMessageTime_, htr); 
          } else if (did.det()==DetId::Hcal) {
            switch (((HcalSubdetector)did.subdetId())) {
            case (HcalBarrel):
            case (HcalEndcap): {
              colls.hbheCont->push_back(HBHEDataFrame(HcalDetId(did)));
              ptr_header=HcalUnpacker_impl::unpack_compact<HBHEDataFrame>(ptr_header, ptr_end, colls.hbheCont->back(), nps, eid, startSample_, endSample_, expectedOrbitMessageTime_, htr);
            } break;
            case (HcalOuter): {
              colls.hoCont->push_back(HODataFrame(HcalDetId(did)));
              ptr_header=HcalUnpacker_impl::unpack_compact<HODataFrame>(ptr_header, ptr_end, colls.hoCont->back(), nps, eid, startSample_, endSample_, expectedOrbitMessageTime_, htr);
          } break;
            case (HcalForward): {
              colls.hfCont->push_back(HFDataFrame(HcalDetId(did)));
              ptr_header=HcalUnpacker_impl::unpack_compact<HFDataFrame>(ptr_header, ptr_end, colls.hfCont->back(), nps, eid, startSample_, endSample_, expectedOrbitMessageTime_, htr);
            } break;
            case (HcalOther) : {
              HcalOtherDetId odid(did);
              if (odid.subdet()==HcalCalibration) {
                colls.calibCont->push_back(HcalCalibDataFrame(HcalCalibDetId(did)));
                ptr_header=HcalUnpacker_impl::unpack_compact<HcalCalibDataFrame>(ptr_header, ptr_end, colls.calibCont->back(), nps, eid, startSample_, endSample_, expectedOrbitMessageTime_, htr); 
              }
            } break;
            case (HcalEmpty): 
            default: {
              for (ptr_header++;
                   ptr_header!=ptr_end && !HcalHTRData::is_channel_header(*ptr_header);
                   ptr_header++);
            }
            break;
            }
          }
        } else {
          report.countUnmappedDigi(eid);
          if (unknownIds_.find(eid)==unknownIds_.end()) {
            if (!silent) edm::LogWarning("HCAL") << "HcalUnpacker: No match found for electronics id :" << eid;
            unknownIds_.insert(eid);
          }
          for (ptr_header++;
               ptr_header!=ptr_end && !HcalHTRData::is_channel_header(*ptr_header);
               ptr_header++);
        }
      }

    }
  }
}
void HcalUnpacker::unpack ( const FEDRawData raw,
const HcalElectronicsMap emap,
std::vector< HcalHistogramDigi > &  histoDigis 
)

Definition at line 527 of file HcalUnpacker.cc.

References HcalHTRData::check(), FEDRawData::data(), DetId::det(), 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(), sourceIdOffset_, HcalDCCHeader::SPIGOT_COUNT, DetId::subdetId(), unknownIds_, and HcalHTRData::unpackHistogram().

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

                                                                                                                         {

  // 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;
  for (int spigot=0; spigot<HcalDCCHeader::SPIGOT_COUNT; spigot++) {
    if (!dccHeader->getSpigotPresent(spigot)) continue;
    
    int retval=dccHeader->getSpigotData(spigot,htr,raw.size());
    // check
    if (retval || !htr.check()) {
      edm::LogWarning("Invalid Data") << "Invalid HTR data observed on spigot " << spigot << " of DCC with source id " << dccHeader->getSourceId();
      continue;
    }
    if (!htr.isHistogramEvent()) {
      edm::LogWarning("Invalid Data") << "Non-histogram data passed to histogram unpacker on spigot " << spigot << " of DCC with source id " << dccHeader->getSourceId();
      continue;
    }

    unsigned int smid=htr.getSubmodule();
    int htr_tb=smid&0x1;
    int htr_slot=(smid>>1)&0x1F;
    int htr_cr=(smid>>6)&0x1F;
    
    // find out the fibers
    int f[2],fc;
    htr.getHistogramFibers(f[0],f[1]);

    for (int nf=0; nf<2; nf++) {
      if (f[nf]<0 || (nf==1 && f[0]==f[1])) continue; // skip if invalid or the same
      for (fc=0; fc<=2; fc++) {
        HcalElectronicsId eid(fc,f[nf],spigot,dccid);     
        eid.setHTR(htr_cr,htr_slot,htr_tb);
        DetId did=emap.lookup(eid);

        if (did.null() || did.det()!=DetId::Hcal || did.subdetId()==0) {
          if (unknownIds_.find(eid)==unknownIds_.end()) {
            edm::LogWarning("HCAL") << "HcalHistogramUnpacker: No match found for electronics id :" << eid;
            unknownIds_.insert(eid);
          }       
          continue;
        }
        histoDigis.push_back(HcalHistogramDigi(HcalDetId(did))); // add it!
        HcalHistogramDigi& digi=histoDigis.back();
        
        // unpack the four capids
        for (int capid=0; capid<4; capid++) 
          htr.unpackHistogram(f[nf],fc,capid,digi.getArray(capid));
        
      }
    }
  }
}      

Member Data Documentation

int HcalUnpacker::endSample_ [private]

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

Definition at line 51 of file HcalUnpacker.h.

Referenced by unpack().

Expected orbit bunch time (needed to evaluate time differences)

Definition at line 52 of file HcalUnpacker.h.

Referenced by setExpectedOrbitMessageTime(), and unpack().

int HcalUnpacker::mode_ [private]

Definition at line 53 of file HcalUnpacker.h.

Referenced by setMode(), and unpack().

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

Definition at line 49 of file HcalUnpacker.h.

Referenced by unpack().

first sample from fed raw data to copy

Definition at line 50 of file HcalUnpacker.h.

Referenced by unpack().

Definition at line 54 of file HcalUnpacker.h.

Referenced by unpack().

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

Definition at line 54 of file HcalUnpacker.h.

Referenced by unpack().