CMS 3D CMS Logo

Functions
ZdcUnpacker_impl Namespace Reference

Functions

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 unsigned short* ZdcUnpacker_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 19 of file ZdcUnpacker.cc.

References HcalHTRData::getFibOrbMsgBCN(), HcalHTRData::is_channel_header(), HcalHTRData::isUnsuppressed(), MessageLogger_cfi::limit, simplePhotonAnalyzer_cfi::sample, HcalHTRData::unpack_per_channel_header(), HcalHTRData::wasMarkAndPassZS(), globals_cff::x1, and HcalHTRData::zsBunchMask().

21  {
22  // set parameters
23  digi.setPresamples(presamples);
24  digi.setReadoutIds(eid);
25  int flavor, error_flags, capid0, channelid;
26 
27  HcalHTRData::unpack_per_channel_header(*startPoint,flavor,error_flags,capid0,channelid);
28  bool isCapRotating=!(error_flags&0x1);
29  bool fiberErr=(error_flags&0x2);
30  bool dataValid=!(error_flags&0x2);
31  int fiberchan=channelid&0x3;
32  int fiber=((channelid>>2)&0x7)+1;
33 
34  uint32_t zsmask=hhd.zsBunchMask()>>startSample;
35  digi.setZSInfo(hhd.isUnsuppressed(),hhd.wasMarkAndPassZS(fiber,fiberchan),zsmask);
36 
37  if (expectedTime>=0 && !hhd.isUnsuppressed()) {
38  digi.setFiberIdleOffset(hhd.getFibOrbMsgBCN(fiber)-expectedTime);
39  }
40 
41  // what is my sample number?
42  int ncurr=0,ntaken=0;
43  const unsigned short* qie_work=startPoint;
44  // we branch here between normal (flavor=5) and error mode (flavor=6)
45  if (flavor==5) {
46  for (qie_work++; qie_work!=limit && !HcalHTRData::is_channel_header(*qie_work); qie_work++) {
47  int capidn=(isCapRotating)?((capid0+ncurr)%4):(capid0);
48  int capidn1=(isCapRotating)?((capid0+ncurr+1)%4):(capid0);
49  // two samples in one...
50  HcalQIESample s0((*qie_work)&0x7F,capidn,fiber,fiberchan,dataValid,fiberErr);
51  HcalQIESample s1(((*qie_work)>>8)&0x7F,capidn1,fiber,fiberchan,dataValid,fiberErr);
52 
53  if (ncurr>=startSample && ncurr<=endSample) {
54  digi.setSample(ntaken,s0);
55  ++ntaken;
56  }
57  ncurr++;
58  if (ncurr>=startSample && ncurr<=endSample) {
59  digi.setSample(ntaken,s1);
60  ++ntaken;
61  }
62  ncurr++;
63  }
64  digi.setSize(ntaken);
65  } else if (flavor==6) {
66  for (qie_work++; qie_work!=limit && !HcalHTRData::is_channel_header(*qie_work); qie_work++) {
67  if (ncurr>=startSample && ncurr<=endSample) {
68  HcalQIESample sample((*qie_work)&0x7F,((*qie_work)>>8)&0x3,fiber,fiberchan,((*qie_work)>>10)&0x1,((*qie_work)>>11)&0x1);
69  digi.setSample(ntaken,sample);
70  ++ntaken;
71  }
72  ncurr++;
73  }
74  digi.setSize(ntaken);
75  } else {
76  edm::LogWarning("Bad Data") << "Invalid flavor " << flavor;
77  qie_work=limit;
78  }
79  return qie_work;
80  }
bool wasMarkAndPassZS(int fiber, int fiberchan) const
Was this channel passed as part of Mark&Pass ZS?
Definition: HcalHTRData.cc:356
unsigned int getFibOrbMsgBCN(int fiber) const
Get the BCN of the Fiber Orbit Messages.
Definition: HcalHTRData.h:178
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:433
bool isUnsuppressed() const
Is this event an unsuppresed event?
Definition: HcalHTRData.cc:353
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:90
uint32_t zsBunchMask() const
ZS Bunch Mask (if available)
Definition: HcalHTRData.cc:373