12 namespace CastorUnpacker_impl {
13 template <
class DigiClass>
24 digi.setPresamples(presamples);
25 int fiber = startPoint->
fiber();
38 int ncurr = 0, ntaken = 0;
40 while (qie_work != limit && qie_work->
fiberAndChan() == myFiberChan) {
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();
114 edm::LogWarning(
"Invalid Data") <<
"CRC Error on HTR data observed on spigot " << spigot
115 <<
" of DCC with source id " << dccHeader->
getSourceId();
121 edm::LogWarning(
"Invalid Data") <<
"Invalid HTR data observed on spigot " << spigot <<
" of DCC with source id "
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;
178 eid.
setHTR(htr_cr, htr_slot, htr_tb);
189 for (tp_work = tp_begin; tp_work != tp_end; tp_work++) {
191 if (tp_work->
raw() == 0xFFFF)
218 colls.
tpCont->back().setPresamples(nps);
228 colls.
tpCont->back().setSample(colls.
tpCont->back().size(), *tp_work);
229 colls.
tpCont->back().setSize(colls.
tpCont->back().size() + 1);
232 if (valid && tpgSOIbitInUse &&
isTPGSOI(*tp_work)) {
233 colls.
tpCont->back().setPresamples(ncurr);
246 for (qie_work = qie_begin; qie_work != qie_end;) {
247 if (qie_work->
raw() == 0xFFFF) {
254 eid.
setHTR(htr_cr, htr_slot, htr_tb);
259 qie_work = CastorUnpacker_impl::unpack<CastorDataFrame>(qie_work,
272 edm::LogWarning(
"CASTOR") <<
"CastorUnpacker: No match found for electronics id :" <<
eid;
bool check() const
Check for a good event Requires a minimum length, matching wordcount and length, not an empty event...
uint16_t *__restrict__ id
static int slb(const HcalTriggerPrimitiveSample &theSample)
int sector() const
get the sector (1-16)
constexpr bool null() const
is this a null id ?
void setHTR(int crate, int slot, int tb)
static bool isTPGSOI(const HcalTriggerPrimitiveSample &s)
constexpr int fiberChan() const
get the fiber channel number
int module() const
get the module (1-2 for EM, 1-12 for HAD)
bool wasMarkAndPassZS(int fiber, int fiberchan) const
Was this channel passed as part of Mark&Pass ZS?
unsigned int getFibOrbMsgBCN(int fiber) const
Get the BCN of the Fiber Orbit Messages.
static int slbChan(const HcalTriggerPrimitiveSample &theSample)
int getFormatVersion() const
Get the version number of this event.
size_t size() const
Lenght of the data buffer in bytes.
void countSpigotFormatError()
std::set< CastorElectronicsId > unknownIds_
void unpack(const FEDRawData &raw, const CastorElectronicsMap &emap, CastorRawCollections &conts, HcalUnpackerReport &report, bool silent=false)
For histograms, no begin and end.
bool isUnsuppressed() const
Is this event an unsuppresed event?
const DetId lookup(CastorElectronicsId fId) const
lookup the logical detid associated with the given electronics id
CastorUnpacker(int sourceIdOffset, int beg, int end)
for normal data
static int slbAndChan(const HcalTriggerPrimitiveSample &theSample)
int zside() const
get the z-side of the cell (1/-1)
uint16_t raw() const
get the raw word
std::vector< CastorDataFrame > * castorCont
std::vector< CastorTriggerPrimitiveDigi > * tpCont
int sourceIdOffset_
number to subtract from the source id to get the dcc id
int expectedOrbitMessageTime_
Expected orbit bunch time (needed to evaluate time differences)
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.
bool unpack(const HcalHTRData &data, HcalTTPDigi &digi)
int getNPS() const
Get the number of presamples in daq data.
int getFirmwareFlavor() const
Get the HTR firmware flavor.
bool wasMarkAndPassZSTP(int slb, int slbchan) const
Was this channel passed as part of Mark&Pass ZS?
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)
uint32_t zsBunchMask() const
ZS Bunch Mask (if available)
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
constexpr uint16_t raw() const
get the raw word
Readout chain identification for Castor Bits for the readout chain : some names need change! [31:26] ...
unsigned int getSubmodule() const
Get the HTR submodule number.
Log< level::Warning, false > LogWarning
static const int MAXSAMPLES
bool isHistogramEvent() const
Is this event a histogram event? (do not call standard unpack in this case!!!!!)
int startSample_
first sample from fed raw data to copy
constexpr int fiber() const
get the fiber number
int endSample_
last sample from fed raw data to copy (if present)
constexpr int fiberAndChan() const
get the id channel
std::vector< HcalTTPDigi > * ttp