File indexing completed on 2023-03-17 10:47:11
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #ifndef CondFormats_L1TObjects_LUT_h
0019 #define CondFormats_L1TObjects_LUT_h
0020
0021 #include <iostream>
0022 #include <vector>
0023 #include <limits>
0024
0025 #include "CondFormats/Serialization/interface/Serializable.h"
0026
0027 namespace l1t {
0028
0029 class LUT {
0030 public:
0031 enum ReadCodes {
0032 SUCCESS = 0,
0033 NO_ENTRIES = 1,
0034 DUP_ENTRIES = 2,
0035 MISS_ENTRIES = 3,
0036 MAX_ADDRESS_OUTOFRANGE = 4,
0037 NO_HEADER = 5
0038 };
0039
0040 LUT() : nrBitsAddress_(0), nrBitsData_(0), addressMask_(0), dataMask_(0), data_() {}
0041
0042 explicit LUT(std::istream& stream) : data_() { read(stream); }
0043
0044 ~LUT() {}
0045
0046 int data(unsigned int address) const {
0047 return (address & addressMask_) < data_.size() ? dataMask_ & data_[addressMask_ & address] : 0;
0048 }
0049 int read(std::istream& stream);
0050 void write(std::ostream& stream) const;
0051
0052 unsigned int nrBitsAddress() const { return nrBitsAddress_; }
0053 unsigned int nrBitsData() const { return nrBitsData_; }
0054
0055 unsigned int maxSize() const {
0056 return addressMask_ == std::numeric_limits<unsigned int>::max() ? addressMask_ : addressMask_ + 1;
0057 }
0058 bool empty() const { return data_.empty(); }
0059
0060 private:
0061 int readHeader_(std::istream&);
0062
0063 unsigned int nrBitsAddress_;
0064 unsigned int nrBitsData_;
0065 unsigned int addressMask_;
0066 unsigned int dataMask_;
0067
0068 std::vector<int> data_;
0069 COND_SERIALIZABLE;
0070 };
0071
0072 }
0073
0074 #endif