CMS 3D CMS Logo

EMTFBlockCounters.cc
Go to the documentation of this file.
1 // Code to unpack the "Block of Counters"
2 
4 
5 #include "EMTFCollections.h"
6 #include "EMTFUnpackerTools.h"
7 
8 // This is the "header" - no EMTFBlockCounters.h file is needed
9 namespace l1t {
10  namespace stage2 {
11  namespace emtf {
12 
13  class CountersBlockUnpacker : public Unpacker { // "CountersBlockUnpacker" inherits from "Unpacker"
14  public:
15  virtual int checkFormat(const Block& block);
16  bool unpack(const Block& block,
17  UnpackerCollections* coll) override; // Apparently it's always good to use override in C++
18  // virtual bool packBlock(const Block& block, UnpackerCollections *coll) override;
19  };
20 
21  // class CountersBlockPacker : public Packer { // "CountersBlockPacker" inherits from "Packer"
22  // public:
23  // virtual bool unpack(const Block& block, UnpackerCollections *coll) override; // Apparently it's always good to use override in C++
24  // };
25 
26  } // namespace emtf
27  } // namespace stage2
28 } // namespace l1t
29 
30 namespace l1t {
31  namespace stage2 {
32  namespace emtf {
33 
35  auto payload = block.payload();
36  int errors = 0;
37 
38  //Check the number of 16-bit words
39  if (payload.size() != 4) {
40  errors += 1;
41  edm::LogError("L1T|EMTF") << "Payload size in 'Block of Counters' is different than expected";
42  }
43 
44  //Check that each word is 16 bits
45  if (GetHexBits(payload[0], 16, 31) != 0) {
46  errors += 1;
47  edm::LogError("L1T|EMTF") << "Payload[0] has more than 16 bits in 'Block of Counters'";
48  }
49  if (GetHexBits(payload[1], 16, 31) != 0) {
50  errors += 1;
51  edm::LogError("L1T|EMTF") << "Payload[1] has more than 16 bits in 'Block of Counters'";
52  }
53  if (GetHexBits(payload[2], 16, 31) != 0) {
54  errors += 1;
55  edm::LogError("L1T|EMTF") << "Payload[2] has more than 16 bits in 'Block of Counters'";
56  }
57  if (GetHexBits(payload[3], 16, 31) != 0) {
58  errors += 1;
59  edm::LogError("L1T|EMTF") << "Payload[3] has more than 16 bits in 'Block of Counters'";
60  }
61 
62  uint16_t BCa = payload[0];
63  uint16_t BCb = payload[1];
64  uint16_t BCc = payload[2];
65  uint16_t BCd = payload[3];
66 
67  //Check Format
68  if (GetHexBits(BCa, 15, 15) != 0) {
69  errors += 1;
70  edm::LogError("L1T|EMTF") << "Format identifier bits in BCa are incorrect";
71  }
72  if (GetHexBits(BCb, 15, 15) != 1) {
73  errors += 1;
74  edm::LogError("L1T|EMTF") << "Format identifier bits in BCb are incorrect";
75  }
76  if (GetHexBits(BCc, 15, 15) != 0) {
77  errors += 1;
78  edm::LogError("L1T|EMTF") << "Format identifier bits in BCc are incorrect";
79  }
80  if (GetHexBits(BCd, 15, 15) != 0) {
81  errors += 1;
82  edm::LogError("L1T|EMTF") << "Format identifier bits in BCd are incorrect";
83  }
84 
85  return errors;
86  } // End function: int CountersBlockUnpacker::checkFormat()
87 
89  // std::cout << "Inside EMTFBlockCounters.cc: unpack" << std::endl;
90 
91  // Get the payload for this block, made up of 16-bit words (0xffff)
92  // Format defined in MTF7Payload::getBlock() in src/Block.cc
93  // payload[0] = bits 0-15, payload[1] = 16-31, payload[3] = 32-47, etc.
94  auto payload = block.payload();
95 
96  // Check Format of Payload
97  l1t::emtf::Counters Counters_;
98  for (int err = 0; err < checkFormat(block); err++)
99  Counters_.add_format_error();
100 
101  // Assign payload to 16-bit words
102  uint16_t BCa = payload[0];
103  uint16_t BCb = payload[1];
104  uint16_t BCc = payload[2];
105  uint16_t BCd = payload[3];
106 
107  // res is a pointer to a collection of EMTFDaqOut class objects
108  // There is one EMTFDaqOut for each MTF7 (60 deg. sector) in the event
110  res = static_cast<EMTFCollections*>(coll)->getEMTFDaqOuts();
111  int iOut = res->size() - 1;
112 
114  // Unpack the Block of Counters
116  if ((res->at(iOut)).HasCounters() == true) {
117  (res->at(iOut)).add_format_error();
118  edm::LogError("L1T|EMTF") << "Why is there already a Counters object?";
119  }
120 
121  Counters_.set_me1a_2(GetHexBits(BCa, 0, 0));
122  Counters_.set_me1a_3(GetHexBits(BCa, 1, 1));
123  Counters_.set_me1a_4(GetHexBits(BCa, 2, 2));
124  Counters_.set_me1a_5(GetHexBits(BCa, 3, 3));
125  Counters_.set_me1a_6(GetHexBits(BCa, 4, 4));
126  Counters_.set_me1a_7(GetHexBits(BCa, 5, 5));
127  Counters_.set_me1a_8(GetHexBits(BCa, 6, 6));
128  Counters_.set_me1a_9(GetHexBits(BCa, 7, 7));
129  Counters_.set_me1b_2(GetHexBits(BCa, 8, 8));
130  Counters_.set_me1b_3(GetHexBits(BCa, 9, 9));
131  Counters_.set_me1b_4(GetHexBits(BCa, 10, 10));
132  Counters_.set_me1b_5(GetHexBits(BCa, 11, 11));
133  Counters_.set_me1b_6(GetHexBits(BCa, 12, 12));
134  Counters_.set_me1b_7(GetHexBits(BCa, 13, 13));
135  Counters_.set_me1b_8(GetHexBits(BCa, 14, 14));
136 
137  Counters_.set_me1b_9(GetHexBits(BCb, 0, 0));
138  Counters_.set_me2_2(GetHexBits(BCb, 1, 1));
139  Counters_.set_me2_3(GetHexBits(BCb, 2, 2));
140  Counters_.set_me2_4(GetHexBits(BCb, 3, 3));
141  Counters_.set_me2_5(GetHexBits(BCb, 4, 4));
142  Counters_.set_me2_6(GetHexBits(BCb, 5, 5));
143  Counters_.set_me2_7(GetHexBits(BCb, 6, 6));
144  Counters_.set_me2_8(GetHexBits(BCb, 7, 7));
145  Counters_.set_me2_9(GetHexBits(BCb, 8, 8));
146  Counters_.set_me3_2(GetHexBits(BCb, 9, 9));
147  Counters_.set_me3_3(GetHexBits(BCb, 10, 10));
148  Counters_.set_me3_4(GetHexBits(BCb, 11, 11));
149  Counters_.set_me3_5(GetHexBits(BCb, 12, 12));
150  Counters_.set_me3_6(GetHexBits(BCb, 13, 13));
151  Counters_.set_me3_7(GetHexBits(BCb, 14, 14));
152 
153  Counters_.set_me3_8(GetHexBits(BCc, 0, 0));
154  Counters_.set_me3_9(GetHexBits(BCc, 1, 1));
155  Counters_.set_me4_2(GetHexBits(BCc, 2, 2));
156  Counters_.set_me4_3(GetHexBits(BCc, 3, 3));
157  Counters_.set_me4_4(GetHexBits(BCc, 4, 4));
158  Counters_.set_me4_5(GetHexBits(BCc, 5, 5));
159  Counters_.set_me4_6(GetHexBits(BCc, 6, 6));
160  Counters_.set_me4_7(GetHexBits(BCc, 7, 7));
161  Counters_.set_me4_8(GetHexBits(BCc, 8, 8));
162  Counters_.set_me4_9(GetHexBits(BCc, 9, 9));
163  Counters_.set_me1n_3(GetHexBits(BCc, 10, 10));
164  Counters_.set_me1n_6(GetHexBits(BCc, 11, 11));
165  Counters_.set_me1n_9(GetHexBits(BCc, 12, 12));
166  Counters_.set_me2n_3(GetHexBits(BCc, 13, 13));
167  Counters_.set_me2n_9(GetHexBits(BCc, 14, 14));
168 
169  Counters_.set_me3n_3(GetHexBits(BCd, 0, 0));
170  Counters_.set_me3n_9(GetHexBits(BCd, 1, 1));
171  Counters_.set_me4n_3(GetHexBits(BCd, 2, 2));
172  Counters_.set_me4n_9(GetHexBits(BCd, 3, 3));
173  Counters_.set_me1a_1(GetHexBits(BCd, 4, 4));
174  Counters_.set_me1b_1(GetHexBits(BCd, 5, 5));
175  Counters_.set_me2_1(GetHexBits(BCd, 6, 6));
176  Counters_.set_me3_1(GetHexBits(BCd, 7, 7));
177  Counters_.set_me4_1(GetHexBits(BCd, 8, 8));
178 
179  Counters_.set_me1a_all(GetHexBits(BCa, 0, 7));
180  Counters_.set_me1b_all(GetHexBits(BCa, 8, 14, BCb, 0, 0));
181  Counters_.set_me2_all(GetHexBits(BCb, 1, 8));
182  Counters_.set_me3_all(GetHexBits(BCb, 9, 14, BCc, 0, 1));
183  Counters_.set_me4_all(GetHexBits(BCc, 2, 9));
184  Counters_.set_meN_all(GetHexBits(BCc, 10, 14, BCd, 0, 3));
185 
186  Counters_.set_me1a_all((Counters_.ME1a_all() << 1) | Counters_.ME1a_1());
187  Counters_.set_me1b_all((Counters_.ME1b_all() << 1) | Counters_.ME1b_1());
188  Counters_.set_me2_all((Counters_.ME2_all() << 1) | Counters_.ME2_1());
189  Counters_.set_me3_all((Counters_.ME3_all() << 1) | Counters_.ME3_1());
190  Counters_.set_me4_all((Counters_.ME4_all() << 1) | Counters_.ME4_1());
191 
192  Counters_.set_me_all(Counters_.MEN_all() | Counters_.ME4_all() | Counters_.ME3_all() | Counters_.ME2_all() |
193  Counters_.ME1b_all() | Counters_.ME1a_all());
194 
195  // Counters_.set_dataword(uint64_t bits) { dataword = bits; };
196 
197  (res->at(iOut)).set_Counters(Counters_);
198 
199  // Finished with unpacking Counters
200  return true;
201 
202  } // End bool CountersBlockUnpacker::unpack
203 
204  // bool CountersBlockPacker::pack(const Block& block, UnpackerCollections *coll) {
205  // std::cout << "Inside CountersBlockPacker::pack" << std::endl;
206  // return true;
207  // } // End bool CountersBlockPacker::pack
208 
209  } // End namespace emtf
210  } // End namespace stage2
211 } // End namespace l1t
212 
214 // DEFINE_L1T_PACKER(l1t::stage2::CountersBlockPacker);
l1t::EMTFDaqOutCollection
std::vector< EMTFDaqOut > EMTFDaqOutCollection
Definition: EMTFDaqOut.h:179
l1t::emtf::Counters::set_me4n_9
void set_me4n_9(int bits)
Definition: Counters.h:152
l1t::emtf::Counters::set_me1a_5
void set_me1a_5(int bits)
Definition: Counters.h:103
l1t::emtf::Counters::set_me3_2
void set_me3_2(int bits)
Definition: Counters.h:127
l1t::emtf::Counters::set_me2_all
void set_me2_all(int bits)
Definition: Counters.h:156
l1t::emtf::Counters::set_me2_1
void set_me2_1(int bits)
Definition: Counters.h:117
l1t::emtf::Counters::set_me_all
void set_me_all(int bits)
Definition: Counters.h:160
l1t::emtf::Counters::set_me1b_2
void set_me1b_2(int bits)
Definition: Counters.h:109
l1t::emtf::Counters::set_me3_all
void set_me3_all(int bits)
Definition: Counters.h:157
l1t::emtf::Counters::set_me4_6
void set_me4_6(int bits)
Definition: Counters.h:140
l1t::emtf::Counters::set_me2_6
void set_me2_6(int bits)
Definition: Counters.h:122
l1t::emtf::Counters::set_me1n_9
void set_me1n_9(int bits)
Definition: Counters.h:146
l1t::emtf::Counters::set_me1b_5
void set_me1b_5(int bits)
Definition: Counters.h:112
l1t::emtf::Counters::set_me4_8
void set_me4_8(int bits)
Definition: Counters.h:142
l1t::emtf::Counters::set_me2_4
void set_me2_4(int bits)
Definition: Counters.h:120
l1t::emtf::Counters::set_me1b_3
void set_me1b_3(int bits)
Definition: Counters.h:110
l1t::emtf::Counters::set_meN_all
void set_meN_all(int bits)
Definition: Counters.h:159
l1t::emtf::Counters::set_me4_2
void set_me4_2(int bits)
Definition: Counters.h:136
l1t::emtf::Counters::set_me1b_6
void set_me1b_6(int bits)
Definition: Counters.h:113
l1t::emtf::Counters::set_me4_1
void set_me4_1(int bits)
Definition: Counters.h:135
l1t::emtf::Counters::set_me3_7
void set_me3_7(int bits)
Definition: Counters.h:132
EMTFCollections.h
l1t::emtf::Counters::set_me1a_9
void set_me1a_9(int bits)
Definition: Counters.h:107
l1t::emtf::Counters::set_me4_5
void set_me4_5(int bits)
Definition: Counters.h:139
l1t::emtf::Counters::set_me1n_3
void set_me1n_3(int bits)
Definition: Counters.h:144
l1t::emtf::Counters::set_me3_6
void set_me3_6(int bits)
Definition: Counters.h:131
l1t::emtf::Counters::ME4_all
int ME4_all() const
Definition: Counters.h:223
l1t::emtf::Counters::set_me1b_8
void set_me1b_8(int bits)
Definition: Counters.h:115
l1t::emtf::Counters::set_me1b_4
void set_me1b_4(int bits)
Definition: Counters.h:111
l1t::emtf::Counters::set_me3n_9
void set_me3n_9(int bits)
Definition: Counters.h:150
l1t::stage2::emtf::CountersBlockUnpacker::checkFormat
virtual int checkFormat(const Block &block)
Definition: EMTFBlockCounters.cc:34
l1t::stage2::emtf::CountersBlockUnpacker::unpack
bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: EMTFBlockCounters.cc:88
l1t::emtf::Counters::set_me2_8
void set_me2_8(int bits)
Definition: Counters.h:124
l1t::emtf::Counters::set_me2_2
void set_me2_2(int bits)
Definition: Counters.h:118
l1t::emtf::Counters::set_me4_9
void set_me4_9(int bits)
Definition: Counters.h:143
l1t::emtf::Counters::set_me3_3
void set_me3_3(int bits)
Definition: Counters.h:128
l1t::emtf::Counters::MEN_all
int MEN_all() const
Definition: Counters.h:224
l1t::emtf::Counters::add_format_error
void add_format_error()
Definition: Counters.h:161
l1t::emtf::Counters::set_me4n_3
void set_me4n_3(int bits)
Definition: Counters.h:151
errors
Definition: errors.py:1
l1t::emtf::Counters::ME4_1
int ME4_1() const
Definition: Counters.h:200
l1t::emtf::Counters::ME2_1
int ME2_1() const
Definition: Counters.h:182
emtf
Definition: Event.h:15
UnpackerFactory.h
jets_cff.payload
payload
Definition: jets_cff.py:32
l1t::emtf::Counters::set_me4_3
void set_me4_3(int bits)
Definition: Counters.h:137
l1t::emtf::Counters::ME1b_1
int ME1b_1() const
Definition: Counters.h:173
l1t::emtf::Counters::set_me1a_3
void set_me1a_3(int bits)
Definition: Counters.h:101
l1t::Unpacker
Definition: Unpacker.h:11
l1t::emtf::Counters::set_me1a_4
void set_me1a_4(int bits)
Definition: Counters.h:102
l1t::emtf::Counters::set_me1a_6
void set_me1a_6(int bits)
Definition: Counters.h:104
l1t::emtf::Counters::set_me1a_1
void set_me1a_1(int bits)
Definition: Counters.h:99
l1t::emtf::Counters::set_me4_4
void set_me4_4(int bits)
Definition: Counters.h:138
l1t::emtf::Counters::set_me1a_7
void set_me1a_7(int bits)
Definition: Counters.h:105
l1t::emtf::Counters::set_me1a_8
void set_me1a_8(int bits)
Definition: Counters.h:106
l1t::emtf::Counters::set_me3_4
void set_me3_4(int bits)
Definition: Counters.h:129
l1t
delete x;
Definition: CaloConfig.h:22
l1t::emtf::Counters::set_me4_7
void set_me4_7(int bits)
Definition: Counters.h:141
l1t::emtf::Counters::set_me2_9
void set_me2_9(int bits)
Definition: Counters.h:125
l1t::emtf::Counters::set_me1n_6
void set_me1n_6(int bits)
Definition: Counters.h:145
l1t::emtf::Counters::ME1b_all
int ME1b_all() const
Definition: Counters.h:220
l1t::emtf::Counters::ME2_all
int ME2_all() const
Definition: Counters.h:221
groupFilesInBlocks.block
block
Definition: groupFilesInBlocks.py:150
l1t::emtf::Counters::set_me2_5
void set_me2_5(int bits)
Definition: Counters.h:121
l1t::emtf::Counters::set_me1b_all
void set_me1b_all(int bits)
Definition: Counters.h:155
l1t::emtf::Counters::set_me1a_all
void set_me1a_all(int bits)
Definition: Counters.h:154
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
submitPVResolutionJobs.err
err
Definition: submitPVResolutionJobs.py:85
res
Definition: Electron.h:6
SiStripSourceConfigTier0_cff.stage2
stage2
Definition: SiStripSourceConfigTier0_cff.py:71
l1t::emtf::Counters::set_me2n_9
void set_me2n_9(int bits)
Definition: Counters.h:148
l1t::emtf::Counters::ME3_all
int ME3_all() const
Definition: Counters.h:222
l1t::emtf::Counters::set_me1b_7
void set_me1b_7(int bits)
Definition: Counters.h:114
l1t::emtf::Counters
Definition: Counters.h:9
l1t::stage2::emtf::CountersBlockUnpacker
Definition: EMTFBlockCounters.cc:13
l1t::emtf::Counters::set_me1b_1
void set_me1b_1(int bits)
Definition: Counters.h:108
l1t::emtf::Counters::set_me3_1
void set_me3_1(int bits)
Definition: Counters.h:126
l1t::emtf::Counters::ME1a_all
int ME1a_all() const
Definition: Counters.h:219
l1t::emtf::Counters::set_me1a_2
void set_me1a_2(int bits)
Definition: Counters.h:100
l1t::emtf::Counters::set_me1b_9
void set_me1b_9(int bits)
Definition: Counters.h:116
EMTFUnpackerTools.h
l1t::UnpackerCollections
Definition: UnpackerCollections.h:9
l1t::emtf::Counters::set_me4_all
void set_me4_all(int bits)
Definition: Counters.h:158
l1t::emtf::Counters::set_me3n_3
void set_me3n_3(int bits)
Definition: Counters.h:149
DEFINE_L1T_UNPACKER
#define DEFINE_L1T_UNPACKER(type)
Definition: UnpackerFactory.h:23
l1t::emtf::Counters::set_me3_8
void set_me3_8(int bits)
Definition: Counters.h:133
l1t::emtf::Counters::set_me3_9
void set_me3_9(int bits)
Definition: Counters.h:134
l1t::emtf::Counters::ME3_1
int ME3_1() const
Definition: Counters.h:191
l1t::emtf::Counters::ME1a_1
int ME1a_1() const
Definition: Counters.h:164
l1t::Block
Definition: Block.h:70
l1t::emtf::Counters::set_me2_3
void set_me2_3(int bits)
Definition: Counters.h:119
l1t::stage2::emtf::GetHexBits
uint16_t GetHexBits(uint16_t word, uint16_t lowBit, uint16_t highBit)
Definition: EMTFUnpackerTools.h:45
l1t::emtf::Counters::set_me2_7
void set_me2_7(int bits)
Definition: Counters.h:123
l1t::emtf::Counters::set_me2n_3
void set_me2n_3(int bits)
Definition: Counters.h:147
l1t::emtf::Counters::set_me3_5
void set_me3_5(int bits)
Definition: Counters.h:130
debug_messages_cfi.errors
errors
Definition: debug_messages_cfi.py:54