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 "CICADAUnpacker.h"
0005 
0006 #include <cmath>
0007 
0008 using namespace edm;
0009 
0010 namespace l1t {
0011   namespace stage2 {
0012     bool CICADAUnpacker::unpack(const Block& block, UnpackerCollections* coll) {
0013       LogDebug("L1T") << "Block Size = " << block.header().getSize();
0014       LogDebug("L1T") << "Board ID = " << block.amc().getBoardID();
0015 
0016       auto res = static_cast<CaloLayer1Collections*>(coll)->getCICADABxCollection();
0017       // default BX range to trigger standard -2 to 2
0018       // Even though CICADA will never have BX information
0019       // And everything gets put in BX 0
0020       res->setBXRange(-2, 2);
0021 
0022       int amc_slot = block.amc().getAMCNumber();
0023       if (not(amc_slot == 7)) {
0024         throw cms::Exception("CICADAUnpacker")
0025             << "Calo Summary (CICADA) unpacker is unpacking an unexpected AMC. Expected AMC number 7, got AMC number "
0026             << amc_slot << std::endl;
0027         return false;
0028       } else {
0029         const uint32_t* base = block.payload().data();
0030         //First 4 bits of the first 4 words are CICADA bits
0031         uint32_t word = (caloCrateCicadaBitsPattern & base[0]) >> 16 | (caloCrateCicadaBitsPattern & base[1]) >> 20 |
0032                         (caloCrateCicadaBitsPattern & base[2]) >> 24 | (caloCrateCicadaBitsPattern & base[3]) >> 28;
0033         float score = static_cast<float>(word) / 256.f;
0034         res->push_back(0, score);
0035         return true;
0036       }
0037     }
0038 
0039   }  // namespace stage2
0040 }  // namespace l1t
0041 
0042 DEFINE_L1T_UNPACKER(l1t::stage2::CICADAUnpacker);