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)
 
template<class DigiClass >
void unpack_compact (HcalUHTRData::const_iterator &i, const HcalUHTRData::const_iterator &iend, DigiClass &digi, int presamples, const HcalElectronicsId &eid, int startSample, int endSample)
 

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 17 of file HcalUnpacker.cc.

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

17  {
18  // set parameters
19  digi.setPresamples(presamples);
20  digi.setReadoutIds(eid);
21 
22  int fiber=startPoint->fiber();
23  int fiberchan=startPoint->fiberChan();
24  uint32_t zsmask=hhd.zsBunchMask()>>startSample;
25  digi.setZSInfo(hhd.isUnsuppressed(),hhd.wasMarkAndPassZS(fiber,fiberchan),zsmask);
26 
27  if (expectedTime>=0 && !hhd.isUnsuppressed()) {
28 #ifdef DebugLog
29  std::cout << hhd.getFibOrbMsgBCN(fiber) << " " << expectedTime << std::endl;
30 #endif
31  digi.setFiberIdleOffset(hhd.getFibOrbMsgBCN(fiber)-expectedTime);
32  }
33 
34  // what is my sample number?
35  int myFiberChan=startPoint->fiberAndChan();
36  int ncurr=0,ntaken=0;
37  const HcalQIESample* qie_work=startPoint;
38  while (qie_work!=limit && qie_work->fiberAndChan()==myFiberChan) {
39  if (ncurr>=startSample && ncurr<=endSample) {
40  digi.setSample(ntaken,*qie_work);
41  ++ntaken;
42  }
43  ncurr++;
44  qie_work++;
45  }
46  digi.setSize(ntaken);
47  return qie_work;
48  }
int fiberAndChan() const
get the id channel
Definition: HcalQIESample.h:36
int fiberChan() const
get the fiber channel number
Definition: HcalQIESample.h:34
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
bool isUnsuppressed() const
Is this event an unsuppresed event?
Definition: HcalHTRData.cc:353
int fiber() const
get the fiber number
Definition: HcalQIESample.h:32
uint32_t zsBunchMask() const
ZS Bunch Mask (if available)
Definition: HcalHTRData.cc:373
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 52 of file HcalUnpacker.cc.

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

54  {
55  // set parameters
56  digi.setPresamples(presamples);
57  digi.setReadoutIds(eid);
58  int flavor, error_flags, capid0, channelid;
59 
60  HcalHTRData::unpack_per_channel_header(*startPoint,flavor,error_flags,capid0,channelid);
61  bool isCapRotating=!(error_flags&0x1);
62  bool fiberErr=(error_flags&0x2);
63  bool dataValid=!(error_flags&0x2);
64  int fiberchan=channelid&0x3;
65  int fiber=((channelid>>2)&0x7)+1;
66 
67  uint32_t zsmask=hhd.zsBunchMask()>>startSample;
68  digi.setZSInfo(hhd.isUnsuppressed(),hhd.wasMarkAndPassZS(fiber,fiberchan),zsmask);
69 
70  if (expectedTime>=0 && !hhd.isUnsuppressed()) {
71 #ifdef DebugLog
72  std::cout << hhd.getFibOrbMsgBCN(fiber) << " " << expectedTime << std::endl;
73 #endif
74  digi.setFiberIdleOffset(hhd.getFibOrbMsgBCN(fiber)-expectedTime);
75  }
76 
77  // what is my sample number?
78  int ncurr=0,ntaken=0;
79  const unsigned short* qie_work=startPoint;
80  // we branch here between normal (flavor=5) and error mode (flavor=6)
81  if (flavor==5) {
82  for (qie_work++; qie_work!=limit && !HcalHTRData::is_channel_header(*qie_work); qie_work++) {
83  int capidn=(isCapRotating)?((capid0+ncurr)%4):(capid0);
84  int capidn1=(isCapRotating)?((capid0+ncurr+1)%4):(capid0);
85  // two samples in one...
86  HcalQIESample s0((*qie_work)&0x7F,capidn,fiber,fiberchan,dataValid,fiberErr);
87  HcalQIESample s1(((*qie_work)>>8)&0x7F,capidn1,fiber,fiberchan,dataValid,fiberErr);
88 
89  if (ncurr>=startSample && ncurr<=endSample) {
90  digi.setSample(ntaken,s0);
91  ++ntaken;
92  }
93  ncurr++;
94  if (ncurr>=startSample && ncurr<=endSample) {
95  digi.setSample(ntaken,s1);
96  ++ntaken;
97  }
98  ncurr++;
99  }
100  digi.setSize(ntaken);
101  } else if (flavor==6) {
102  for (qie_work++; qie_work!=limit && !HcalHTRData::is_channel_header(*qie_work); qie_work++) {
103  if (ncurr>=startSample && ncurr<=endSample) {
104  HcalQIESample sample((*qie_work)&0x7F,((*qie_work)>>8)&0x3,fiber,fiberchan,((*qie_work)>>10)&0x1,((*qie_work)>>11)&0x1);
105  digi.setSample(ntaken,sample);
106  ++ntaken;
107  }
108  ncurr++;
109  }
110  digi.setSize(ntaken);
111  } else {
112  edm::LogWarning("Bad Data") << "Invalid flavor " << flavor;
113  qie_work=limit;
114  }
115  return qie_work;
116  }
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
template<class DigiClass >
void HcalUnpacker_impl::unpack_compact ( HcalUHTRData::const_iterator i,
const HcalUHTRData::const_iterator iend,
DigiClass &  digi,
int  presamples,
const HcalElectronicsId eid,
int  startSample,
int  endSample 
)

