Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:10:57

0001 #ifndef EventFilter_RPCRawToDigi_RPCAMC13Record_icc
0002 #define EventFilter_RPCRawToDigi_RPCAMC13Record_icc
0003 
0004 #include "EventFilter/RPCRawToDigi/interface/RPCAMC13Record.h"
0005 
0006 namespace rpcamc13 {
0007 
0008   inline void Header::set(std::uint64_t const record) { record_ = record; }
0009 
0010   inline void Header::reset() { record_ = 0x0; }
0011 
0012   inline std::uint64_t const& Header::getRecord() const { return record_; }
0013 
0014   inline unsigned int Header::getFirmwareVersion() const { return (record_ & ufov_mask_) >> ufov_offset_; }
0015 
0016   inline unsigned int Header::getNAMC() const { return (record_ & n_amc_mask_) >> n_amc_offset_; }
0017 
0018   inline unsigned int Header::getOrbitCounter() const {
0019     return (record_ & orbit_counter_mask_) >> orbit_counter_offset_;
0020   }
0021 
0022   inline void Header::setFirmwareVersion(unsigned int ufov) {
0023     record_ &= ~ufov_mask_;
0024     record_ |= (((std::uint64_t)(ufov) << ufov_offset_) & ufov_mask_);
0025   }
0026 
0027   inline void Header::setNAMC(unsigned int n_amc) {
0028     record_ &= ~n_amc_mask_;
0029     record_ |= (((std::uint64_t)(n_amc) << n_amc_offset_) & n_amc_mask_);
0030   }
0031 
0032   inline void Header::setOrbitCounter(unsigned int orbit_counter) {
0033     record_ &= ~orbit_counter_mask_;
0034     record_ |= (((std::uint64_t)(orbit_counter) << orbit_counter_offset_) & orbit_counter_mask_);
0035   }
0036 
0037   inline void Trailer::set(std::uint64_t const record) { record_ = record; }
0038 
0039   inline void Trailer::reset() { record_ = 0x0; }
0040 
0041   inline std::uint64_t const& Trailer::getRecord() const { return record_; }
0042 
0043   inline std::uint32_t Trailer::getCRC() const { return (record_ & crc_mask_) >> crc_offset_; }
0044 
0045   inline unsigned int Trailer::getBlockNumber() const { return (record_ & block_number_mask_) >> block_number_offset_; }
0046 
0047   inline unsigned int Trailer::getEventCounter() const {
0048     return (record_ & event_counter_mask_) >> event_counter_offset_;
0049   }
0050 
0051   inline unsigned int Trailer::getBXCounter() const { return (record_ & bx_counter_mask_) >> bx_counter_offset_; }
0052 
0053   inline void Trailer::setCRC(std::uint32_t crc) {
0054     record_ &= ~crc_mask_;
0055     record_ |= (((std::uint64_t)(crc) << crc_offset_) & crc_mask_);
0056   }
0057 
0058   inline void Trailer::setBlockNumber(unsigned int block_number) {
0059     record_ &= ~block_number_mask_;
0060     record_ |= (((std::uint64_t)(block_number) << block_number_offset_) & block_number_mask_);
0061   }
0062 
0063   inline void Trailer::setEventCounter(unsigned int event_counter) {
0064     record_ &= ~event_counter_mask_;
0065     record_ |= (((std::uint64_t)(event_counter) << event_counter_offset_) & event_counter_mask_);
0066   }
0067 
0068   inline void Trailer::setBXCounter(unsigned int bx_counter) {
0069     record_ &= ~bx_counter_mask_;
0070     record_ |= (((std::uint64_t)(bx_counter) << bx_counter_offset_) & bx_counter_mask_);
0071   }
0072 
0073   inline void AMCHeader::set(std::uint64_t const record) { record_ = record; }
0074 
0075   inline void AMCHeader::reset() { record_ = enabled_mask_ | present_mask_ | valid_mask_ | crc_ok_mask_; }
0076 
0077   inline std::uint64_t const& AMCHeader::getRecord() const { return record_; }
0078 
0079   inline bool AMCHeader::isLengthCorrect() const { return ((record_ & length_incorrect_mask_) ? false : true); }
0080 
0081   inline bool AMCHeader::isLastBlock() const { return ((record_ & more_blocks_mask_) ? false : true); }
0082 
0083   inline bool AMCHeader::isFirstBlock() const { return ((record_ & segmented_mask_) ? false : true); }
0084 
0085   inline bool AMCHeader::isEnabled() const { return ((record_ & enabled_mask_) ? true : false); }
0086 
0087   inline bool AMCHeader::isPresent() const { return ((record_ & present_mask_) ? true : false); }
0088 
0089   inline bool AMCHeader::isValid() const { return ((record_ & valid_mask_) ? true : false); }
0090 
0091   inline bool AMCHeader::isCRCOk() const {
0092     if (isLastBlock()) {
0093       return ((record_ & crc_ok_mask_) ? true : false);
0094     }
0095     return true;
0096   }
0097 
0098   inline unsigned int AMCHeader::getSize() const { return (record_ & size_mask_) >> size_offset_; }
0099 
0100   inline unsigned int AMCHeader::getSizeInBlock() const {
0101     unsigned int size(getSize());
0102     if ((record_ & more_blocks_mask_) == more_blocks_mask_) {
0103       return size_max_;
0104     }
0105     return size;
0106   }
0107 
0108   inline bool AMCHeader::hasTotalSize() const {
0109     return ((record_ & segmented_mask_) == 0x0         // first block
0110             && (record_ & size_mask_) != size_mask_);  // and it's set
0111   }
0112 
0113   inline unsigned int AMCHeader::getBlockNumber() const {
0114     return (record_ & block_number_mask_) >> block_number_offset_;
0115   }
0116 
0117   inline unsigned int AMCHeader::getAMCNumber() const { return (record_ & amc_number_mask_) >> amc_number_offset_; }
0118 
0119   inline unsigned int AMCHeader::getBoardId() const { return (record_ & board_id_mask_) >> board_id_offset_; }
0120 
0121   inline void AMCHeader::setLengthCorrect(bool length_correct) {
0122     if (!length_correct)
0123       record_ |= length_incorrect_mask_;
0124     else
0125       record_ &= ~(length_incorrect_mask_);
0126   }
0127 
0128   inline void AMCHeader::setLastBlock(bool last_block) {
0129     if (!last_block)
0130       record_ |= more_blocks_mask_;
0131     else
0132       record_ &= ~(more_blocks_mask_);
0133   }
0134 
0135   inline void AMCHeader::setFirstBlock(bool first_block) {
0136     if (!first_block)
0137       record_ |= segmented_mask_;
0138     else
0139       record_ &= ~(segmented_mask_);
0140   }
0141 
0142   inline void AMCHeader::setEnabled(bool enabled) {
0143     if (enabled)
0144       record_ |= enabled_mask_;
0145     else
0146       record_ &= ~(enabled_mask_);
0147   }
0148 
0149   inline void AMCHeader::setPresent(bool present) {
0150     if (present)
0151       record_ |= present_mask_;
0152     else
0153       record_ &= ~(present_mask_);
0154   }
0155 
0156   inline void AMCHeader::setValid(bool valid) {
0157     if (valid)
0158       record_ |= valid_mask_;
0159     else
0160       record_ &= ~(valid_mask_);
0161   }
0162 
0163   inline void AMCHeader::setCRCOk(bool crc_ok) {
0164     if (crc_ok)
0165       record_ |= crc_ok_mask_;
0166     else
0167       record_ &= ~(crc_ok_mask_);
0168   }
0169 
0170   inline void AMCHeader::setSize(unsigned int size) {
0171     record_ &= ~size_mask_;
0172     record_ |= (((std::uint64_t)(size) << size_offset_) & size_mask_);
0173   }
0174 
0175   inline void AMCHeader::setBlockNumber(unsigned int block_number) {
0176     record_ &= ~block_number_mask_;
0177     record_ |= (((std::uint64_t)(block_number) << block_number_offset_) & block_number_mask_);
0178   }
0179 
0180   inline void AMCHeader::setAMCNumber(unsigned int amc_number) {
0181     record_ &= ~amc_number_mask_;
0182     record_ |= (((std::uint64_t)(amc_number) << amc_number_offset_) & amc_number_mask_);
0183   }
0184 
0185   inline void AMCHeader::setBoardId(unsigned int board_id) {
0186     record_ &= ~board_id_mask_;
0187     record_ |= (((std::uint64_t)(board_id) << board_id_offset_) & board_id_mask_);
0188   }
0189 
0190   inline bool AMCPayload::isValid() const { return valid_; }
0191 
0192   inline AMCHeader const& AMCPayload::getAMCHeader() const { return amc_header_; }
0193 
0194   inline AMCHeader& AMCPayload::getAMCHeader() { return amc_header_; }
0195 
0196   inline std::vector<std::uint64_t> const& AMCPayload::getData() const { return data_; }
0197 
0198   inline std::vector<std::uint64_t>& AMCPayload::getData() { return data_; }
0199 
0200   inline void AMCPayload::setValid(bool valid) { valid_ = valid; }
0201 
0202   inline void AMCPayload::setAMCHeader(AMCHeader const& word) { amc_header_ = word; }
0203 
0204   inline void AMCPayload::insert(std::uint64_t const* word_begin, unsigned int size) {
0205     if (size) {
0206       data_.reserve(data_.size() + size);
0207       data_.insert(data_.end(), word_begin, word_begin + size);
0208     }
0209   }
0210 
0211   inline void AMCPayload::clear() { data_.clear(); }
0212 
0213 }  // namespace rpcamc13
0214 
0215 #endif  // EventFilter_RPCRawToDigi_RPCAMC13Record_icc