CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Attributes
HcalUnpacker Class Reference

#include <HcalUnpacker.h>

Classes

struct  Collections
 

Public Member Functions

 HcalUnpacker (int sourceIdOffset, int beg, int end)
 for normal data More...
 
 HcalUnpacker (int sourceIdOffset)
 For histograms, no begin and end. More...
 
void setExpectedOrbitMessageTime (int time)
 
void unpack (const FEDRawData &raw, const HcalElectronicsMap &emap, std::vector< HcalHistogramDigi > &histoDigis)
 
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< HBHEDataFrame > &precision, std::vector< HcalTriggerPrimitiveDigi > &tp)
 
void unpack (const FEDRawData &raw, const HcalElectronicsMap &emap, std::vector< HODataFrame > &precision, std::vector< HcalTriggerPrimitiveDigi > &tp)
 
void unpack (const FEDRawData &raw, const HcalElectronicsMap &emap, std::vector< HFDataFrame > &precision, std::vector< HcalTriggerPrimitiveDigi > &tp)
 

Private Attributes

int endSample_
 last sample from fed raw data to copy (if present) More...
 
int expectedOrbitMessageTime_
 Expected orbit bunch time (needed to evaluate time differences) More...
 
int sourceIdOffset_
 number to subtract from the source id to get the dcc id More...
 
int startSample_
 first sample from fed raw data to copy More...
 
std::set< HcalElectronicsIdunknownIds_
 
std::set< HcalElectronicsIdunknownIdsTrig_
 Recorded to limit number of times a log message is generated. More...
 

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.

35 : sourceIdOffset_(sourceIdOffset), startSample_(beg), endSample_(end), expectedOrbitMessageTime_(-1) { }
int sourceIdOffset_
number to subtract from the source id to get the dcc id
Definition: HcalUnpacker.h:48
int endSample_
last sample from fed raw data to copy (if present)
Definition: HcalUnpacker.h:50
int startSample_
first sample from fed raw data to copy
Definition: HcalUnpacker.h:49
int expectedOrbitMessageTime_
Expected orbit bunch time (needed to evaluate time differences)
Definition: HcalUnpacker.h:51
#define end
Definition: vmac.h:38
HcalUnpacker::HcalUnpacker ( int  sourceIdOffset)
inline

For histograms, no begin and end.

Definition at line 37 of file HcalUnpacker.h.

37 : sourceIdOffset_(sourceIdOffset), startSample_(-1), endSample_(-1), expectedOrbitMessageTime_(-1) { }
int sourceIdOffset_
number to subtract from the source id to get the dcc id
Definition: HcalUnpacker.h:48
int endSample_
last sample from fed raw data to copy (if present)
Definition: HcalUnpacker.h:50
int startSample_
first sample from fed raw data to copy
Definition: HcalUnpacker.h:49
int expectedOrbitMessageTime_
Expected orbit bunch time (needed to evaluate time differences)
Definition: HcalUnpacker.h:51

Member Function Documentation

void HcalUnpacker::setExpectedOrbitMessageTime ( int  time)
inline

Definition at line 38 of file HcalUnpacker.h.

References expectedOrbitMessageTime_, and cond::rpcobgas::time.

Referenced by HcalRawToDigi::HcalRawToDigi().

int expectedOrbitMessageTime_
Expected orbit bunch time (needed to evaluate time differences)
Definition: HcalUnpacker.h:51
void HcalUnpacker::unpack ( const FEDRawData raw,
const HcalElectronicsMap emap,
std::vector< HcalHistogramDigi > &  histoDigis 
)

Definition at line 483 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 HcalHistogramRawToDigi::produce(), HcalRawToDigi::produce(), and unpack().

