diff --git a/Configuration/StandardSequences/python/DigiToRawPreMixing_cff.py b/Configuration/StandardSequences/python/DigiToRawPreMixing_cff.py index 841fd3202108c..3e797b5c4ad4d 100644 --- a/Configuration/StandardSequences/python/DigiToRawPreMixing_cff.py +++ b/Configuration/StandardSequences/python/DigiToRawPreMixing_cff.py @@ -23,6 +23,7 @@ ecalPacker.InstanceEE = 'eeDigis' ecalPacker.labelEBSRFlags = "simEcalDigis:ebSrFlags" ecalPacker.labelEESRFlags = "simEcalDigis:eeSrFlags" +hcalRawDatauHTR.premix = cms.bool(True) from Configuration.Eras.Modifier_phase2_common_cff import phase2_common phase2_common.toReplaceWith(DigiToRaw, DigiToRaw.copyAndExclude([castorRawData])) diff --git a/EventFilter/HcalRawToDigi/interface/HcalUHTRData.h b/EventFilter/HcalRawToDigi/interface/HcalUHTRData.h index 6e13261a81d25..c232d7354dcdb 100644 --- a/EventFilter/HcalRawToDigi/interface/HcalUHTRData.h +++ b/EventFilter/HcalRawToDigi/interface/HcalUHTRData.h @@ -41,11 +41,13 @@ class HcalUHTRData { public: const_iterator(const uint16_t* ptr, const uint16_t* limit=0); - bool isHeader() const { return ((*m_ptr)&0x8000)!=0; } - int flavor() const { return ((*m_ptr)>>12)&0x7; } - int errFlags() const { return ((*m_ptr)>>10)&0x3; } - int capid0() const { return ((*m_ptr)>>8)&0x3; } - int channelid() const { return ((*m_ptr))&0xFF; } + bool isHeader() const { return ((*m_ptr)&0x8000)!=0; } + int flavor() const { return ((*m_ptr)>>12)&0x7; } + int errFlags() const; + bool dataValid() const; + int capid0() const { return ((*m_ptr)>>8)&0x3; } + int channelid() const { return ((*m_ptr))&0xFF; } + int technicalDataType() const; uint16_t value() const { return *m_ptr; } @@ -72,7 +74,8 @@ class HcalUHTRData { int m_microstep; int m_stepclass; int m_flavor; - }; + int m_technicalDataType; + }; const_iterator begin() const; const_iterator end() const; diff --git a/EventFilter/HcalRawToDigi/plugins/HcalDigiToRawuHTR.cc b/EventFilter/HcalRawToDigi/plugins/HcalDigiToRawuHTR.cc index 37a3b18efbd03..8224b826c966f 100644 --- a/EventFilter/HcalRawToDigi/plugins/HcalDigiToRawuHTR.cc +++ b/EventFilter/HcalRawToDigi/plugins/HcalDigiToRawuHTR.cc @@ -64,6 +64,7 @@ class HcalDigiToRawuHTR : public edm::stream::EDProducer<> { edm::Handle tpDigiCollection; edm::InputTag qie10Tag_, qie11Tag_, hbheqie8Tag_, hfqie8Tag_, trigTag_; + bool premix_; }; HcalDigiToRawuHTR::HcalDigiToRawuHTR(const edm::ParameterSet& iConfig) : @@ -73,7 +74,8 @@ HcalDigiToRawuHTR::HcalDigiToRawuHTR(const edm::ParameterSet& iConfig) : qie11Tag_(iConfig.getParameter("QIE11")), hbheqie8Tag_(iConfig.getParameter("HBHEqie8")), hfqie8Tag_(iConfig.getParameter("HFqie8")), - trigTag_(iConfig.getParameter("TP")) + trigTag_(iConfig.getParameter("TP")), + premix_(iConfig.getParameter("premix")) { produces(""); tok_QIE10DigiCollection_ = consumes >(qie10Tag_); @@ -174,7 +176,7 @@ void HcalDigiToRawuHTR::produce(edm::Event& iEvent, const edm::EventSetup& iSetu if( ! uhtrs.exist(uhtrIndex) ){ uhtrs.newUHTR( uhtrIndex , presamples ); } - uhtrs.addChannel(uhtrIndex,qiedf,readoutMap,_verbosity); + uhtrs.addChannel(uhtrIndex,qiedf,readoutMap,premix_,_verbosity); } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -195,7 +197,7 @@ void HcalDigiToRawuHTR::produce(edm::Event& iEvent, const edm::EventSetup& iSetu if( ! uhtrs.exist(uhtrIndex) ){ uhtrs.newUHTR( uhtrIndex , presamples ); } - uhtrs.addChannel(uhtrIndex,qiedf,readoutMap,_verbosity); + uhtrs.addChannel(uhtrIndex,qiedf,readoutMap,premix_,_verbosity); } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -280,6 +282,7 @@ void HcalDigiToRawuHTR::fillDescriptions(edm::ConfigurationDescriptions& descrip desc.add("HBHEqie8", edm::InputTag("simHcalDigis")); desc.add("HFqie8", edm::InputTag("simHcalDigis")); desc.add("TP", edm::InputTag("simHcalTriggerPrimitiveDigis")); + desc.add("premix", false); descriptions.add("hcalDigiToRawuHTR",desc); descriptions.addDefault(desc); } diff --git a/EventFilter/HcalRawToDigi/plugins/PackerHelp.h b/EventFilter/HcalRawToDigi/plugins/PackerHelp.h index 274900948b6a6..b21b4ffce6dd1 100644 --- a/EventFilter/HcalRawToDigi/plugins/PackerHelp.h +++ b/EventFilter/HcalRawToDigi/plugins/PackerHelp.h @@ -93,6 +93,8 @@ namespace QIE8HeaderSpec{ static const int MASK_FLAVOR = 0x7; static const int OFFSET_HEADER_BIT = 15; static const int MASK_HEADER_BIT = 0x1; + static const int OFFSET_TECHNICAL_DATA_TYPE = 8; + static const int MASK_TECHNICAL_DATA_TYPE = 0xF; } namespace QIE10HeaderSpec{ @@ -144,6 +146,17 @@ namespace TPHeaderSpec{ static const int MASK_HEADER_BIT = 0x1; } +namespace QIE8SampleSpec{ + static const int OFFSET_ADC = 0; + static const int MASK_ADC = 0x7F; + static const int OFFSET_CAPID = 8; + static const int MASK_CAPID = 0x3; + static const int OFFSET_DV = 10; + static const int MASK_DV = 0x1; + static const int OFFSET_ER = 11; + static const int MASK_ER = 0x1; +} + class HCalFED{ public: @@ -331,7 +344,8 @@ class UHTRpacker{ return uhtrs.count(uhtrIndex) != 0 ; }; - uint16_t packQIE8header(const HcalQIESample &qieSample, const HcalElectronicsId &eid){ + // flavor should be 5, or 7 (only for premixing in sim) + uint16_t packQIE8header(const HcalQIESample &qieSample, const HcalElectronicsId &eid, int flavor){ uint16_t header =0; int fiber = eid.fiberIndex()+1; @@ -341,14 +355,35 @@ class UHTRpacker{ header |= (fiberchan & QIE8HeaderSpec::MASK_FIBERCHAN)<push_back( 0 ); }; - void addChannel( int uhtrIndex , edm::SortedCollection::const_iterator& qiedf , const HcalElectronicsMap* readoutMap, int verbosity = 0 ){ + void addChannel( int uhtrIndex , edm::SortedCollection::const_iterator& qiedf , const HcalElectronicsMap* readoutMap, bool premix, int verbosity = 0 ){ if( qiedf->size() == 0 ) return; DetId detid = qiedf->id(); HcalElectronicsId eid(readoutMap->lookup(detid)); - uint16_t header = packQIE8header(qiedf->sample(0), eid); + uint16_t header = packQIE8header(qiedf->sample(0), eid, premix ? 7 : 5); uhtrs[uhtrIndex].push_back(header); // loop over words in dataframe - for(int iTS = 0; iTS < qiedf->size(); iTS +=2 ){ - uint16_t cont =0; - int adc0 = qiedf->sample(iTS).adc(); - int adc1 = qiedf->sample(iTS+1).adc(); - cont |= adc0&0xFF; - cont |= (adc1&0xFF)<<8; - uhtrs[uhtrIndex].push_back(cont); + if(premix){ + for(int iTS = 0; iTS < qiedf->size(); ++iTS){ + uhtrs[uhtrIndex].push_back(packQIE8sample(qiedf->sample(iTS))); + } + } + else { + for(int iTS = 0; iTS < qiedf->size(); iTS +=2 ){ + uint16_t cont =0; + int adc0 = qiedf->sample(iTS).adc(); + int adc1 = qiedf->sample(iTS+1).adc(); + cont |= adc0&0xFF; + cont |= (adc1&0xFF)<<8; + uhtrs[uhtrIndex].push_back(cont); + } }// end loop over dataframe words }; - void addChannel( int uhtrIndex , edm::SortedCollection::const_iterator qiedf , const HcalElectronicsMap* readoutMap, int verbosity = 0 ){ + void addChannel( int uhtrIndex , edm::SortedCollection::const_iterator qiedf , const HcalElectronicsMap* readoutMap, bool premix, int verbosity = 0 ){ if( qiedf->size() == 0 ) return; DetId detid = qiedf->id(); HcalElectronicsId eid(readoutMap->lookup(detid)); - uint16_t header = packQIE8header(qiedf->sample(0), eid); + uint16_t header = packQIE8header(qiedf->sample(0), eid, premix ? 7 : 5); uhtrs[uhtrIndex].push_back(header); // loop over words in dataframe - for(int iTS = 0; iTS < qiedf->size(); iTS +=2 ){ - uint16_t cont =0; - int adc0 = qiedf->sample(iTS).adc(); - int adc1 = qiedf->sample(iTS+1).adc(); - cont |= adc0&0xFF; - cont |= (adc1&0xFF)<<8; - uhtrs[uhtrIndex].push_back(cont); + if(premix){ + for(int iTS = 0; iTS < qiedf->size(); ++iTS){ + uhtrs[uhtrIndex].push_back(packQIE8sample(qiedf->sample(iTS))); + } + } + else { + for(int iTS = 0; iTS < qiedf->size(); iTS +=2 ){ + uint16_t cont =0; + int adc0 = qiedf->sample(iTS).adc(); + int adc1 = qiedf->sample(iTS+1).adc(); + cont |= adc0&0xFF; + cont |= (adc1&0xFF)<<8; + uhtrs[uhtrIndex].push_back(cont); + } }// end loop over dataframe words }; @@ -508,7 +557,7 @@ class UHTRpacker{ DetId detid = qiedf.detid(); HcalElectronicsId eid(readoutMap->lookup(detid)); // loop over words in dataframe - for(edm::DataFrame::iterator dfi=qiedf.begin() ; dfi!=qiedf.end(); ++dfi){ + for(edm::DataFrame::iterator dfi=qiedf.begin() ; dfi!=qiedf.end(); ++dfi){ if( dfi >= qiedf.end()-QIE11DataFrame::FLAG_WORDS ){ continue; } diff --git a/EventFilter/HcalRawToDigi/src/HcalUHTRData.cc b/EventFilter/HcalRawToDigi/src/HcalUHTRData.cc index 48424751e16b9..f8fadd0500df7 100644 --- a/EventFilter/HcalRawToDigi/src/HcalUHTRData.cc +++ b/EventFilter/HcalRawToDigi/src/HcalUHTRData.cc @@ -3,7 +3,9 @@ static const int HEADER_LENGTH_16BIT=2*sizeof(uint64_t)/sizeof(uint16_t); -HcalUHTRData::const_iterator::const_iterator(const uint16_t* ptr, const uint16_t* limit) : m_ptr(ptr), m_limit(limit), m_stepclass(0) { +HcalUHTRData::const_iterator::const_iterator(const uint16_t* ptr, const uint16_t* limit) : + m_ptr(ptr), m_limit(limit), m_stepclass(0), m_technicalDataType(0) +{ if (isHeader()) determineMode(); } @@ -33,21 +35,38 @@ void HcalUHTRData::const_iterator::determineMode() { m_stepclass=0; if (m_flavor==5) { m_stepclass=1; m_microstep=0; } else if (m_flavor == 2) { m_stepclass=2; } + if (m_flavor==7) { m_technicalDataType = technicalDataType(); } +} + +int HcalUHTRData::const_iterator::errFlags() const { + if ((m_flavor==7 && m_technicalDataType==15) && !isHeader()) return ((*m_ptr)>>11)&0x1; + else return ((*m_ptr)>>10)&0x3; +} + +bool HcalUHTRData::const_iterator::dataValid() const { + if ((m_flavor==7 && m_technicalDataType==15) && !isHeader()) return ((*m_ptr)>>10)&0x1; + else return !(errFlags()&0x2); +} + +int HcalUHTRData::const_iterator::technicalDataType() const { + if (m_flavor==7) return ((*m_ptr)>>8)&0xF; + else return 0; } uint8_t HcalUHTRData::const_iterator::adc() const { - if (m_flavor==0x5 && m_microstep==0) return ((*m_ptr)>>8)&0x7F; + if (m_flavor==5 && m_microstep==0) return ((*m_ptr)>>8)&0x7F; + else if (m_flavor==7 && m_technicalDataType==15) return (*m_ptr)&0x7F; else return (*m_ptr)&0xFF; } uint8_t HcalUHTRData::const_iterator::le_tdc() const { - if (m_flavor==0x5) return 0x80; + if (m_flavor==5 || (m_flavor==7 && m_technicalDataType==15)) return 0x80; else if (m_flavor == 2) return (m_ptr[1]&0x3F); else return (((*m_ptr)&0x3F00)>>8); } bool HcalUHTRData::const_iterator::soi() const { - if (m_flavor==0x5) return false; + if (m_flavor==5 || (m_flavor==7 && m_technicalDataType==15)) return false; else if (m_flavor == 2) return (m_ptr[0]&0x2000); else return (((*m_ptr)&0x4000)); } @@ -59,6 +78,9 @@ uint8_t HcalUHTRData::const_iterator::te_tdc() const { uint8_t HcalUHTRData::const_iterator::capid() const { if (m_flavor==2) return(m_ptr[1]>>12)&0x3; + else if (m_flavor==7 && m_technicalDataType==15) { + return ((*m_ptr)>>8)&0x3; + } else if (m_flavor == 1 || m_flavor == 0) { // For flavor 0,1 we only get the first capid in the header, and so we need // to count the number of data rows and figure out which cap we want, diff --git a/EventFilter/HcalRawToDigi/src/HcalUnpacker.cc b/EventFilter/HcalRawToDigi/src/HcalUnpacker.cc index 7fedc0199730a..100a4b2fb6b55 100644 --- a/EventFilter/HcalRawToDigi/src/HcalUnpacker.cc +++ b/EventFilter/HcalRawToDigi/src/HcalUnpacker.cc @@ -123,6 +123,7 @@ namespace HcalUnpacker_impl { digi.setReadoutIds(eid); int error_flags=i.errFlags(); int capid0=i.capid0(); + int flavor = i.flavor(); bool isCapRotating=!(error_flags&0x1); bool fiberErr=(error_flags&0x2); @@ -134,19 +135,33 @@ namespace HcalUnpacker_impl { // what is my sample number? int ncurr=0,ntaken=0; - for (++i; i!=iend && !i.isHeader(); ++i) { - int capidn=(isCapRotating)?((capid0+ncurr)%4):(capid0); + if(flavor==5){ + for (++i; i!=iend && !i.isHeader(); ++i) { + int capidn=(isCapRotating)?((capid0+ncurr)%4):(capid0); - HcalQIESample s(i.adc(),capidn,fiber,fiberchan,dataValid,fiberErr); + HcalQIESample s(i.adc(),capidn,fiber,fiberchan,dataValid,fiberErr); - if (ncurr>=startSample && ncurr<=endSample) { - digi.setSample(ntaken,s); - ++ntaken; + if (ncurr>=startSample && ncurr<=endSample) { + digi.setSample(ntaken,s); + ++ntaken; + } + ncurr++; } - ncurr++; + digi.setSize(ntaken); + } + else if(flavor==7){ //similar to VME flavor 6, used for premix in MC + for (++i; i!=iend && !i.isHeader(); ++i) { + if (ncurr>=startSample && ncurr<=endSample) { + HcalQIESample sample(i.adc(),i.capid(),fiber,fiberchan,i.dataValid(),i.errFlags()); + digi.setSample(ntaken,sample); + ++ntaken; + } + ncurr++; + } + digi.setSize(ntaken); } - digi.setSize(ntaken); } + } @@ -705,7 +720,7 @@ void HcalUnpacker::unpackUTCA(const FEDRawData& raw, const HcalElectronicsMap& e #endif } } - else if (i.flavor()==0x5) { // Old-style digis + else if (i.flavor()==5 || (i.flavor()==7 && i.technicalDataType()==15)) { // Old-style digis int ifiber=((i.channelid()>>2)&0x1F); int ichan=(i.channelid()&0x3); HcalElectronicsId eid(crate,slot,ifiber,ichan, false);