CMS 3D CMS Logo

CaloTowerPacker.cc
Go to the documentation of this file.
3 
5 
6 #include "CaloTokens.h"
7 #include "CaloTowerPacker.h"
8 
9 namespace l1t {
10 namespace stage2 {
11  Blocks
13  {
14 
16  event.getByToken(static_cast<const CaloTokens*>(toks)->getCaloTowerToken(), towers);
17 
18  Blocks res;
19 
20  for (int i = towers->getFirstBX(); i <= towers->getLastBX(); ++i) {
21 
22  for (int phi = 1; phi <=72; phi=phi+2) { // Two phi values per link
23 
24  unsigned int id = 2*phi - 2; // Block IDs start at zero and span even numbers up to 142
25  std::vector<uint32_t> load;
26 
27  for (int eta = 1; eta <=41; eta++) { // This is abs(eta) since +/- eta are interleaved in time
28 
29  if (eta==CaloTools::kHFBegin) continue;
30 
31  // Get four towers +/- eta and phi and phi+1 to all be packed in this loop
32  l1t::CaloTower t1 = towers->at(i,l1t::CaloTools::caloTowerHash(eta,phi));
33  l1t::CaloTower t2 = towers->at(i,l1t::CaloTools::caloTowerHash(eta,phi+1));
34  l1t::CaloTower t3 = towers->at(i,l1t::CaloTools::caloTowerHash(-1*eta,phi));
35  l1t::CaloTower t4 = towers->at(i,l1t::CaloTools::caloTowerHash(-1*eta,phi+1));
36 
37  // Merge phi and phi+1 into one block (phi is LSW, phi+1 is MSW)
38  uint32_t word1 = \
39  std::min(t1.hwPt(), 0x1FF) |
40  (t1.hwEtRatio() & 0x7) << 9 |
41  (t1.hwQual() & 0xF) << 12;
42 
43  word1 = word1 |
44  std::min(t2.hwPt(), 0x1FF) << 16 |
45  (t2.hwEtRatio() & 0x7) << 25 |
46  (t2.hwQual() & 0xF) << 28;
47 
48  load.push_back(word1);
49 
50  // Do it all again for -eta
51 
52  uint32_t word2 = \
53  std::min(t3.hwPt(), 0x1FF) |
54  (t3.hwEtRatio() & 0x7) << 9 |
55  (t3.hwQual() & 0xF) << 12;
56 
57  word2 = word2 |
58  std::min(t4.hwPt(), 0x1FF) << 16 |
59  (t4.hwEtRatio() & 0x7) << 25 |
60  (t4.hwQual() & 0xF) << 28;
61 
62  load.push_back(word2);
63 
64  }
65 
66  res.push_back(Block(id, load));
67 
68  }
69  }
70  return res;
71  }
72 }
73 }
74 
int hwEtRatio() const
Definition: CaloTower.cc:74
delete x;
Definition: CaloConfig.h:22
Definition: Electron.h:6
static size_t caloTowerHash(int iEta, int iPhi)
Definition: CaloTools.cc:66
static const int kHFBegin
Definition: CaloTools.h:40
Blocks pack(const edm::Event &, const PackerTokens *) override
std::vector< Block > Blocks
Definition: Block.h:72
T min(T a, T b)
Definition: MathUtil.h:58
int hwQual() const
Definition: L1Candidate.h:51
#define DEFINE_L1T_PACKER(type)
Definition: PackerFactory.h:22
int hwPt() const
Definition: L1Candidate.h:48
def load(fileName)
Definition: svgfig.py:546
Definition: event.py:1