CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CaloSpareHFPacker.cc
Go to the documentation of this file.
3 
4 #include "CaloSpareHFPacker.h"
5 #include "CaloTokens.h"
6 
7 namespace l1t {
8  namespace stage1 {
10  edm::Handle<CaloSpareBxCollection> calosparesHFBitCounts;
11  event.getByToken(static_cast<const CaloTokens*>(toks)->getCaloSpareHFBitCountsToken(), calosparesHFBitCounts);
12 
13  edm::Handle<CaloSpareBxCollection> calosparesHFRingSums;
14  event.getByToken(static_cast<const CaloTokens*>(toks)->getCaloSpareHFRingSumsToken(), calosparesHFRingSums);
15 
16  std::vector<uint32_t> load;
17 
18  for (int i = calosparesHFBitCounts->getFirstBX(); i <= calosparesHFBitCounts->getLastBX(); ++i) {
19  int n = 0;
20 
21  int hfbitcount = 0;
22  int hfringsum = 0;
23 
24  for (auto j = calosparesHFBitCounts->begin(i); j != calosparesHFBitCounts->end(i) && n < 2; ++j, ++n) {
25  hfbitcount = std::min(j->hwPt(), 0xFFF);
26  }
27 
28  n = 0;
29 
30  for (auto j = calosparesHFRingSums->begin(i); j != calosparesHFRingSums->end(i) && n < 2; ++j, ++n) {
31  hfringsum = std::min(j->hwPt(), 0xFFF);
32  }
33 
34  uint16_t object[2] = {0, 0};
35 
36  object[0] = hfbitcount | ((hfringsum & 0x7) << 12);
37  object[1] = ((hfringsum >> 3) & 0x1FF) | (0x1) << 10 | (0x1) << 12 | (0x1) << 14;
38 
39  uint32_t word0 = (object[0] & 0xFFFF);
40  uint32_t word1 = (object[1] & 0xFFFF);
41 
42  word0 |= (1 << 15);
43  word1 |= ((i == 0) << 15);
44 
45  load.push_back(word0);
46  load.push_back(word1);
47  }
48 
49  return {Block(97, load)};
50  }
51  } // namespace stage1
52 } // namespace l1t
53 
Blocks pack(const edm::Event &, const PackerTokens *) override
def load
Definition: svgfig.py:547
std::vector< Block > Blocks
Definition: Block.h:99
#define DEFINE_L1T_PACKER(type)
Definition: PackerFactory.h:23