Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-28 03:09:50

0001 #include "EventFilter/L1TRawToDigi/interface/OmtfRpcPacker.h"
0002 
0003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0004 
0005 #include "CondFormats/RPCObjects/interface/RPCReadOutMapping.h"
0006 #include "EventFilter/RPCRawToDigi/interface/RPCRecordFormatter.h"
0007 #include "EventFilter/RPCRawToDigi/interface/RPCPackingModule.h"
0008 #include "EventFilter/RPCRawToDigi/interface/DebugDigisPrintout.h"
0009 #include "CondFormats/RPCObjects/interface/RPCEMap.h"
0010 #include "EventFilter/L1TRawToDigi/interface/OmtfRpcDataWord64.h"
0011 
0012 namespace omtf {
0013 
0014   void RpcPacker::initCabling(const RPCEMap& readoutMapping) {
0015     thePactCabling.reset(readoutMapping.convert());
0016     LogDebug("OmtfPacker") << " Has PACT readout map, VERSION: " << thePactCabling->version() << std::endl;
0017   }
0018 
0019   void RpcPacker::init(const RPCEMap& readoutMapping, const RPCAMCLinkMap& linkMap) {
0020     initCabling(readoutMapping);
0021     RpcLinkMap omtfLink2Ele;
0022     omtfLink2Ele.init(linkMap);
0023     thePact2Omtf = translatePact2Omtf(omtfLink2Ele, thePactCabling.get());
0024   }
0025 
0026   void RpcPacker::init(const RPCEMap& readoutMapping, const std::string& connectionFile) {
0027     initCabling(readoutMapping);
0028     RpcLinkMap omtfLink2Ele;
0029     omtfLink2Ele.init(connectionFile);
0030     thePact2Omtf = translatePact2Omtf(omtfLink2Ele, thePactCabling.get());
0031   }
0032 
0033   void RpcPacker::pack(const RPCDigiCollection* digis, FedAmcRawsMap& raws) {
0034     LogTrace("") << " HERE HERE !!! RPC PACKER" << rpcrawtodigi::DebugDigisPrintout()(digis);
0035     for (int dcc = 790; dcc <= 792; dcc++) {
0036       RPCRecordFormatter formatter(dcc, thePactCabling.get());
0037       const std::vector<rpcrawtodigi::EventRecords>& merged =
0038           RPCPackingModule::eventRecords(dcc, 200, digis, formatter);
0039       LogTrace("") << " SIZE OF MERGED, for DCC=" << dcc << " is: " << merged.size() << std::endl;
0040       for (const auto& rpcEvent : merged) {
0041         RpcDataWord64 data;
0042         data.bxNum_ = rpcEvent.dataToTriggerDelay();
0043         data.frame1_ = rpcEvent.recordCD().data();
0044         LinkBoardElectronicIndex rpcEle = {
0045             dcc, rpcEvent.recordSLD().rmb(), rpcEvent.recordSLD().tbLinkInputNumber(), rpcEvent.recordCD().lbInLink()};
0046         auto it = thePact2Omtf.find(rpcEle);
0047         if (it != thePact2Omtf.end()) {
0048           const EleIndex& omtfEle1 = it->second.first;
0049           const EleIndex& omtfEle2 = it->second.second;
0050           if (omtfEle1.fed()) {
0051             data.linkNum_ = omtfEle1.link();
0052             raws[std::make_pair(omtfEle1.fed(), omtfEle1.amc() * 2 - 1)].push_back(data.rawData);
0053           }
0054           if (omtfEle2.fed()) {
0055             data.linkNum_ = omtfEle2.link();
0056             raws[std::make_pair(omtfEle2.fed(), omtfEle2.amc() * 2 - 1)].push_back(data.rawData);
0057           }
0058         }
0059       }
0060     }
0061   }
0062 
0063 };  // namespace omtf