CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
CastorCtdcUnpacker Class Reference

#include <CastorCtdcUnpacker.h>

Public Member Functions

 CastorCtdcUnpacker (int sourceIdOffset, int beg, int end)
 for normal data More...
 
void unpack (const FEDRawData &raw, const CastorElectronicsMap &emap, CastorRawCollections &conts, HcalUnpackerReport &report)
 

Private Attributes

int endSample_
 last sample from fed raw data to copy (if present) 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< CastorElectronicsIdunknownIds_
 
std::set< CastorElectronicsIdunknownIdsTrig_
 Recorded to limit number of times a log message is generated. More...
 

Detailed Description

Definition at line 14 of file CastorCtdcUnpacker.h.

Constructor & Destructor Documentation

◆ CastorCtdcUnpacker()

CastorCtdcUnpacker::CastorCtdcUnpacker ( int  sourceIdOffset,
int  beg,
int  end 
)

for normal data

Definition at line 12 of file CastorCtdcUnpacker.cc.

12  : sourceIdOffset_(sourceIdOffset) {
13  if (beg >= 0 && beg <= CastorDataFrame::MAXSAMPLES - 1) {
14  startSample_ = beg;
15  } else {
16  startSample_ = 0;
17  }
18  if (end >= 0 && end <= CastorDataFrame::MAXSAMPLES - 1 && end >= beg) {
19  endSample_ = end;
20  } else {
22  }
23 }

References mps_fire::end, endSample_, CastorDataFrame::MAXSAMPLES, and startSample_.

Member Function Documentation

◆ unpack()

void CastorCtdcUnpacker::unpack ( const FEDRawData raw,
const CastorElectronicsMap emap,
CastorRawCollections conts,
HcalUnpackerReport report 
)

work through all channels

Definition at line 25 of file CastorCtdcUnpacker.cc.

28  {
29  if (raw.size() < 16) {
30  edm::LogWarning("Invalid Data") << "Empty/invalid DCC data, size = " << raw.size();
31  return;
32  }
33 
34  // get the CTDC header
35  const CastorCTDCHeader* ctdcHeader = (const CastorCTDCHeader*)(raw.data());
36  int ctdcid = ctdcHeader->getSourceId() - sourceIdOffset_;
37 
38  // space for unpacked data from one COR
41  std::vector<unsigned char> preclen(CastorCORData::CHANNELS_PER_SPIGOT);
42  std::vector<unsigned char> triglen(CastorCORData::CHANNELS_PER_SPIGOT);
43 
44  // walk through the COR data...
45  CastorCORData cor;
46  for (int spigot = 0; spigot < CastorCTDCHeader::SPIGOT_COUNT; spigot++) {
47  if (!ctdcHeader->getSpigotPresent(spigot))
48  continue;
49 
50  int retval = ctdcHeader->getSpigotData(spigot, cor, raw.size());
51  if (retval != 0) {
52  if (retval == -1) {
53  edm::LogWarning("Invalid Data") << "Invalid COR data (data beyond payload size) observed on spigot " << spigot
54  << " of CTDC with source id " << ctdcHeader->getSourceId();
55  report.countSpigotFormatError();
56  }
57  continue;
58  }
59  // check
60  if (!cor.check()) {
61  edm::LogWarning("Invalid Data") << "Invalid COR data observed on spigot " << spigot << " of CTDC with source id "
62  << ctdcHeader->getSourceId();
63  report.countSpigotFormatError();
64  continue;
65  }
66  if (cor.isHistogramEvent()) {
67  edm::LogWarning("Invalid Data") << "Histogram data passed to non-histogram unpacker on spigot " << spigot
68  << " of CTDC with source id " << ctdcHeader->getSourceId();
69  continue;
70  }
71  // calculate "real" number of presamples
72  int nps = cor.getNPS() - startSample_;
73 
74  // new: do not use get pointers .. instead make use of CastorCORData::unpack
75 
76  cor.unpack(&(preclen[0]), &(precdata[0]), &(triglen[0]), &(trigdata[0]));
77 
79  int ichan;
80  for (ichan = 0; ichan < CastorCORData::CHANNELS_PER_SPIGOT; ichan++) {
81  if (preclen[ichan] == 0 || preclen[ichan] & 0xc0)
82  continue;
83  int fiber = ichan / 3;
84  int fiberchan = ichan % 3;
85  // lookup the right channel
86  CastorElectronicsId partialEid(fiberchan, fiber + 1, spigot, ctdcid);
87  // does this partial id exist?
89  HcalGenericDetId did;
90  bool found;
91  found = emap.lookup(partialEid, eid, did);
92 
93  if (found) {
95  // set parameters - presamples
96  digi.setPresamples(nps);
97 
98  int ntaken = 0;
99  for (int sample = startSample_; sample <= endSample_; sample++) {
100  digi.setSample(ntaken, precdata[ichan * CastorCORData::MAXIMUM_SAMPLES_PER_CHANNEL + sample]);
101  ntaken++;
102  }
103  digi.setSize(ntaken);
104  colls.castorCont->push_back(digi);
105  } else {
106  report.countUnmappedDigi();
107  if (unknownIds_.find(partialEid) == unknownIds_.end()) {
108  edm::LogWarning("CASTOR") << "CastorCtdcUnpacker: No match found for electronics partialEid :" << partialEid;
109  unknownIds_.insert(partialEid);
110  }
111  }
112  }
113  }
114 }

