CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 12 of file HcalUnpacker.cc.

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

12  {
13  // set parameters
14  digi.setPresamples(presamples);
15  digi.setReadoutIds(eid);
16 
17  int fiber=startPoint->fiber();
18  int fiberchan=startPoint->fiberChan();
19  uint32_t zsmask=hhd.zsBunchMask()>>startSample;
20  digi.setZSInfo(hhd.isUnsuppressed(),hhd.wasMarkAndPassZS(fiber,fiberchan),zsmask);
21 
22  if (expectedTime>=0 && !hhd.isUnsuppressed()) {
23  // std::cout << hhd.getFibOrbMsgBCN(fiber) << " " << expectedTime << std::endl;
24  digi.setFiberIdleOffset(hhd.getFibOrbMsgBCN(fiber)-expectedTime);
25  }
26 
27  // what is my sample number?
28  int myFiberChan=startPoint->fiberAndChan();
29  int ncurr=0,ntaken=0;
30  const HcalQIESample* qie_work=startPoint;
31  while (qie_work!=limit && qie_work->fiberAndChan()==myFiberChan) {
32  if (ncurr>=startSample && ncurr<=endSample) {
33  digi.setSample(ntaken,*qie_work);
34  ++ntaken;
35  }
36  ncurr++;
37  qie_work++;
38  }
39  digi.setSize(ntaken);
40  return qie_work;
41  }
int fiberAndChan() const
get the id channel
Definition: HcalQIESample.h:38
int fiberChan() const
get the fiber channel number
Definition: HcalQIESample.h:36
bool wasMarkAndPassZS(int fiber, int fiberchan) const
Was this channel passed as part of Mark&amp;Pass ZS?
Definition: HcalHTRData.cc:358
unsigned int getFibOrbMsgBCN(int fiber) const
Get the BCN of the Fiber Orbit Messages.
Definition: HcalHTRData.h:179
bool isUnsuppressed() const
Is this event an unsuppresed event?
Definition: HcalHTRData.cc:355
int fiber() const
get the fiber number
Definition: HcalQIESample.h:34
uint32_t zsBunchMask() const
ZS Bunch Mask (if available)
Definition: HcalHTRData.cc:375
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 45 of file HcalUnpacker.cc.

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

47  {
48  // set parameters
49  digi.setPresamples(presamples);
50  digi.setReadoutIds(eid);
51  int flavor, error_flags, capid0, channelid;
52 
53  HcalHTRData::unpack_per_channel_header(*startPoint,flavor,error_flags,capid0,channelid);
54  bool isCapRotating=!(error_flags&0x1);
55  bool fiberErr=(error_flags&0x2);
56  bool dataValid=!(error_flags&0x2);
57  int fiberchan=channelid&0x3;
58  int fiber=((channelid>>2)&0x7)+1;
59 
60  uint32_t zsmask=hhd.zsBunchMask()>>startSample;
61  digi.setZSInfo(hhd.isUnsuppressed(),hhd.wasMarkAndPassZS(fiber,fiberchan),zsmask);
62 
63  if (expectedTime>=0 && !hhd.isUnsuppressed()) {
64  // std::cout << hhd.getFibOrbMsgBCN(fiber) << " " << expectedTime << std::endl;
65  digi.setFiberIdleOffset(hhd.getFibOrbMsgBCN(fiber)-expectedTime);
66  }
67 
68  // what is my sample number?
69  int ncurr=0,ntaken=0;
70  const unsigned short* qie_work=startPoint;
71  // we branch here between normal (flavor=5) and error mode (flavor=6)
72  if (flavor==5) {
73  for (qie_work++; qie_work!=limit && !HcalHTRData::is_channel_header(*qie_work); qie_work++) {
74  int capidn=(isCapRotating)?((capid0+ncurr)%4):(capid0);
75  int capidn1=(isCapRotating)?((capid0+ncurr+1)%4):(capid0);
76  // two samples in one...
77  HcalQIESample s0((*qie_work)&0x7F,capidn,fiber,fiberchan,dataValid,fiberErr);
78  HcalQIESample s1(((*qie_work)>>8)&0x7F,capidn1,fiber,fiberchan,dataValid,fiberErr);
79 
80  if (ncurr>=startSample && ncurr<=endSample) {
81  digi.setSample(ntaken,s0);
82  ++ntaken;
83  }
84  ncurr++;
85  if (ncurr>=startSample && ncurr<=endSample) {
86  digi.setSample(ntaken,s1);
87  ++ntaken;
88  }
89  ncurr++;
90  }
91  digi.setSize(ntaken);
92  } else if (flavor==6) {
93  for (qie_work++; qie_work!=limit && !HcalHTRData::is_channel_header(*qie_work); qie_work++) {
94  if (ncurr>=startSample && ncurr<=endSample) {
95  HcalQIESample sample((*qie_work)&0x7F,((*qie_work)>>8)&0x3,fiber,fiberchan,((*qie_work)>>10)&0x1,((*qie_work)>>11)&0x1);
96  digi.setSample(ntaken,sample);
97  ++ntaken;
98  }
99  ncurr++;
100  }
101  digi.setSize(ntaken);
102  }
103  return qie_work;
104  }
bool wasMarkAndPassZS(int fiber, int fiberchan) const
Was this channel passed as part of Mark&amp;Pass ZS?
Definition: HcalHTRData.cc:358
unsigned int getFibOrbMsgBCN(int fiber) const
Get the BCN of the Fiber Orbit Messages.
Definition: HcalHTRData.h:179
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:435
bool isUnsuppressed() const
Is this event an unsuppresed event?
Definition: HcalHTRData.cc:355
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:92
uint32_t zsBunchMask() const
ZS Bunch Mask (if available)
Definition: HcalHTRData.cc:375