Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "EventFilter/L1TRawToDigi/interface/OmtfRpcUnpacker.h"
0002 
0003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0004 
0005 #include "EventFilter/RPCRawToDigi/interface/RPCRecordFormatter.h"
0006 #include "EventFilter/RPCRawToDigi/interface/RPCPackingModule.h"
0007 #include "EventFilter/RPCRawToDigi/interface/DebugDigisPrintout.h"
0008 #include "CondFormats/RPCObjects/interface/RPCEMap.h"
0009 #include "CondFormats/DataRecord/interface/RPCEMapRcd.h"
0010 #include "EventFilter/L1TRawToDigi/interface/OmtfRpcDataWord64.h"
0011 
0012 #include "DataFormats/RPCDigi/interface/DataRecord.h"
0013 #include "DataFormats/RPCDigi/interface/RecordBX.h"
0014 #include "DataFormats/RPCDigi/interface/RecordSLD.h"
0015 #include "DataFormats/RPCDigi/interface/RecordCD.h"
0016 
0017 namespace omtf {
0018 
0019   void RpcUnpacker::initCabling(const RPCEMap& readoutMapping) {
0020     thePactCabling.reset(readoutMapping.convert());
0021 
0022     LogDebug("OmtfUnpacker") << " Has PACT readout map, VERSION: " << thePactCabling->version() << std::endl;
0023   }
0024 
0025   void RpcUnpacker::init(const RPCEMap& readoutMapping, const RPCAMCLinkMap& linkMap) {
0026     initCabling(readoutMapping);
0027     RpcLinkMap omtfLink2Ele;
0028     omtfLink2Ele.init(linkMap);
0029     theOmtf2Pact = translateOmtf2Pact(omtfLink2Ele, thePactCabling.get());
0030   }
0031 
0032   void RpcUnpacker::init(const RPCEMap& readoutMapping, const std::string& connectionFile) {
0033     initCabling(readoutMapping);
0034     RpcLinkMap omtfLink2Ele;
0035     omtfLink2Ele.init(connectionFile);
0036     theOmtf2Pact = translateOmtf2Pact(omtfLink2Ele, thePactCabling.get());
0037   }
0038 
0039   void RpcUnpacker::unpack(
0040       int triggerBX, unsigned int fed, unsigned int amc, const RpcDataWord64& data, RPCDigiCollection* prod) {
0041     LogTrace("RpcUnpacker:") << data;
0042 
0043     //  EleIndex omtfEle(fedHeader.sourceID(), bh.getAMCNumber()/2+1, data.linkNum());
0044     EleIndex omtfEle(fed, amc, data.linkNum());
0045     LinkBoardElectronicIndex rpcEle = theOmtf2Pact.at(omtfEle);
0046     RPCRecordFormatter formater(rpcEle.dccId, thePactCabling.get());
0047 
0048     rpcrawtodigi::EventRecords records(triggerBX);
0049     rpcrawtodigi::RecordBX recordBX(triggerBX + data.bxNum() - 3);
0050     records.add(recordBX);  // warning: event records must be added in right order
0051     rpcrawtodigi::RecordSLD recordSLD(rpcEle.tbLinkInputNum, rpcEle.dccInputChannelNum);
0052     records.add(recordSLD);  // warning: event records must be added in right order
0053 
0054     for (unsigned int iframe = 1; iframe <= 3; iframe++) {
0055       uint16_t frame = (iframe == 1) ? data.frame1() : ((iframe == 2) ? data.frame2() : data.frame3());
0056       if (frame == 0)
0057         continue;
0058       rpcrawtodigi::RecordCD recordCD(frame);
0059       records.add(recordCD);
0060 
0061       LogTrace("") << "OMTF->RPC Event isComplete: " << records.complete()
0062                    << records.print(rpcrawtodigi::DataRecord::StartOfBXData);  // << std::endl;
0063       LogTrace("") << "OMTF->RPC Event:             "
0064                    << records.print(rpcrawtodigi::DataRecord::StartOfTbLinkInputNumberData) << std::endl;
0065       LogTrace("") << "OMTF->RPC Event:             " << records.print(rpcrawtodigi::DataRecord::ChamberData)
0066                    << " lb:" << recordCD.lbInLink() << " part: " << recordCD.partitionNumber()
0067                    << " partData: " << recordCD.partitionData() << std::endl
0068                    << std::endl;
0069 
0070       if (records.complete())
0071         formater.recordUnpack(records, prod, nullptr, nullptr);
0072     }
0073   }
0074 }  // namespace omtf