483  {
484 
485  // get the DCC header
486  const HcalDCCHeader* dccHeader=(const HcalDCCHeader*)(raw.data());
487  int dccid=dccHeader->getSourceId()-sourceIdOffset_;
488 
489  // check the summary status
490 
491  // walk through the HTR data...
492  HcalHTRData htr;
493  for (int spigot=0; spigot<HcalDCCHeader::SPIGOT_COUNT; spigot++) {
494  if (!dccHeader->getSpigotPresent(spigot)) continue;
495 
496  int retval=dccHeader->getSpigotData(spigot,htr,raw.size());
497  // check
498  if (retval || !htr.check()) {
499  edm::LogWarning("Invalid Data") << "Invalid HTR data observed on spigot " << spigot << " of DCC with source id " << dccHeader->getSourceId();
500  continue;
501  }
502  if (!htr.isHistogramEvent()) {
503  edm::LogWarning("Invalid Data") << "Non-histogram data passed to histogram unpacker on spigot " << spigot << " of DCC with source id " << dccHeader->getSourceId();
504  continue;
505  }
506 
507  unsigned int smid=htr.getSubmodule();
508  int htr_tb=smid&0x1;
509  int htr_slot=(smid>>1)&0x1F;
510  int htr_cr=(smid>>6)&0x1F;
511 
512  // find out the fibers
513  int f[2],fc;
514  htr.getHistogramFibers(f[0],f[1]);
515 
516  for (int nf=0; nf<2; nf++) {
517  if (f[nf]<0 || (nf==1 && f[0]==f[1])) continue; // skip if invalid or the same
518  for (fc=0; fc<=2; fc++) {
519  HcalElectronicsId eid(fc,f[nf],spigot,dccid);
520  eid.setHTR(htr_cr,htr_slot,htr_tb);
521  DetId did=emap.lookup(eid);
522 
523  if (did.null() || did.det()!=DetId::Hcal || did.subdetId()==0) {
524  if (unknownIds_.find(eid)==unknownIds_.end()) {
525  edm::LogWarning("HCAL") << "HcalHistogramUnpacker: No match found for electronics id :" << eid;
526  unknownIds_.insert(eid);
527  }
528  continue;
529  }
530  histoDigis.push_back(HcalHistogramDigi(HcalDetId(did))); // add it!
531  HcalHistogramDigi& digi=histoDigis.back();
532 
533  // unpack the four capids
534  for (int capid=0; capid<4; capid++)
535  htr.unpackHistogram(f[nf],fc,capid,digi.getArray(capid));
536 
537  }
538  }
539  }
540 }
std::set< HcalElectronicsId > unknownIds_
Definition: HcalUnpacker.h:52
int sourceIdOffset_
number to subtract from the source id to get the dcc id
Definition: HcalUnpacker.h:48
bool check() const
Check for a good event Requires a minimum length, matching wordcount and length, not an empty event...
Definition: HcalHTRData.cc:64
void getHistogramFibers(int &a, int &b) const
Get the fiber numbers for the data present in this event (only in histogram mode!) ...
Definition: HcalHTRData.cc:415
int getSpigotData(int nspigot, HcalHTRData &decodeTool, int validSize) const
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:49
bool unpackHistogram(int fiber, int fiberchan, int capid, unsigned short *histogram) const
Unpack special histogramming mode data.
Definition: HcalHTRData.cc:443
double f[11][100]
bool getSpigotPresent(unsigned int nspigot) const
Read the &quot;PRESENT&quot; bit for this spigot.
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
int getSourceId() const
Definition: HcalDCCHeader.h:34
Definition: DetId.h:20
bool null() const
is this a null id ?
Definition: DetId.h:47
static const int SPIGOT_COUNT
Definition: HcalDCCHeader.h:21
uint16_t * getArray(int capid)
get the array for the specified capid
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:29
unsigned int getSubmodule() const
Get the HTR submodule number.
Definition: HcalHTRData.cc:333
Detector det() const
get the detector field from this detid
Definition: DetId.h:37
Readout chain identification for Hcal [31:26] Unused (so far) [25] Trigger-chain id flag [24:20] Read...
const DetId lookup(HcalElectronicsId fId) const
lookup the logical detid associated with the given electronics id
bool isHistogramEvent() const
Is this event a histogram event? (do not call standard unpack in this case!!!!!)
Definition: HcalHTRData.cc:387
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 114 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, HcalHTRData::getFirmwareFlavor(), HcalHTRData::getFormatVersion(), HcalHTRData::getNPS(), 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, errorMatrix2Lands_multiChannel::id, HcalDetId::ieta(), HOUnrolledTP::ieta, HcalDetId::iphi(), HOUnrolledTP::iphi, HcalHTRData::is_channel_header(), HcalHTRData::isBusy(), HcalHTRData::isEmptyEvent(), HcalHTRData::isHistogramEvent(), HcalHTRData::isOverflowWarning(), isTPGSOI(), HcalHTRData::isUnsuppressed(), LogDebug, HcalElectronicsMap::lookup(), HcalElectronicsMap::lookupTrigger(), 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(), TrackValidation_HighPurity_cff::valid, HOUnrolledTP::valid, HcalHTRData::wasMarkAndPassZSTP(), and HcalUnpacker::Collections::zdcCont.

