Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:26:01

0001 #include "FWCore/Framework/interface/Event.h"
0002 #include "EventFilter/L1TRawToDigi/plugins/PackerFactory.h"
0003 
0004 #include "CaloTokens.h"
0005 #include "PhysCandPacker.h"
0006 
0007 template <typename T, typename F>
0008 l1t::Blocks process(unsigned int id1, unsigned int id2, const BXVector<T>& coll, F filter) {
0009   std::vector<uint32_t> load[2];
0010 
0011   for (int i = coll.getFirstBX(); i <= coll.getLastBX(); ++i) {
0012     uint16_t jetbit[4] = {0, 0, 0, 0};
0013     int n = 0;
0014     for (auto j = coll.begin(i); j != coll.end(i) && n < 4; ++j) {
0015       if (!filter(*j))
0016         continue;
0017       //std::cout << j->hwPt() << " @ " << j->hwEta() << ", " << j->hwPhi() << " > " << j->hwQual() << " > " << j->hwIso() << std::endl;
0018       jetbit[n++] = std::min(j->hwPt(), 0x3F) | (abs(j->hwEta()) & 0x7) << 6 | ((j->hwEta() >> 3) & 0x1) << 9 |
0019                     (j->hwPhi() & 0x1F) << 10;
0020     }
0021     uint32_t word0 = (jetbit[0] & 0xFFFF);
0022     uint32_t word1 = (jetbit[1] & 0xFFFF);
0023     uint32_t word2 = (jetbit[2] & 0xFFFF);
0024     uint32_t word3 = (jetbit[3] & 0xFFFF);
0025 
0026     load[0].push_back(word0);
0027     load[0].push_back(word2);
0028 
0029     load[1].push_back(word1);
0030     load[1].push_back(word3);
0031   }
0032 
0033   return {l1t::Block(id1, load[0]), l1t::Block(id2, load[1])};
0034 }
0035 
0036 namespace l1t {
0037   namespace stage1 {
0038     Blocks IsoEGammaPacker::pack(const edm::Event& event, const PackerTokens* toks) {
0039       edm::Handle<EGammaBxCollection> egammas;
0040       event.getByToken(static_cast<const CaloTokens*>(toks)->getEGammaToken(), egammas);
0041 
0042       return process(85, 87, *egammas, [](const l1t::EGamma& eg) -> bool { return eg.hwIso() == 1; });
0043     }
0044 
0045     Blocks NonIsoEGammaPacker::pack(const edm::Event& event, const PackerTokens* toks) {
0046       edm::Handle<EGammaBxCollection> egammas;
0047       event.getByToken(static_cast<const CaloTokens*>(toks)->getEGammaToken(), egammas);
0048 
0049       return process(89, 91, *egammas, [](const l1t::EGamma& eg) -> bool { return eg.hwIso() == 0; });
0050     }
0051 
0052     Blocks CentralJetPacker::pack(const edm::Event& event, const PackerTokens* toks) {
0053       edm::Handle<JetBxCollection> jets;
0054       event.getByToken(static_cast<const CaloTokens*>(toks)->getJetToken(), jets);
0055 
0056       return process(77, 79, *jets, [](const l1t::Jet& jet) -> bool { return !(jet.hwQual() & 2); });
0057     }
0058 
0059     Blocks ForwardJetPacker::pack(const edm::Event& event, const PackerTokens* toks) {
0060       edm::Handle<JetBxCollection> jets;
0061       event.getByToken(static_cast<const CaloTokens*>(toks)->getJetToken(), jets);
0062 
0063       return process(81, 83, *jets, [](const l1t::Jet& jet) -> bool { return jet.hwQual() & 2; });
0064     }
0065 
0066     Blocks TauPacker::pack(const edm::Event& event, const PackerTokens* toks) {
0067       edm::Handle<TauBxCollection> taus;
0068       event.getByToken(static_cast<const CaloTokens*>(toks)->getTauToken(), taus);
0069 
0070       return process(101, 103, *taus, [](const l1t::Tau& tau) -> bool { return true; });
0071     }
0072 
0073     Blocks IsoTauPacker::pack(const edm::Event& event, const PackerTokens* toks) {
0074       edm::Handle<TauBxCollection> taus;
0075       event.getByToken(static_cast<const CaloTokens*>(toks)->getIsoTauToken(), taus);
0076 
0077       return process(105, 107, *taus, [](const l1t::Tau& tau) -> bool { return true; });
0078     }
0079   }  // namespace stage1
0080 }  // namespace l1t
0081 
0082 DEFINE_L1T_PACKER(l1t::stage1::IsoEGammaPacker);
0083 DEFINE_L1T_PACKER(l1t::stage1::NonIsoEGammaPacker);
0084 DEFINE_L1T_PACKER(l1t::stage1::CentralJetPacker);
0085 DEFINE_L1T_PACKER(l1t::stage1::ForwardJetPacker);
0086 DEFINE_L1T_PACKER(l1t::stage1::TauPacker);
0087 DEFINE_L1T_PACKER(l1t::stage1::IsoTauPacker);