Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-06-28 02:36:16

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 "DataFormats/L1CaloTrigger/interface/CICADA.h"
0009 
0010 #include "CaloSummaryUnpacker.h"
0011 #include "GTSetup.h"
0012 
0013 #include <cmath>
0014 
0015 bool l1t::stage2::CaloSummaryUnpacker::unpack(const Block& block, UnpackerCollections* coll) {
0016   LogDebug("L1T") << "Block ID  = " << block.header().getID() << " size = " << block.header().getSize();
0017 
0018   //Just a few things to help us handle the number of BXs
0019   //Strictly, we should generally get five BXs, starting at -2, and going to 2
0020   //With the central BX at 0. The frames count up from -2
0021   int nBX = int(ceil(block.header().getSize() / nFramesPerEvent));
0022   int firstBX = (nBX / 2) - nBX + 1;
0023   int lastBX = nBX / 2;
0024   int processedBXs = 0;  //This will just help us keep track of what words we are grabbing
0025 
0026   auto res_ = static_cast<L1TObjectCollections*>(coll)->getCICADAScore();
0027   res_->setBXRange(firstBX, lastBX);
0028 
0029   for (int bx = firstBX; bx <= lastBX; ++bx) {
0030     unsigned short baseLocation = processedBXs * nFramesPerEvent;
0031     const uint32_t* base = block.payload().data() + baseLocation;
0032     //The take the first 4 bits of the first 4 words, and arrange them in order
0033     uint32_t word = (cicadaBitsPattern & base[0]) >> 16 | (cicadaBitsPattern & base[1]) >> 20 |
0034                     (cicadaBitsPattern & base[2]) >> 24 | (cicadaBitsPattern & base[3]) >> 28;
0035     //The score needs to be shifted 8 bits over the decimal point
0036     float score = static_cast<float>(word) / 256.f;
0037     res_->push_back(bx, score);
0038     ++processedBXs;  //index BXs
0039   }
0040 
0041   return true;
0042 }
0043 
0044 DEFINE_L1T_UNPACKER(l1t::stage2::CaloSummaryUnpacker);