115  {
116 
117  if (raw.size()<16) {
118  if (!silent) edm::LogWarning("Invalid Data") << "Empty/invalid DCC data, size = " << raw.size();
119  return;
120  }
121 
122  // get the DCC header
123  const HcalDCCHeader* dccHeader=(const HcalDCCHeader*)(raw.data());
124  int dccid=dccHeader->getSourceId()-sourceIdOffset_;
125 
126  // check the summary status
127 
128  // walk through the HTR data...
129  HcalHTRData htr;
130  const unsigned short* daq_first, *daq_last, *tp_first, *tp_last;
131  const HcalQIESample* qie_begin, *qie_end, *qie_work;
132  const HcalTriggerPrimitiveSample *tp_begin, *tp_end, *tp_work;
133  for (int spigot=0; spigot<HcalDCCHeader::SPIGOT_COUNT; spigot++) {
134  if (!dccHeader->getSpigotPresent(spigot)) continue;
135 
136  int retval=dccHeader->getSpigotData(spigot,htr,raw.size());
137  if (retval!=0) {
138  if (retval==-1) {
139  if (!silent) edm::LogWarning("Invalid Data") << "Invalid HTR data (data beyond payload size) observed on spigot " << spigot << " of DCC with source id " << dccHeader->getSourceId();
140  report.countSpigotFormatError();
141  }
142  continue;
143  }
144  // check
145  if (dccHeader->getSpigotCRCError(spigot)) {
146  if (!silent)
147  edm::LogWarning("Invalid Data") << "CRC Error on HTR data observed on spigot " << spigot << " of DCC with source id " << dccHeader->getSourceId();
148  report.countSpigotFormatError();
149  continue;
150  }
151  // check for EE
152  if (htr.isEmptyEvent()) {
153  report.countEmptyEventSpigot();
154  }
155  if (htr.isOverflowWarning()) {
156  report.countOFWSpigot();
157  }
158  if (htr.isBusy()) {
159  report.countBusySpigot();
160  }
161  if (!htr.check()) {
162  if (!silent)
163  edm::LogWarning("Invalid Data") << "Invalid HTR data observed on spigot " << spigot << " of DCC with source id " << dccHeader->getSourceId();
164  report.countSpigotFormatError();
165  continue;
166  }
167  if (htr.isHistogramEvent()) {
168  if (!silent) edm::LogWarning("Invalid Data") << "Histogram data passed to non-histogram unpacker on spigot " << spigot << " of DCC with source id " << dccHeader->getSourceId();
169  continue;
170  }
171  if ((htr.getFirmwareFlavor()&0xE0)==0x80) { // some kind of TTP data
172  if (colls.ttp!=0) {
173  HcalTTPUnpacker ttpUnpack;
174  colls.ttp->push_back(HcalTTPDigi());
175  ttpUnpack.unpack(htr,colls.ttp->back());
176  } else {
177  LogDebug("HcalTechTrigProcessor") << "Skipping data on spigot " << spigot << " of DCC with source id " << dccHeader->getSourceId() << " which is from the TechTrigProcessor (use separate unpacker!)";
178  }
179  continue;
180  }
181  if (htr.getFirmwareFlavor()>=0x80) {
182  if (!silent) edm::LogWarning("HcalUnpacker") << "Skipping data on spigot " << spigot << " of DCC with source id " << dccHeader->getSourceId() << " which is of unknown flavor " << htr.getFirmwareFlavor();
183  continue;
184  }
185 
186  // calculate "real" number of presamples
187  int nps=htr.getNPS()-startSample_;
188 
189  // get pointers
190  htr.dataPointers(&daq_first,&daq_last,&tp_first,&tp_last);
191  unsigned int smid=htr.getSubmodule();
192  int htr_tb=smid&0x1;
193  int htr_slot=(smid>>1)&0x1F;
194  int htr_cr=(smid>>6)&0x1F;
195 
196  tp_begin=(HcalTriggerPrimitiveSample*)tp_first;
197  tp_end=(HcalTriggerPrimitiveSample*)(tp_last+1); // one beyond last..
198 
200  int currFiberChan=0x3F; // invalid fiber+channel...
201  int ncurr=0;
202  bool valid=false;
203 
204  bool tpgSOIbitInUse=htr.getFormatVersion()>=3; // version 3 and later
205  bool isHOtpg=htr.getFormatVersion()>=3 && htr.getFirmwareFlavor()==0; // HO is flavor zero
206  int npre=0;
207  /*
208  Unpack the trigger primitives
209  */
210  if (isHOtpg) {
211  HOUnrolledTP unrolled[24];
212  for (tp_work=tp_begin; tp_work!=tp_end; tp_work++) {
213  if (tp_work->raw()==0xFFFF) continue; // filler word
214  int sector=tp_work->slbChan();
215  if (sector>2) continue;
216 
217  for (int ibit=0; ibit<8; ibit++) {
218  int linear=sector*8+ibit;
219  if (!unrolled[linear].checked) {
220  unrolled[linear].checked=true;
221  int fiber=(linear/3)+1;
222  int fc=(linear%3);
223  // electronics id (use precision match for HO TP)
224  HcalElectronicsId eid(fc,fiber,spigot,dccid);
225  eid.setHTR(htr_cr,htr_slot,htr_tb);
226  DetId did=emap.lookup(eid);
227  if (!did.null()) {
228  if (did.det()==DetId::Hcal && ((HcalSubdetector)did.subdetId())==HcalOuter ) {
229  HcalDetId hid(did);
230  unrolled[linear].valid=true;
231  unrolled[linear].ieta=hid.ieta();
232  unrolled[linear].iphi=hid.iphi();
233  }
234  } else {
235  report.countUnmappedTPDigi(eid);
236  }
237  }
238  if (unrolled[linear].valid) {
239  if (isTPGSOI(*tp_work)) unrolled[linear].soi=unrolled[linear].samples;
240  if (tp_work->raw()&(1<<ibit)) unrolled[linear].setbit(unrolled[linear].samples);
241  unrolled[linear].samples++;
242  }
243  }
244  }
245  for (int i=0; i<24; i++) {
246  if (unrolled[i].valid)
247  colls.tphoCont->push_back(HOTriggerPrimitiveDigi(
248  unrolled[i].ieta,
249  unrolled[i].iphi,
250  unrolled[i].samples,
251  unrolled[i].soi,
252  unrolled[i].databits));
253  }
254  } else { // regular TPs (not HO)
255  for (tp_work=tp_begin; tp_work!=tp_end; tp_work++) {
256  if (tp_work->raw()==0xFFFF) continue; // filler word
257  if (tp_work->slbAndChan()!=currFiberChan) { // start new set
258  npre=0;
259  currFiberChan=tp_work->slbAndChan();
260  // lookup the right channel
261  HcalElectronicsId eid(tp_work->slbChan(),tp_work->slb(),spigot,dccid,htr_cr,htr_slot,htr_tb);
262  DetId did=emap.lookupTrigger(eid);
263  if (did.null()) {
264  report.countUnmappedTPDigi(eid);
265  if (unknownIdsTrig_.find(eid)==unknownIdsTrig_.end()) {
266  if (!silent) edm::LogWarning("HCAL") << "HcalUnpacker: No trigger primitive match found for electronics id :" << eid;
267  unknownIdsTrig_.insert(eid);
268  }
269  valid=false;
270  continue;
271  } else if (did==HcalTrigTowerDetId::Undefined ||
272  (did.det()==DetId::Hcal && did.subdetId()==0)) {
273  // known to be unmapped
274  valid=false;
275  continue;
276  }
277  HcalTrigTowerDetId id(did);
278  colls.tpCont->push_back(HcalTriggerPrimitiveDigi(id));
279  // set the various bits
280  if (!tpgSOIbitInUse) colls.tpCont->back().setPresamples(nps);
281  colls.tpCont->back().setZSInfo(htr.isUnsuppressed(),htr.wasMarkAndPassZSTP(tp_work->slb(),tp_work->slbChan()));
282 
283  // no hits recorded for current
284  ncurr=0;
285  valid=true;
286  }
287  // add the word (if within settings or recent firmware [recent firmware ignores startSample/endSample])
288  if (valid && ((tpgSOIbitInUse && ncurr<10) || (ncurr>=startSample_ && ncurr<=endSample_))) {
289  colls.tpCont->back().setSample(colls.tpCont->back().size(),*tp_work);
290  colls.tpCont->back().setSize(colls.tpCont->back().size()+1);
291  }
292  // set presamples,if SOI
293  if (valid && tpgSOIbitInUse && isTPGSOI(*tp_work)) {
294  colls.tpCont->back().setPresamples(ncurr);
295  }
296  ncurr++;
297  npre++;
298  }
299  }
300 
303 
304  qie_begin=(HcalQIESample*)daq_first;
305  qie_end=(HcalQIESample*)(daq_last+1); // one beyond last..
306 
308  currFiberChan=0x3F; // invalid fiber+channel...
309  ncurr=0;
310  valid=false;
311 
312 
313  for (qie_work=qie_begin; qie_work!=qie_end; ) {
314  if (qie_work->raw()==0xFFFF) {
315  qie_work++;
316  continue; // filler word
317  }
318  // always at the beginning ...
319  currFiberChan=qie_work->fiberAndChan();
320 
321  // lookup the right channel
322  HcalElectronicsId eid(qie_work->fiberChan(),qie_work->fiber(),spigot,dccid);
323  eid.setHTR(htr_cr,htr_slot,htr_tb);
324  DetId did=emap.lookup(eid);
325 
326  if (!did.null()) {
327  if (did.det()==DetId::Calo && did.subdetId()==HcalZDCDetId::SubdetectorId) {
328  colls.zdcCont->push_back(ZDCDataFrame(HcalZDCDetId(did)));
329  qie_work=HcalUnpacker_impl::unpack<ZDCDataFrame>(qie_work, qie_end, colls.zdcCont->back(), nps, eid, startSample_, endSample_, expectedOrbitMessageTime_, htr);
330  } else if (did.det()==DetId::Hcal) {
331  switch (((HcalSubdetector)did.subdetId())) {
332  case (HcalBarrel):
333  case (HcalEndcap): {
334  colls.hbheCont->push_back(HBHEDataFrame(HcalDetId(did)));
335  qie_work=HcalUnpacker_impl::unpack<HBHEDataFrame>(qie_work, qie_end, colls.hbheCont->back(), nps, eid, startSample_, endSample_, expectedOrbitMessageTime_, htr);
336  } break;
337  case (HcalOuter): {
338  colls.hoCont->push_back(HODataFrame(HcalDetId(did)));
339  qie_work=HcalUnpacker_impl::unpack<HODataFrame>(qie_work, qie_end, colls.hoCont->back(), nps, eid, startSample_, endSample_, expectedOrbitMessageTime_, htr);
340  } break;
341  case (HcalForward): {
342  colls.hfCont->push_back(HFDataFrame(HcalDetId(did)));
343  qie_work=HcalUnpacker_impl::unpack<HFDataFrame>(qie_work, qie_end, colls.hfCont->back(), nps, eid, startSample_, endSample_, expectedOrbitMessageTime_, htr);
344  } break;
345  case (HcalOther) : {
346  HcalOtherDetId odid(did);
347  if (odid.subdet()==HcalCalibration) {
348  colls.calibCont->push_back(HcalCalibDataFrame(HcalCalibDetId(did)));
349  qie_work=HcalUnpacker_impl::unpack<HcalCalibDataFrame>(qie_work, qie_end, colls.calibCont->back(), nps, eid, startSample_, endSample_, expectedOrbitMessageTime_, htr);
350  }
351  } break;
352  case (HcalEmpty):
353  default: {
354  for (int fiberC=qie_work->fiberAndChan();
355  qie_work!=qie_end && qie_work->fiberAndChan()==fiberC;
356  qie_work++);
357  }
358  break;
359  }
360  }
361  } else {
362  report.countUnmappedDigi(eid);
363  if (unknownIds_.find(eid)==unknownIds_.end()) {
364  if (!silent) edm::LogWarning("HCAL") << "HcalUnpacker: No match found for electronics id :" << eid;
365  unknownIds_.insert(eid);
366  }
367  for (int fiberC=qie_work->fiberAndChan();
368  qie_work!=qie_end && qie_work->fiberAndChan()==fiberC;
369  qie_work++);
370  }
371  }
372  } else {
373  // this is the branch for unpacking the compact data format with per-channel headers
374  const unsigned short* ptr_header=daq_first;
375  const unsigned short* ptr_end=daq_last+1;
376  int flavor, error_flags, capid0, channelid;
377 
378  while (ptr_header!=ptr_end) {
379  if (*ptr_header==0xFFFF) { // impossible filler word
380  ptr_header++;
381  continue;
382  }
383  // unpack the header word
384  bool isheader=HcalHTRData::unpack_per_channel_header(*ptr_header,flavor,error_flags,capid0,channelid);
385  if (!isheader) {
386  ptr_header++;
387  continue;
388  }
389 
390  int fiberchan=channelid&0x3;
391  int fiber=((channelid>>2)&0x7)+1;
392 
393  // lookup the right channel
394  HcalElectronicsId eid(fiberchan,fiber,spigot,dccid);
395  eid.setHTR(htr_cr,htr_slot,htr_tb);
396  DetId did=emap.lookup(eid);
397 
398  if (!did.null()) {
399  if (did.det()==DetId::Calo && did.subdetId()==HcalZDCDetId::SubdetectorId) {
400  colls.zdcCont->push_back(ZDCDataFrame(HcalZDCDetId(did)));
401  ptr_header=HcalUnpacker_impl::unpack_compact<ZDCDataFrame>(ptr_header, ptr_end, colls.zdcCont->back(), nps, eid, startSample_, endSample_, expectedOrbitMessageTime_, htr);
402  } else if (did.det()==DetId::Hcal) {
403  switch (((HcalSubdetector)did.subdetId())) {
404  case (HcalBarrel):
405  case (HcalEndcap): {
406  colls.hbheCont->push_back(HBHEDataFrame(HcalDetId(did)));
407  ptr_header=HcalUnpacker_impl::unpack_compact<HBHEDataFrame>(ptr_header, ptr_end, colls.hbheCont->back(), nps, eid, startSample_, endSample_, expectedOrbitMessageTime_, htr);
408  } break;
409  case (HcalOuter): {
410  colls.hoCont->push_back(HODataFrame(HcalDetId(did)));
411  ptr_header=HcalUnpacker_impl::unpack_compact<HODataFrame>(ptr_header, ptr_end, colls.hoCont->back(), nps, eid, startSample_, endSample_, expectedOrbitMessageTime_, htr);
412  } break;
413  case (HcalForward): {
414  colls.hfCont->push_back(HFDataFrame(HcalDetId(did)));
415  ptr_header=HcalUnpacker_impl::unpack_compact<HFDataFrame>(ptr_header, ptr_end, colls.hfCont->back(), nps, eid, startSample_, endSample_, expectedOrbitMessageTime_, htr);
416  } break;
417  case (HcalOther) : {
418  HcalOtherDetId odid(did);
419  if (odid.subdet()==HcalCalibration) {
420  colls.calibCont->push_back(HcalCalibDataFrame(HcalCalibDetId(did)));
421  ptr_header=HcalUnpacker_impl::unpack_compact<HcalCalibDataFrame>(ptr_header, ptr_end, colls.calibCont->back(), nps, eid, startSample_, endSample_, expectedOrbitMessageTime_, htr);
422  }
423  } break;
424  case (HcalEmpty):
425  default: {
426  for (ptr_header++;
427  ptr_header!=ptr_end && !HcalHTRData::is_channel_header(*ptr_header);
428  ptr_header++);
429  }
430  break;
431  }
432  }
433  } else {
434  report.countUnmappedDigi(eid);
435  if (unknownIds_.find(eid)==unknownIds_.end()) {
436  if (!silent) edm::LogWarning("HCAL") << "HcalUnpacker: No match found for electronics id :" << eid;
437  unknownIds_.insert(eid);
438  }
439  for (ptr_header++;
440  ptr_header!=ptr_end && !HcalHTRData::is_channel_header(*ptr_header);
441  ptr_header++);
442  }
443  }
444 
445  }
446  }
447 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
std::set< HcalElectronicsId > unknownIds_
Definition: HcalUnpacker.h:52
int sourceIdOffset_
number to subtract from the source id to get the dcc id
Definition: HcalUnpacker.h:48
int endSample_
last sample from fed raw data to copy (if present)
Definition: HcalUnpacker.h:50
int startSample_
first sample from fed raw data to copy
Definition: HcalUnpacker.h:49
uint16_t raw() const
get the raw word
Definition: HcalQIESample.h:22
bool check() const
Check for a good event Requires a minimum length, matching wordcount and length, not an empty event...
Definition: HcalHTRData.cc:64
int fiberAndChan() const
get the id channel
Definition: HcalQIESample.h:38
int fiberChan() const
get the fiber channel number
Definition: HcalQIESample.h:36
bool getSpigotCRCError(unsigned int nspigot) const
Read the &quot;CRC-Mismatch&quot; bit for this spigot.
static bool isTPGSOI(const HcalTriggerPrimitiveSample &s)
Definition: HcalUnpacker.cc:93
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
int getSpigotData(int nspigot, HcalHTRData &decodeTool, int validSize) const
int slbChan() const
get the slb channel number
int getFormatVersion() const
Get the version number of this event.
Definition: HcalHTRData.h:35
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:49
bool isUnsuppressed() const
Is this event an unsuppresed event?
Definition: HcalHTRData.cc:355
bool isOverflowWarning() const
Definition: HcalHTRData.cc:111
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
int slbAndChan() const
get the id channel
int expectedOrbitMessageTime_
Expected orbit bunch time (needed to evaluate time differences)
Definition: HcalUnpacker.h:51
bool isEmptyEvent() const
Definition: HcalHTRData.cc:102
HcalSubdetector
Definition: HcalAssistant.h:32
uint16_t raw() const
get the raw word
int fiber() const
get the fiber number
Definition: HcalQIESample.h:34
bool getSpigotPresent(unsigned int nspigot) const
Read the &quot;PRESENT&quot; bit for this spigot.
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
std::set< HcalElectronicsId > unknownIdsTrig_
Recorded to limit number of times a log message is generated.
Definition: HcalUnpacker.h:52
int getSourceId() const
Definition: HcalDCCHeader.h:34
Definition: DetId.h:20
void setHTR(int crate, int slot, int tb)
static const int SubdetectorId
Definition: HcalZDCDetId.h:22
void dataPointers(const unsigned short **daq_first, const unsigned short **daq_last, const unsigned short **tp_first, const unsigned short **tp_last) const
Obtain the starting and ending pointers for external unpacking of the data.
Definition: HcalHTRData.cc:155
bool unpack(const HcalHTRData &data, HcalTTPDigi &digi)
bool null() const
is this a null id ?
Definition: DetId.h:47
void setbit(int i)
int getNPS() const
Get the number of presamples in daq data.
Definition: HcalHTRData.cc:402
static const HcalTrigTowerDetId Undefined
static const int FORMAT_VERSION_COMPACT_DATA
Definition: HcalHTRData.h:22
int getFirmwareFlavor() const
Get the HTR firmware flavor.
Definition: HcalHTRData.cc:411
int slb() const
get the slb site number
static const int SPIGOT_COUNT
Definition: HcalDCCHeader.h:21
bool wasMarkAndPassZSTP(int slb, int slbchan) const
Was this channel passed as part of Mark&amp;Pass ZS?
Definition: HcalHTRData.cc:366
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:29
const DetId lookupTrigger(HcalElectronicsId fId) const
brief lookup the trigger logical detid associated with the given electronics id
unsigned int getSubmodule() const
Get the HTR submodule number.
Definition: HcalHTRData.cc:333
bool isBusy() const
Definition: HcalHTRData.cc:119
Detector det() const
get the detector field from this detid
Definition: DetId.h:37
Readout chain identification for Hcal [31:26] Unused (so far) [25] Trigger-chain id flag [24:20] Read...
const DetId lookup(HcalElectronicsId fId) const
lookup the logical detid associated with the given electronics id
bool isHistogramEvent() const
Is this event a histogram event? (do not call standard unpack in this case!!!!!)
Definition: HcalHTRData.cc:387
void HcalUnpacker::unpack ( const FEDRawData raw,
const HcalElectronicsMap emap,
std::vector< HBHEDataFrame > &  precision,
std::vector< HcalTriggerPrimitiveDigi > &  tp 
)

