CMS 3D CMS Logo

OmtfRpcUnpacker.cc
Go to the documentation of this file.
2 
6 
13 
18 
19 namespace omtf {
20 
22 {
23  edm::ESTransientHandle<RPCEMap> readoutMapping;
24  es.get<RPCEMapRcd>().get(readoutMapping);
25  thePactCabling.reset(readoutMapping->convert());
26 
27  LogDebug("OmtfUnpacker") <<" Has PACT readout map, VERSION: " << thePactCabling->version() << std::endl;
28 }
29 
31 {
32  initCabling(es);
33  RpcLinkMap omtfLink2Ele;
34  omtfLink2Ele.init(es);
35  theOmtf2Pact = translateOmtf2Pact(omtfLink2Ele,thePactCabling.get());
36 }
37 
38 void RpcUnpacker::init(const edm::EventSetup & es, const std::string & connectionFile)
39 {
40  initCabling(es);
41  RpcLinkMap omtfLink2Ele;
42  omtfLink2Ele.init(connectionFile);
43  theOmtf2Pact = translateOmtf2Pact(omtfLink2Ele,thePactCabling.get());
44 }
45 
46 void RpcUnpacker::unpack(int triggerBX, unsigned int fed, unsigned int amc, const RpcDataWord64 &data, RPCDigiCollection * prod)
47 {
48  LogTrace("RpcUnpacker:") << data;
49 
50 // EleIndex omtfEle(fedHeader.sourceID(), bh.getAMCNumber()/2+1, data.linkNum());
51  EleIndex omtfEle(fed, amc, data.linkNum());
52  LinkBoardElectronicIndex rpcEle = theOmtf2Pact.at(omtfEle);
53  RPCRecordFormatter formater(rpcEle.dccId, thePactCabling.get());
54 
55 
56  rpcrawtodigi::EventRecords records(triggerBX);
57  rpcrawtodigi::RecordBX recordBX(triggerBX+data.bxNum()-3);
58  records.add(recordBX); // warning: event records must be added in right order
59  rpcrawtodigi::RecordSLD recordSLD(rpcEle.tbLinkInputNum, rpcEle.dccInputChannelNum);
60  records.add(recordSLD); // warning: event records must be added in right order
61 
62  for (unsigned int iframe=1; iframe <=3; iframe++) {
63 
64  uint16_t frame = (iframe==1) ? data.frame1() : ( (iframe==2) ? data.frame2() : data.frame3() );
65  if (frame==0) continue;
66  rpcrawtodigi::RecordCD recordCD(frame);
67  records.add(recordCD);
68 
69  LogTrace("") <<"OMTF->RPC Event isComplete: "<<records.complete() <<records.print(rpcrawtodigi::DataRecord::StartOfBXData); // << std::endl;
70  LogTrace("") <<"OMTF->RPC Event: "<<records.print(rpcrawtodigi::DataRecord::StartOfTbLinkInputNumberData) << std::endl;
71  LogTrace("") <<"OMTF->RPC Event: "<<records.print(rpcrawtodigi::DataRecord::ChamberData)
72  <<" lb:"<< recordCD.lbInLink()
73  <<" part: "<< recordCD.partitionNumber()
74  <<" partData: "<<recordCD.partitionData()
75  << std::endl << std::endl;
76 
77  if (records.complete()) formater.recordUnpack( records, prod, nullptr,nullptr);
78  }
79 }
80 }
#define LogDebug(id)
void init(const edm::EventSetup &es)
int lbInLink() const
Definition: RecordCD.cc:28
unsigned int frame3() const
unsigned int linkNum() const
unsigned int frame2() const
void initCabling(const edm::EventSetup &es)
int partitionData() const
Definition: RecordCD.cc:36
void unpack(int triggerBX, unsigned int fed, unsigned int amc, const RpcDataWord64 &raw, RPCDigiCollection *prod)
#define LogTrace(id)
int partitionNumber() const
Definition: RecordCD.cc:30
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
MapEleIndex2LBIndex translateOmtf2Pact(const RpcLinkMap &omtfLnks, const RPCReadOutMapping *pactCabling)
T get() const
Definition: EventSetup.h:71
std::unique_ptr< const RPCReadOutMapping > thePactCabling
RPCReadOutMapping const * convert() const
Definition: RPCEMap.h:67
void init(const edm::EventSetup &es)
unsigned int frame1() const
Definition: AMCSpec.h:8
MapEleIndex2LBIndex theOmtf2Pact
unsigned int bxNum() const