1 #ifndef EventFilter_HcalRawToDigi_PackerHelp_h 2 #define EventFilter_HcalRawToDigi_PackerHelp_h 209 for (
int is = 0; is < 8; is++) {
210 outVec.push_back((var64bit >> (is * 8)) & 0xFF);
259 uhtrs.push_back(uhtr);
280 for (
unsigned int iAMC = 0; iAMC <
AMCHeaders.size(); ++iAMC) {
288 for (
unsigned int iAMC = 0; iAMC <
uhtrs.size(); ++iAMC) {
289 unsigned int nWords16 =
uhtrs[iAMC].size();
290 for (
unsigned int amcWord = 0; amcWord < nWords16; ++amcWord) {
297 while (
fedData.size() % 8 != 0)
302 unsigned char* words =
reinterpret_cast<unsigned char*
>(
rawData.data());
304 for (
unsigned int i = 0;
i <
fedData.size(); ++
i) {
347 bool exist(
int uhtrIndex) {
return uhtrs.count(uhtrIndex) != 0; };
353 int fiber =
eid.fiberIndex() + 1;
354 int fiberchan =
eid.fiberChanId();
361 int fiberErr = qieSample.
er();
362 int capid0 = qieSample.
capid();
375 int adc = qieSample.
adc();
376 int capid = qieSample.
capid();
377 int dv = qieSample.
dv();
378 int er = qieSample.
er();
403 int fiber =
eid.fiberIndex();
404 int fiberchan =
eid.fiberChanId();
420 int fiber =
eid.fiberIndex();
421 int fiberchan =
eid.fiberChanId();
422 int flavor = qiedf[0].
flavor();
432 int capid0 = qiedf[0].capid();
450 uint64_t uhtrCrate = uhtrIndex & 0xFF;
451 uint64_t uhtrSlot = (uhtrIndex & 0xF00) >> 8;
476 for (
unsigned int i = 0;
i < 4; ++
i) {
477 uhtrs[uhtrIndex][
i] = (uhtrHeader1 >> (
i * 16)) & 0xFFFF;
478 uhtrs[uhtrIndex][
i + 4] = (uhtrHeader2 >> (
i * 16)) & 0xFFFF;
481 return &(
uhtrs[uhtrIndex]);
485 uint64_t uhtr_size = uhtr->size() - 8;
488 uhtr->at(0) = uhtr_size & 0xFFFF;
489 uhtr->at(1) |= (uhtr_size >> 16) & 0xF;
491 unsigned int toAdd = 4 - uhtr->size() % 4;
492 for (
unsigned int ia = 0; ia <
toAdd; ia++) {
493 uhtr->push_back(0xD07F);
497 uhtr->push_back(uhtr_size & 0xFFFF);
498 uhtr->push_back((uhtr_size >> 16) & 0xF);
511 if (qiedf->
size() == 0)
513 DetId detid = qiedf->id();
519 for (
int iTS = 0; iTS < qiedf->
size(); ++iTS) {
523 for (
int iTS = 0; iTS < qiedf->
size(); iTS += 2) {
525 int adc0 = qiedf->sample(iTS).adc();
526 int adc1 = qiedf->sample(iTS + 1).adc();
528 cont |= (adc1 & 0xFF) << 8;
539 if (qiedf->
size() == 0)
541 DetId detid = qiedf->id();
547 for (
int iTS = 0; iTS < qiedf->
size(); ++iTS) {
551 for (
int iTS = 0; iTS < qiedf->
size(); iTS += 2) {
553 int adc0 = qiedf->sample(iTS).adc();
554 int adc1 = qiedf->sample(iTS + 1).adc();
556 cont |= (adc1 & 0xFF) << 8;
566 if (qiedf->
size() == 0)
571 for (
int iTS = 0; iTS < qiedf->
size(); iTS++) {
573 auto raw = qiedf->sample(iTS).raw();
575 if (iTS == qiedf->presamples())
577 uhtrs[uhtrIndex].push_back(raw);
595 uhtrs[uhtrIndex].push_back(dfi[0]);
613 uhtrs[uhtrIndex].push_back(dfi[0]);
621 std::vector<int>
const& tdc1,
622 std::vector<int>
const& tdc2,
629 int capid = qiehe[0].capid();
631 static const int hbflavor = 3;
633 static const int maxHBdepth = 4;
641 if (it == qiehe.
begin())
643 adc = qiehe[is].adc();
644 tdc = qiehe[is].tdc();
645 soi = qiehe[is].soi();
647 if (tdc >= 0 && tdc <=
first)
651 else if (tdc >
second && tdc <= tdcmax)
std::vector< uhtrData > uhtrs
constexpr DetId detid() const
Get the detector id.
static const int FLAG_WORDS
static const int OFFSET_PRESAMPLES
static const int OFFSET_ORN
void addChannel(int uhtrIndex, QIE11DataFrame qiedf, const HcalElectronicsMap *readoutMap, int verbosity=0)
static const int OFFSET_PAYLOAD_FORMAT
std::vector< unsigned char > fedData
void addUHTR(uhtrData uhtr, uint64_t crate, uint64_t slot)
void finalizeHeadTail(uhtrData *uhtr, bool verbosity)
static const int OFFSET_CAPID
static const int MASK_ORN
uint16_t packQIE8header(const HcalQIESample &qieSample, const HcalElectronicsId &eid, int flavor)
QIE11DataFrame convertHB(QIE11DataFrame qiehe, std::vector< int > const &tdc1, std::vector< int > const &tdc2, const int tdcmax)
void setNAMC(uint64_t NAMC)
static const int HEADER_WORDS
constexpr edm::DataFrame::iterator end()
static const int OFFSET_EVENT_TYPE
const DetId lookup(HcalElectronicsId fId) const
lookup the logical detid associated with the given electronics id
constexpr bool dv() const
is the Data Valid bit set?
constexpr int flavor() const
get the flavor of the frame
uhtrData * newUHTR(int uhtrIndex, int ps=0, int orn=0, int bcn=0, uint64_t evt=0)
std::vector< T >::const_iterator const_iterator
constexpr edm::DataFrame::iterator begin()
iterators
static const int OFFSET_ADC
static const int MASK_SLOT_ID
void addAMCHeader(uint64_t crate, uint64_t slot, uint64_t AMCsize, uint64_t presamples=10, uint64_t blockNum=0)
constexpr DetId detid() const
Get the detector id.
std::vector< uint16_t > uhtrData
static const int OFFSET_FILED_BY_AMC13
std::vector< uint64_t > AMCHeaders
U second(std::pair< T, U > const &p)
static const int MASK_FW_VERSION
void addChannel(int uhtrIndex, edm::SortedCollection< HcalTriggerPrimitiveDigi >::const_iterator qiedf, int channelid, int verbosity=0)
uint16_t packQIE11header(const QIE11DataFrame &qiedf, const HcalElectronicsId &eid)
constexpr void setFlavor(int flavor)
static const int OFFSET_CRATE_ID
static const int OFFSET_DV
uint16_t packQIE10header(const HcalElectronicsId &eid)
static const int MASK_PRESAMPLES
constexpr int ieta() const
get the cell ieta
std::vector< uint16_t > uhtrData
Abs< T >::type abs(const T &t)
void addChannel(int uhtrIndex, edm::SortedCollection< HBHEDataFrame >::const_iterator qiedf, const HcalElectronicsMap *readoutMap, bool premix, int verbosity=0)
static const int OFFSET_FW_FLAVOR
constexpr edm::DataFrame::iterator end()
uint16_t packTPheader(const HcalTriggerPrimitiveSample &tpSample, int channelid)
static const int MASK_PAYLOAD_FORMAT
void addChannel(int uhtrIndex, QIE10DataFrame qiedf, const HcalElectronicsMap *readoutMap, int verbosity=0)
constexpr void setSample(edm::DataFrame::size_type isample, int adc, int tdc, bool soi=false)
set the sample contents
void split64bitTo8bit(std::vector< unsigned char > &outVec, const uint64_t &var64bit)
static const int MASK_EVN
static const int OFFSET_FW_VERSION
static const int MASK_CAPID
unsigned long long uint64_t
static const int FLAG_WORDS
static const int MASK_BCN
static const int OFFSET_SLOT_ID
constexpr edm::DataFrame::iterator begin()
iterators
static const int HEADER_WORDS
static const int MASK_FILED_BY_AMC13
std::map< int, uhtrData > UHTRMap
uint16_t packQIE8sample(const HcalQIESample &qieSample)
void addChannel(int uhtrIndex, edm::SortedCollection< HFDataFrame >::const_iterator &qiedf, const HcalElectronicsMap *readoutMap, bool premix, int verbosity=0)
static const int OFFSET_ER
bool exist(int uhtrIndex)
constexpr int capid() const
get the Capacitor id
constexpr bool er() const
is the error bit set?
data_type const * const_iterator
constexpr int adc() const
get the ADC sample
static const int OFFSET_EVN
static const int OFFSET_BCN
void formatFEDdata(FEDRawData &rawData)
static const int OFFSET_DATA_LENGTH
constexpr void setCapid0(int cap0)
HCalFED(int fedId_, uint64_t EventNum_=9999, uint64_t OrbitNum_=999, uint64_t BxNum_=99)
Readout chain identification for Hcal.
cont
load Luminosity info ##
static const int MASK_EVENT_TYPE
uint16_t *__restrict__ uint16_t const *__restrict__ adc
static const int MASK_FW_FLAVOR
static const int MASK_CRATE_ID
static const int MASK_DATA_LENGTH
static const int MASK_ADC
constexpr int depth() const
get the tower depth