File indexing completed on 2024-04-06 12:10:50
0001 #include "FWCore/Framework/interface/Event.h"
0002 #include "EventFilter/L1TRawToDigi/plugins/PackerFactory.h"
0003
0004 #include "L1Trigger/L1TCalorimeter/interface/CaloTools.h"
0005
0006 #include "CaloTokens.h"
0007 #include "CaloTowerPacker.h"
0008
0009 namespace l1t {
0010 namespace stage2 {
0011 Blocks CaloTowerPacker::pack(const edm::Event& event, const PackerTokens* toks) {
0012 edm::Handle<CaloTowerBxCollection> towers;
0013 event.getByToken(static_cast<const CaloTokens*>(toks)->getCaloTowerToken(), towers);
0014
0015 Blocks res;
0016
0017 for (int i = towers->getFirstBX(); i <= towers->getLastBX(); ++i) {
0018 for (int phi = 1; phi <= 72; phi = phi + 2) {
0019
0020 unsigned int id = 2 * phi - 2;
0021 std::vector<uint32_t> load;
0022
0023 for (int eta = 1; eta <= 41; eta++) {
0024
0025 if (eta == CaloTools::kHFBegin)
0026 continue;
0027
0028
0029 l1t::CaloTower t1 = towers->at(i, l1t::CaloTools::caloTowerHash(eta, phi));
0030 l1t::CaloTower t2 = towers->at(i, l1t::CaloTools::caloTowerHash(eta, phi + 1));
0031 l1t::CaloTower t3 = towers->at(i, l1t::CaloTools::caloTowerHash(-1 * eta, phi));
0032 l1t::CaloTower t4 = towers->at(i, l1t::CaloTools::caloTowerHash(-1 * eta, phi + 1));
0033
0034
0035 uint32_t word1 = std::min(t1.hwPt(), 0x1FF) | (t1.hwEtRatio() & 0x7) << 9 | (t1.hwQual() & 0xF) << 12;
0036
0037 word1 = word1 | std::min(t2.hwPt(), 0x1FF) << 16 | (t2.hwEtRatio() & 0x7) << 25 | (t2.hwQual() & 0xF) << 28;
0038
0039 load.push_back(word1);
0040
0041
0042
0043 uint32_t word2 = std::min(t3.hwPt(), 0x1FF) | (t3.hwEtRatio() & 0x7) << 9 | (t3.hwQual() & 0xF) << 12;
0044
0045 word2 = word2 | std::min(t4.hwPt(), 0x1FF) << 16 | (t4.hwEtRatio() & 0x7) << 25 | (t4.hwQual() & 0xF) << 28;
0046
0047 load.push_back(word2);
0048 }
0049
0050 res.push_back(Block(id, load));
0051 }
0052 }
0053 return res;
0054 }
0055 }
0056 }
0057
0058 DEFINE_L1T_PACKER(l1t::stage2::CaloTowerPacker);