CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1GctJetCounts.cc
Go to the documentation of this file.
1 
3 
4 using std::vector;
5 using std::ostream;
6 using std::endl;
7 
11 const unsigned L1GctJetCounts::MAX_TOTAL_COUNTS=12;
14 const unsigned L1GctJetCounts::MAX_TRUE_COUNTS=6;
15 
16 // default constructor
18  m_data0(0),
19  m_data1(0),
20  m_bx(0)
21 {
22 
23 }
24 
25 // constructor for unpacking
26 L1GctJetCounts::L1GctJetCounts(uint32_t data0, uint32_t data1) :
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(0)
30 {
31 }
32 
33 // constructor for unpacking
34 L1GctJetCounts::L1GctJetCounts(uint32_t data0, uint32_t data1, int16_t bx) :
35  m_data0(data0 & 0x7fff7fff), // Mask off bits 15 and 31 for better compression and consistency
36  m_data1(data1 & 0x7fff7fff), // with emulator constructor - these bits are not jet count data!
37  m_bx(bx)
38 {
39 }
40 
41 // constructor for emulator
42 L1GctJetCounts::L1GctJetCounts(vector<unsigned> counts) :
43  m_data0(0),
44  m_data1(0),
45  m_bx(0)
46 {
47  // Assumes all required output data has been packed
48  // into 12 5-bit fields
49  if (counts.size() != MAX_TOTAL_COUNTS) { }
50  else {
51  for (unsigned int i=0; i<3; ++i) {
52  m_data0 += (counts[i] << (5*i));
53  m_data0 += (counts[i+3] << (5*i + 16));
54  m_data1 += (counts[i+6] << (5*i));
55  m_data1 += (counts[i+9] << (5*i + 16));
56  }
57  }
58 }
59 
60 // constructor for emulator
61 L1GctJetCounts::L1GctJetCounts(vector<unsigned> counts, int16_t bx) :
62  m_data0(0),
63  m_data1(0),
64  m_bx(bx)
65 {
66  if (counts.size() != MAX_TOTAL_COUNTS) { }
67  else {
68  for (unsigned int i=0; i<3; ++i) {
69  m_data0 += (counts[i] << (5*i));
70  m_data0 += (counts[i+3] << (5*i + 16));
71  m_data1 += (counts[i+6] << (5*i));
72  m_data1 += (counts[i+9] << (5*i + 16));
73  }
74  }
75 }
76 
77 // destructor
79 {
80 
81 }
82 
83 // return counts by index
84 unsigned L1GctJetCounts::count(unsigned i) const
85 {
86  if (i<6){ return ((m_data0 >> (i<3 ? (5*i) : ((5*i)+1))) & 0x1f); }
87  else if (i < MAX_TOTAL_COUNTS) { return ((m_data1 >> (i<9 ? ((5*i)-30) : ((5*i)-29))) & 0x1f); }
88  else { return 0; }
89 }
90 
91 // pretty print
92 ostream& operator<<(ostream& s, const L1GctJetCounts& c) {
93  s << "L1GctJetCounts : ";
94  for (unsigned int i=0 ; i<12 ; ++i) {
95  s << "\n count " << i<< "=" << c.count(i);
96  }
97  return s;
98 }
int i
Definition: DBlmapReader.cc:9
virtual ~L1GctJetCounts()
destructor
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
static const unsigned MAX_TRUE_COUNTS
unsigned count(unsigned i) const
get count by index
static const unsigned MAX_TOTAL_COUNTS
L1GctJetCounts()
default constructor
uint32_t m_data0
uint32_t m_data1