References CastorRawCollections::castorCont, CastorCORData::CHANNELS_PER_SPIGOT, CastorCORData::check(), FEDRawData::data(), runTauDisplay::eid, endSample_, newFWLiteAna::found, CastorCORData::getNPS(), CastorCTDCHeader::getSourceId(), CastorCTDCHeader::getSpigotData(), CastorCTDCHeader::getSpigotPresent(), CastorCORData::isHistogramEvent(), CastorElectronicsMap::lookup(), CastorCORData::MAXIMUM_SAMPLES_PER_CHANNEL, edmIntegrityCheck::report, simplePhotonAnalyzer_cfi::sample, CastorDataFrame::setPresamples(), CastorDataFrame::setSample(), CastorDataFrame::setSize(), FEDRawData::size(), sourceIdOffset_, CastorCTDCHeader::SPIGOT_COUNT, startSample_, unknownIds_, and CastorCORData::unpack().

Referenced by CastorRawToDigi::produce().

Member Data Documentation

◆ endSample_

int CastorCtdcUnpacker::endSample_
private

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

Definition at line 26 of file CastorCtdcUnpacker.h.

Referenced by CastorCtdcUnpacker(), and unpack().

◆ sourceIdOffset_

int CastorCtdcUnpacker::sourceIdOffset_
private

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

Definition at line 24 of file CastorCtdcUnpacker.h.

Referenced by unpack().

◆ startSample_

int CastorCtdcUnpacker::startSample_
private

first sample from fed raw data to copy

Definition at line 25 of file CastorCtdcUnpacker.h.

Referenced by CastorCtdcUnpacker(), and unpack().

◆ unknownIds_

std::set<CastorElectronicsId> CastorCtdcUnpacker::unknownIds_
private

Definition at line 27 of file CastorCtdcUnpacker.h.

Referenced by unpack().

◆ unknownIdsTrig_

std::set<CastorElectronicsId> CastorCtdcUnpacker::unknownIdsTrig_
private

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

Definition at line 27 of file CastorCtdcUnpacker.h.

CastorDataFrame::setSample
void setSample(int i, const HcalQIESample &sam)
Definition: CastorDataFrame.h:49
CastorCTDCHeader
Definition: CastorCTDCHeader.h:17
HcalGenericDetId
Definition: HcalGenericDetId.h:15
simplePhotonAnalyzer_cfi.sample
sample
Definition: simplePhotonAnalyzer_cfi.py:12
CastorCORData::unpack
void unpack(unsigned char *daq_lengths, unsigned short *daq_samples, unsigned char *tp_lengths, unsigned short *tp_samples) const
Obtain the starting and ending pointers for external unpacking of the data.
Definition: CastorCORData.cc:102
CastorCTDCHeader::getSourceId
int getSourceId() const
Definition: CastorCTDCHeader.h:32
CastorCORData::isHistogramEvent
bool isHistogramEvent() const
Is this event a histogram event? (do not call standard unpack in this case!!!!!)
Definition: CastorCORData.cc:294
CastorCORData::getNPS
int getNPS() const
Get the number of presamples in daq data.
Definition: CastorCORData.cc:311
CastorElectronicsId
Readout chain identification for Castor Bits for the readout chain : some names need change!...
Definition: CastorElectronicsId.h:20
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
CastorCtdcUnpacker::endSample_
int endSample_
last sample from fed raw data to copy (if present)
Definition: CastorCtdcUnpacker.h:26
FEDRawData::data
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
CastorCtdcUnpacker::startSample_
int startSample_
first sample from fed raw data to copy
Definition: CastorCtdcUnpacker.h:25
mps_fire.end
end
Definition: mps_fire.py:242
CastorCORData
Definition: CastorCORData.h:14
HcalCastorDetId
Definition: HcalCastorDetId.h:23
CastorCTDCHeader::getSpigotPresent
bool getSpigotPresent(unsigned int nspigot) const
Read the "PRESENT" bit for this spigot.
Definition: CastorCTDCHeader.h:95
CastorDataFrame
Definition: CastorDataFrame.h:15
CastorDataFrame::setSize
void setSize(int size)
Definition: CastorDataFrame.cc:9
runTauDisplay.eid
eid
Definition: runTauDisplay.py:298
CastorCTDCHeader::SPIGOT_COUNT
static const int SPIGOT_COUNT
Definition: CastorCTDCHeader.h:19
FEDRawData::size
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
edmIntegrityCheck.report
report
Definition: edmIntegrityCheck.py:349
CastorCtdcUnpacker::sourceIdOffset_
int sourceIdOffset_
number to subtract from the source id to get the dcc id
Definition: CastorCtdcUnpacker.h:24
CastorCORData::CHANNELS_PER_SPIGOT
static const int CHANNELS_PER_SPIGOT
Definition: CastorCORData.h:16
CastorDataFrame::setPresamples
void setPresamples(int ps)
Definition: CastorDataFrame.cc:18
CastorCORData::MAXIMUM_SAMPLES_PER_CHANNEL
static const int MAXIMUM_SAMPLES_PER_CHANNEL
Definition: CastorCORData.h:17
CastorElectronicsMap::lookup
const DetId lookup(CastorElectronicsId fId) const
lookup the logical detid associated with the given electronics id
Definition: CastorElectronicsMap.cc:105
CastorCTDCHeader::getSpigotData
int getSpigotData(int nspigot, CastorCORData &decodeTool, int validSize) const
Definition: CastorCTDCHeader.cc:22
CastorCORData::check
bool check() const
Check for a good event Requires a minimum length, matching wordcount and length, not an empty event.
Definition: CastorCORData.cc:64
CastorCtdcUnpacker::unknownIds_
std::set< CastorElectronicsId > unknownIds_
Definition: CastorCtdcUnpacker.h:27
CastorDataFrame::MAXSAMPLES
static const int MAXSAMPLES
Definition: CastorDataFrame.h:54