CMS 3D CMS Logo

Functions

HcalUnpacker_impl Namespace Reference

Functions

template<class DigiClass >
const HcalQIESampleunpack (const HcalQIESample *startPoint, const HcalQIESample *limit, DigiClass &digi, int presamples, const HcalElectronicsId &eid, int startSample, int endSample, int expectedTime, const HcalHTRData &hhd)
template<class DigiClass >
const unsigned short * unpack_compact (const unsigned short *startPoint, const unsigned short *limit, DigiClass &digi, int presamples, const HcalElectronicsId &eid, int startSample, int endSample, int expectedTime, const HcalHTRData &hhd)

Function Documentation

template<class DigiClass >
const HcalQIESample* HcalUnpacker_impl::unpack ( const HcalQIESample startPoint,
const HcalQIESample limit,
DigiClass &  digi,
int  presamples,
const HcalElectronicsId eid,
int  startSample,
int  endSample,
int  expectedTime,
const HcalHTRData hhd 
)

Definition at line 11 of file HcalUnpacker.cc.

References HcalQIESample::fiber(), HcalQIESample::fiberAndChan(), HcalQIESample::fiberChan(), HcalHTRData::getFibOrbMsgBCN(), HcalHTRData::isUnsuppressed(), HcalHTRData::wasMarkAndPassZS(), and HcalHTRData::zsBunchMask().

                                                                                                                                                                                                                                    {
    // set parameters
    digi.setPresamples(presamples);
    digi.setReadoutIds(eid);

    int fiber=startPoint->fiber();
    int fiberchan=startPoint->fiberChan();
    uint32_t zsmask=hhd.zsBunchMask()>>startSample;
    digi.setZSInfo(hhd.isUnsuppressed(),hhd.wasMarkAndPassZS(fiber,fiberchan),zsmask);

    if (expectedTime>=0 && !hhd.isUnsuppressed()) {
      //      std::cout << hhd.getFibOrbMsgBCN(fiber) << " " << expectedTime << std::endl;
      digi.setFiberIdleOffset(hhd.getFibOrbMsgBCN(fiber)-expectedTime);
    }

    // what is my sample number?
    int myFiberChan=startPoint->fiberAndChan();
    int ncurr=0,ntaken=0;
    const HcalQIESample* qie_work=startPoint;
    while (qie_work!=limit && qie_work->fiberAndChan()==myFiberChan) {
      if (ncurr>=startSample && ncurr<=endSample) {
        digi.setSample(ntaken,*qie_work);
        ++ntaken;
      }
      ncurr++;
      qie_work++;
    }
    digi.setSize(ntaken);
    return qie_work;
  }
template<class DigiClass >
const unsigned short* HcalUnpacker_impl::unpack_compact ( const unsigned short *  startPoint,
const unsigned short *  limit,
DigiClass &  digi,
int  presamples,
const HcalElectronicsId eid,
int  startSample,
int  endSample,
int  expectedTime,
const HcalHTRData hhd 
)

Definition at line 44 of file HcalUnpacker.cc.

References HcalHTRData::getFibOrbMsgBCN(), HcalHTRData::is_channel_header(), HcalHTRData::isUnsuppressed(), HcalHTRData::unpack_per_channel_header(), HcalHTRData::wasMarkAndPassZS(), and HcalHTRData::zsBunchMask().

                                                                                                                                                               {
    // set parameters
    digi.setPresamples(presamples);
    digi.setReadoutIds(eid);
    int flavor, error_flags, capid0, channelid;

    HcalHTRData::unpack_per_channel_header(*startPoint,flavor,error_flags,capid0,channelid);
    bool isCapRotating=!(error_flags&0x1);
    bool fiberErr=(error_flags&0x2);
    bool dataValid=!(error_flags&0x2);
    int fiberchan=channelid&0x3;
    int fiber=((channelid>>2)&0x7)+1;

    uint32_t zsmask=hhd.zsBunchMask()>>startSample;
    digi.setZSInfo(hhd.isUnsuppressed(),hhd.wasMarkAndPassZS(fiber,fiberchan),zsmask);

    if (expectedTime>=0 && !hhd.isUnsuppressed()) {
      //      std::cout << hhd.getFibOrbMsgBCN(fiber) << " " << expectedTime << std::endl;
      digi.setFiberIdleOffset(hhd.getFibOrbMsgBCN(fiber)-expectedTime);
    }

    // what is my sample number?
    int ncurr=0,ntaken=0;
    const unsigned short* qie_work=startPoint;
    for (qie_work++; qie_work!=limit && !HcalHTRData::is_channel_header(*qie_work); qie_work++) {
      int capidn=(isCapRotating)?((capid0+ncurr)%4):(capid0);
      int capidn1=(isCapRotating)?((capid0+ncurr+1)%4):(capid0);
      // two samples in one...
      HcalQIESample s0((*qie_work)&0x7F,capidn,fiber,fiberchan,dataValid,fiberErr);
      HcalQIESample s1(((*qie_work)>>8)&0x7F,capidn1,fiber,fiberchan,dataValid,fiberErr);

      if (ncurr>=startSample && ncurr<=endSample) {
        digi.setSample(ntaken,s0);
        ++ntaken;
      }
      ncurr++;
      if (ncurr>=startSample && ncurr<=endSample) {
        digi.setSample(ntaken,s1);
        ++ntaken;
      }
      ncurr++;
    }
    digi.setSize(ntaken);
    return qie_work;
  }