CMS 3D CMS Logo

L1GctJetCounts.cc
Go to the documentation of this file.
1 
3 
4 using std::endl;
5 using std::ostream;
6 using std::vector;
7 
11 const unsigned L1GctJetCounts::MAX_TOTAL_COUNTS = 12;
14 const unsigned L1GctJetCounts::MAX_TRUE_COUNTS = 6;
15 
16 // default constructor
17 L1GctJetCounts::L1GctJetCounts() : m_data0(0), m_data1(0), m_bx(0) {}
18 
19 // constructor for unpacking
20 L1GctJetCounts::L1GctJetCounts(uint32_t data0, uint32_t data1)
21  : m_data0(data0 & 0x7fff7fff), // Mask off bits 15 and 31 for better compression and consistency
22  m_data1(data1 & 0x7fff7fff), // with emulator constructor - these bits are not jet count data!
23  m_bx(0) {}
24 
25 // constructor for unpacking
26 L1GctJetCounts::L1GctJetCounts(uint32_t data0, uint32_t data1, int16_t bx)
27  : m_data0(data0 & 0x7fff7fff), // Mask off bits 15 and 31 for better compression and consistency
28  m_data1(data1 & 0x7fff7fff), // with emulator constructor - these bits are not jet count data!
29  m_bx(bx) {}
30 
31 // constructor for emulator
32 L1GctJetCounts::L1GctJetCounts(const std::vector<unsigned>& counts) : m_data0(0), m_data1(0), m_bx(0) {
33  // Assumes all required output data has been packed
34  // into 12 5-bit fields
35  if (counts.size() != MAX_TOTAL_COUNTS) {
36  } else {
37  for (unsigned int i = 0; i < 3; ++i) {
38  m_data0 += (counts[i] << (5 * i));
39  m_data0 += (counts[i + 3] << (5 * i + 16));
40  m_data1 += (counts[i + 6] << (5 * i));
41  m_data1 += (counts[i + 9] << (5 * i + 16));
42  }
43  }
44 }
45 
46 // constructor for emulator
47 L1GctJetCounts::L1GctJetCounts(const std::vector<unsigned>& counts, int16_t bx) : m_data0(0), m_data1(0), m_bx(bx) {
48  if (counts.size() != MAX_TOTAL_COUNTS) {
49  } else {
50  for (unsigned int i = 0; i < 3; ++i) {
51  m_data0 += (counts[i] << (5 * i));
52  m_data0 += (counts[i + 3] << (5 * i + 16));
53  m_data1 += (counts[i + 6] << (5 * i));
54  m_data1 += (counts[i + 9] << (5 * i + 16));
55  }
56  }
57 }
58 
59 // destructor
61 
62 // return counts by index
63 unsigned L1GctJetCounts::count(unsigned i) const {
64  if (i < 6) {
65  return ((m_data0 >> (i < 3 ? (5 * i) : ((5 * i) + 1))) & 0x1f);
66  } else if (i < MAX_TOTAL_COUNTS) {
67  return ((m_data1 >> (i < 9 ? ((5 * i) - 30) : ((5 * i) - 29))) & 0x1f);
68  } else {
69  return 0;
70  }
71 }
72 
73 // pretty print
74 ostream& operator<<(ostream& s, const L1GctJetCounts& c) {
75  s << "L1GctJetCounts : ";
76  for (unsigned int i = 0; i < 12; ++i) {
77  s << "\n count " << i << "=" << c.count(i);
78  }
79  return s;
80 }
mps_fire.i
i
Definition: mps_fire.py:428
L1GctJetCounts.h
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
alignCSCRings.s
s
Definition: alignCSCRings.py:92
L1GctJetCounts::MAX_TRUE_COUNTS
static const unsigned MAX_TRUE_COUNTS
Definition: L1GctJetCounts.h:22
L1GctJetCounts::m_data1
uint32_t m_data1
Definition: L1GctJetCounts.h:85
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
L1GctJetCounts
Definition: L1GctJetCounts.h:16
operator<<
ostream & operator<<(ostream &s, const L1GctJetCounts &c)
Definition: L1GctJetCounts.cc:74
L1GctJetCounts::~L1GctJetCounts
virtual ~L1GctJetCounts()
destructor
Definition: L1GctJetCounts.cc:60
L1GctJetCounts::count
unsigned count(unsigned i) const
get count by index
Definition: L1GctJetCounts.cc:63
dqmiodumpmetadata.counts
counts
Definition: dqmiodumpmetadata.py:25
L1GctJetCounts::m_data0
uint32_t m_data0
Definition: L1GctJetCounts.h:84
L1GctJetCounts::MAX_TOTAL_COUNTS
static const unsigned MAX_TOTAL_COUNTS
Definition: L1GctJetCounts.h:21
L1GctJetCounts::L1GctJetCounts
L1GctJetCounts()
default constructor
Definition: L1GctJetCounts.cc:17