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