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 setMode (int mode)
 
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 mode_
 
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), mode_(0) { }
int sourceIdOffset_
number to subtract from the source id to get the dcc id
Definition: HcalUnpacker.h:49
int endSample_
last sample from fed raw data to copy (if present)
Definition: HcalUnpacker.h:51
int startSample_
first sample from fed raw data to copy
Definition: HcalUnpacker.h:50
int expectedOrbitMessageTime_
Expected orbit bunch time (needed to evaluate time differences)
Definition: HcalUnpacker.h:52
#define end
Definition: vmac.h:37
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), mode_(0) { }
int sourceIdOffset_
number to subtract from the source id to get the dcc id
Definition: HcalUnpacker.h:49
int endSample_
last sample from fed raw data to copy (if present)
Definition: HcalUnpacker.h:51
int startSample_
first sample from fed raw data to copy
Definition: HcalUnpacker.h:50
int expectedOrbitMessageTime_
Expected orbit bunch time (needed to evaluate time differences)
Definition: HcalUnpacker.h:52

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:52
void HcalUnpacker::setMode ( int  mode)
inline

Definition at line 47 of file HcalUnpacker.h.

References alignBH_cfg::mode, and mode_.

Referenced by HcalRawToDigi::HcalRawToDigi().

47 { mode_=mode; }
void HcalUnpacker::unpack ( const FEDRawData raw,
const HcalElectronicsMap emap,
std::vector< HcalHistogramDigi > &  histoDigis 
)

Definition at line 527 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().

527  {
528 
529  // get the DCC header
530  const HcalDCCHeader* dccHeader=(const HcalDCCHeader*)(raw.data());
531  int dccid=dccHeader->getSourceId()-sourceIdOffset_;
532 
533  // check the summary status
534 
535  // walk through the HTR data...
536  HcalHTRData htr;
537  for (int spigot=0; spigot<HcalDCCHeader::SPIGOT_COUNT; spigot++) {
538  if (!dccHeader->getSpigotPresent(spigot)) continue;
539 
540  int retval=dccHeader->getSpigotData(spigot,htr,raw.size());
541  // check
542  if (retval || !htr.check()) {
543  edm::LogWarning("Invalid Data") << "Invalid HTR data observed on spigot " << spigot << " of DCC with source id " << dccHeader->getSourceId();
544  continue;
545  }
546  if (!htr.isHistogramEvent()) {
547  edm::LogWarning("Invalid Data") << "Non-histogram data passed to histogram unpacker on spigot " << spigot << " of DCC with source id " << dccHeader->getSourceId();
548  continue;
549  }
550 
551  unsigned int smid=htr.getSubmodule();
552  int htr_tb=smid&0x1;
553  int htr_slot=(smid>>1)&0x1F;
554  int htr_cr=(smid>>6)&0x1F;
555 
556  // find out the fibers
557  int f[2],fc;
558  htr.getHistogramFibers(f[0],f[1]);
559 
560  for (int nf=0; nf<2; nf++) {
561  if (f[nf]<0 || (nf==1 && f[0]==f[1])) continue; // skip if invalid or the same
562  for (fc=0; fc<=2; fc++) {
563  HcalElectronicsId eid(fc,f[nf],spigot,dccid);
564  eid.setHTR(htr_cr,htr_slot,htr_tb);
565  DetId did=emap.lookup(eid);
566 
567  if (did.null() || did.det()!=DetId::Hcal || did.subdetId()==0) {
568  if (unknownIds_.find(eid)==unknownIds_.end()) {
569  edm::LogWarning("HCAL") << "HcalHistogramUnpacker: No match found for electronics id :" << eid;
570  unknownIds_.insert(eid);
571  }
572  continue;
573  }
574  histoDigis.push_back(HcalHistogramDigi(HcalDetId(did))); // add it!
575  HcalHistogramDigi& digi=histoDigis.back();
576 
577  // unpack the four capids
578  for (int capid=0; capid<4; capid++)
579  htr.unpackHistogram(f[nf],fc,capid,digi.getArray(capid));
580 
581  }
582  }
583  }
584 }
std::set< HcalElectronicsId > unknownIds_
Definition: HcalUnpacker.h:54
int sourceIdOffset_
number to subtract from the source id to get the dcc id
Definition: HcalUnpacker.h:49
bool check() const
Check for a good event Requires a minimum length, matching wordcount and length, not an empty event...
Definition: HcalHTRData.cc:62
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:413
int getSpigotData(int nspigot, HcalHTRData &decodeTool, int validSize) const
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
bool unpackHistogram(int fiber, int fiberchan, int capid, unsigned short *histogram) const
Unpack special histogramming mode data.
Definition: HcalHTRData.cc:441
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:37
int getSourceId() const
Definition: HcalDCCHeader.h:32
Definition: DetId.h:18
bool null() const
is this a null id ?
Definition: DetId.h:45
static const int SPIGOT_COUNT
Definition: HcalDCCHeader.h:19
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:28
unsigned int getSubmodule() const
Get the HTR submodule number.
Definition: HcalHTRData.cc:331
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
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:385
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 129 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, HcalDCCHeader::getDCCDataFormatVersion(), HcalHTRData::getFirmwareFlavor(), HcalHTRData::getFormatVersion(), HcalHTRData::getNPS(), HcalDTCHeader::getSlotCRCError(), HcalDTCHeader::getSlotData(), HcalDTCHeader::getSlotPresent(), HcalDCCHeader::getSourceId(), HcalDTCHeader::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, 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(), HcalDTCHeader::MAXIMUM_SLOT, mode_, 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.

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

Definition at line 503 of file HcalUnpacker.cc.

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

503  {
504  Collections c;
505  c.hbheCont=&container;
506  c.tpCont=&tp;
508  unpack(raw,emap,c,r);
509 }
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 511 of file HcalUnpacker.cc.

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

511  {
512  Collections c;
513  c.hoCont=&container;
514  c.tpCont=&tp;
516  unpack(raw,emap,c,r);
517 }
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 519 of file HcalUnpacker.cc.

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

519  {
520  Collections c;
521  c.hfCont=&container;
522  c.tpCont=&tp;
524  unpack(raw,emap,c,r);
525 }
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 51 of file HcalUnpacker.h.

Referenced by unpack().

int HcalUnpacker::expectedOrbitMessageTime_
private

Expected orbit bunch time (needed to evaluate time differences)

Definition at line 52 of file HcalUnpacker.h.

Referenced by setExpectedOrbitMessageTime(), and unpack().

int HcalUnpacker::mode_
private

Definition at line 53 of file HcalUnpacker.h.

Referenced by setMode(), and unpack().

int HcalUnpacker::sourceIdOffset_
private

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

Definition at line 49 of file HcalUnpacker.h.

Referenced by unpack().

int HcalUnpacker::startSample_
private

first sample from fed raw data to copy

Definition at line 50 of file HcalUnpacker.h.

Referenced by unpack().

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

Definition at line 54 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 54 of file HcalUnpacker.h.

Referenced by unpack().