diff --git a/DataFormats/HcalDigi/interface/HBHEDataFrame.h b/DataFormats/HcalDigi/interface/HBHEDataFrame.h index c8c2ad54a2957..a558b6c4d0216 100644 --- a/DataFormats/HcalDigi/interface/HBHEDataFrame.h +++ b/DataFormats/HcalDigi/interface/HBHEDataFrame.h @@ -11,97 +11,99 @@ Precision readout digi for HB and HE. */ -class HBHEDataFrame { -public: - typedef HcalDetId key_type; ///< For the sorted collection +namespace io_v1 { + class HBHEDataFrame { + public: + typedef HcalDetId key_type; ///< For the sorted collection - constexpr HBHEDataFrame() : id_(0), size_(0), hcalPresamples_(0) {} - constexpr explicit HBHEDataFrame(const HcalDetId& id) : id_(id), size_(0), hcalPresamples_(0) { - // TODO : test id for HcalBarrel or HcalEndcap - } - - constexpr const HcalDetId& id() const { return id_; } - constexpr const HcalElectronicsId& elecId() const { return electronicsId_; } + constexpr HBHEDataFrame() : id_(0), size_(0), hcalPresamples_(0) {} + constexpr explicit HBHEDataFrame(const HcalDetId& id) : id_(id), size_(0), hcalPresamples_(0) { + // TODO : test id for HcalBarrel or HcalEndcap + } - /// total number of samples in the digi - constexpr int size() const { return size_ & 0xF; } - /// number of samples before the sample from the triggered beam crossing (according to the hardware) - constexpr int presamples() const { return hcalPresamples_ & 0xF; } - /// was ZS MarkAndPass? - constexpr bool zsMarkAndPass() const { return (hcalPresamples_ & 0x10); } - /// was ZS unsuppressed? - constexpr bool zsUnsuppressed() const { return (hcalPresamples_ & 0x20); } - /// zs crossing mask (which sums considered) - constexpr uint32_t zsCrossingMask() const { return (hcalPresamples_ & 0x3FF000) >> 12; } + constexpr const HcalDetId& id() const { return id_; } + constexpr const HcalElectronicsId& elecId() const { return electronicsId_; } - /// access a sample - constexpr HcalQIESample const& operator[](int i) const { return data_[i]; } - /// access a sample - constexpr HcalQIESample const& sample(int i) const { return data_[i]; } + /// total number of samples in the digi + constexpr int size() const { return size_ & 0xF; } + /// number of samples before the sample from the triggered beam crossing (according to the hardware) + constexpr int presamples() const { return hcalPresamples_ & 0xF; } + /// was ZS MarkAndPass? + constexpr bool zsMarkAndPass() const { return (hcalPresamples_ & 0x10); } + /// was ZS unsuppressed? + constexpr bool zsUnsuppressed() const { return (hcalPresamples_ & 0x20); } + /// zs crossing mask (which sums considered) + constexpr uint32_t zsCrossingMask() const { return (hcalPresamples_ & 0x3FF000) >> 12; } - /// offset of bunch number for this channel relative to nominal set in the unpacker (range is +7->-7. -1000 indicates the data is invalid/unavailable) - constexpr int fiberIdleOffset() const { - int val = (hcalPresamples_ & 0xF00) >> 8; - return (val == 0) ? (-1000) : (((val & 0x8) == 0) ? (-(val & 0x7)) : (val & 0x7)); - } + /// access a sample + constexpr HcalQIESample const& operator[](int i) const { return data_[i]; } + /// access a sample + constexpr HcalQIESample const& sample(int i) const { return data_[i]; } - /// validate appropriate DV and ER bits as well as capid rotation for the specified samples (default is all) - constexpr bool validate(int firstSample = 0, int nSamples = 100) const { - int capid = -1; - bool ok = true; - for (int i = 0; ok && i < nSamples && i + firstSample < size_; i++) { - if (data_[i + firstSample].er() || !data_[i + firstSample].dv()) - ok = false; - if (i == 0) - capid = data_[i + firstSample].capid(); - if (capid != data_[i + firstSample].capid()) - ok = false; - capid = (capid + 1) % 4; + /// offset of bunch number for this channel relative to nominal set in the unpacker (range is +7->-7. -1000 indicates the data is invalid/unavailable) + constexpr int fiberIdleOffset() const { + int val = (hcalPresamples_ & 0xF00) >> 8; + return (val == 0) ? (-1000) : (((val & 0x8) == 0) ? (-(val & 0x7)) : (val & 0x7)); } - return ok; - } - constexpr void setSize(int size) { - if (size > MAXSAMPLES) - size_ = MAXSAMPLES; - else if (size <= 0) - size_ = 0; - else - size_ = size; - } - constexpr void setPresamples(int ps) { hcalPresamples_ |= ps & 0xF; } - constexpr void setZSInfo(bool unsuppressed, bool markAndPass, uint32_t crossingMask = 0) { - hcalPresamples_ &= 0x7FC00F0F; // preserve actual presamples and fiber idle offset - if (markAndPass) - hcalPresamples_ |= 0x10; - if (unsuppressed) - hcalPresamples_ |= 0x20; - hcalPresamples_ |= (crossingMask & 0x3FF) << 12; - } - constexpr void setSample(int i, const HcalQIESample& sam) { data_[i] = sam; } - constexpr void setReadoutIds(const HcalElectronicsId& eid) { electronicsId_ = eid; } - constexpr void setFiberIdleOffset(int offset) { - hcalPresamples_ &= 0x7FFFF0FF; - if (offset >= 7) - hcalPresamples_ |= 0xF00; - else if (offset >= 0) - hcalPresamples_ |= (0x800) | (offset << 8); - else if (offset >= -7) - hcalPresamples_ |= ((-offset) << 8); - else - hcalPresamples_ |= 0x700; - } + /// validate appropriate DV and ER bits as well as capid rotation for the specified samples (default is all) + constexpr bool validate(int firstSample = 0, int nSamples = 100) const { + int capid = -1; + bool ok = true; + for (int i = 0; ok && i < nSamples && i + firstSample < size_; i++) { + if (data_[i + firstSample].er() || !data_[i + firstSample].dv()) + ok = false; + if (i == 0) + capid = data_[i + firstSample].capid(); + if (capid != data_[i + firstSample].capid()) + ok = false; + capid = (capid + 1) % 4; + } + return ok; + } - static const int MAXSAMPLES = 10; + constexpr void setSize(int size) { + if (size > MAXSAMPLES) + size_ = MAXSAMPLES; + else if (size <= 0) + size_ = 0; + else + size_ = size; + } + constexpr void setPresamples(int ps) { hcalPresamples_ |= ps & 0xF; } + constexpr void setZSInfo(bool unsuppressed, bool markAndPass, uint32_t crossingMask = 0) { + hcalPresamples_ &= 0x7FC00F0F; // preserve actual presamples and fiber idle offset + if (markAndPass) + hcalPresamples_ |= 0x10; + if (unsuppressed) + hcalPresamples_ |= 0x20; + hcalPresamples_ |= (crossingMask & 0x3FF) << 12; + } + constexpr void setSample(int i, const HcalQIESample& sam) { data_[i] = sam; } + constexpr void setReadoutIds(const HcalElectronicsId& eid) { electronicsId_ = eid; } + constexpr void setFiberIdleOffset(int offset) { + hcalPresamples_ &= 0x7FFFF0FF; + if (offset >= 7) + hcalPresamples_ |= 0xF00; + else if (offset >= 0) + hcalPresamples_ |= (0x800) | (offset << 8); + else if (offset >= -7) + hcalPresamples_ |= ((-offset) << 8); + else + hcalPresamples_ |= 0x700; + } -private: - HcalDetId id_; - HcalElectronicsId electronicsId_; - int size_; - int hcalPresamples_; - HcalQIESample data_[MAXSAMPLES]; -}; + static const int MAXSAMPLES = 10; -std::ostream& operator<<(std::ostream&, const HBHEDataFrame&); + private: + HcalDetId id_; + HcalElectronicsId electronicsId_; + int size_; + int hcalPresamples_; + HcalQIESample data_[MAXSAMPLES]; + }; + std::ostream& operator<<(std::ostream&, const HBHEDataFrame&); +} // namespace io_v1 +using HBHEDataFrame = io_v1::HBHEDataFrame; #endif diff --git a/DataFormats/HcalDigi/interface/HBHEDataFrameFwd.h b/DataFormats/HcalDigi/interface/HBHEDataFrameFwd.h index b35111146c1fb..db119c215b823 100644 --- a/DataFormats/HcalDigi/interface/HBHEDataFrameFwd.h +++ b/DataFormats/HcalDigi/interface/HBHEDataFrameFwd.h @@ -1,6 +1,9 @@ #ifndef DataFormats_HcalDigi_HBHEDataFrameFwd_h #define DataFormats_HcalDigi_HBHEDataFrameFwd_h -class HBHEDataFrame; +namespace io_v1 { + class HBHEDataFrame; +} +using HBHEDataFrame = io_v1::HBHEDataFrame; #endif diff --git a/DataFormats/HcalDigi/interface/HFDataFrame.h b/DataFormats/HcalDigi/interface/HFDataFrame.h index 12157e574b0b7..ea08c3447b8d0 100644 --- a/DataFormats/HcalDigi/interface/HFDataFrame.h +++ b/DataFormats/HcalDigi/interface/HFDataFrame.h @@ -11,97 +11,99 @@ Precision readout digi for HF */ -class HFDataFrame { -public: - typedef HcalDetId key_type; ///< For the sorted collection +namespace io_v1 { + class HFDataFrame { + public: + typedef HcalDetId key_type; ///< For the sorted collection - constexpr HFDataFrame() : id_(0), size_(0), hcalPresamples_(0) {} - constexpr explicit HFDataFrame(const HcalDetId& id) - : id_(id), size_(0), hcalPresamples_(0) { // TODO : test id for HcalForward - } - - constexpr HcalDetId const& id() const { return id_; } - constexpr HcalElectronicsId const& elecId() const { return electronicsId_; } + constexpr HFDataFrame() : id_(0), size_(0), hcalPresamples_(0) {} + constexpr explicit HFDataFrame(const HcalDetId& id) + : id_(id), size_(0), hcalPresamples_(0) { // TODO : test id for HcalForward + } - /// total number of samples in the digi - constexpr int size() const { return size_ & 0xF; } - /// number of samples before the sample from the triggered beam crossing (according to the hardware) - constexpr int presamples() const { return hcalPresamples_ & 0xF; } - /// was ZS MarkAndPass? - constexpr bool zsMarkAndPass() const { return (hcalPresamples_ & 0x10); } - /// was ZS unsuppressed? - constexpr bool zsUnsuppressed() const { return (hcalPresamples_ & 0x20); } - /// zs crossing mask (which sums considered) - constexpr uint32_t zsCrossingMask() const { return (hcalPresamples_ & 0x3FF000) >> 12; } + constexpr HcalDetId const& id() const { return id_; } + constexpr HcalElectronicsId const& elecId() const { return electronicsId_; } - /// access a sample - constexpr HcalQIESample const& operator[](int i) const { return data_[i]; } - /// access a sample - constexpr HcalQIESample const& sample(int i) const { return data_[i]; } + /// total number of samples in the digi + constexpr int size() const { return size_ & 0xF; } + /// number of samples before the sample from the triggered beam crossing (according to the hardware) + constexpr int presamples() const { return hcalPresamples_ & 0xF; } + /// was ZS MarkAndPass? + constexpr bool zsMarkAndPass() const { return (hcalPresamples_ & 0x10); } + /// was ZS unsuppressed? + constexpr bool zsUnsuppressed() const { return (hcalPresamples_ & 0x20); } + /// zs crossing mask (which sums considered) + constexpr uint32_t zsCrossingMask() const { return (hcalPresamples_ & 0x3FF000) >> 12; } - /// offset of bunch number for this channel relative to nominal set in the unpacker (range is +7->-7. -1000 indicates the data is invalid/unavailable) - constexpr int fiberIdleOffset() const { - int val = (hcalPresamples_ & 0xF00) >> 8; - return (val == 0) ? (-1000) : (((val & 0x8) == 0) ? (-(val & 0x7)) : (val & 0x7)); - } + /// access a sample + constexpr HcalQIESample const& operator[](int i) const { return data_[i]; } + /// access a sample + constexpr HcalQIESample const& sample(int i) const { return data_[i]; } - /// validate appropriate DV and ER bits as well as capid rotation for the specified samples (default is all) - constexpr bool validate(int firstSample = 0, int nSamples = 100) const { - int capid = -1; - bool ok = true; - for (int i = 0; ok && i < nSamples && i + firstSample < size_; i++) { - if (data_[i + firstSample].er() || !data_[i + firstSample].dv()) - ok = false; - if (i == 0) - capid = data_[i + firstSample].capid(); - if (capid != data_[i + firstSample].capid()) - ok = false; - capid = (capid + 1) % 4; + /// offset of bunch number for this channel relative to nominal set in the unpacker (range is +7->-7. -1000 indicates the data is invalid/unavailable) + constexpr int fiberIdleOffset() const { + int val = (hcalPresamples_ & 0xF00) >> 8; + return (val == 0) ? (-1000) : (((val & 0x8) == 0) ? (-(val & 0x7)) : (val & 0x7)); } - return ok; - } - constexpr void setSize(int size) { - if (size > MAXSAMPLES) - size_ = MAXSAMPLES; - else if (size <= 0) - size_ = 0; - else - size_ = size; - } - constexpr void setPresamples(int ps) { hcalPresamples_ |= ps & 0xF; } - constexpr void setZSInfo(bool unsuppressed, bool markAndPass, uint32_t crossingMask = 0) { - hcalPresamples_ &= 0x7FC00F0F; // preserve actual presamples and fiber idle offset - if (markAndPass) - hcalPresamples_ |= 0x10; - if (unsuppressed) - hcalPresamples_ |= 0x20; - hcalPresamples_ |= (crossingMask & 0x3FF) << 12; - } - constexpr void setSample(int i, const HcalQIESample& sam) { data_[i] = sam; } - constexpr void setReadoutIds(const HcalElectronicsId& eid) { electronicsId_ = eid; } - constexpr void setFiberIdleOffset(int offset) { - hcalPresamples_ &= 0x7FFFF0FF; - if (offset >= 7) - hcalPresamples_ |= 0xF00; - else if (offset >= 0) - hcalPresamples_ |= (0x800) | (offset << 8); - else if (offset >= -7) - hcalPresamples_ |= ((-offset) << 8); - else - hcalPresamples_ |= 0x700; - } + /// validate appropriate DV and ER bits as well as capid rotation for the specified samples (default is all) + constexpr bool validate(int firstSample = 0, int nSamples = 100) const { + int capid = -1; + bool ok = true; + for (int i = 0; ok && i < nSamples && i + firstSample < size_; i++) { + if (data_[i + firstSample].er() || !data_[i + firstSample].dv()) + ok = false; + if (i == 0) + capid = data_[i + firstSample].capid(); + if (capid != data_[i + firstSample].capid()) + ok = false; + capid = (capid + 1) % 4; + } + return ok; + } - static const int MAXSAMPLES = 10; + constexpr void setSize(int size) { + if (size > MAXSAMPLES) + size_ = MAXSAMPLES; + else if (size <= 0) + size_ = 0; + else + size_ = size; + } + constexpr void setPresamples(int ps) { hcalPresamples_ |= ps & 0xF; } + constexpr void setZSInfo(bool unsuppressed, bool markAndPass, uint32_t crossingMask = 0) { + hcalPresamples_ &= 0x7FC00F0F; // preserve actual presamples and fiber idle offset + if (markAndPass) + hcalPresamples_ |= 0x10; + if (unsuppressed) + hcalPresamples_ |= 0x20; + hcalPresamples_ |= (crossingMask & 0x3FF) << 12; + } + constexpr void setSample(int i, const HcalQIESample& sam) { data_[i] = sam; } + constexpr void setReadoutIds(const HcalElectronicsId& eid) { electronicsId_ = eid; } + constexpr void setFiberIdleOffset(int offset) { + hcalPresamples_ &= 0x7FFFF0FF; + if (offset >= 7) + hcalPresamples_ |= 0xF00; + else if (offset >= 0) + hcalPresamples_ |= (0x800) | (offset << 8); + else if (offset >= -7) + hcalPresamples_ |= ((-offset) << 8); + else + hcalPresamples_ |= 0x700; + } -private: - HcalDetId id_; - HcalElectronicsId electronicsId_; - int size_; - int hcalPresamples_; - HcalQIESample data_[MAXSAMPLES]; -}; + static const int MAXSAMPLES = 10; -std::ostream& operator<<(std::ostream&, const HFDataFrame&); + private: + HcalDetId id_; + HcalElectronicsId electronicsId_; + int size_; + int hcalPresamples_; + HcalQIESample data_[MAXSAMPLES]; + }; + std::ostream& operator<<(std::ostream&, const HFDataFrame&); +} // namespace io_v1 +using HFDataFrame = io_v1::HFDataFrame; #endif diff --git a/DataFormats/HcalDigi/interface/HFDataFrameFwd.h b/DataFormats/HcalDigi/interface/HFDataFrameFwd.h index 0365b03775c87..7e8d4b4ebac04 100644 --- a/DataFormats/HcalDigi/interface/HFDataFrameFwd.h +++ b/DataFormats/HcalDigi/interface/HFDataFrameFwd.h @@ -1,6 +1,8 @@ #ifndef DataFormats_HcalDigi_HFDataFrameFwd_h #define DataFormats_HcalDigi_HFDataFrameFwd_h -class HFDataFrame; - +namespace io_v1 { + class HFDataFrame; +} +using HFDataFrame = io_v1::HFDataFrame; #endif diff --git a/DataFormats/HcalDigi/interface/HODataFrame.h b/DataFormats/HcalDigi/interface/HODataFrame.h index 593b29cced06e..72d94c29850c7 100644 --- a/DataFormats/HcalDigi/interface/HODataFrame.h +++ b/DataFormats/HcalDigi/interface/HODataFrame.h @@ -11,97 +11,99 @@ Precision readout digi for HO */ -class HODataFrame { -public: - typedef HcalDetId key_type; ///< For the sorted collection +namespace io_v1 { + class HODataFrame { + public: + typedef HcalDetId key_type; ///< For the sorted collection - HODataFrame() : id_(0), size_(0), hcalPresamples_(0) {} - explicit constexpr HODataFrame(const HcalDetId& id) - : id_(id), size_(0), hcalPresamples_(0) { // TODO : test id for HcalOuter - } - - constexpr HcalDetId const& id() const { return id_; } - constexpr HcalElectronicsId const& elecId() const { return electronicsId_; } + HODataFrame() : id_(0), size_(0), hcalPresamples_(0) {} + explicit constexpr HODataFrame(const HcalDetId& id) + : id_(id), size_(0), hcalPresamples_(0) { // TODO : test id for HcalOuter + } - /// total number of samples in the digi - constexpr int size() const { return size_ & 0xF; } - /// number of samples before the sample from the triggered beam crossing (according to the hardware) - constexpr int presamples() const { return hcalPresamples_ & 0xF; } - /// was ZS MarkAndPass? - constexpr bool zsMarkAndPass() const { return (hcalPresamples_ & 0x10); } - /// was ZS unsuppressed? - constexpr bool zsUnsuppressed() const { return (hcalPresamples_ & 0x20); } - /// zs crossing mask (which sums considered) - constexpr uint32_t zsCrossingMask() const { return (hcalPresamples_ & 0x3FF000) >> 12; } + constexpr HcalDetId const& id() const { return id_; } + constexpr HcalElectronicsId const& elecId() const { return electronicsId_; } - /// access a sample - constexpr const HcalQIESample& operator[](int i) const { return data_[i]; } - /// access a sample - constexpr const HcalQIESample& sample(int i) const { return data_[i]; } + /// total number of samples in the digi + constexpr int size() const { return size_ & 0xF; } + /// number of samples before the sample from the triggered beam crossing (according to the hardware) + constexpr int presamples() const { return hcalPresamples_ & 0xF; } + /// was ZS MarkAndPass? + constexpr bool zsMarkAndPass() const { return (hcalPresamples_ & 0x10); } + /// was ZS unsuppressed? + constexpr bool zsUnsuppressed() const { return (hcalPresamples_ & 0x20); } + /// zs crossing mask (which sums considered) + constexpr uint32_t zsCrossingMask() const { return (hcalPresamples_ & 0x3FF000) >> 12; } - /// offset of bunch number for this channel relative to nominal set in the unpacker (range is +7->-7. -1000 indicates the data is invalid/unavailable) - constexpr int fiberIdleOffset() const { - int val = (hcalPresamples_ & 0xF00) >> 8; - return (val == 0) ? (-1000) : (((val & 0x8) == 0) ? (-(val & 0x7)) : (val & 0x7)); - } + /// access a sample + constexpr const HcalQIESample& operator[](int i) const { return data_[i]; } + /// access a sample + constexpr const HcalQIESample& sample(int i) const { return data_[i]; } - /// validate appropriate DV and ER bits as well as capid rotation for the specified samples (default is all) - constexpr bool validate(int firstSample = 0, int nSamples = 100) const { - int capid = -1; - bool ok = true; - for (int i = 0; ok && i < nSamples && i + firstSample < size_; i++) { - if (data_[i + firstSample].er() || !data_[i + firstSample].dv()) - ok = false; - if (i == 0) - capid = data_[i + firstSample].capid(); - if (capid != data_[i + firstSample].capid()) - ok = false; - capid = (capid + 1) % 4; + /// offset of bunch number for this channel relative to nominal set in the unpacker (range is +7->-7. -1000 indicates the data is invalid/unavailable) + constexpr int fiberIdleOffset() const { + int val = (hcalPresamples_ & 0xF00) >> 8; + return (val == 0) ? (-1000) : (((val & 0x8) == 0) ? (-(val & 0x7)) : (val & 0x7)); } - return ok; - } - constexpr void setSize(int size) { - if (size > MAXSAMPLES) - size_ = MAXSAMPLES; - else if (size <= 0) - size_ = 0; - else - size_ = size; - } - constexpr void setPresamples(int ps) { hcalPresamples_ |= ps & 0xF; } - constexpr void setZSInfo(bool unsuppressed, bool markAndPass, uint32_t crossingMask = 0) { - hcalPresamples_ &= 0x7FC00F0F; // preserve actual presamples and fiber idle offset - if (markAndPass) - hcalPresamples_ |= 0x10; - if (unsuppressed) - hcalPresamples_ |= 0x20; - hcalPresamples_ |= (crossingMask & 0x3FF) << 12; - } - constexpr void setSample(int i, const HcalQIESample& sam) { data_[i] = sam; } - constexpr void setReadoutIds(const HcalElectronicsId& eid) { electronicsId_ = eid; } - constexpr void setFiberIdleOffset(int offset) { - hcalPresamples_ &= 0xFFFF0FF; - if (offset >= 7) - hcalPresamples_ |= 0xF00; - else if (offset >= 0) - hcalPresamples_ |= (0x800) | (offset << 8); - else if (offset >= -7) - hcalPresamples_ |= ((-offset) << 8); - else - hcalPresamples_ |= 0x700; - } + /// validate appropriate DV and ER bits as well as capid rotation for the specified samples (default is all) + constexpr bool validate(int firstSample = 0, int nSamples = 100) const { + int capid = -1; + bool ok = true; + for (int i = 0; ok && i < nSamples && i + firstSample < size_; i++) { + if (data_[i + firstSample].er() || !data_[i + firstSample].dv()) + ok = false; + if (i == 0) + capid = data_[i + firstSample].capid(); + if (capid != data_[i + firstSample].capid()) + ok = false; + capid = (capid + 1) % 4; + } + return ok; + } - static const int MAXSAMPLES = 10; + constexpr void setSize(int size) { + if (size > MAXSAMPLES) + size_ = MAXSAMPLES; + else if (size <= 0) + size_ = 0; + else + size_ = size; + } + constexpr void setPresamples(int ps) { hcalPresamples_ |= ps & 0xF; } + constexpr void setZSInfo(bool unsuppressed, bool markAndPass, uint32_t crossingMask = 0) { + hcalPresamples_ &= 0x7FC00F0F; // preserve actual presamples and fiber idle offset + if (markAndPass) + hcalPresamples_ |= 0x10; + if (unsuppressed) + hcalPresamples_ |= 0x20; + hcalPresamples_ |= (crossingMask & 0x3FF) << 12; + } + constexpr void setSample(int i, const HcalQIESample& sam) { data_[i] = sam; } + constexpr void setReadoutIds(const HcalElectronicsId& eid) { electronicsId_ = eid; } + constexpr void setFiberIdleOffset(int offset) { + hcalPresamples_ &= 0xFFFF0FF; + if (offset >= 7) + hcalPresamples_ |= 0xF00; + else if (offset >= 0) + hcalPresamples_ |= (0x800) | (offset << 8); + else if (offset >= -7) + hcalPresamples_ |= ((-offset) << 8); + else + hcalPresamples_ |= 0x700; + } -private: - HcalDetId id_; - HcalElectronicsId electronicsId_; - int size_; - int hcalPresamples_; - HcalQIESample data_[MAXSAMPLES]; -}; + static const int MAXSAMPLES = 10; -std::ostream& operator<<(std::ostream&, const HODataFrame&); + private: + HcalDetId id_; + HcalElectronicsId electronicsId_; + int size_; + int hcalPresamples_; + HcalQIESample data_[MAXSAMPLES]; + }; + std::ostream& operator<<(std::ostream&, const HODataFrame&); +} // namespace io_v1 +using HODataFrame = io_v1::HODataFrame; #endif diff --git a/DataFormats/HcalDigi/interface/HODataFrameFwd.h b/DataFormats/HcalDigi/interface/HODataFrameFwd.h index e037c8db34a86..d58d7a29f75c6 100644 --- a/DataFormats/HcalDigi/interface/HODataFrameFwd.h +++ b/DataFormats/HcalDigi/interface/HODataFrameFwd.h @@ -1,6 +1,8 @@ #ifndef DataFormats_HcalDigi_HODataFrameFwd_h #define DataFormats_HcalDigi_HODataFrameFwd_h -class HODataFrame; - +namespace io_v1 { + class HODataFrame; +} +using HODataFrame = io_v1::HODataFrame; #endif diff --git a/DataFormats/HcalDigi/interface/HcalTriggerPrimitiveDigi.h b/DataFormats/HcalDigi/interface/HcalTriggerPrimitiveDigi.h index d667a12fa4f8a..d394796bf7fb5 100644 --- a/DataFormats/HcalDigi/interface/HcalTriggerPrimitiveDigi.h +++ b/DataFormats/HcalDigi/interface/HcalTriggerPrimitiveDigi.h @@ -10,47 +10,49 @@ \author J. Mans - Minnesota */ -class HcalTriggerPrimitiveDigi { -public: - typedef HcalTrigTowerDetId key_type; ///< For the sorted collection - - HcalTriggerPrimitiveDigi(); // for persistence - explicit HcalTriggerPrimitiveDigi(const HcalTrigTowerDetId& id); - - const HcalTrigTowerDetId& id() const { return id_; } - int size() const { return (size_ & 0xF); } - int presamples() const { return hcalPresamples_ & 0xF; } - - /// was ZS MarkAndPass? - bool zsMarkAndPass() const { return (hcalPresamples_ & 0x10); } - /// was ZS unsuppressed? - bool zsUnsuppressed() const { return (hcalPresamples_ & 0x20); } - - void setZSInfo(bool unsuppressed, bool markAndPass); - - const HcalTriggerPrimitiveSample& operator[](int i) const { return data_[i]; } - const HcalTriggerPrimitiveSample& sample(int i) const { return data_[i]; } - - /// Full "Sample of Interest" - const HcalTriggerPrimitiveSample& t0() const { return data_[presamples()]; } - /// Fine-grain bit for the "Sample of Interest" - bool SOI_fineGrain(int i = 0) const { return t0().fineGrain(i); } - /// Compressed ET for the "Sample of Interest" - int SOI_compressedEt() const { return t0().compressedEt(); } - - void setSize(int size); - void setPresamples(int ps); - void setSample(int i, const HcalTriggerPrimitiveSample& sam) { data_[i] = sam; } - - static const int MAXSAMPLES = 10; - -private: - HcalTrigTowerDetId id_; - int size_; - int hcalPresamples_; - HcalTriggerPrimitiveSample data_[MAXSAMPLES]; -}; - -std::ostream& operator<<(std::ostream& s, const HcalTriggerPrimitiveDigi& digi); - +namespace io_v1 { + class HcalTriggerPrimitiveDigi { + public: + typedef HcalTrigTowerDetId key_type; ///< For the sorted collection + + HcalTriggerPrimitiveDigi(); // for persistence + explicit HcalTriggerPrimitiveDigi(const HcalTrigTowerDetId& id); + + const HcalTrigTowerDetId& id() const { return id_; } + int size() const { return (size_ & 0xF); } + int presamples() const { return hcalPresamples_ & 0xF; } + + /// was ZS MarkAndPass? + bool zsMarkAndPass() const { return (hcalPresamples_ & 0x10); } + /// was ZS unsuppressed? + bool zsUnsuppressed() const { return (hcalPresamples_ & 0x20); } + + void setZSInfo(bool unsuppressed, bool markAndPass); + + const HcalTriggerPrimitiveSample& operator[](int i) const { return data_[i]; } + const HcalTriggerPrimitiveSample& sample(int i) const { return data_[i]; } + + /// Full "Sample of Interest" + const HcalTriggerPrimitiveSample& t0() const { return data_[presamples()]; } + /// Fine-grain bit for the "Sample of Interest" + bool SOI_fineGrain(int i = 0) const { return t0().fineGrain(i); } + /// Compressed ET for the "Sample of Interest" + int SOI_compressedEt() const { return t0().compressedEt(); } + + void setSize(int size); + void setPresamples(int ps); + void setSample(int i, const HcalTriggerPrimitiveSample& sam) { data_[i] = sam; } + + static const int MAXSAMPLES = 10; + + private: + HcalTrigTowerDetId id_; + int size_; + int hcalPresamples_; + HcalTriggerPrimitiveSample data_[MAXSAMPLES]; + }; + + std::ostream& operator<<(std::ostream& s, const HcalTriggerPrimitiveDigi& digi); +} // namespace io_v1 +using HcalTriggerPrimitiveDigi = io_v1::HcalTriggerPrimitiveDigi; #endif diff --git a/DataFormats/HcalDigi/interface/HcalUnpackerReport.h b/DataFormats/HcalDigi/interface/HcalUnpackerReport.h index 75a493d0a48de..a689be45b6dd7 100644 --- a/DataFormats/HcalDigi/interface/HcalUnpackerReport.h +++ b/DataFormats/HcalDigi/interface/HcalUnpackerReport.h @@ -11,75 +11,77 @@ * * \author J. Mans - Minnesota */ -class HcalUnpackerReport { -public: - HcalUnpackerReport(); - const std::vector& getFedsUnpacked() const { return FEDsUnpacked_; } - const std::vector& getFedsError() const { return FEDsError_; } - bool errorFree() const; - bool anyValidHCAL() const; - int unmappedDigis() const { return unmappedDigis_; } - int unmappedTPDigis() const { return unmappedTPDigis_; } - int spigotFormatErrors() const { return spigotFormatErrors_; } - int badQualityDigis() const { return badqualityDigis_; } - int totalDigis() const { return totalDigis_; } - int totalTPDigis() const { return totalTPDigis_; } - int totalHOTPDigis() const { return totalHOTPDigis_; } - int emptyEventSpigots() const { return emptyEventSpigots_; } - int OFWSpigots() const { return ofwSpigots_; } - int busySpigots() const { return busySpigots_; } +namespace io_v1 { + class HcalUnpackerReport { + public: + HcalUnpackerReport(); + const std::vector& getFedsUnpacked() const { return FEDsUnpacked_; } + const std::vector& getFedsError() const { return FEDsError_; } + bool errorFree() const; + bool anyValidHCAL() const; + int unmappedDigis() const { return unmappedDigis_; } + int unmappedTPDigis() const { return unmappedTPDigis_; } + int spigotFormatErrors() const { return spigotFormatErrors_; } + int badQualityDigis() const { return badqualityDigis_; } + int totalDigis() const { return totalDigis_; } + int totalTPDigis() const { return totalTPDigis_; } + int totalHOTPDigis() const { return totalHOTPDigis_; } + int emptyEventSpigots() const { return emptyEventSpigots_; } + int OFWSpigots() const { return ofwSpigots_; } + int busySpigots() const { return busySpigots_; } - bool unsuppressedChannels() const { return unsuppressed_; } + bool unsuppressedChannels() const { return unsuppressed_; } - bool hasFedWithCalib() const { return !fedInfo_.empty(); } - HcalCalibrationEventType fedCalibType(uint16_t fed) const; + bool hasFedWithCalib() const { return !fedInfo_.empty(); } + HcalCalibrationEventType fedCalibType(uint16_t fed) const; - void setFedCalibInfo(uint16_t fed, HcalCalibrationEventType ctype); + void setFedCalibInfo(uint16_t fed, HcalCalibrationEventType ctype); - typedef std::vector DetIdVector; - typedef std::vector ElectronicsIdVector; + typedef std::vector DetIdVector; + typedef std::vector ElectronicsIdVector; - DetIdVector::const_iterator bad_quality_begin() const { return badqualityIds_.begin(); } - DetIdVector::const_iterator bad_quality_end() const { return badqualityIds_.end(); } - ElectronicsIdVector::const_iterator unmapped_begin() const { return unmappedIds_.begin(); } - ElectronicsIdVector::const_iterator unmapped_end() const { return unmappedIds_.end(); } + DetIdVector::const_iterator bad_quality_begin() const { return badqualityIds_.begin(); } + DetIdVector::const_iterator bad_quality_end() const { return badqualityIds_.end(); } + ElectronicsIdVector::const_iterator unmapped_begin() const { return unmappedIds_.begin(); } + ElectronicsIdVector::const_iterator unmapped_end() const { return unmappedIds_.end(); } - bool hasReportInfo(const std::string& name) const; - std::string getReportInfo(const std::string& name) const; - std::vector getReportKeys() const; + bool hasReportInfo(const std::string& name) const; + std::string getReportInfo(const std::string& name) const; + std::vector getReportKeys() const; - // setters - void addUnpacked(int fed); - void addError(int fed); - void countDigi(); - void countTPDigi(bool ho = false); - void countUnmappedDigi(); - void countUnmappedTPDigi(); - void countSpigotFormatError(); - void countBadQualityDigi(); - void countEmptyEventSpigot(); - void countOFWSpigot(); - void countBusySpigot(); - void countUnmappedDigi(const HcalElectronicsId& eid); - void countUnmappedTPDigi(const HcalElectronicsId& eid); - void countBadQualityDigi(const DetId& did); - void setUnsuppressed(bool isSup); - void setReportInfo(const std::string& name, const std::string& value); + // setters + void addUnpacked(int fed); + void addError(int fed); + void countDigi(); + void countTPDigi(bool ho = false); + void countUnmappedDigi(); + void countUnmappedTPDigi(); + void countSpigotFormatError(); + void countBadQualityDigi(); + void countEmptyEventSpigot(); + void countOFWSpigot(); + void countBusySpigot(); + void countUnmappedDigi(const HcalElectronicsId& eid); + void countUnmappedTPDigi(const HcalElectronicsId& eid); + void countBadQualityDigi(const DetId& did); + void setUnsuppressed(bool isSup); + void setReportInfo(const std::string& name, const std::string& value); -private: - std::vector FEDsUnpacked_; - std::vector FEDsError_; - int unmappedDigis_, unmappedTPDigis_; - int spigotFormatErrors_, badqualityDigis_; - int totalDigis_, totalTPDigis_, totalHOTPDigis_; - DetIdVector badqualityIds_; - ElectronicsIdVector unmappedIds_; - bool unsuppressed_; + private: + std::vector FEDsUnpacked_; + std::vector FEDsError_; + int unmappedDigis_, unmappedTPDigis_; + int spigotFormatErrors_, badqualityDigis_; + int totalDigis_, totalTPDigis_, totalHOTPDigis_; + DetIdVector badqualityIds_; + ElectronicsIdVector unmappedIds_; + bool unsuppressed_; - std::vector reportInfo_; - std::vector fedInfo_; // first is fed, second is type - - int emptyEventSpigots_, ofwSpigots_, busySpigots_; -}; + std::vector reportInfo_; + std::vector fedInfo_; // first is fed, second is type + int emptyEventSpigots_, ofwSpigots_, busySpigots_; + }; +} // namespace io_v1 +using HcalUnpackerReport = io_v1::HcalUnpackerReport; #endif diff --git a/DataFormats/HcalDigi/interface/QIE10DataFrame.h b/DataFormats/HcalDigi/interface/QIE10DataFrame.h index 15892a9db8aed..dcf4faadafac3 100644 --- a/DataFormats/HcalDigi/interface/QIE10DataFrame.h +++ b/DataFormats/HcalDigi/interface/QIE10DataFrame.h @@ -8,129 +8,137 @@ /** Precision readout digi from QIE10 including TDC information */ -class QIE10DataFrame { -public: - static const int WORDS_PER_SAMPLE = 2; - static const int HEADER_WORDS = 1; - static const int FLAG_WORDS = 1; +namespace io_v1 { + class QIE10DataFrame { + public: + static const int WORDS_PER_SAMPLE = 2; + static const int HEADER_WORDS = 1; + static const int FLAG_WORDS = 1; - constexpr QIE10DataFrame() {} - constexpr QIE10DataFrame(edm::DataFrame const& df) : m_data(df) {} + constexpr QIE10DataFrame() {} + constexpr QIE10DataFrame(edm::DataFrame const& df) : m_data(df) {} - class Sample { - public: - typedef uint32_t wide_type; + class Sample { + public: + typedef uint32_t wide_type; - constexpr Sample(const edm::DataFrame& frame, edm::DataFrame::size_type i) - : word1_(frame[i]), word2_(frame[i + 1]) {} - constexpr Sample(const edm::DataFrame::data_type& word1, const edm::DataFrame::data_type& word2) - : word1_(word1), word2_(word2) {} - explicit Sample(const wide_type wide) : word1_{0}, word2_{0} { - static_assert(sizeof(wide) == 2 * sizeof(word1_), "The wide input type must be able to contain two words"); - const edm::DataFrame::data_type* ptr = reinterpret_cast(&wide); - word1_ = ptr[0]; - word2_ = ptr[1]; - } + constexpr Sample(const edm::DataFrame& frame, edm::DataFrame::size_type i) + : word1_(frame[i]), word2_(frame[i + 1]) {} + constexpr Sample(const edm::DataFrame::data_type& word1, const edm::DataFrame::data_type& word2) + : word1_(word1), word2_(word2) {} + explicit Sample(const wide_type wide) : word1_{0}, word2_{0} { + static_assert(sizeof(wide) == 2 * sizeof(word1_), "The wide input type must be able to contain two words"); + const edm::DataFrame::data_type* ptr = reinterpret_cast(&wide); + word1_ = ptr[0]; + word2_ = ptr[1]; + } - static const int MASK_ADC = 0xFF; - static const int MASK_LE_TDC = 0x3F; - static const int MASK_TE_TDC = 0x1F; - static const int OFFSET_TE_TDC = 6; - static const int MASK_SOI = 0x2000; - static const int MASK_OK = 0x1000; - static const int MASK_CAPID = 0x3; - static const int OFFSET_CAPID = 12; + static const int MASK_ADC = 0xFF; + static const int MASK_LE_TDC = 0x3F; + static const int MASK_TE_TDC = 0x1F; + static const int OFFSET_TE_TDC = 6; + static const int MASK_SOI = 0x2000; + static const int MASK_OK = 0x1000; + static const int MASK_CAPID = 0x3; + static const int OFFSET_CAPID = 12; - constexpr inline int adc() const { return word1_ & MASK_ADC; } - constexpr inline int le_tdc() const { return word2_ & MASK_LE_TDC; } - constexpr inline int te_tdc() const { return (word2_ >> OFFSET_TE_TDC) & MASK_TE_TDC; } - constexpr inline bool ok() const { return word1_ & MASK_OK; } - constexpr inline bool soi() const { return word1_ & MASK_SOI; } - constexpr inline int capid() const { return (word2_ >> OFFSET_CAPID) & MASK_CAPID; } - constexpr inline edm::DataFrame::data_type raw(edm::DataFrame::size_type i) const { - return (i > WORDS_PER_SAMPLE) ? 0 : ((i == 1) ? word2_ : word1_); - } - QIE10DataFrame::Sample::wide_type wideRaw() const { - static_assert(sizeof(QIE10DataFrame::Sample::wide_type) == 2 * sizeof(word1_), - "The wide result type must be able to contain two words"); - wide_type result = 0; - edm::DataFrame::data_type* ptr = reinterpret_cast(&result); - ptr[0] = word1_; - ptr[1] = word2_; - return result; - } + constexpr inline int adc() const { return word1_ & MASK_ADC; } + constexpr inline int le_tdc() const { return word2_ & MASK_LE_TDC; } + constexpr inline int te_tdc() const { return (word2_ >> OFFSET_TE_TDC) & MASK_TE_TDC; } + constexpr inline bool ok() const { return word1_ & MASK_OK; } + constexpr inline bool soi() const { return word1_ & MASK_SOI; } + constexpr inline int capid() const { return (word2_ >> OFFSET_CAPID) & MASK_CAPID; } + constexpr inline edm::DataFrame::data_type raw(edm::DataFrame::size_type i) const { + return (i > WORDS_PER_SAMPLE) ? 0 : ((i == 1) ? word2_ : word1_); + } + QIE10DataFrame::Sample::wide_type wideRaw() const { + static_assert(sizeof(QIE10DataFrame::Sample::wide_type) == 2 * sizeof(word1_), + "The wide result type must be able to contain two words"); + wide_type result = 0; + edm::DataFrame::data_type* ptr = reinterpret_cast(&result); + ptr[0] = word1_; + ptr[1] = word2_; + return result; + } - private: - edm::DataFrame::data_type word1_; - edm::DataFrame::data_type word2_; - }; + private: + edm::DataFrame::data_type word1_; + edm::DataFrame::data_type word2_; + }; - constexpr void copyContent(const QIE10DataFrame& digi) { - for (edm::DataFrame::size_type i = 0; i < size() && i < digi.size(); i++) { - Sample sam = digi[i]; - setSample(i, sam.adc(), sam.le_tdc(), sam.te_tdc(), sam.capid(), sam.soi(), sam.ok()); + constexpr void copyContent(const QIE10DataFrame& digi) { + for (edm::DataFrame::size_type i = 0; i < size() && i < digi.size(); i++) { + Sample sam = digi[i]; + setSample(i, sam.adc(), sam.le_tdc(), sam.te_tdc(), sam.capid(), sam.soi(), sam.ok()); + } } - } - /// Get the detector id - constexpr DetId detid() const { return DetId(m_data.id()); } - constexpr edm::DataFrame::id_type id() const { return m_data.id(); } - /// more accessors - constexpr edm::DataFrame::size_type size() const { return m_data.size(); } - /// iterators - constexpr edm::DataFrame::iterator begin() { return m_data.begin(); } - constexpr edm::DataFrame::iterator end() { return m_data.end(); } - constexpr edm::DataFrame::const_iterator begin() const { return m_data.begin(); } - constexpr edm::DataFrame::const_iterator end() const { return m_data.end(); } - /// total number of samples in the digi - constexpr int samples() const { return (size() - HEADER_WORDS - FLAG_WORDS) / WORDS_PER_SAMPLE; } - /// for backward compatibility - constexpr int presamples() const { - for (int i = 0; i < samples(); i++) { - if ((*this)[i].soi()) - return i; + /// Get the detector id + constexpr DetId detid() const { return DetId(m_data.id()); } + constexpr edm::DataFrame::id_type id() const { return m_data.id(); } + /// more accessors + constexpr edm::DataFrame::size_type size() const { return m_data.size(); } + /// iterators + constexpr edm::DataFrame::iterator begin() { return m_data.begin(); } + constexpr edm::DataFrame::iterator end() { return m_data.end(); } + constexpr edm::DataFrame::const_iterator begin() const { return m_data.begin(); } + constexpr edm::DataFrame::const_iterator end() const { return m_data.end(); } + /// total number of samples in the digi + constexpr int samples() const { return (size() - HEADER_WORDS - FLAG_WORDS) / WORDS_PER_SAMPLE; } + /// for backward compatibility + constexpr int presamples() const { + for (int i = 0; i < samples(); i++) { + if ((*this)[i].soi()) + return i; + } + return -1; } - return -1; - } - /// get the flavor of the frame - static const int OFFSET_FLAVOR = 12; - static const int MASK_FLAVOR = 0x7; - constexpr int flavor() const { return ((m_data[0] >> OFFSET_FLAVOR) & MASK_FLAVOR); } - /// was there a link error? - static const int MASK_LINKERROR = 0x800; - constexpr bool linkError() const { return m_data[0] & MASK_LINKERROR; } - /// was this a mark-and-pass ZS event? - static const int MASK_MARKPASS = 0x100; - constexpr bool zsMarkAndPass() const { return m_data[0] & MASK_MARKPASS; } - /// set ZS params - constexpr void setZSInfo(bool markAndPass) { - if (markAndPass) - m_data[0] |= MASK_MARKPASS; - } - /// get the sample - constexpr inline Sample operator[](edm::DataFrame::size_type i) const { - return Sample(m_data, i * WORDS_PER_SAMPLE + HEADER_WORDS); - } - /// set the sample contents - constexpr void setSample( - edm::DataFrame::size_type isample, int adc, int le_tdc, int te_tdc, int capid, bool soi = false, bool ok = true) { - if (isample >= size()) - return; - m_data[isample * WORDS_PER_SAMPLE + HEADER_WORDS] = - (adc & Sample::MASK_ADC) | (soi ? (Sample::MASK_SOI) : (0)) | (ok ? (Sample::MASK_OK) : (0)); - m_data[isample * WORDS_PER_SAMPLE + HEADER_WORDS + 1] = - (le_tdc & Sample::MASK_LE_TDC) | ((te_tdc & Sample::MASK_TE_TDC) << Sample::OFFSET_TE_TDC) | - ((capid & Sample::MASK_CAPID) << Sample::OFFSET_CAPID) | 0x4000; // 0x4000 marks this as second word of a pair - } - /// get the flag word - constexpr uint16_t flags() const { return m_data[size() - 1]; } - /// set the flag word - constexpr void setFlags(uint16_t v) { m_data[size() - 1] = v; } - -private: - edm::DataFrame m_data; -}; + /// get the flavor of the frame + static const int OFFSET_FLAVOR = 12; + static const int MASK_FLAVOR = 0x7; + constexpr int flavor() const { return ((m_data[0] >> OFFSET_FLAVOR) & MASK_FLAVOR); } + /// was there a link error? + static const int MASK_LINKERROR = 0x800; + constexpr bool linkError() const { return m_data[0] & MASK_LINKERROR; } + /// was this a mark-and-pass ZS event? + static const int MASK_MARKPASS = 0x100; + constexpr bool zsMarkAndPass() const { return m_data[0] & MASK_MARKPASS; } + /// set ZS params + constexpr void setZSInfo(bool markAndPass) { + if (markAndPass) + m_data[0] |= MASK_MARKPASS; + } + /// get the sample + constexpr inline Sample operator[](edm::DataFrame::size_type i) const { + return Sample(m_data, i * WORDS_PER_SAMPLE + HEADER_WORDS); + } + /// set the sample contents + constexpr void setSample(edm::DataFrame::size_type isample, + int adc, + int le_tdc, + int te_tdc, + int capid, + bool soi = false, + bool ok = true) { + if (isample >= size()) + return; + m_data[isample * WORDS_PER_SAMPLE + HEADER_WORDS] = + (adc & Sample::MASK_ADC) | (soi ? (Sample::MASK_SOI) : (0)) | (ok ? (Sample::MASK_OK) : (0)); + m_data[isample * WORDS_PER_SAMPLE + HEADER_WORDS + 1] = + (le_tdc & Sample::MASK_LE_TDC) | ((te_tdc & Sample::MASK_TE_TDC) << Sample::OFFSET_TE_TDC) | + ((capid & Sample::MASK_CAPID) << Sample::OFFSET_CAPID) | + 0x4000; // 0x4000 marks this as second word of a pair + } + /// get the flag word + constexpr uint16_t flags() const { return m_data[size() - 1]; } + /// set the flag word + constexpr void setFlags(uint16_t v) { m_data[size() - 1] = v; } -std::ostream& operator<<(std::ostream&, const QIE10DataFrame&); + private: + edm::DataFrame m_data; + }; + std::ostream& operator<<(std::ostream&, const QIE10DataFrame&); +} // namespace io_v1 +using QIE10DataFrame = io_v1::QIE10DataFrame; #endif // DATAFORMATS_HCALDIGI_QIE10DATAFRAME_H diff --git a/DataFormats/HcalDigi/interface/QIE10DataFrameFwd.h b/DataFormats/HcalDigi/interface/QIE10DataFrameFwd.h index 640bdc0683568..a914e5f1b0f30 100644 --- a/DataFormats/HcalDigi/interface/QIE10DataFrameFwd.h +++ b/DataFormats/HcalDigi/interface/QIE10DataFrameFwd.h @@ -1,6 +1,9 @@ #ifndef DataFormats_HcalDigi_QIE10DataFrameFwd_h #define DataFormats_HcalDigi_QIE10DataFrameFwd_h -class QIE10DataFrame; +namespace io_v1 { + class QIE10DataFrame; +} +using QIE10DataFrame = io_v1::QIE10DataFrame; #endif diff --git a/DataFormats/HcalDigi/interface/QIE11DataFrame.h b/DataFormats/HcalDigi/interface/QIE11DataFrame.h index d2433a54f8e32..eabe6771e83cf 100644 --- a/DataFormats/HcalDigi/interface/QIE11DataFrame.h +++ b/DataFormats/HcalDigi/interface/QIE11DataFrame.h @@ -8,136 +8,139 @@ /** Precision readout digi from QIE11 including TDC information */ -class QIE11DataFrame { -public: - static const int WORDS_PER_SAMPLE = 1; - static const int HEADER_WORDS = 1; - static const int FLAG_WORDS = 1; +namespace io_v1 { + class QIE11DataFrame { + public: + static const int WORDS_PER_SAMPLE = 1; + static const int HEADER_WORDS = 1; + static const int FLAG_WORDS = 1; - static const int OFFSET_FLAVOR = 12; - static const int MASK_FLAVOR = 0x7; - static const int FLAVOR_HB = 3; - static const int MASK_LINKERROR = 0x800; + static const int OFFSET_FLAVOR = 12; + static const int MASK_FLAVOR = 0x7; + static const int FLAVOR_HB = 3; + static const int MASK_LINKERROR = 0x800; - constexpr QIE11DataFrame() {} - constexpr QIE11DataFrame(edm::DataFrame const& df) : m_data(df) {} + constexpr QIE11DataFrame() {} + constexpr QIE11DataFrame(edm::DataFrame const& df) : m_data(df) {} - class Sample { - public: - constexpr Sample(const edm::DataFrame& frame, edm::DataFrame::size_type i) : frame_(frame), i_(i) {} - static const int MASK_ADC = 0xFF; - static const int MASK_TDC_HE = 0x3F; - static const int MASK_TDC_HB = 0x3; - static const int OFFSET_TDC = 8; // 8 bits - static const int MASK_SOI = 0x4000; - static const int MASK_LE_HB = 0x2000; - static const int MASK_CAPID = 0x3; - static const int MASK_CAPID_INV_HB = 0xF3FF; - static const int MASK_CAPID_KEEP_HB = 0x0C00; - static const int OFFSET_CAPID_HE = 8; - static const int OFFSET_CAPID_HB = 10; - constexpr int flavor() const { return ((frame_[0] >> OFFSET_FLAVOR) & MASK_FLAVOR); } - constexpr int adc() const { return frame_[i_] & MASK_ADC; } - constexpr int tdc() const { - return (frame_[i_] >> OFFSET_TDC) & ((flavor() == FLAVOR_HB) ? (MASK_TDC_HB) : (MASK_TDC_HE)); - } - constexpr bool soi() const { return frame_[i_] & MASK_SOI; } - constexpr int capid() const { - return (flavor() == FLAVOR_HB) - ? ((frame_[i_] >> OFFSET_CAPID_HB) & MASK_CAPID) - : ((((frame_[0] >> OFFSET_CAPID_HE) & MASK_CAPID) + i_ - HEADER_WORDS) & MASK_CAPID); - } - constexpr bool linkError() const { - return (flavor() == FLAVOR_HB) ? (frame_[i_] & MASK_LE_HB) : (frame_[0] & MASK_LINKERROR); - } + class Sample { + public: + constexpr Sample(const edm::DataFrame& frame, edm::DataFrame::size_type i) : frame_(frame), i_(i) {} + static const int MASK_ADC = 0xFF; + static const int MASK_TDC_HE = 0x3F; + static const int MASK_TDC_HB = 0x3; + static const int OFFSET_TDC = 8; // 8 bits + static const int MASK_SOI = 0x4000; + static const int MASK_LE_HB = 0x2000; + static const int MASK_CAPID = 0x3; + static const int MASK_CAPID_INV_HB = 0xF3FF; + static const int MASK_CAPID_KEEP_HB = 0x0C00; + static const int OFFSET_CAPID_HE = 8; + static const int OFFSET_CAPID_HB = 10; + constexpr int flavor() const { return ((frame_[0] >> OFFSET_FLAVOR) & MASK_FLAVOR); } + constexpr int adc() const { return frame_[i_] & MASK_ADC; } + constexpr int tdc() const { + return (frame_[i_] >> OFFSET_TDC) & ((flavor() == FLAVOR_HB) ? (MASK_TDC_HB) : (MASK_TDC_HE)); + } + constexpr bool soi() const { return frame_[i_] & MASK_SOI; } + constexpr int capid() const { + return (flavor() == FLAVOR_HB) + ? ((frame_[i_] >> OFFSET_CAPID_HB) & MASK_CAPID) + : ((((frame_[0] >> OFFSET_CAPID_HE) & MASK_CAPID) + i_ - HEADER_WORDS) & MASK_CAPID); + } + constexpr bool linkError() const { + return (flavor() == FLAVOR_HB) ? (frame_[i_] & MASK_LE_HB) : (frame_[0] & MASK_LINKERROR); + } - private: - const edm::DataFrame& frame_; - edm::DataFrame::size_type i_; - }; + private: + const edm::DataFrame& frame_; + edm::DataFrame::size_type i_; + }; - constexpr void copyContent(const QIE11DataFrame& digi) { - for (edm::DataFrame::size_type i = 0; i < size() && i < digi.size(); i++) { - Sample sam = digi[i]; - setSample(i, sam.adc(), sam.tdc(), sam.soi()); + constexpr void copyContent(const QIE11DataFrame& digi) { + for (edm::DataFrame::size_type i = 0; i < size() && i < digi.size(); i++) { + Sample sam = digi[i]; + setSample(i, sam.adc(), sam.tdc(), sam.soi()); + } } - } - /// Get the detector id - constexpr DetId detid() const { return DetId(m_data.id()); } - constexpr edm::DataFrame::id_type id() const { return m_data.id(); } - /// more accessors - constexpr edm::DataFrame::size_type size() const { return m_data.size(); } - /// iterators - constexpr edm::DataFrame::iterator begin() { return m_data.begin(); } - constexpr edm::DataFrame::iterator end() { return m_data.end(); } - constexpr edm::DataFrame::const_iterator begin() const { return m_data.begin(); } - constexpr edm::DataFrame::const_iterator end() const { return m_data.end(); } - /// total number of samples in the digi - constexpr int samples() const { return (size() - HEADER_WORDS - FLAG_WORDS) / WORDS_PER_SAMPLE; } - /// for backward compatibility - constexpr int presamples() const { - for (int i = 0; i < samples(); i++) { - if ((*this)[i].soi()) - return i; + /// Get the detector id + constexpr DetId detid() const { return DetId(m_data.id()); } + constexpr edm::DataFrame::id_type id() const { return m_data.id(); } + /// more accessors + constexpr edm::DataFrame::size_type size() const { return m_data.size(); } + /// iterators + constexpr edm::DataFrame::iterator begin() { return m_data.begin(); } + constexpr edm::DataFrame::iterator end() { return m_data.end(); } + constexpr edm::DataFrame::const_iterator begin() const { return m_data.begin(); } + constexpr edm::DataFrame::const_iterator end() const { return m_data.end(); } + /// total number of samples in the digi + constexpr int samples() const { return (size() - HEADER_WORDS - FLAG_WORDS) / WORDS_PER_SAMPLE; } + /// for backward compatibility + constexpr int presamples() const { + for (int i = 0; i < samples(); i++) { + if ((*this)[i].soi()) + return i; + } + return -1; } - return -1; - } - /// get the flavor of the frame - constexpr int flavor() const { return ((m_data[0] >> OFFSET_FLAVOR) & MASK_FLAVOR); } - /// was there a link error? - constexpr bool linkError() const { return m_data[0] & MASK_LINKERROR; } - /// was there a capid rotation error? - static const int MASK_CAPIDERROR = 0x400; - constexpr bool capidError() const { return m_data[0] & MASK_CAPIDERROR; } - /// was this a mark-and-pass ZS event? - constexpr bool zsMarkAndPass() const { return (flavor() == 1); } - /// set ZS params - constexpr void setZSInfo(bool markAndPass) { - if (markAndPass) - m_data[0] |= (markAndPass & MASK_FLAVOR) << OFFSET_FLAVOR; - } - /// get the sample - constexpr inline Sample operator[](edm::DataFrame::size_type i) const { return Sample(m_data, i + HEADER_WORDS); } + /// get the flavor of the frame + constexpr int flavor() const { return ((m_data[0] >> OFFSET_FLAVOR) & MASK_FLAVOR); } + /// was there a link error? + constexpr bool linkError() const { return m_data[0] & MASK_LINKERROR; } + /// was there a capid rotation error? + static const int MASK_CAPIDERROR = 0x400; + constexpr bool capidError() const { return m_data[0] & MASK_CAPIDERROR; } + /// was this a mark-and-pass ZS event? + constexpr bool zsMarkAndPass() const { return (flavor() == 1); } + /// set ZS params + constexpr void setZSInfo(bool markAndPass) { + if (markAndPass) + m_data[0] |= (markAndPass & MASK_FLAVOR) << OFFSET_FLAVOR; + } + /// get the sample + constexpr inline Sample operator[](edm::DataFrame::size_type i) const { return Sample(m_data, i + HEADER_WORDS); } - // set flavor - constexpr void setFlavor(int flavor) { - m_data[0] &= 0x9FFF; // inversion of flavor mask - m_data[0] |= ((flavor & MASK_FLAVOR) << OFFSET_FLAVOR); - } + // set flavor + constexpr void setFlavor(int flavor) { + m_data[0] &= 0x9FFF; // inversion of flavor mask + m_data[0] |= ((flavor & MASK_FLAVOR) << OFFSET_FLAVOR); + } - constexpr void setCapid0(int cap0) { - if (flavor() == FLAVOR_HB) { - for (int i = 0; i < samples(); i++) { - m_data[i + 1] &= Sample::MASK_CAPID_INV_HB; - m_data[i + 1] |= ((cap0 + i) & Sample::MASK_CAPID) << Sample::OFFSET_CAPID_HB; + constexpr void setCapid0(int cap0) { + if (flavor() == FLAVOR_HB) { + for (int i = 0; i < samples(); i++) { + m_data[i + 1] &= Sample::MASK_CAPID_INV_HB; + m_data[i + 1] |= ((cap0 + i) & Sample::MASK_CAPID) << Sample::OFFSET_CAPID_HB; + } + } else { + m_data[0] &= 0xFCFF; // inversion of the capid0 mask + m_data[0] |= ((cap0 & Sample::MASK_CAPID) << Sample::OFFSET_CAPID_HE); } - } else { - m_data[0] &= 0xFCFF; // inversion of the capid0 mask - m_data[0] |= ((cap0 & Sample::MASK_CAPID) << Sample::OFFSET_CAPID_HE); } - } - /// set the sample contents - constexpr void setSample(edm::DataFrame::size_type isample, int adc, int tdc, bool soi = false) { - if (isample >= size()) - return; - if (flavor() == FLAVOR_HB) - m_data[isample + 1] = (adc & Sample::MASK_ADC) | (soi ? (Sample::MASK_SOI) : (0)) | - ((tdc & Sample::MASK_TDC_HB) << Sample::OFFSET_TDC) | - (m_data[isample + 1] & Sample::MASK_CAPID_KEEP_HB); - else - m_data[isample + 1] = (adc & Sample::MASK_ADC) | (soi ? (Sample::MASK_SOI) : (0)) | - ((tdc & Sample::MASK_TDC_HE) << Sample::OFFSET_TDC); - } - /// get the flag word - constexpr uint16_t flags() const { return m_data[size() - 1]; } - /// set the flag word - constexpr void setFlags(uint16_t v) { m_data[size() - 1] = v; } + /// set the sample contents + constexpr void setSample(edm::DataFrame::size_type isample, int adc, int tdc, bool soi = false) { + if (isample >= size()) + return; + if (flavor() == FLAVOR_HB) + m_data[isample + 1] = (adc & Sample::MASK_ADC) | (soi ? (Sample::MASK_SOI) : (0)) | + ((tdc & Sample::MASK_TDC_HB) << Sample::OFFSET_TDC) | + (m_data[isample + 1] & Sample::MASK_CAPID_KEEP_HB); + else + m_data[isample + 1] = (adc & Sample::MASK_ADC) | (soi ? (Sample::MASK_SOI) : (0)) | + ((tdc & Sample::MASK_TDC_HE) << Sample::OFFSET_TDC); + } + /// get the flag word + constexpr uint16_t flags() const { return m_data[size() - 1]; } + /// set the flag word + constexpr void setFlags(uint16_t v) { m_data[size() - 1] = v; } -private: - edm::DataFrame m_data; -}; + private: + edm::DataFrame m_data; + }; -std::ostream& operator<<(std::ostream&, const QIE11DataFrame&); + std::ostream& operator<<(std::ostream&, const QIE11DataFrame&); +} // namespace io_v1 +using QIE11DataFrame = io_v1::QIE11DataFrame; #endif // DATAFORMATS_HCALDIGI_QIE11DATAFRAME_H diff --git a/DataFormats/HcalDigi/interface/QIE11DataFrameFwd.h b/DataFormats/HcalDigi/interface/QIE11DataFrameFwd.h index a67df2c7bc4dc..1b33b0f3b42ea 100644 --- a/DataFormats/HcalDigi/interface/QIE11DataFrameFwd.h +++ b/DataFormats/HcalDigi/interface/QIE11DataFrameFwd.h @@ -1,6 +1,8 @@ #ifndef DataFormats_HcalDigi_QIE11DataFrameFwd_h #define DataFormats_HcalDigi_QIE11DataFrameFwd_h -class QIE11DataFrame; - +namespace io_v1 { + class QIE11DataFrame; +} +using QIE11DataFrame = io_v1::QIE11DataFrame; #endif diff --git a/DataFormats/HcalDigi/interface/ZDCDataFrame.h b/DataFormats/HcalDigi/interface/ZDCDataFrame.h index 238bc3027b344..4d156d117ff3a 100644 --- a/DataFormats/HcalDigi/interface/ZDCDataFrame.h +++ b/DataFormats/HcalDigi/interface/ZDCDataFrame.h @@ -12,55 +12,57 @@ Precision readout digi for ZDC */ -class ZDCDataFrame { -public: - typedef HcalZDCDetId key_type; ///< For the sorted collection +namespace io_v1 { + class ZDCDataFrame { + public: + typedef HcalZDCDetId key_type; ///< For the sorted collection - ZDCDataFrame(); // for persistence - explicit ZDCDataFrame(const HcalZDCDetId& id); + ZDCDataFrame(); // for persistence + explicit ZDCDataFrame(const HcalZDCDetId& id); - const HcalZDCDetId& id() const { return id_; } - const HcalElectronicsId& elecId() const { return electronicsId_; } + const HcalZDCDetId& id() const { return id_; } + const HcalElectronicsId& elecId() const { return electronicsId_; } - /// total number of samples in the digi - int size() const { return size_ & 0xF; } - /// number of samples before the sample from the triggered beam crossing (according to the hardware) - int presamples() const { return hcalPresamples_ & 0xF; } - /// was ZS MarkAndPass? - bool zsMarkAndPass() const { return (hcalPresamples_ & 0x10); } - /// was ZS unsuppressed? - bool zsUnsuppressed() const { return (hcalPresamples_ & 0x20); } - /// zs crossing mask (which sums considered) - uint32_t zsCrossingMask() const { return (hcalPresamples_ & 0x3FF000) >> 12; } + /// total number of samples in the digi + int size() const { return size_ & 0xF; } + /// number of samples before the sample from the triggered beam crossing (according to the hardware) + int presamples() const { return hcalPresamples_ & 0xF; } + /// was ZS MarkAndPass? + bool zsMarkAndPass() const { return (hcalPresamples_ & 0x10); } + /// was ZS unsuppressed? + bool zsUnsuppressed() const { return (hcalPresamples_ & 0x20); } + /// zs crossing mask (which sums considered) + uint32_t zsCrossingMask() const { return (hcalPresamples_ & 0x3FF000) >> 12; } - /// access a sample - const HcalQIESample& operator[](int i) const { return data_[i]; } - /// access a sample - const HcalQIESample& sample(int i) const { return data_[i]; } + /// access a sample + const HcalQIESample& operator[](int i) const { return data_[i]; } + /// access a sample + const HcalQIESample& sample(int i) const { return data_[i]; } - /// offset of bunch number for this channel relative to nominal set in the unpacker (range is +7->-7. -1000 indicates the data is invalid/unavailable) - int fiberIdleOffset() const; + /// offset of bunch number for this channel relative to nominal set in the unpacker (range is +7->-7. -1000 indicates the data is invalid/unavailable) + int fiberIdleOffset() const; - /// validate appropriate DV and ER bits as well as capid rotation for the specified samples (default is all) - bool validate(int firstSample = 0, int nSamples = 100) const; + /// validate appropriate DV and ER bits as well as capid rotation for the specified samples (default is all) + bool validate(int firstSample = 0, int nSamples = 100) const; - void setSize(int size); - void setPresamples(int ps); - void setZSInfo(bool unsuppressed, bool markAndPass, uint32_t crossingMask = 0); - void setSample(int i, const HcalQIESample& sam) { data_[i] = sam; } - void setReadoutIds(const HcalElectronicsId& eid); - void setFiberIdleOffset(int offset); + void setSize(int size); + void setPresamples(int ps); + void setZSInfo(bool unsuppressed, bool markAndPass, uint32_t crossingMask = 0); + void setSample(int i, const HcalQIESample& sam) { data_[i] = sam; } + void setReadoutIds(const HcalElectronicsId& eid); + void setFiberIdleOffset(int offset); - static const int MAXSAMPLES = 10; + static const int MAXSAMPLES = 10; -private: - HcalZDCDetId id_; - HcalElectronicsId electronicsId_; - int size_; - int hcalPresamples_; // also contains information about ZS MarkAndPass - HcalQIESample data_[MAXSAMPLES]; -}; - -std::ostream& operator<<(std::ostream&, const ZDCDataFrame&); + private: + HcalZDCDetId id_; + HcalElectronicsId electronicsId_; + int size_; + int hcalPresamples_; // also contains information about ZS MarkAndPass + HcalQIESample data_[MAXSAMPLES]; + }; + std::ostream& operator<<(std::ostream&, const ZDCDataFrame&); +} // namespace io_v1 +using ZDCDataFrame = io_v1::ZDCDataFrame; #endif diff --git a/DataFormats/HcalDigi/interface/ZDCDataFrameFwd.h b/DataFormats/HcalDigi/interface/ZDCDataFrameFwd.h index becff03902464..54be0687601c7 100644 --- a/DataFormats/HcalDigi/interface/ZDCDataFrameFwd.h +++ b/DataFormats/HcalDigi/interface/ZDCDataFrameFwd.h @@ -1,6 +1,9 @@ #ifndef DataFormats_HcalDigi_ZDCDataFrameFwd_h #define DataFormats_HcalDigi_ZDCDataFrameFwd_h -class ZDCDataFrame; +namespace io_v1 { + class ZDCDataFrame; +} +using ZDCDataFrame = io_v1::ZDCDataFrame; #endif diff --git a/DataFormats/HcalDigi/src/HBHEDataFrame.cc b/DataFormats/HcalDigi/src/HBHEDataFrame.cc index 65212819382e4..ce0bbc4b34989 100644 --- a/DataFormats/HcalDigi/src/HBHEDataFrame.cc +++ b/DataFormats/HcalDigi/src/HBHEDataFrame.cc @@ -1,19 +1,20 @@ #include "DataFormats/HcalDigi/interface/HBHEDataFrame.h" - -std::ostream& operator<<(std::ostream& s, const HBHEDataFrame& digi) { - s << digi.id() << " " << digi.size() << " samples " << digi.presamples() << " presamples "; - if (digi.zsUnsuppressed()) - s << " zsUS"; - if (digi.zsMarkAndPass()) - s << " zsM&P"; - if (digi.fiberIdleOffset() != 0) { - if (digi.fiberIdleOffset() == -1000) - s << " nofiberOffset"; - else - s << " fiberOffset=" << digi.fiberIdleOffset(); +namespace io_v1 { + std::ostream& operator<<(std::ostream& s, const HBHEDataFrame& digi) { + s << digi.id() << " " << digi.size() << " samples " << digi.presamples() << " presamples "; + if (digi.zsUnsuppressed()) + s << " zsUS"; + if (digi.zsMarkAndPass()) + s << " zsM&P"; + if (digi.fiberIdleOffset() != 0) { + if (digi.fiberIdleOffset() == -1000) + s << " nofiberOffset"; + else + s << " fiberOffset=" << digi.fiberIdleOffset(); + } + s << std::endl; + for (int i = 0; i < digi.size(); i++) + s << " " << digi.sample(i) << std::endl; + return s; } - s << std::endl; - for (int i = 0; i < digi.size(); i++) - s << " " << digi.sample(i) << std::endl; - return s; -} +} // namespace io_v1 diff --git a/DataFormats/HcalDigi/src/HFDataFrame.cc b/DataFormats/HcalDigi/src/HFDataFrame.cc index 696fd706075f9..13645a7007fa1 100644 --- a/DataFormats/HcalDigi/src/HFDataFrame.cc +++ b/DataFormats/HcalDigi/src/HFDataFrame.cc @@ -1,19 +1,20 @@ #include "DataFormats/HcalDigi/interface/HFDataFrame.h" - -std::ostream& operator<<(std::ostream& s, const HFDataFrame& digi) { - s << digi.id() << " " << digi.size() << " samples " << digi.presamples() << " presamples "; - if (digi.zsUnsuppressed()) - s << " zsUS "; - if (digi.zsMarkAndPass()) - s << " zsM&P "; - if (digi.fiberIdleOffset() != 0) { - if (digi.fiberIdleOffset() == -1000) - s << " nofiberOffset"; - else - s << " fiberOffset=" << digi.fiberIdleOffset(); +namespace io_v1 { + std::ostream& operator<<(std::ostream& s, const HFDataFrame& digi) { + s << digi.id() << " " << digi.size() << " samples " << digi.presamples() << " presamples "; + if (digi.zsUnsuppressed()) + s << " zsUS "; + if (digi.zsMarkAndPass()) + s << " zsM&P "; + if (digi.fiberIdleOffset() != 0) { + if (digi.fiberIdleOffset() == -1000) + s << " nofiberOffset"; + else + s << " fiberOffset=" << digi.fiberIdleOffset(); + } + s << std::endl; + for (int i = 0; i < digi.size(); i++) + s << " " << digi.sample(i) << std::endl; + return s; } - s << std::endl; - for (int i = 0; i < digi.size(); i++) - s << " " << digi.sample(i) << std::endl; - return s; -} +} // namespace io_v1 diff --git a/DataFormats/HcalDigi/src/HODataFrame.cc b/DataFormats/HcalDigi/src/HODataFrame.cc index 0a634ca6b1424..37b841b85d8af 100644 --- a/DataFormats/HcalDigi/src/HODataFrame.cc +++ b/DataFormats/HcalDigi/src/HODataFrame.cc @@ -1,19 +1,21 @@ #include "DataFormats/HcalDigi/interface/HODataFrame.h" -std::ostream& operator<<(std::ostream& s, const HODataFrame& digi) { - s << digi.id() << " " << digi.size() << " samples " << digi.presamples() << " presamples "; - if (digi.zsUnsuppressed()) - s << " zsUS "; - if (digi.zsMarkAndPass()) - s << " zsM&P "; - if (digi.fiberIdleOffset() != 0) { - if (digi.fiberIdleOffset() == -1000) - s << " nofiberOffset"; - else - s << " fiberOffset=" << digi.fiberIdleOffset(); +namespace io_v1 { + std::ostream& operator<<(std::ostream& s, const HODataFrame& digi) { + s << digi.id() << " " << digi.size() << " samples " << digi.presamples() << " presamples "; + if (digi.zsUnsuppressed()) + s << " zsUS "; + if (digi.zsMarkAndPass()) + s << " zsM&P "; + if (digi.fiberIdleOffset() != 0) { + if (digi.fiberIdleOffset() == -1000) + s << " nofiberOffset"; + else + s << " fiberOffset=" << digi.fiberIdleOffset(); + } + s << std::endl; + for (int i = 0; i < digi.size(); i++) + s << " " << digi.sample(i) << std::endl; + return s; } - s << std::endl; - for (int i = 0; i < digi.size(); i++) - s << " " << digi.sample(i) << std::endl; - return s; -} +} // namespace io_v1 diff --git a/DataFormats/HcalDigi/src/HcalTriggerPrimitiveDigi.cc b/DataFormats/HcalDigi/src/HcalTriggerPrimitiveDigi.cc index e359075942f02..c8e08e86cc749 100644 --- a/DataFormats/HcalDigi/src/HcalTriggerPrimitiveDigi.cc +++ b/DataFormats/HcalDigi/src/HcalTriggerPrimitiveDigi.cc @@ -1,40 +1,42 @@ #include "DataFormats/HcalDigi/interface/HcalTriggerPrimitiveDigi.h" -HcalTriggerPrimitiveDigi::HcalTriggerPrimitiveDigi() : size_(0), hcalPresamples_(0) {} -HcalTriggerPrimitiveDigi::HcalTriggerPrimitiveDigi(const HcalTrigTowerDetId& id) - : id_(id), size_(0), hcalPresamples_(0) {} +namespace io_v1 { + HcalTriggerPrimitiveDigi::HcalTriggerPrimitiveDigi() : size_(0), hcalPresamples_(0) {} + HcalTriggerPrimitiveDigi::HcalTriggerPrimitiveDigi(const HcalTrigTowerDetId& id) + : id_(id), size_(0), hcalPresamples_(0) {} -void HcalTriggerPrimitiveDigi::setSize(int size) { - if (size < 0) - size_ = 0; - else if (size > MAXSAMPLES) - size_ = MAXSAMPLES; - else - size_ = size; -} -void HcalTriggerPrimitiveDigi::setPresamples(int ps) { - if (ps < 0) - hcalPresamples_ &= 0xFFFFFF0; - // else if (ps>=size_) hcalPresamples_=size_-1; - else - hcalPresamples_ |= ps & 0xF; -} + void HcalTriggerPrimitiveDigi::setSize(int size) { + if (size < 0) + size_ = 0; + else if (size > MAXSAMPLES) + size_ = MAXSAMPLES; + else + size_ = size; + } + void HcalTriggerPrimitiveDigi::setPresamples(int ps) { + if (ps < 0) + hcalPresamples_ &= 0xFFFFFF0; + // else if (ps>=size_) hcalPresamples_=size_-1; + else + hcalPresamples_ |= ps & 0xF; + } -void HcalTriggerPrimitiveDigi::setZSInfo(bool unsuppressed, bool markAndPass) { - if (markAndPass) - hcalPresamples_ |= 0x10; - if (unsuppressed) - hcalPresamples_ |= 0x20; -} + void HcalTriggerPrimitiveDigi::setZSInfo(bool unsuppressed, bool markAndPass) { + if (markAndPass) + hcalPresamples_ |= 0x10; + if (unsuppressed) + hcalPresamples_ |= 0x20; + } -std::ostream& operator<<(std::ostream& s, const HcalTriggerPrimitiveDigi& digi) { - s << digi.id() << " " << digi.size() << " samples " << digi.presamples() << " presamples"; - if (digi.zsUnsuppressed()) - s << " zsUS"; - if (digi.zsMarkAndPass()) - s << " zsM&P"; - s << std::endl; - for (int i = 0; i < digi.size(); i++) - s << " " << digi.sample(i) << std::endl; - return s; -} + std::ostream& operator<<(std::ostream& s, const HcalTriggerPrimitiveDigi& digi) { + s << digi.id() << " " << digi.size() << " samples " << digi.presamples() << " presamples"; + if (digi.zsUnsuppressed()) + s << " zsUS"; + if (digi.zsMarkAndPass()) + s << " zsM&P"; + s << std::endl; + for (int i = 0; i < digi.size(); i++) + s << " " << digi.sample(i) << std::endl; + return s; + } +} // namespace io_v1 diff --git a/DataFormats/HcalDigi/src/QIE10DataFrame.cc b/DataFormats/HcalDigi/src/QIE10DataFrame.cc index 5f61ea2f4fc8c..b8626f93a1072 100644 --- a/DataFormats/HcalDigi/src/QIE10DataFrame.cc +++ b/DataFormats/HcalDigi/src/QIE10DataFrame.cc @@ -1,27 +1,29 @@ #include "DataFormats/HcalDigi/interface/QIE10DataFrame.h" #include "DataFormats/HcalDetId/interface/HcalGenericDetId.h" -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.zsMarkAndPass()) - s << " MaP "; - s << std::endl; - for (int i = 0; i < digi.samples(); i++) { - QIE10DataFrame::Sample sam = digi[i]; - s << " ADC=" << sam.adc() << " TDC(LE)=" << sam.le_tdc() << " TDC(TE)=" << sam.te_tdc() - << " CAPID=" << sam.capid(); - if (sam.soi()) - s << " SOI "; - if (!sam.ok()) - s << " !OK "; +namespace io_v1 { + 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.zsMarkAndPass()) + s << " MaP "; s << std::endl; + for (int i = 0; i < digi.samples(); i++) { + QIE10DataFrame::Sample sam = digi[i]; + s << " ADC=" << sam.adc() << " TDC(LE)=" << sam.le_tdc() << " TDC(TE)=" << sam.te_tdc() + << " CAPID=" << sam.capid(); + if (sam.soi()) + s << " SOI "; + if (!sam.ok()) + s << " !OK "; + s << std::endl; + } + return s; } - return s; -} +} // namespace io_v1 diff --git a/DataFormats/HcalDigi/src/QIE11DataFrame.cc b/DataFormats/HcalDigi/src/QIE11DataFrame.cc index 9e8811ca9a475..8d71033a63dcb 100644 --- a/DataFormats/HcalDigi/src/QIE11DataFrame.cc +++ b/DataFormats/HcalDigi/src/QIE11DataFrame.cc @@ -1,26 +1,28 @@ #include "DataFormats/HcalDigi/interface/QIE11DataFrame.h" #include "DataFormats/HcalDetId/interface/HcalGenericDetId.h" -std::ostream& operator<<(std::ostream& s, const QIE11DataFrame& digi) { - if (digi.detid().det() == DetId::Hcal) { - s << "DetID=" << HcalGenericDetId(digi.detid()) << " flavor=" << digi.flavor(); - } else { - s << "DetId(" << digi.detid().rawId() << ")"; - } - s << " " << digi.samples() << " samples"; - if (digi.linkError()) - s << " LinkError "; - if (digi.capidError()) - s << " CapIdError "; - if (digi.zsMarkAndPass()) - s << " M&P "; - s << std::endl; - for (int i = 0; i < digi.samples(); i++) { - QIE11DataFrame::Sample sam = digi[i]; - s << " ADC=" << sam.adc() << " TDC=" << sam.tdc() << " CAPID=" << sam.capid(); - if (sam.soi()) - s << " SOI "; +namespace io_v1 { + std::ostream& operator<<(std::ostream& s, const QIE11DataFrame& digi) { + if (digi.detid().det() == DetId::Hcal) { + s << "DetID=" << HcalGenericDetId(digi.detid()) << " flavor=" << digi.flavor(); + } else { + s << "DetId(" << digi.detid().rawId() << ")"; + } + s << " " << digi.samples() << " samples"; + if (digi.linkError()) + s << " LinkError "; + if (digi.capidError()) + s << " CapIdError "; + if (digi.zsMarkAndPass()) + s << " M&P "; s << std::endl; + for (int i = 0; i < digi.samples(); i++) { + QIE11DataFrame::Sample sam = digi[i]; + s << " ADC=" << sam.adc() << " TDC=" << sam.tdc() << " CAPID=" << sam.capid(); + if (sam.soi()) + s << " SOI "; + s << std::endl; + } + return s; } - return s; -} +} // namespace io_v1 diff --git a/DataFormats/HcalDigi/src/ZDCDataFrame.cc b/DataFormats/HcalDigi/src/ZDCDataFrame.cc index 9858416d430fd..d460f03c85452 100644 --- a/DataFormats/HcalDigi/src/ZDCDataFrame.cc +++ b/DataFormats/HcalDigi/src/ZDCDataFrame.cc @@ -1,77 +1,79 @@ #include "DataFormats/HcalDigi/interface/ZDCDataFrame.h" -ZDCDataFrame::ZDCDataFrame() : id_(0), size_(0), hcalPresamples_(0) {} +namespace io_v1 { + ZDCDataFrame::ZDCDataFrame() : id_(0), size_(0), hcalPresamples_(0) {} -ZDCDataFrame::ZDCDataFrame(const HcalZDCDetId& id) : id_(id), size_(0), hcalPresamples_(0) { - // TODO : test id for ZDC -} - -void ZDCDataFrame::setSize(int size) { - if (size > MAXSAMPLES) - size_ = MAXSAMPLES; - else if (size <= 0) - size_ = 0; - else - size_ = size; -} -void ZDCDataFrame::setPresamples(int ps) { hcalPresamples_ |= ps & 0xF; } -void ZDCDataFrame::setReadoutIds(const HcalElectronicsId& eid) { electronicsId_ = eid; } + ZDCDataFrame::ZDCDataFrame(const HcalZDCDetId& id) : id_(id), size_(0), hcalPresamples_(0) { + // TODO : test id for ZDC + } -bool ZDCDataFrame::validate(int firstSample, int nSamples) const { - int capid = -1; - bool ok = true; - for (int i = 0; ok && i < nSamples && i + firstSample < size_; i++) { - if (data_[i + firstSample].er() || !data_[i + firstSample].dv()) - ok = false; - if (i == 0) - capid = data_[i + firstSample].capid(); - if (capid != data_[i + firstSample].capid()) - ok = false; - capid = (capid + 1) % 4; + void ZDCDataFrame::setSize(int size) { + if (size > MAXSAMPLES) + size_ = MAXSAMPLES; + else if (size <= 0) + size_ = 0; + else + size_ = size; } - return ok; -} + void ZDCDataFrame::setPresamples(int ps) { hcalPresamples_ |= ps & 0xF; } + void ZDCDataFrame::setReadoutIds(const HcalElectronicsId& eid) { electronicsId_ = eid; } -void ZDCDataFrame::setZSInfo(bool unsuppressed, bool markAndPass, uint32_t crossingMask) { - hcalPresamples_ &= 0x7FC00F0F; // preserve actual presamples and fiber idle offset - if (markAndPass) - hcalPresamples_ |= 0x10; - if (unsuppressed) - hcalPresamples_ |= 0x20; - hcalPresamples_ |= (crossingMask & 0x3FF) << 12; -} + bool ZDCDataFrame::validate(int firstSample, int nSamples) const { + int capid = -1; + bool ok = true; + for (int i = 0; ok && i < nSamples && i + firstSample < size_; i++) { + if (data_[i + firstSample].er() || !data_[i + firstSample].dv()) + ok = false; + if (i == 0) + capid = data_[i + firstSample].capid(); + if (capid != data_[i + firstSample].capid()) + ok = false; + capid = (capid + 1) % 4; + } + return ok; + } -int ZDCDataFrame::fiberIdleOffset() const { - int val = (hcalPresamples_ & 0xF00) >> 8; - return (val == 0) ? (-1000) : (((val & 0x8) == 0) ? (-(val & 0x7)) : (val & 0x7)); -} + void ZDCDataFrame::setZSInfo(bool unsuppressed, bool markAndPass, uint32_t crossingMask) { + hcalPresamples_ &= 0x7FC00F0F; // preserve actual presamples and fiber idle offset + if (markAndPass) + hcalPresamples_ |= 0x10; + if (unsuppressed) + hcalPresamples_ |= 0x20; + hcalPresamples_ |= (crossingMask & 0x3FF) << 12; + } -void ZDCDataFrame::setFiberIdleOffset(int offset) { - hcalPresamples_ &= 0x7FFFF0FF; - if (offset >= 7) - hcalPresamples_ |= 0xF00; - else if (offset >= 0) - hcalPresamples_ |= (0x800) | (offset << 8); - else if (offset >= -7) - hcalPresamples_ |= ((-offset) << 8); - else - hcalPresamples_ |= 0x700; -} + int ZDCDataFrame::fiberIdleOffset() const { + int val = (hcalPresamples_ & 0xF00) >> 8; + return (val == 0) ? (-1000) : (((val & 0x8) == 0) ? (-(val & 0x7)) : (val & 0x7)); + } -std::ostream& operator<<(std::ostream& s, const ZDCDataFrame& digi) { - s << digi.id() << " " << digi.size() << " samples " << digi.presamples() << " presamples "; - if (digi.zsUnsuppressed()) - s << " zsUS "; - if (digi.zsMarkAndPass()) - s << " zsM&P "; - if (digi.fiberIdleOffset() != 0) { - if (digi.fiberIdleOffset() == -1000) - s << " nofiberOffset"; + void ZDCDataFrame::setFiberIdleOffset(int offset) { + hcalPresamples_ &= 0x7FFFF0FF; + if (offset >= 7) + hcalPresamples_ |= 0xF00; + else if (offset >= 0) + hcalPresamples_ |= (0x800) | (offset << 8); + else if (offset >= -7) + hcalPresamples_ |= ((-offset) << 8); else - s << " fiberOffset=" << digi.fiberIdleOffset(); + hcalPresamples_ |= 0x700; + } + + std::ostream& operator<<(std::ostream& s, const ZDCDataFrame& digi) { + s << digi.id() << " " << digi.size() << " samples " << digi.presamples() << " presamples "; + if (digi.zsUnsuppressed()) + s << " zsUS "; + if (digi.zsMarkAndPass()) + s << " zsM&P "; + if (digi.fiberIdleOffset() != 0) { + if (digi.fiberIdleOffset() == -1000) + s << " nofiberOffset"; + else + s << " fiberOffset=" << digi.fiberIdleOffset(); + } + s << std::endl; + for (int i = 0; i < digi.size(); i++) + s << " " << digi.sample(i) << std::endl; + return s; } - s << std::endl; - for (int i = 0; i < digi.size(); i++) - s << " " << digi.sample(i) << std::endl; - return s; -} +} // namespace io_v1 diff --git a/DataFormats/HcalDigi/src/classes_def.xml b/DataFormats/HcalDigi/src/classes_def.xml index aa664b497c3ce..a4a78aaed4895 100644 --- a/DataFormats/HcalDigi/src/classes_def.xml +++ b/DataFormats/HcalDigi/src/classes_def.xml @@ -1,112 +1,108 @@ - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - + + - - + + - - - - - + + - - - + + + - + - + - - - + + + - + - + - - + + - - - + + + - + - + - - - + + + - + - + - - - + + +