Definition at line 119 of file HcalUnpacker.cc.

References HcalUHTRData::const_iterator::adc(), HcalUHTRData::const_iterator::capid(), HcalUHTRData::const_iterator::capid0(), HcalUHTRData::const_iterator::channelid(), HcalUHTRData::const_iterator::dataValid(), HcalUHTRData::const_iterator::errFlags(), HcalUHTRData::const_iterator::flavor(), mps_fire::i, HcalUHTRData::const_iterator::isHeader(), alignCSCRings::s, and simplePhotonAnalyzer_cfi::sample.

120  {
121  // set parameters
122  digi.setPresamples(presamples-startSample);
123  digi.setReadoutIds(eid);
124  int error_flags=i.errFlags();
125  int capid0=i.capid0();
126  int flavor = i.flavor();
127 
128  bool isCapRotating=!(error_flags&0x1);
129  bool fiberErr=(error_flags&0x2);
130  bool dataValid=!(error_flags&0x2);
131  int fiberchan=i.channelid()&0x3;
132  int fiber=((i.channelid()>>2)&0x7)+1;
133 
134  // digi.setZSInfo(hhd.isUnsuppressed(),hhd.wasMarkAndPassZS(fiber,fiberchan),zsmask);
135 
136  // what is my sample number?
137  int ncurr=0,ntaken=0;
138  if(flavor==5){
139  for (++i; i!=iend && !i.isHeader(); ++i) {
140  int capidn=(isCapRotating)?((capid0+ncurr)%4):(capid0);
141 
142  HcalQIESample s(i.adc(),capidn,fiber,fiberchan,dataValid,fiberErr);
143 
144  if (ncurr>=startSample && ncurr<=endSample) {
145  digi.setSample(ntaken,s);
146  ++ntaken;
147  }
148  ncurr++;
149  }
150  digi.setSize(ntaken);
151  }
152  else if(flavor==7){ //similar to VME flavor 6, used for premix in MC
153  for (++i; i!=iend && !i.isHeader(); ++i) {
154  if (ncurr>=startSample && ncurr<=endSample) {
155  HcalQIESample sample(i.adc(),i.capid(),fiber,fiberchan,i.dataValid(),i.errFlags());
156  digi.setSample(ntaken,sample);
157  ++ntaken;
158  }
159  ncurr++;
160  }
161  digi.setSize(ntaken);
162  }
163  }