Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:10:51

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 "L1TObjectCollections.h"
0007 
0008 #include "L1TStage2Layer2Constants.h"
0009 #include "EtSumUnpacker_0x10010057.h"
0010 
0011 namespace l1t {
0012   namespace stage2 {
0013     EtSumUnpacker_0x10010057::EtSumUnpacker_0x10010057() : EtSumCopy_(0) {}
0014 
0015     bool EtSumUnpacker_0x10010057::unpack(const Block& block, UnpackerCollections* coll) {
0016       using namespace l1t::stage2::layer2;
0017 
0018       LogDebug("L1T") << "Block ID  = " << block.header().getID() << " size = " << block.header().getSize();
0019 
0020       int nBX = int(
0021           ceil(block.header().getSize() / demux::nOutputFramePerBX));  // Since there 6 frames per demux output event
0022       // expect the first four frames to be the first 4 EtSum objects reported per event (see CMS IN-2013/005)
0023 
0024       // Find the central, first and last BXs
0025       int firstBX = -(ceil((double)nBX / 2.) - 1);
0026       int lastBX;
0027       if (nBX % 2 == 0) {
0028         lastBX = ceil((double)nBX / 2.);
0029       } else {
0030         lastBX = ceil((double)nBX / 2.) - 1;
0031       }
0032 
0033       auto res_ = static_cast<L1TObjectCollections*>(coll)->getEtSums(EtSumCopy_);
0034       res_->setBXRange(firstBX, lastBX);
0035 
0036       LogDebug("L1T") << "nBX = " << nBX << " first BX = " << firstBX << " lastBX = " << lastBX;
0037 
0038       // Loop over multiple BX and fill EtSums collection
0039       for (int bx = firstBX; bx <= lastBX; bx++) {
0040         // ET
0041         int iFrame = (bx - firstBX) * demux::nOutputFramePerBX;
0042 
0043         uint32_t raw_data = block.payload().at(iFrame);
0044 
0045         l1t::EtSum et{l1t::EtSum::kTotalEt};
0046 
0047         et.setHwPt(raw_data & 0xFFF);
0048         et.setP4(l1t::CaloTools::p4Demux(&et));
0049 
0050         LogDebug("L1T") << "ET: pT " << et.hwPt() << " bx " << bx;
0051 
0052         res_->push_back(bx, et);
0053 
0054         // ET EM
0055 
0056         l1t::EtSum etem{l1t::EtSum::kTotalEtEm};
0057 
0058         etem.setHwPt((raw_data >> 12) & 0xFFF);
0059         etem.setP4(l1t::CaloTools::p4Demux(&etem));
0060 
0061         LogDebug("L1T") << "ETEM: pT " << etem.hwPt() << " bx " << bx;
0062 
0063         res_->push_back(bx, etem);
0064 
0065         // MBHFPT0
0066 
0067         l1t::EtSum mbp0{l1t::EtSum::kMinBiasHFP0};
0068         mbp0.setHwPt((raw_data >> 28) & 0xf);
0069 
0070         res_->push_back(bx, mbp0);
0071 
0072         // HT
0073 
0074         raw_data = block.payload()[iFrame + 1];
0075 
0076         l1t::EtSum ht{l1t::EtSum::kTotalHt};
0077 
0078         ht.setHwPt(raw_data & 0xFFF);
0079         ht.setP4(l1t::CaloTools::p4Demux(&ht));
0080 
0081         LogDebug("L1T") << "HT: pT " << ht.hwPt();
0082 
0083         res_->push_back(bx, ht);
0084 
0085         //MBHFMT0
0086 
0087         l1t::EtSum mbm0{l1t::EtSum::kMinBiasHFM0};
0088         mbm0.setHwPt((raw_data >> 28) & 0xf);
0089 
0090         res_->push_back(bx, mbm0);
0091 
0092         //  MET (no HF)
0093 
0094         raw_data = block.payload()[iFrame + 2];
0095 
0096         l1t::EtSum met{l1t::EtSum::kMissingEt};
0097 
0098         met.setHwPt(raw_data & 0xFFF);
0099         met.setHwPhi((raw_data >> 12) & 0xFF);
0100         met.setP4(l1t::CaloTools::p4Demux(&met));
0101 
0102         LogDebug("L1T") << "MET: phi " << met.hwPhi() << " pT " << met.hwPt() << " bx " << bx;
0103 
0104         res_->push_back(bx, met);
0105 
0106         // MBHFPT1
0107 
0108         l1t::EtSum mbp1{l1t::EtSum::kMinBiasHFP1};
0109         mbp1.setHwPt((raw_data >> 28) & 0xf);
0110 
0111         res_->push_back(bx, mbp1);
0112 
0113         // ET ASYMM
0114 
0115         l1t::EtSum etAsym{l1t::EtSum::kAsymEt};
0116         etAsym.setHwPt((raw_data >> 20) & 0xFF);
0117 
0118         res_->push_back(bx, etAsym);
0119 
0120         // MHT
0121 
0122         raw_data = block.payload()[iFrame + 3];
0123 
0124         l1t::EtSum mht{l1t::EtSum::kMissingHt};
0125 
0126         mht.setHwPt(raw_data & 0xFFF);
0127         mht.setHwPhi((raw_data >> 12) & 0xFF);
0128         mht.setP4(l1t::CaloTools::p4Demux(&mht));
0129 
0130         LogDebug("L1T") << "MHT: phi " << mht.hwPhi() << " pT " << mht.hwPt() << " bx " << bx;
0131 
0132         res_->push_back(bx, mht);
0133 
0134         // MBHFMT1
0135 
0136         l1t::EtSum mbm1{l1t::EtSum::kMinBiasHFM1};
0137         mbm1.setHwPt((raw_data >> 28) & 0xf);
0138 
0139         res_->push_back(bx, mbm1);
0140 
0141         // HT ASYMM
0142 
0143         l1t::EtSum htAsym{l1t::EtSum::kAsymHt};
0144         htAsym.setHwPt((raw_data >> 20) & 0xFF);
0145 
0146         res_->push_back(bx, htAsym);
0147 
0148         //  MET (with HF)
0149 
0150         raw_data = block.payload()[iFrame + 4];
0151 
0152         l1t::EtSum methf{l1t::EtSum::kMissingEtHF};
0153 
0154         methf.setHwPt(raw_data & 0xFFF);
0155         methf.setHwPhi((raw_data >> 12) & 0xFF);
0156         methf.setP4(l1t::CaloTools::p4Demux(&methf));
0157 
0158         LogDebug("L1T") << "METHF: phi " << methf.hwPhi() << " pT " << methf.hwPt() << " bx " << bx;
0159 
0160         res_->push_back(bx, methf);
0161 
0162         // ETHF ASYMM
0163 
0164         l1t::EtSum etHFAsym{l1t::EtSum::kAsymEtHF};
0165         etHFAsym.setHwPt((raw_data >> 20) & 0xFF);
0166 
0167         res_->push_back(bx, etHFAsym);
0168 
0169         // CENTRALITY LOWER NIB
0170 
0171         uint32_t centLN = ((raw_data >> 28) & 0xF);
0172 
0173         // MHT with HF
0174 
0175         raw_data = block.payload()[iFrame + 5];
0176 
0177         l1t::EtSum mhthf{l1t::EtSum::kMissingHtHF};
0178 
0179         mhthf.setHwPt(raw_data & 0xFFF);
0180         mhthf.setHwPhi((raw_data >> 12) & 0xFF);
0181         mhthf.setP4(l1t::CaloTools::p4Demux(&mhthf));
0182 
0183         LogDebug("L1T") << "MHThf: phi " << mhthf.hwPhi() << " pT " << mhthf.hwPt() << " bx " << bx;
0184 
0185         res_->push_back(bx, mhthf);
0186 
0187         // HTHF ASYMM
0188 
0189         l1t::EtSum htHFAsym{l1t::EtSum::kAsymHtHF};
0190         htHFAsym.setHwPt((raw_data >> 20) & 0xFF);
0191 
0192         res_->push_back(bx, htHFAsym);
0193 
0194         // CENTRALITY UPPER NIB
0195 
0196         uint32_t centUN = ((raw_data >> 28) & 0xF);
0197 
0198         l1t::EtSum cent{l1t::EtSum::kCentrality};
0199         cent.setHwPt((centUN << 4) | centLN);
0200 
0201         res_->push_back(bx, cent);
0202 
0203         //HI-SUM
0204 
0205         raw_data = block.payload()[iFrame + 1];
0206 
0207         l1t::EtSum towCount{l1t::EtSum::kTowerCount};
0208         towCount.setHwPt((raw_data >> 12) & 0x1FFF);
0209         towCount.setP4(l1t::CaloTools::p4Demux(&towCount));
0210 
0211         res_->push_back(bx, towCount);
0212       }
0213 
0214       return true;
0215     }
0216   }  // namespace stage2
0217 }  // namespace l1t
0218 
0219 DEFINE_L1T_UNPACKER(l1t::stage2::EtSumUnpacker_0x10010057);