File indexing completed on 2024-04-06 12:04:27
0001
0002 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctJetCounts.h"
0003
0004 using std::endl;
0005 using std::ostream;
0006 using std::vector;
0007
0008
0009
0010
0011 const unsigned L1GctJetCounts::MAX_TOTAL_COUNTS = 12;
0012
0013
0014 const unsigned L1GctJetCounts::MAX_TRUE_COUNTS = 6;
0015
0016
0017 L1GctJetCounts::L1GctJetCounts() : m_data0(0), m_data1(0), m_bx(0) {}
0018
0019
0020 L1GctJetCounts::L1GctJetCounts(uint32_t data0, uint32_t data1)
0021 : m_data0(data0 & 0x7fff7fff),
0022 m_data1(data1 & 0x7fff7fff),
0023 m_bx(0) {}
0024
0025
0026 L1GctJetCounts::L1GctJetCounts(uint32_t data0, uint32_t data1, int16_t bx)
0027 : m_data0(data0 & 0x7fff7fff),
0028 m_data1(data1 & 0x7fff7fff),
0029 m_bx(bx) {}
0030
0031
0032 L1GctJetCounts::L1GctJetCounts(const std::vector<unsigned>& counts) : m_data0(0), m_data1(0), m_bx(0) {
0033
0034
0035 if (counts.size() != MAX_TOTAL_COUNTS) {
0036 } else {
0037 for (unsigned int i = 0; i < 3; ++i) {
0038 m_data0 += (counts[i] << (5 * i));
0039 m_data0 += (counts[i + 3] << (5 * i + 16));
0040 m_data1 += (counts[i + 6] << (5 * i));
0041 m_data1 += (counts[i + 9] << (5 * i + 16));
0042 }
0043 }
0044 }
0045
0046
0047 L1GctJetCounts::L1GctJetCounts(const std::vector<unsigned>& counts, int16_t bx) : m_data0(0), m_data1(0), m_bx(bx) {
0048 if (counts.size() != MAX_TOTAL_COUNTS) {
0049 } else {
0050 for (unsigned int i = 0; i < 3; ++i) {
0051 m_data0 += (counts[i] << (5 * i));
0052 m_data0 += (counts[i + 3] << (5 * i + 16));
0053 m_data1 += (counts[i + 6] << (5 * i));
0054 m_data1 += (counts[i + 9] << (5 * i + 16));
0055 }
0056 }
0057 }
0058
0059
0060 L1GctJetCounts::~L1GctJetCounts() {}
0061
0062
0063 unsigned L1GctJetCounts::count(unsigned i) const {
0064 if (i < 6) {
0065 return ((m_data0 >> (i < 3 ? (5 * i) : ((5 * i) + 1))) & 0x1f);
0066 } else if (i < MAX_TOTAL_COUNTS) {
0067 return ((m_data1 >> (i < 9 ? ((5 * i) - 30) : ((5 * i) - 29))) & 0x1f);
0068 } else {
0069 return 0;
0070 }
0071 }
0072
0073
0074 ostream& operator<<(ostream& s, const L1GctJetCounts& c) {
0075 s << "L1GctJetCounts : ";
0076 for (unsigned int i = 0; i < 12; ++i) {
0077 s << "\n count " << i << "=" << c.count(i);
0078 }
0079 return s;
0080 }