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
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 
l1t::Blocks
std::vector< Block > Blocks
Definition: Block.h:99
RandomServiceHelper.t2
t2
Definition: RandomServiceHelper.py:257
HLT_FULL_cff.towers
towers
Definition: HLT_FULL_cff.py:36362
CaloTokens.h
mps_fire.i
i
Definition: mps_fire.py:428
PackerFactory.h
CaloTools.h
l1t::stage2::CaloTowerPacker::pack
Blocks pack(const edm::Event &, const PackerTokens *) override
Definition: CaloTowerPacker.cc:11
l1t::CaloTools::kHFBegin
static const int kHFBegin
Definition: CaloTools.h:39
min
T min(T a, T b)
Definition: MathUtil.h:58
l1t::L1Candidate::hwQual
int hwQual() const
Definition: L1Candidate.h:38
edm::Handle
Definition: AssociativeIterator.h:50
l1t::CaloTower
Definition: CaloTower.h:12
RandomServiceHelper.t1
t1
Definition: RandomServiceHelper.py:256
PVValHelper::eta
Definition: PVValidationHelpers.h:69
svgfig.load
def load(fileName)
Definition: svgfig.py:547
RandomServiceHelper.t3
t3
Definition: RandomServiceHelper.py:258
DEFINE_L1T_PACKER
#define DEFINE_L1T_PACKER(type)
Definition: PackerFactory.h:23
Event.h
l1t
delete x;
Definition: CaloConfig.h:22
l1t::CaloTower::hwEtRatio
int hwEtRatio() const
Definition: CaloTower.cc:41
l1t::PackerTokens
Definition: PackerTokens.h:10
res
Definition: Electron.h:6
SiStripSourceConfigTier0_cff.stage2
stage2
Definition: SiStripSourceConfigTier0_cff.py:71
l1t::CaloTools::caloTowerHash
static size_t caloTowerHash(int iEta, int iPhi)
Definition: CaloTools.cc:81
l1t::L1Candidate::hwPt
int hwPt() const
Definition: L1Candidate.h:35
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
l1t::stage2::CaloTowerPacker
Definition: CaloTowerPacker.h:8
l1t::Block
Definition: Block.h:70
CaloTowerPacker.h