diff --git a/CalibFormats/HcalObjects/src/HcalText2DetIdConverter.cc b/CalibFormats/HcalObjects/src/HcalText2DetIdConverter.cc index 5d801b3caba52..c205a46f268c3 100644 --- a/CalibFormats/HcalObjects/src/HcalText2DetIdConverter.cc +++ b/CalibFormats/HcalObjects/src/HcalText2DetIdConverter.cc @@ -94,9 +94,17 @@ bool HcalText2DetIdConverter::init (DetId fId) { } else { flavorName = "HT"; - setField (1, triggerId.ieta()); - setField (2, triggerId.iphi()); - setField (3, 1); + if (triggerId.version() == 0) { + setField (1, triggerId.ieta()); + setField (2, triggerId.iphi()); + setField (3, 1); + } else if (triggerId.version() == 1) { + setField (1, triggerId.ieta()); + setField (2, triggerId.iphi()); + setField (3, 10); // We use the tens digit to indicate version + } else { + // Unknown version + } } } else if (genId.isHcalZDCDetId ()) { @@ -158,7 +166,24 @@ bool HcalText2DetIdConverter::init (const std::string& fFlavor, const std::strin mId = HcalDetId (sub, getField (1), getField (2), getField (3)); } else if (flavorName == "HT") { - mId = HcalTrigTowerDetId (getField (1), getField (2)); + // We use the depth to signal the "version" being used (RCT or 1x1 HF). RCT + // has a 0 in the 10s digit, whereas 1x1 has a 1. The ones digit is still + // used to indicate depth, although in the 1x1 case this must be 0, so we + // set it as such. + const int depth_field = getField(3); + const int ones = depth_field % 10; + const int tens = (depth_field - ones) / 10; + if (tens == 0) { + const int depth = ones; + const int version = 0; + mId = HcalTrigTowerDetId (getField (1), getField (2), depth, version); + } else if (tens == 1) { + const int depth = 0; + const int version = 1; + mId = HcalTrigTowerDetId(getField(1), getField(2), depth, version); + } else { + // Undefined version! + } } else if (flavorName.find ("ZDC_") == 0) { HcalZDCDetId::Section section = flavorName == "ZDC_EM" ? HcalZDCDetId::EM : diff --git a/DQM/HcalMonitorTasks/src/HcalDigiMonitor.cc b/DQM/HcalMonitorTasks/src/HcalDigiMonitor.cc index 0ce4c4a6216d5..b0ead9945059c 100644 --- a/DQM/HcalMonitorTasks/src/HcalDigiMonitor.cc +++ b/DQM/HcalMonitorTasks/src/HcalDigiMonitor.cc @@ -582,6 +582,7 @@ void HcalDigiMonitor::analyze(edm::Event const&e, edm::EventSetup const&s) dccHeader->getSpigotData(spigot, htr, fed.size()); int NTS = htr.getNDD(); //number time slices, in precision channels + if (NTS==0) continue; // no DAQ data in this HTR (fully zero-suppressed) int dccid=dccHeader->getSourceId(); if(dccid==720 && (spigot==12 || spigot==13)) continue; // calibration HTR diff --git a/DataFormats/HcalDetId/interface/HcalTrigTowerDetId.h b/DataFormats/HcalDetId/interface/HcalTrigTowerDetId.h index 5581396fa4a63..0bfcc4f89a9c6 100644 --- a/DataFormats/HcalDetId/interface/HcalTrigTowerDetId.h +++ b/DataFormats/HcalDetId/interface/HcalTrigTowerDetId.h @@ -23,12 +23,17 @@ class HcalTrigTowerDetId : public DetId { /** \brief Constructor from signed ieta, iphi, depth */ HcalTrigTowerDetId(int ieta, int iphi, int depth); + /** \brief Constructor from signed ieta, iphi, depth, version + */ + HcalTrigTowerDetId(int ieta, int iphi, int depth, int version); /** Constructor from a generic cell id */ HcalTrigTowerDetId(const DetId& id); /** Assignment from a generic cell id */ HcalTrigTowerDetId& operator=(const DetId& id); + void setVersion(int version); + /// get the subdetector HcalSubdetector subdet() const { return (HcalSubdetector)(subdetId()); } /// get the z-side of the tower (1/-1) @@ -39,8 +44,10 @@ class HcalTrigTowerDetId : public DetId { int ieta() const { return zside()*ietaAbs(); } /// get the tower iphi int iphi() const { return id_&0x7F; } - /// get the depth (zero for LHC, may be nonzero for SuperCMS) + /// get the depth (zero for LHC Run 1, may be nonzero for later runs) int depth() const { return (id_>>14)&0x7; } + /// get the version code for the trigger tower + int version() const { return (id_>>17)&0x7; } static const HcalTrigTowerDetId Undefined; diff --git a/DataFormats/HcalDetId/src/HcalTrigTowerDetId.cc b/DataFormats/HcalDetId/src/HcalTrigTowerDetId.cc index 1cb9633adb55e..d4ac7e41feac6 100644 --- a/DataFormats/HcalDetId/src/HcalTrigTowerDetId.cc +++ b/DataFormats/HcalDetId/src/HcalTrigTowerDetId.cc @@ -21,6 +21,13 @@ HcalTrigTowerDetId::HcalTrigTowerDetId(int ieta, int iphi, int depth) : DetId(Hc (iphi&0x7F); } +HcalTrigTowerDetId::HcalTrigTowerDetId(int ieta, int iphi, int depth, int version) : DetId(Hcal,HcalTriggerTower) { + id_|=((depth&0x7)<<14) | + ((ieta>0)?(0x2000|(ieta<<7)):((-ieta)<<7)) | + (iphi&0x7F); + id_|=((version&0x7)<<17); +} + HcalTrigTowerDetId::HcalTrigTowerDetId(const DetId& gen) { if (!gen.null() && (gen.det()!=Hcal || gen.subdetId()!=HcalTriggerTower)) { throw cms::Exception("Invalid DetId") << "Cannot initialize HcalTrigTowerDetId from " << std::hex << gen.rawId() << std::dec; @@ -28,6 +35,10 @@ HcalTrigTowerDetId::HcalTrigTowerDetId(const DetId& gen) { id_=gen.rawId(); } +void HcalTrigTowerDetId::setVersion(int version) { + id_|=((version&0x7)<<17); +} + HcalTrigTowerDetId& HcalTrigTowerDetId::operator=(const DetId& gen) { if (!gen.null() && (gen.det()!=Hcal || gen.subdetId()!=HcalTriggerTower)) { throw cms::Exception("Invalid DetId") << "Cannot assign HcalTrigTowerDetId from " << std::hex << gen.rawId() << std::dec; @@ -37,7 +48,7 @@ HcalTrigTowerDetId& HcalTrigTowerDetId::operator=(const DetId& gen) { } std::ostream& operator<<(std::ostream& s,const HcalTrigTowerDetId& id) { - s << "(HcalTrigTower " << id.ieta() << ',' << id.iphi(); + s << "(HcalTrigTower v" << id.version() << ": " << id.ieta() << ',' << id.iphi(); if (id.depth()>0) s << ',' << id.depth(); return s << ')'; diff --git a/DataFormats/HcalDigi/interface/HcalDigiCollections.h b/DataFormats/HcalDigi/interface/HcalDigiCollections.h index 02b104194f5b8..217aa4d41ffdb 100644 --- a/DataFormats/HcalDigi/interface/HcalDigiCollections.h +++ b/DataFormats/HcalDigi/interface/HcalDigiCollections.h @@ -15,6 +15,9 @@ #include "DataFormats/HcalDigi/interface/HOTriggerPrimitiveDigi.h" #include "DataFormats/HcalDigi/interface/HcalTTPDigi.h" +#include "DataFormats/HcalDigi/interface/QIE10DataFrame.h" +#include "DataFormats/HcalDigi/interface/QIE11DataFrame.h" + typedef edm::SortedCollection HBHEDigiCollection; typedef edm::SortedCollection HODigiCollection; typedef edm::SortedCollection HFDigiCollection; @@ -29,4 +32,23 @@ typedef edm::SortedCollection CastorTrigPrimDigiColl typedef edm::SortedCollection HOTrigPrimDigiCollection; typedef edm::SortedCollection HcalTTPDigiCollection; +#include "DataFormats/Common/interface/DataFrameContainer.h" + +template +class HcalDataFrameContainer : protected edm::DataFrameContainer { +public: + HcalDataFrameContainer() { } + HcalDataFrameContainer(int nsamples_per_digi) : edm::DataFrameContainer(nsamples_per_digi*Digi::WORDS_PER_SAMPLE+Digi::HEADER_WORDS) { } + + int size() const { return int(edm::DataFrameContainer::size()); } + Digi operator[](size_type i) const { return Digi(edm::DataFrameContainer::operator[](i));} + void addDataFrame(DetId detid, const uint16_t* data) { push_back(detid.rawId(),data); } + int samples() const { return int((stride()-Digi::HEADER_WORDS)/Digi::WORDS_PER_SAMPLE); } + void sort() { edm::DataFrameContainer::sort(); } +}; + +typedef HcalDataFrameContainer QIE10DigiCollection; +typedef HcalDataFrameContainer QIE11DigiCollection; + + #endif diff --git a/DataFormats/HcalDigi/interface/QIE10DataFrame.h b/DataFormats/HcalDigi/interface/QIE10DataFrame.h new file mode 100644 index 0000000000000..d909adc87dd5b --- /dev/null +++ b/DataFormats/HcalDigi/interface/QIE10DataFrame.h @@ -0,0 +1,55 @@ +#ifndef DATAFORMATS_HCALDIGI_QIE10DATAFRAME_H +#define DATAFORMATS_HCALDIGI_QIE10DATAFRAME_H + +#include "DataFormats/HcalDetId/interface/HcalDetId.h" +#include "DataFormats/Common/interface/DataFrame.h" +#include + +/** Precision readout digi from QIE10 including TDC information + + */ +class QIE10DataFrame : protected edm::DataFrame { +public: + + static const int WORDS_PER_SAMPLE = 2; + static const int HEADER_WORDS = 1; + + QIE10DataFrame() { } + QIE10DataFrame(const edm::DataFrameContainer& c, edm::DataFrame::size_type i) : edm::DataFrame(c,i) { } + QIE10DataFrame(edm::DataFrame df) : edm::DataFrame(df) { } + + class Sample { + public: + Sample(const edm::DataFrame& frame, edm::DataFrame::size_type i) : frame_(frame),i_(i) { } + int adc() const { return frame_[i_]&0xFF; } + int le_tdc() const { return frame_[i_+1]&0x3F; } + int te_tdc() const { return (frame_[i_]>>6)&0x1F; } + bool ok() const { return frame_[i_]&0x1000; } + bool soi() const { return frame_[i_]&0x2000; } + int capid() const { return (frame_[i_+1]>>12)&0x3; } + private: + const edm::DataFrame& frame_; + edm::DataFrame::size_type i_; + }; + + /// Get the detector id + DetId detid() const { return DetId(id()); } + /// total number of samples in the digi + int samples() const { return (size()-1)/2; } + /// get the flavor of the frame + int flavor() const { return ((edm::DataFrame::operator[](0)>>12)&0x7); } + /// was there a link error? + bool linkError() const { return edm::DataFrame::operator[](0)&0x800; } + /// was this a mark-and-pass ZS event? + bool wasMarkAndPass() const {return edm::DataFrame::operator[](0)&0x100; } + /// get the sample + inline Sample operator[](edm::DataFrame::size_type i) const { return Sample(*this,i*2+1); } + /// set the sample contents + void setSample(edm::DataFrame::size_type isample, int adc, int le_tdc, int fe_tdc, int capid, bool soi=false, bool ok=true); + +}; + +std::ostream& operator<<(std::ostream&, const QIE10DataFrame&); + + +#endif // DATAFORMATS_HCALDIGI_QIE10DATAFRAME_H diff --git a/DataFormats/HcalDigi/interface/QIE11DataFrame.h b/DataFormats/HcalDigi/interface/QIE11DataFrame.h new file mode 100644 index 0000000000000..31215ea9c91ed --- /dev/null +++ b/DataFormats/HcalDigi/interface/QIE11DataFrame.h @@ -0,0 +1,56 @@ +#ifndef DATAFORMATS_HCALDIGI_QIE11DATAFRAME_H +#define DATAFORMATS_HCALDIGI_QIE11DATAFRAME_H + +#include "DataFormats/HcalDetId/interface/HcalDetId.h" +#include "DataFormats/Common/interface/DataFrame.h" +#include + +/** Precision readout digi from QIE11 including TDC information + + */ +class QIE11DataFrame : protected edm::DataFrame { +public: + + static const int WORDS_PER_SAMPLE = 1; + static const int HEADER_WORDS = 1; + + QIE11DataFrame() { } + QIE11DataFrame(const edm::DataFrameContainer& c, edm::DataFrame::size_type i) : edm::DataFrame(c,i) { } + QIE11DataFrame(edm::DataFrame df) : edm::DataFrame(df) { } + + class Sample { + public: + Sample(const edm::DataFrame& frame, edm::DataFrame::size_type i) : frame_(frame),i_(i) { } + int adc() const { return frame_[i_]&0xFF; } + int tdc() const { return (frame_[i_]>>8)&0x3F; } + bool soi() const { return frame_[i_]&0x4000; } + int capid() const { return ((((frame_[0]>>8)&0x3)+i_)%4); } + private: + const edm::DataFrame& frame_; + edm::DataFrame::size_type i_; + }; + + /// Get the detector id + DetId detid() const { return DetId(id()); } + /// total number of samples in the digi + int samples() const { return (size()-1)/2; } + /// get the flavor of the frame + int flavor() const { return ((edm::DataFrame::operator[](0)>>12)&0x7); } + /// was there a link error? + bool linkError() const { return edm::DataFrame::operator[](0)&0x800; } + /// was there a capid rotation error? + bool capidError() const { return edm::DataFrame::operator[](0)&0x400; } + /// was this a mark-and-pass ZS event? + bool wasMarkAndPass() const {return (flavor()==1); } + /// get the sample + inline Sample operator[](edm::DataFrame::size_type i) const { return Sample(*this,i+1); } + void setCapid0(int cap0); + /// set the sample contents + void setSample(edm::DataFrame::size_type isample, int adc, int tdc, bool soi=false); + +}; + +std::ostream& operator<<(std::ostream&, const QIE11DataFrame&); + + +#endif // DATAFORMATS_HCALDIGI_QIE11DATAFRAME_H diff --git a/DataFormats/HcalDigi/src/QIE10DataFrame.cc b/DataFormats/HcalDigi/src/QIE10DataFrame.cc new file mode 100644 index 0000000000000..6424a6d3aa4cd --- /dev/null +++ b/DataFormats/HcalDigi/src/QIE10DataFrame.cc @@ -0,0 +1,27 @@ +#include "DataFormats/HcalDigi/interface/QIE10DataFrame.h" +#include "DataFormats/HcalDetId/interface/HcalGenericDetId.h" + +void QIE10DataFrame::setSample(edm::DataFrame::size_type isample, int adc, int le_tdc, int fe_tdc, int capid, bool soi, bool ok) { + if (isample>=size()) return; + edm::DataFrame::operator[](isample*2+1)=(adc&0xFF)|(soi?(0x2000):(0))|(ok?(0x1000):(0)); + edm::DataFrame::operator[](isample*2+2)=(le_tdc&0x3F)|((fe_tdc&0x1F)<<6)|((capid&0x3)<<12)|0x4000; +} + +std::ostream& operator<<(std::ostream& s, const QIE10DataFrame& digi) { + if (digi.detid().det()==DetId::Hcal) { + s << HcalGenericDetId(digi.detid()); + } else { + s << "DetId(" << digi.detid().rawId() << ")"; + } + s << " " << digi.samples() << " samples"; + if (digi.linkError()) s << " LinkError "; + if (digi.wasMarkAndPass()) s << " MaP "; + s << std::endl; + for (int i=0; i=size()) return; + edm::DataFrame::operator[](isample+1)=(adc&0xFF)|(soi?(0x4000):(0))|((tdc&0x3F)<<8); +} + +std::ostream& operator<<(std::ostream& s, const QIE11DataFrame& digi) { + if (digi.detid().det()==DetId::Hcal) { + s << HcalGenericDetId(digi.detid()); + } else { + s << "DetId(" << digi.detid().rawId() << ")"; + } + s << " " << digi.samples() << " samples"; + if (digi.linkError()) s << " LinkError "; + if (digi.capidError()) s << " CapIdError "; + if (digi.wasMarkAndPass()) s << " M&P "; + s << std::endl; + for (int i=0; i > anotherHBHE_; edm::Wrapper > anotherHO_; @@ -66,6 +68,8 @@ namespace DataFormats_HcalDigi { edm::Wrapper theTTPw_; edm::Wrapper theUHBHEw_; edm::Wrapper theUHFw_; + edm::Wrapper theQIE10w_; + edm::Wrapper theQIE11w_; }; } diff --git a/DataFormats/HcalDigi/src/classes_def.xml b/DataFormats/HcalDigi/src/classes_def.xml index c6f9614ec67f8..bf33552fb411d 100644 --- a/DataFormats/HcalDigi/src/classes_def.xml +++ b/DataFormats/HcalDigi/src/classes_def.xml @@ -73,6 +73,8 @@ + + @@ -99,6 +101,8 @@ + + diff --git a/DataFormats/HcalDigi/test/HcalDigiDump.cc b/DataFormats/HcalDigi/test/HcalDigiDump.cc index 3b8d2d437aeb9..2af00fe93228e 100644 --- a/DataFormats/HcalDigi/test/HcalDigiDump.cc +++ b/DataFormats/HcalDigi/test/HcalDigiDump.cc @@ -32,6 +32,8 @@ HcalDigiDump::HcalDigiDump(edm::ParameterSet const& conf) { consumesMany(); consumesMany(); consumesMany(); + consumesMany(); + consumesMany(); } void HcalDigiDump::analyze(edm::Event const& e, edm::EventSetup const& c) { @@ -47,12 +49,16 @@ void HcalDigiDump::analyze(edm::Event const& e, edm::EventSetup const& c) { std::vector > hh; std::vector > ttp; std::vector > hup; + std::vector > qie10s; + std::vector > qie11s; try { e.getManyByType(hbhe); std::vector >::iterator i; for (i=hbhe.begin(); i!=hbhe.end(); i++) { const HBHEDigiCollection& c=*(*i); + + cout << "HB/HE Digis: " << i->provenance()->branchName() << endl; for (HBHEDigiCollection::const_iterator j=c.begin(); j!=c.end(); j++) cout << *j << std::endl; @@ -66,6 +72,8 @@ void HcalDigiDump::analyze(edm::Event const& e, edm::EventSetup const& c) { std::vector >::iterator i; for (i=hf.begin(); i!=hf.end(); i++) { const HFDigiCollection& c=*(*i); + + cout << "HF Digis: " << i->provenance()->branchName() << endl; for (HFDigiCollection::const_iterator j=c.begin(); j!=c.end(); j++) cout << *j << std::endl; @@ -79,7 +87,9 @@ void HcalDigiDump::analyze(edm::Event const& e, edm::EventSetup const& c) { std::vector >::iterator i; for (i=ho.begin(); i!=ho.end(); i++) { const HODigiCollection& c=*(*i); - + + cout << "HO Digis: " << i->provenance()->branchName() << endl; + for (HODigiCollection::const_iterator j=c.begin(); j!=c.end(); j++) cout << *j << std::endl; @@ -93,7 +103,9 @@ void HcalDigiDump::analyze(edm::Event const& e, edm::EventSetup const& c) { std::vector >::iterator i; for (i=htp.begin(); i!=htp.end(); i++) { const HcalTrigPrimDigiCollection& c=*(*i); - + + cout << "HcalTrigPrim Digis: " << i->provenance()->branchName() << endl; + for (HcalTrigPrimDigiCollection::const_iterator j=c.begin(); j!=c.end(); j++) cout << *j << std::endl; @@ -107,7 +119,9 @@ void HcalDigiDump::analyze(edm::Event const& e, edm::EventSetup const& c) { std::vector >::iterator i; for (i=hotp.begin(); i!=hotp.end(); i++) { const HOTrigPrimDigiCollection& c=*(*i); - + + cout << "HO TP Digis: " << i->provenance()->branchName() << endl; + for (HOTrigPrimDigiCollection::const_iterator j=c.begin(); j!=c.end(); j++) cout << *j << std::endl; @@ -121,7 +135,9 @@ void HcalDigiDump::analyze(edm::Event const& e, edm::EventSetup const& c) { std::vector >::iterator i; for (i=hc.begin(); i!=hc.end(); i++) { const HcalCalibDigiCollection& c=*(*i); - + + cout << "Calibration Digis: " << i->provenance()->branchName() << endl; + for (HcalCalibDigiCollection::const_iterator j=c.begin(); j!=c.end(); j++) cout << *j << std::endl; } @@ -133,7 +149,9 @@ void HcalDigiDump::analyze(edm::Event const& e, edm::EventSetup const& c) { std::vector >::iterator i; for (i=zdc.begin(); i!=zdc.end(); i++) { const ZDCDigiCollection& c=*(*i); - + + cout << "ZDC Digis: " << i->provenance()->branchName() << endl; + for (ZDCDigiCollection::const_iterator j=c.begin(); j!=c.end(); j++) cout << *j << std::endl; } @@ -145,7 +163,9 @@ void HcalDigiDump::analyze(edm::Event const& e, edm::EventSetup const& c) { std::vector >::iterator i; for (i=castor.begin(); i!=castor.end(); i++) { const CastorDigiCollection& c=*(*i); - + + cout << "Castor Digis: " << i->provenance()->branchName() << endl; + for (CastorDigiCollection::const_iterator j=c.begin(); j!=c.end(); j++) cout << *j << std::endl; } @@ -204,6 +224,29 @@ void HcalDigiDump::analyze(edm::Event const& e, edm::EventSetup const& c) { } catch (...) { } + try { + e.getManyByType(qie10s); + std::vector >::iterator i; + for (i=qie10s.begin(); i!=qie10s.end(); i++) { + const QIE10DigiCollection& c=*(*i); + + for (int j=0; j < c.size(); j++) + cout << c[j] << std::endl; + } + } catch (...) { + } + + try { + e.getManyByType(qie11s); + std::vector >::iterator i; + for (i=qie11s.begin(); i!=qie11s.end(); i++) { + const QIE11DigiCollection& c=*(*i); + + for (int j=0; j < c.size(); j++) + cout << c[j] << std::endl; + } + } catch (...) { + } cout << endl; } diff --git a/EventFilter/HcalRawToDigi/interface/HcalHTRData.h b/EventFilter/HcalRawToDigi/interface/HcalHTRData.h index 0dd26849c9579..b0ee495b0d4ae 100644 --- a/EventFilter/HcalRawToDigi/interface/HcalHTRData.h +++ b/EventFilter/HcalRawToDigi/interface/HcalHTRData.h @@ -100,7 +100,8 @@ class HcalHTRData { do_capid=false); /** \brief pack header and trailer (call _after_ pack)*/ void packHeaderTrailer(int L1Anumber, int bcn, int submodule, int - orbitn, int pipeline, int ndd, int nps, int firmwareRev=0); + orbitn, int pipeline, int ndd, int nps, int firmwareRev=0, + int firmwareFlav=0); /** \brief pack trailer with Mark and Pass bits */ void packUnsuppressed(const bool* mp); diff --git a/EventFilter/HcalRawToDigi/interface/HcalUHTRData.h b/EventFilter/HcalRawToDigi/interface/HcalUHTRData.h index 5bc534df7a782..dc3e8c6947006 100644 --- a/EventFilter/HcalRawToDigi/interface/HcalUHTRData.h +++ b/EventFilter/HcalRawToDigi/interface/HcalUHTRData.h @@ -50,9 +50,11 @@ class HcalUHTRData { uint16_t value() const { return *m_ptr; } uint8_t adc() const; - uint8_t re_tdc() const; - uint8_t fe_tdc() const; + uint8_t le_tdc() const; + uint8_t te_tdc() const; bool soi() const; + uint8_t capid() const; + bool ok() const; uint16_t operator*() const { return *m_ptr; } @@ -61,10 +63,12 @@ class HcalUHTRData { bool operator==(const const_iterator& i) { return m_ptr==i.m_ptr; } bool operator!=(const const_iterator& i) { return m_ptr!=i.m_ptr; } + const uint16_t* raw() const { return m_ptr; } private: void determineMode(); const uint16_t* m_ptr, *m_limit; + const uint16_t* m_header_ptr, *m_0th_data_ptr; int m_microstep; int m_stepclass; int m_flavor; diff --git a/EventFilter/HcalRawToDigi/interface/HcalUnpacker.h b/EventFilter/HcalRawToDigi/interface/HcalUnpacker.h index 1625f5a35f163..dad1833e95e37 100644 --- a/EventFilter/HcalRawToDigi/interface/HcalUnpacker.h +++ b/EventFilter/HcalRawToDigi/interface/HcalUnpacker.h @@ -14,6 +14,7 @@ #include "DataFormats/FEDRawData/interface/FEDRawData.h" #include "CondFormats/HcalObjects/interface/HcalElectronicsMap.h" #include "DataFormats/HcalDigi/interface/HcalTTPDigi.h" +#include "DataFormats/HcalDigi/interface/HcalDigiCollections.h" #include class HcalUnpacker { @@ -29,6 +30,7 @@ class HcalUnpacker { std::vector* tpCont; std::vector* tphoCont; std::vector* ttp; + QIE10DigiCollection* qie10; }; /// for normal data diff --git a/EventFilter/HcalRawToDigi/plugins/HcalRawToDigi.cc b/EventFilter/HcalRawToDigi/plugins/HcalRawToDigi.cc index f562862873fb2..832c574cf31fc 100644 --- a/EventFilter/HcalRawToDigi/plugins/HcalRawToDigi.cc +++ b/EventFilter/HcalRawToDigi/plugins/HcalRawToDigi.cc @@ -53,6 +53,7 @@ HcalRawToDigi::HcalRawToDigi(edm::ParameterSet const& conf): produces(); if (unpackTTP_) produces(); + produces(); memset(&stats_,0,sizeof(stats_)); @@ -172,6 +173,10 @@ void HcalRawToDigi::produce(edm::Event& e, const edm::EventSetup& es) std::auto_ptr ho_prod(new HODigiCollection()); std::auto_ptr htp_prod(new HcalTrigPrimDigiCollection()); std::auto_ptr hotp_prod(new HOTrigPrimDigiCollection()); + if (colls.qie10 == 0) { + colls.qie10 = new QIE10DigiCollection(); + } + std::auto_ptr qie10_prod(colls.qie10); hbhe_prod->swap_contents(hbhe); hf_prod->swap_contents(hf); @@ -198,12 +203,14 @@ void HcalRawToDigi::produce(edm::Event& e, const edm::EventSetup& es) hf_prod->sort(); htp_prod->sort(); hotp_prod->sort(); + qie10_prod->sort(); e.put(hbhe_prod); e.put(ho_prod); e.put(hf_prod); e.put(htp_prod); e.put(hotp_prod); + e.put(qie10_prod); /// calib if (unpackCalib_) { diff --git a/EventFilter/HcalRawToDigi/src/HcalDCCHeader.cc b/EventFilter/HcalRawToDigi/src/HcalDCCHeader.cc index 12b233da53c44..cf4df0ed3a4af 100644 --- a/EventFilter/HcalRawToDigi/src/HcalDCCHeader.cc +++ b/EventFilter/HcalRawToDigi/src/HcalDCCHeader.cc @@ -51,6 +51,8 @@ void HcalDCCHeader::clear() { void HcalDCCHeader::setHeader(int sourceid, int bcn, int l1aN, int orbN) { commondataformat0=0x8|((sourceid&0xFFF)<<8)|((bcn&0xFFF)<<20); commondataformat1=0x50000000u|(l1aN&0xFFFFFF); + commondataformat2=((orbN&0xFFFFFFF)<<4); + commondataformat3=((orbN>>28)&0xF); } void HcalDCCHeader::copySpigotData(unsigned int spigot_id, const HcalHTRData& data, bool valid, unsigned char LRB_error_word) { diff --git a/EventFilter/HcalRawToDigi/src/HcalHTRData.cc b/EventFilter/HcalRawToDigi/src/HcalHTRData.cc index 2f81f9ca20f85..2ee3c99bf4982 100644 --- a/EventFilter/HcalRawToDigi/src/HcalHTRData.cc +++ b/EventFilter/HcalRawToDigi/src/HcalHTRData.cc @@ -235,7 +235,7 @@ void HcalHTRData::pack(unsigned char* daq_lengths, unsigned short* daq_samples, unsigned short* ptr=m_ownData+headerLen; if (tp_samples!=0 && tp_lengths!=0) { for (ichan=0; ichan<24; ichan++) { - unsigned short chanid=((ichan%3)+((ichan/3)<<2))<<11; + unsigned short chanid=((ichan%4)+(((ichan/4)+1)<<2))<<11; for (isample=0; isample>8; if (m_formatVersion==-1) { @@ -297,7 +297,7 @@ void HcalHTRData::packHeaderTrailer(int L1Anumber, int bcn, int submodule, int o m_ownData[4]=((m_formatVersion&0xF)<<12)|(bcn&0xFFF); m_ownData[5]|=((nps&0x1F)<<3)|0x1; m_ownData[6]=((firmwareRev&0x70000)>>3)|(firmwareRev&0x1FFF); - m_ownData[7]=pipeline&0xFF; + m_ownData[7]=(pipeline&0xFF)|((firmwareFlav&0x3F)<<8); m_ownData[m_rawLength-4]&=0x7FF; m_ownData[m_rawLength-4]|=(ndd&0x1F)<<11; } diff --git a/EventFilter/HcalRawToDigi/src/HcalPacker.cc b/EventFilter/HcalRawToDigi/src/HcalPacker.cc index 4fd8eb7ad5747..e85fe9bce6183 100644 --- a/EventFilter/HcalRawToDigi/src/HcalPacker.cc +++ b/EventFilter/HcalRawToDigi/src/HcalPacker.cc @@ -18,7 +18,7 @@ HcalPacker::Collections::Collections() { template int process(const Coll* pt, const DetId& did, unsigned short* buffer, int& presamples,bool& isUS, bool& isMP) { isUS=false; isMP=false; - if (pt==0) return 0; + if (pt==0) { return 0; } int size=0; typename Coll::const_iterator i=pt->find(DetIdClass(did)); if (i!=pt->end()) { @@ -26,31 +26,34 @@ int process(const Coll* pt, const DetId& did, unsigned short* buffer, int& presa isMP=i->zsMarkAndPass(); presamples=i->presamples(); size=i->size(); - for (int j=0; jfind(tid); + bool any_nonzero=false; if (i!=pt->end()) { int presamples=i->presamples(); - int samples=i->size(); + size=i->size(); - for (int j=0; j0) { - if (samples<0) samples=mysamples; + if (samples<0) { samples=mysamples; } else if (samples!=mysamples) { edm::LogError("HCAL") << "Mismatch of samples in a single HTR (unsupported) " << mysamples << " != " << samples; continue; @@ -132,13 +135,15 @@ void HcalPacker::pack(int fedid, int dccnumber, edm::LogError("HCAL") << "Mismatch of presamples in a single HTR (unsupported) " << mypresamples << " != " << presamples; continue; } - for (int ii=0; ii0) { spigots[spigot].pack(&(preclen[0]),&(precdata[0]), @@ -173,6 +188,14 @@ void HcalPacker::pack(int fedid, int dccnumber, int submodule=exampleEId.htrTopBottom()&0x1; submodule|=(exampleEId.htrSlot()&0x1F)<<1; submodule|=(exampleEId.readoutVMECrateId()&0x1f)<<6; + // Samples and Presamples can't be negative, or the HeaderTrailer will + // generate a large large number using them (unsigned int roll over) + if (samples < 0) { + samples = 0; + } + if (presamples < 0) { + presamples = 0; + } spigots[spigot].packHeaderTrailer(nl1a, bcn, submodule, @@ -180,7 +203,8 @@ void HcalPacker::pack(int fedid, int dccnumber, pipeline, samples, presamples, - firmwareRev); + firmwareRev, + 1); // need non-zero falvor if (haveUnsuppressed) { spigots[spigot].packUnsuppressed(channelIsMP); } @@ -203,8 +227,9 @@ void HcalPacker::pack(int fedid, int dccnumber, // pack the HTR data into the FEDRawData block using HcalDCCHeader for (int spigot=0; spigot<15; spigot++) { - if (spigots[spigot].getRawLength()>0) + if (spigots[spigot].getRawLength()>0) { dcc->copySpigotData(spigot,spigots[spigot],true,0); + } } // trailer FEDTrailer fedTrailer(output.data()+(output.size()-8)); diff --git a/EventFilter/HcalRawToDigi/src/HcalUHTRData.cc b/EventFilter/HcalRawToDigi/src/HcalUHTRData.cc index a736fdb145906..e0e3fd02180fd 100644 --- a/EventFilter/HcalRawToDigi/src/HcalUHTRData.cc +++ b/EventFilter/HcalRawToDigi/src/HcalUHTRData.cc @@ -14,9 +14,16 @@ HcalUHTRData::const_iterator& HcalUHTRData::const_iterator::operator++() { if (m_microstep==0) { m_ptr++; m_microstep++; } else { m_microstep--; } } - else if (m_stepclass==2) m_ptr+=2; + else if (m_stepclass==2) { + if (isHeader()) { m_ptr++; } + else { m_ptr+=2; } + } - if (isHeader()) determineMode(); + if (isHeader()) { + determineMode(); + m_header_ptr = m_ptr; + m_0th_data_ptr = m_header_ptr + 1; + } return *this; } @@ -25,7 +32,7 @@ void HcalUHTRData::const_iterator::determineMode() { m_flavor=flavor(); m_stepclass=0; if (m_flavor==5) { m_stepclass=1; m_microstep=0; } - else if ((m_flavor&0x6)==0x2) { m_stepclass=2; } + else if (m_flavor == 2) { m_stepclass=2; } } uint8_t HcalUHTRData::const_iterator::adc() const { @@ -33,23 +40,39 @@ uint8_t HcalUHTRData::const_iterator::adc() const { else return (*m_ptr)&0xFF; } -uint8_t HcalUHTRData::const_iterator::re_tdc() const { +uint8_t HcalUHTRData::const_iterator::le_tdc() const { if (m_flavor==0x5) return 0x80; - else if ((m_flavor&0x6)==0x2) return (m_ptr[1]&0x3F); + 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; - else if ((m_flavor&0x6)==0x2) return (m_ptr[0]&0x2000); + else if (m_flavor == 2) return (m_ptr[0]&0x2000); else return (((*m_ptr)&0x4000)); } -uint8_t HcalUHTRData::const_iterator::fe_tdc() const { - if (m_flavor==0x5 || (m_flavor&0x6)==0x0) return 0x80; - else return ((m_ptr[1]>>6)&0xF); +uint8_t HcalUHTRData::const_iterator::te_tdc() const { + if (m_flavor==2) return(m_ptr[1]>>6)&0x1F; + else return 0x80; } +uint8_t HcalUHTRData::const_iterator::capid() const { + if (m_flavor==2) return(m_ptr[1]>>12)&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, + // knowing that they go 0->1->2->3->0 + return 0; + } + else { return 0; } +} + +bool HcalUHTRData::const_iterator::ok() const { + if (m_flavor == 2) { return (m_ptr[0]>>12)&0x1; } + else if (m_flavor == 4) { return (m_ptr[0]>>13)&0x1; } + else { return false; } +} HcalUHTRData::const_iterator HcalUHTRData::begin() const { return HcalUHTRData::const_iterator(m_raw16+HEADER_LENGTH_16BIT,m_raw16+(m_rawLength64-1)*sizeof(uint64_t)/sizeof(uint16_t)); diff --git a/EventFilter/HcalRawToDigi/src/HcalUnpacker.cc b/EventFilter/HcalRawToDigi/src/HcalUnpacker.cc index 3d16e2b6f734e..c379ae3577157 100644 --- a/EventFilter/HcalRawToDigi/src/HcalUnpacker.cc +++ b/EventFilter/HcalRawToDigi/src/HcalUnpacker.cc @@ -590,7 +590,33 @@ void HcalUnpacker::unpackUTCA(const FEDRawData& raw, const HcalElectronicsMap& e ++i; continue; } - if (i.flavor()==0x5) { // Old-style digis + if (i.flavor() == 2) { + int ifiber=((i.channelid()>>2)&0x1F); + int ichan=(i.channelid()&0x3); + HcalElectronicsId eid(crate,slot,ifiber,ichan, false); + DetId did=emap.lookup(eid); + + // Count from current position to next header, or equal to end + const uint16_t* head_pos = i.raw(); + int ns = 0; + for (++i; i != iend && !i.isHeader(); ++i) { + ns++; + } + + // Check QEI10 container exists + if (colls.qie10 == 0) { + colls.qie10 = new QIE10DigiCollection(ns); + } + else if (colls.qie10->samples() != ns) { + // This is horrible + edm::LogError("Invalid Data") << "Collection has " << colls.qie10->samples() << " samples per digi, raw data has " << ns << "!"; + return; + } + + // Insert data + colls.qie10->addDataFrame(did, head_pos); + } + else if (i.flavor()==0x5) { // Old-style digis int ifiber=((i.channelid()>>2)&0x1F); int ichan=(i.channelid()&0x3); HcalElectronicsId eid(crate,slot,ifiber,ichan, false); @@ -642,7 +668,7 @@ void HcalUnpacker::unpackUTCA(const FEDRawData& raw, const HcalElectronicsMap& e ++i); } } else if (i.flavor()==0x4) { // TP digis - int ilink=((i.channelid()>>4)&0x7); + int ilink=((i.channelid()>>4)&0xF); int itower=(i.channelid()&0xF); HcalElectronicsId eid(crate,slot,ilink,itower,true); DetId did=emap.lookupTrigger(eid); @@ -688,6 +714,7 @@ HcalUnpacker::Collections::Collections() { zdcCont=0; calibCont=0; ttp=0; + qie10=0; } void HcalUnpacker::unpack(const FEDRawData& raw, const HcalElectronicsMap& emap, std::vector& histoDigis) { diff --git a/L1Trigger/RegionalCaloTrigger/src/L1RCT.cc b/L1Trigger/RegionalCaloTrigger/src/L1RCT.cc index c58c92ffd9a41..1bdc9f8bc8e51 100644 --- a/L1Trigger/RegionalCaloTrigger/src/L1RCT.cc +++ b/L1Trigger/RegionalCaloTrigger/src/L1RCT.cc @@ -164,6 +164,9 @@ void L1RCT::digiInput(const EcalTrigPrimDigiCollection& ecalCollection, //if (nHcalDigi != 4176){ std::cout << "L1RCT: Warning: There are " << nHcalDigi << "hcal digis instead of 4176!" << std::endl;} // incl HF 4032 + 144 = 4176 for (int i = 0; i < nHcalDigi; i++){ + if (hcalCollection[i].id().version() != 0) { + continue; + } short ieta = (short) hcalCollection[i].id().ieta(); unsigned short absIeta = (unsigned short) abs(ieta); unsigned short cal_iphi = (unsigned short) hcalCollection[i].id().iphi();