Definition at line 459 of file HcalUnpacker.cc.

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

459  {
460  Collections c;
461  c.hbheCont=&container;
462  c.tpCont=&tp;
464  unpack(raw,emap,c,r);
465 }
void unpack(const FEDRawData &raw, const HcalElectronicsMap &emap, std::vector< HcalHistogramDigi > &histoDigis)
void HcalUnpacker::unpack ( const FEDRawData raw,
const HcalElectronicsMap emap,
std::vector< HODataFrame > &  precision,
std::vector< HcalTriggerPrimitiveDigi > &  tp 
)

Definition at line 467 of file HcalUnpacker.cc.

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

467  {
468  Collections c;
469  c.hoCont=&container;
470  c.tpCont=&tp;
472  unpack(raw,emap,c,r);
473 }
void unpack(const FEDRawData &raw, const HcalElectronicsMap &emap, std::vector< HcalHistogramDigi > &histoDigis)
void HcalUnpacker::unpack ( const FEDRawData raw,
const HcalElectronicsMap emap,
std::vector< HFDataFrame > &  precision,
std::vector< HcalTriggerPrimitiveDigi > &  tp 
)

Definition at line 475 of file HcalUnpacker.cc.

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

475  {
476  Collections c;
477  c.hfCont=&container;
478  c.tpCont=&tp;
480  unpack(raw,emap,c,r);
481 }
void unpack(const FEDRawData &raw, const HcalElectronicsMap &emap, std::vector< HcalHistogramDigi > &histoDigis)

Member Data Documentation

int HcalUnpacker::endSample_
private

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

Definition at line 50 of file HcalUnpacker.h.

Referenced by unpack().

int HcalUnpacker::expectedOrbitMessageTime_
private

Expected orbit bunch time (needed to evaluate time differences)

Definition at line 51 of file HcalUnpacker.h.

Referenced by setExpectedOrbitMessageTime(), and unpack().

int HcalUnpacker::sourceIdOffset_
private

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

Definition at line 48 of file HcalUnpacker.h.

Referenced by unpack().

int HcalUnpacker::startSample_
private

first sample from fed raw data to copy

Definition at line 49 of file HcalUnpacker.h.

Referenced by unpack().

std::set<HcalElectronicsId> HcalUnpacker::unknownIds_
private

Definition at line 52 of file HcalUnpacker.h.

Referenced by unpack().

std::set<HcalElectronicsId> HcalUnpacker::unknownIdsTrig_
private

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

Definition at line 52 of file HcalUnpacker.h.

Referenced by unpack().