13 template <
class DigiClass>
38 int ncurr = 0, ntaken = 0;
41 if (ncurr >= startSample && ncurr <= endSample) {
42 digi.setSample(ntaken, *qie_work);
58 : sourceIdOffset_(sourceIdOffset), expectedOrbitMessageTime_(-1) {
64 if (
end >= 0 && end <= CastorDataFrame::MAXSAMPLES - 1 && end >= beg) {
80 if (raw.
size() < 16) {
94 const unsigned short *daq_first, *daq_last, *tp_first, *tp_last;
105 edm::LogWarning(
"Invalid Data") <<
"Invalid HTR data (data beyond payload size) observed on spigot " << spigot
106 <<
" of DCC with source id " << dccHeader->
getSourceId();
107 report.countSpigotFormatError();
114 edm::LogWarning(
"Invalid Data") <<
"CRC Error on HTR data observed on spigot " << spigot
115 <<
" of DCC with source id " << dccHeader->
getSourceId();
116 report.countSpigotFormatError();
121 edm::LogWarning(
"Invalid Data") <<
"Invalid HTR data observed on spigot " << spigot <<
" of DCC with source id " 123 report.countSpigotFormatError();
128 edm::LogWarning(
"Invalid Data") <<
"Histogram data passed to non-histogram unpacker on spigot " << spigot
129 <<
" of DCC with source id " << dccHeader->
getSourceId();
133 if (colls.
ttp !=
nullptr) {
136 ttpUnpack.
unpack(htr, colls.
ttp->back());
138 LogDebug(
"CastorUnpackerHcalTechTrigProcessor")
139 <<
"Skipping data on spigot " << spigot <<
" of DCC with source id " << dccHeader->
getSourceId()
140 <<
" which is from the TechTrigProcessor (use separate unpacker!)";
147 <<
"Skipping data on spigot " << spigot <<
" of DCC with source id " << dccHeader->
getSourceId()
155 htr.
dataPointers(&daq_first, &daq_last, &tp_first, &tp_last);
157 int htr_tb = smid & 0x1;
158 int htr_slot = (smid >> 1) & 0x1F;
159 int htr_cr = (smid >> 6) & 0x1F;
165 int currFiberChan = 0x3F;
177 eid.setHTR(htr_cr, htr_slot, htr_tb);
183 if (
id1.module() > 12)
188 for (tp_work = tp_begin; tp_work != tp_end; tp_work++) {
190 if (tp_work->
raw() == 0xFFFF)
216 colls.
tpCont->back().setPresamples(nps);
226 colls.
tpCont->back().setSample(colls.
tpCont->back().size(), *tp_work);
227 colls.
tpCont->back().setSize(colls.
tpCont->back().size() + 1);
231 colls.
tpCont->back().setPresamples(ncurr);
243 for (qie_work = qie_begin; qie_work != qie_end;) {
244 if (qie_work->
raw() == 0xFFFF) {
251 eid.setHTR(htr_cr, htr_slot, htr_tb);
256 qie_work = CastorUnpacker_impl::unpack<CastorDataFrame>(qie_work,
266 report.countUnmappedDigi();
269 edm::LogWarning(
"CASTOR") <<
"CastorUnpacker: No match found for electronics id :" <<
eid;
bool isHistogramEvent() const
Is this event a histogram event? (do not call standard unpack in this case!!!!!)
bool wasMarkAndPassZS(int fiber, int fiberchan) const
Was this channel passed as part of Mark&Pass ZS?
static int slb(const HcalTriggerPrimitiveSample &theSample)
constexpr int fiberChan() const
get the fiber channel number
constexpr int fiberAndChan() const
get the id channel
static bool isTPGSOI(const HcalTriggerPrimitiveSample &s)
int getNPS() const
Get the number of presamples in daq data.
size_t size() const
Lenght of the data buffer in bytes.
static int slbChan(const HcalTriggerPrimitiveSample &theSample)
uint32_t zsBunchMask() const
ZS Bunch Mask (if available)
int getFirmwareFlavor() const
Get the HTR firmware flavor.
std::set< CastorElectronicsId > unknownIds_
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.
void unpack(const FEDRawData &raw, const CastorElectronicsMap &emap, CastorRawCollections &conts, HcalUnpackerReport &report, bool silent=false)
For histograms, no begin and end.
constexpr bool null() const
is this a null id ?
uint16_t raw() const
get the raw word
CastorUnpacker(int sourceIdOffset, int beg, int end)
for normal data
static int slbAndChan(const HcalTriggerPrimitiveSample &theSample)
int getFormatVersion() const
Get the version number of this event.
bool wasMarkAndPassZSTP(int slb, int slbchan) const
Was this channel passed as part of Mark&Pass ZS?
std::vector< CastorDataFrame > * castorCont
std::vector< CastorTriggerPrimitiveDigi > * tpCont
int sourceIdOffset_
number to subtract from the source id to get the dcc id
constexpr uint16_t raw() const
get the raw word
int expectedOrbitMessageTime_
Expected orbit bunch time (needed to evaluate time differences)
constexpr int fiber() const
get the fiber number
bool unpack(const HcalHTRData &data, HcalTTPDigi &digi)
const DetId lookup(CastorElectronicsId fId) const
lookup the logical detid associated with the given electronics id
const HcalQIESample * unpack(const HcalQIESample *startPoint, const HcalQIESample *limit, DigiClass &digi, int presamples, const CastorElectronicsId &eid, int startSample, int endSample, int expectedTime, const HcalHTRData &hhd)
Readout chain identification for Castor Bits for the readout chain : some names need change! [31:26] ...
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
unsigned int getFibOrbMsgBCN(int fiber) const
Get the BCN of the Fiber Orbit Messages.
unsigned int getSubmodule() const
Get the HTR submodule number.
Log< level::Warning, false > LogWarning
bool check() const
Check for a good event Requires a minimum length, matching wordcount and length, not an empty event...
static const int MAXSAMPLES
int startSample_
first sample from fed raw data to copy
int endSample_
last sample from fed raw data to copy (if present)
std::vector< HcalTTPDigi > * ttp
bool isUnsuppressed() const
Is this event an unsuppresed event?