CMS 3D CMS Logo

HFRingPacker.cc
Go to the documentation of this file.
3 
4 #include "CaloTokens.h"
5 #include "HFRingPacker.h"
6 
7 namespace l1t {
8  namespace stage1 {
11  event.getByToken(static_cast<const CaloTokens*>(toks)->getEtSumToken(), etSums);
12 
13  edm::Handle<CaloSpareBxCollection> calosparesHFBitCounts;
14  event.getByToken(static_cast<const CaloTokens*>(toks)->getCaloSpareHFBitCountsToken(), calosparesHFBitCounts);
15 
16  edm::Handle<CaloSpareBxCollection> calosparesHFRingSums;
17  event.getByToken(static_cast<const CaloTokens*>(toks)->getCaloSpareHFRingSumsToken(), calosparesHFRingSums);
18 
19  std::vector<uint32_t> load;
20 
21  for (int i = etSums->getFirstBX(); i <= etSums->getLastBX(); ++i) {
22  int n = 0;
23 
24  int hfbitcount = 0;
25  int hfringsum = 0;
26  int htmissphi = 0;
27  int htmiss = 0;
28 
29  int flaghtmiss = 0;
30 
31  for (auto j = etSums->begin(i); j != etSums->end(i) && n < 4; ++j, ++n) {
32  if (j->getType() == l1t::EtSum::kMissingHt) {
33  flaghtmiss = j->hwQual() & 0x1;
34  htmiss = std::min(j->hwPt(), 0x7F);
35  htmissphi = std::min(j->hwPhi(), 0x1F);
36  }
37  }
38 
39  n = 0;
40 
41  for (auto j = calosparesHFBitCounts->begin(i); j != calosparesHFBitCounts->end(i) && n < 2; ++j, ++n) {
42  hfbitcount = std::min(j->hwPt(), 0xFFF);
43  }
44 
45  n = 0;
46 
47  for (auto j = calosparesHFRingSums->begin(i); j != calosparesHFRingSums->end(i) && n < 2; ++j, ++n) {
48  hfringsum = std::min(j->hwPt(), 0xFFF);
49  }
50 
51  uint16_t object[4] = {0, 0, 0, 0};
52 
53  object[0] = hfbitcount | ((hfringsum & 0x7) << 12);
54  object[1] = htmissphi | ((htmiss & 0x7F) << 5) | (flaghtmiss << 12) | (0x1 << 14);
55  object[2] = ((hfringsum >> 3) & 0x1FF) | (0x1) << 10 | (0x1) << 12 | (0x1) << 14;
56  object[3] = 0x1 | (0x1 << 2) | (0x1 << 4) | (0x1 << 6) | (0x1 << 8) | (0x1 << 10) | (0x1 << 12) | (0x1 << 14);
57 
58  uint32_t word0 = (object[0] & 0xFFFF) | ((object[1] & 0xFFFF) << 16);
59  uint32_t word1 = (object[2] & 0xFFFF) | ((object[3] & 0xFFFF) << 16);
60 
61  word0 |= (1 << 31) | (1 << 15);
62  word1 |= ((i == 0) << 31) | ((i == 0) << 15);
63 
64  load.push_back(word0);
65  load.push_back(word1);
66  }
67 
68  return {Block(7, load)};
69  }
70  } // namespace stage1
71 } // namespace l1t
72 
delete x;
Definition: CaloConfig.h:22
std::vector< Block > Blocks
Definition: Block.h:83
T min(T a, T b)
Definition: MathUtil.h:58
Blocks pack(const edm::Event &, const PackerTokens *) override
Definition: HFRingPacker.cc:9
#define DEFINE_L1T_PACKER(type)
Definition: PackerFactory.h:23
def load(fileName)
Definition: svgfig.py:547
Definition: event.py:1