Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0002 #include "EventFilter/L1TRawToDigi/plugins/UnpackerFactory.h"
0003 
0004 #include "L1Trigger/L1TCalorimeter/interface/CaloTools.h"
0005 
0006 #include "CaloCollections.h"
0007 #include "MPUnpacker_0x1001000b.h"
0008 
0009 namespace l1t {
0010   namespace stage2 {
0011 
0012     int MPUnpacker_0x1001000b::etaSign(int blkId) {
0013       if ((blkId == BLK_TOT_NEG) || (blkId == BLK_X_NEG) || (blkId == BLK_Y_NEG)) {
0014         return -1;
0015       }
0016       return 1;
0017     }
0018 
0019     bool MPUnpacker_0x1001000b::unpack(const Block& block, UnpackerCollections* coll) {
0020       LogDebug("L1T") << "Block ID  = " << block.header().getID() << " size = " << block.header().getSize()
0021                       << " AMC = " << block.amc().getAMCNumber();
0022 
0023       // check this is the correct MP
0024       unsigned int amc = block.amc().getAMCNumber();
0025       unsigned int bxid = block.amc().getBX();
0026       LogDebug("L1T") << "Unpacking AMC " << amc << " for BX " << bxid;
0027 
0028       auto res1_ = static_cast<CaloCollections*>(coll)->getMPJets();
0029       auto res2_ = static_cast<CaloCollections*>(coll)->getMPEtSums();
0030       auto res3_ = static_cast<CaloCollections*>(coll)->getMPEGammas();
0031       auto res4_ = static_cast<CaloCollections*>(coll)->getMPTaus();
0032 
0033       res1_->setBXRange(0, 0);
0034       res2_->setBXRange(0, 0);
0035       res3_->setBXRange(0, 0);
0036       res4_->setBXRange(0, 0);
0037 
0038       // Initialise frame indices for each data type
0039       int unsigned fet = 0;
0040       int unsigned fht = 2;
0041       int unsigned feg = 3;
0042       int unsigned ftau = 5;
0043       int unsigned fjet = 7;
0044 
0045       //      ===== Jets and Sums =====
0046 
0047       // ET / MET(x) / MET (y)
0048 
0049       uint32_t raw_data = block.payload()[fet];
0050 
0051       l1t::EtSum et = l1t::EtSum();
0052 
0053       switch (block.header().getID()) {
0054         case BLK_TOT_POS:
0055           et.setType(l1t::EtSum::kTotalEt);
0056           et.setHwPt((uint32_t(raw_data & 0xFFFFFF) << 16) >> 16);
0057           break;
0058         case BLK_X_POS:
0059           et.setType(l1t::EtSum::kTotalEtx);
0060           et.setHwPt((uint32_t(raw_data)));
0061           break;
0062         case BLK_Y_POS:
0063           et.setType(l1t::EtSum::kTotalEty);
0064           et.setHwPt((uint32_t(raw_data)));
0065           break;
0066         case BLK_TOT_NEG:
0067           et.setType(l1t::EtSum::kTotalEt);
0068           et.setHwPt((uint32_t(raw_data & 0xFFFFFF) << 16) >> 16);
0069           break;
0070         case BLK_X_NEG:
0071           et.setType(l1t::EtSum::kTotalEtx);
0072           et.setHwPt((uint32_t(raw_data)));
0073           break;
0074         case BLK_Y_NEG:
0075           et.setType(l1t::EtSum::kTotalEty);
0076           et.setHwPt((uint32_t(raw_data)));
0077           break;
0078         default:
0079           break;
0080       }
0081 
0082       LogDebug("L1T") << "ET/METx/METy: pT " << et.hwPt();
0083 
0084       res2_->push_back(0, et);
0085 
0086       // HT / MHT(x)/ MHT (y)
0087 
0088       raw_data = block.payload()[fht];
0089 
0090       l1t::EtSum ht = l1t::EtSum();
0091 
0092       //ht.setHwPt(raw_data & 0xFFFFF);
0093       ht.setHwPt((uint32_t(raw_data & 0xFFFFFF) << 16) >> 16);
0094       switch (block.header().getID()) {
0095         case BLK_TOT_POS:
0096           ht.setType(l1t::EtSum::kTotalHt);
0097           break;
0098         case BLK_X_POS:
0099           ht.setType(l1t::EtSum::kTotalHtx);
0100           break;
0101         case BLK_Y_POS:
0102           ht.setType(l1t::EtSum::kTotalHty);
0103           break;
0104         case BLK_TOT_NEG:
0105           ht.setType(l1t::EtSum::kTotalHt);
0106           break;
0107         case BLK_X_NEG:
0108           ht.setType(l1t::EtSum::kTotalHtx);
0109           break;
0110         case BLK_Y_NEG:
0111           ht.setType(l1t::EtSum::kTotalHty);
0112           break;
0113         default:
0114           break;
0115       }
0116 
0117       LogDebug("L1T") << "HT/MHTx/MHTy: pT " << ht.hwPt();
0118 
0119       res2_->push_back(0, ht);
0120 
0121       // Two jets
0122       for (unsigned nJet = 0; nJet < 2; nJet++) {
0123         raw_data = block.payload()[fjet + nJet];
0124 
0125         if (raw_data == 0)
0126           continue;
0127 
0128         l1t::Jet jet = l1t::Jet();
0129 
0130         int etasign = etaSign(block.header().getID());
0131 
0132         LogDebug("L1") << "block ID=" << block.header().getID() << " etasign=" << etasign;
0133 
0134         int mpEta = etasign * (raw_data & 0x3F);
0135         jet.setHwEta(CaloTools::caloEta(mpEta));
0136         jet.setHwPhi((raw_data >> 6) & 0x7F);
0137         jet.setHwPt((raw_data >> 13) & 0xFFFF);
0138         jet.setHwQual((raw_data >> 29) & 0x1);
0139 
0140         LogDebug("L1T") << "Jet: eta " << jet.hwEta() << " phi " << jet.hwPhi() << " pT " << jet.hwPt() << " qual "
0141                         << jet.hwQual();
0142 
0143         jet.setP4(l1t::CaloTools::p4MP(&jet));
0144         res1_->push_back(0, jet);
0145       }
0146 
0147       //      ===== EGammas =====
0148 
0149       // Two EGammas
0150 
0151       for (unsigned nEG = 0; nEG < 2; nEG++) {
0152         raw_data = block.payload()[feg + nEG];
0153 
0154         if (raw_data == 0)
0155           continue;
0156 
0157         l1t::EGamma eg = l1t::EGamma();
0158 
0159         int etasign = etaSign(block.header().getID());
0160 
0161         LogDebug("L1") << "block ID=" << block.header().getID() << " etasign=" << etasign;
0162 
0163         eg.setHwEta(etasign * ((raw_data >> 3) & 0x3F));
0164         eg.setHwPhi((raw_data >> 9) & 0x7F);
0165         eg.setHwPt((raw_data >> 20) & 0xFFF);
0166         eg.setHwIso((raw_data >> 1) & 0x3);
0167         eg.setHwQual((raw_data >> 16) & 0xf);
0168 
0169         LogDebug("L1T") << "Egamma: eta " << eg.hwEta() << " phi " << eg.hwPhi() << " pT " << eg.hwPt() << " qual "
0170                         << eg.hwQual();
0171 
0172         eg.setP4(l1t::CaloTools::p4MP(&eg));
0173         res3_->push_back(0, eg);
0174       }
0175 
0176       //      ===== Taus =====
0177 
0178       // Two taus
0179 
0180       for (unsigned nTau = 0; nTau < 2; nTau++) {
0181         raw_data = block.payload()[ftau + nTau];
0182 
0183         if (raw_data == 0)
0184           continue;
0185 
0186         l1t::Tau tau = l1t::Tau();
0187 
0188         int etasign = etaSign(block.header().getID());
0189 
0190         LogDebug("L1") << "block ID=" << block.header().getID() << " etasign=" << etasign;
0191 
0192         tau.setHwEta(etasign * ((raw_data >> 3) & 0x3F));
0193         tau.setHwPhi((raw_data >> 9) & 0x7F);
0194         tau.setHwPt((raw_data >> 20) & 0xFFF);
0195         tau.setHwIso((raw_data >> 1) & 0x3);
0196         tau.setHwQual((raw_data >> 16) & 0xf);
0197 
0198         LogDebug("L1T") << "Tau: eta " << tau.hwEta() << " phi " << tau.hwPhi() << " pT " << tau.hwPt() << " qual "
0199                         << tau.hwQual();
0200 
0201         tau.setP4(l1t::CaloTools::p4MP(&tau));
0202         res4_->push_back(0, tau);
0203       }
0204 
0205       return true;
0206     }
0207   }  // namespace stage2
0208 }  // namespace l1t
0209 
0210 DEFINE_L1T_UNPACKER(l1t::stage2::MPUnpacker_0x1001000b);