1 #ifndef EventFilter_HcalRawToDigi_PackerHelp_h
2 #define EventFilter_HcalRawToDigi_PackerHelp_h
18 namespace CDFHeaderSpec{
36 namespace AMC13HeaderSpec{
52 namespace AMCHeaderSpec{
83 namespace QIE8HeaderSpec{
98 namespace QIE10HeaderSpec{
115 namespace QIE11HeaderSpec{
130 namespace TPHeaderSpec{
179 for(
int is=0; is<8; is++){
180 outVec.push_back( (var64bit>> (is*8) ) & 0xFF);
236 uhtrs.push_back(uhtr);
258 for(
unsigned int iAMC = 0 ; iAMC <
AMCHeaders.size() ; ++iAMC ){
266 for(
unsigned int iAMC = 0 ; iAMC<
uhtrs.size() ; ++iAMC ){
268 unsigned int nWords16 =
uhtrs[iAMC].size();
269 for(
unsigned int amcWord = 0 ; amcWord<nWords16 ; ++amcWord ){
281 unsigned char* words =
reinterpret_cast<unsigned char*
>(rawData.
data());
283 for(
unsigned int i = 0 ;
i <
fedData.size() ; ++
i ){
332 return uhtrs.count(uhtrIndex) != 0 ;
340 int fiberErr = qieSample.
er();
341 int capid0 = qieSample.
capid();
387 int capid0 = qiedf.
samples() == 0? 0 : qiedf[0].capid();
406 uint64_t uhtrCrate = uhtrIndex&0xFF;
407 uint64_t uhtrSlot = (uhtrIndex&0xF00)>>8;
433 if(specialSimPremixBit){
438 for (
unsigned int i = 0;
i< 4; ++
i){
439 uhtrs[uhtrIndex][
i] = ( uhtrHeader1>>(
i*16) )&0xFFFF ;
440 uhtrs[uhtrIndex][
i+4] = ( uhtrHeader2>>(
i*16) )&0xFFFF ;
443 return &(
uhtrs[uhtrIndex]);
448 uint64_t uhtr_size = uhtr->size()-8;
451 uhtr->at(0) = uhtr_size&0xFFFF ;
452 uhtr->at(1) |= (uhtr_size>>16)&0xF ;
454 unsigned int toAdd = 4-uhtr->size()%4;
455 for(
unsigned int ia=0; ia<
toAdd; ia++){
456 uhtr->push_back(0xD07F);
460 uhtr->push_back( uhtr_size&0xFFFF );
461 uhtr->push_back( (uhtr_size>>16)&0xF );
465 uhtr->push_back( 0 );
466 uhtr->push_back( 0 );
470 if( qiedf->
size() == 0 )
return;
471 DetId detid = qiedf->id();
474 uhtrs[uhtrIndex].push_back(header);
476 for(
int iTS = 0; iTS < qiedf->
size(); iTS +=2 ){
478 int adc0 = qiedf->sample(iTS).adc();
479 int adc1 = qiedf->sample(iTS+1).adc();
481 cont |= (adc1&0xFF)<<8;
482 uhtrs[uhtrIndex].push_back(cont);
487 if( qiedf->
size() == 0 )
return;
488 DetId detid = qiedf->id();
491 uhtrs[uhtrIndex].push_back(header);
493 for(
int iTS = 0; iTS < qiedf->
size(); iTS +=2 ){
495 int adc0 = qiedf->sample(iTS).adc();
496 int adc1 = qiedf->sample(iTS+1).adc();
498 cont |= (adc1&0xFF)<<8;
499 uhtrs[uhtrIndex].push_back(cont);
504 if( qiedf->
size() ==0 )
return;
505 uint16_t header =
packTPheader(qiedf->sample(0), channelid);
506 uhtrs[uhtrIndex].push_back(header);
508 for(
int iTS = 0 ; iTS < qiedf->
size() ; iTS++ ){
510 uhtrs[uhtrIndex].push_back(qiedf->sample(iTS).raw());
519 if( dfi >= qiedf.
end() ){
524 uhtrs[uhtrIndex].push_back(header);
528 uhtrs[uhtrIndex].push_back(dfi[0]);
542 uhtrs[uhtrIndex].push_back(header);
546 uhtrs[uhtrIndex].push_back(dfi[0]);
DetId detid() const
Get the detector id.
std::vector< uhtrData > uhtrs
static const int OFFSET_PRESAMPLES
static const int OFFSET_ORN
edm::DataFrame::iterator begin()
iterators
int fiberIndex() const
get the fiber index. For VME 1-8 (which of eight fibers carried by a spigot), for uTCA fibers are zer...
void addChannel(int uhtrIndex, QIE11DataFrame qiedf, const HcalElectronicsMap *readoutMap, int verbosity=0)
static const int OFFSET_PAYLOAD_FORMAT
std::vector< unsigned char > fedData
tuple cont
load Luminosity info ##
void addUHTR(uhtrData uhtr, uint64_t crate, uint64_t slot)
void finalizeHeadTail(uhtrData *uhtr, bool verbosity)
static const int MASK_ORN
void setNAMC(uint64_t NAMC)
std::map< int, uhtrData > UHTRMap
static const int HEADER_WORDS
static const int OFFSET_EVENT_TYPE
std::vector< T >::const_iterator const_iterator
static const int MASK_PRESAMPLES_MSB
uint16_t packQIE8header(const HcalQIESample &qieSample, const HcalElectronicsId &eid)
void addChannel(int uhtrIndex, edm::SortedCollection< HBHEDataFrame >::const_iterator qiedf, const HcalElectronicsMap *readoutMap, int verbosity=0)
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)
std::vector< uint16_t > uhtrData
static const int OFFSET_FILED_BY_AMC13
void addChannel(int uhtrIndex, edm::SortedCollection< HFDataFrame >::const_iterator &qiedf, const HcalElectronicsMap *readoutMap, int verbosity=0)
std::vector< uint64_t > AMCHeaders
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)
static const int OFFSET_CRATE_ID
uint16_t packQIE10header(const HcalElectronicsId &eid)
static const int MASK_PRESAMPLES
void resize(size_t newsize)
std::vector< uint16_t > uhtrData
static const int OFFSET_FW_FLAVOR
DetId detid() const
Get the detector id.
uint16_t packTPheader(const HcalTriggerPrimitiveSample &tpSample, int channelid)
static const int MASK_PAYLOAD_FORMAT
int fiberChanId() const
get the fiber channel id (which of channels on a fiber)
edm::DataFrame::iterator end()
void addChannel(int uhtrIndex, QIE10DataFrame qiedf, const HcalElectronicsMap *readoutMap, int verbosity=0)
void split64bitTo8bit(std::vector< unsigned char > &outVec, const uint64_t &var64bit)
static const int MASK_EVN
static const int OFFSET_FW_VERSION
unsigned long long uint64_t
int capid() const
get the Capacitor id
static const int FLAG_WORDS
static const int MASK_BCN
static const int OFFSET_SLOT_ID
static const int HEADER_WORDS
static const int MASK_FILED_BY_AMC13
uhtrData * newUHTR(int uhtrIndex, int ps, bool specialSimPremixBit=false, int orn=0, int bcn=0, uint64_t evt=0)
bool exist(int uhtrIndex)
static const int OFFSET_EVN
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
static const int OFFSET_BCN
edm::DataFrame::iterator begin()
iterators
void formatFEDdata(FEDRawData &rawData)
static const int OFFSET_DATA_LENGTH
edm::DataFrame::iterator end()
int samples() const
total number of samples in the digi
HCalFED(int fedId_, uint64_t EventNum_=9999, uint64_t OrbitNum_=999, uint64_t BxNum_=99)
Readout chain identification for Hcal.
const DetId lookup(HcalElectronicsId fId) const
lookup the logical detid associated with the given electronics id
bool er() const
is the error bit set?
static const int MASK_EVENT_TYPE
static const int MASK_FW_FLAVOR
static const int MASK_CRATE_ID
static const int MASK_DATA_LENGTH