CMS 3D CMS Logo

RPCRecordFormatter.cc
Go to the documentation of this file.
1 
9 
12 
15 
18 
20 
21 
22 
23 #include <bitset>
24 #include <sstream>
25 
26 using namespace std;
27 using namespace edm;
28 using namespace rpcrawtodigi;
29 
30 
32  : currentFED(fedId), readoutMapping(r)
33 { }
34 
36 { }
37 
38 
39 std::vector<EventRecords> RPCRecordFormatter::recordPack(
40  uint32_t rawDetId, const RPCDigi & digi, int trigger_BX) const
41 {
42  std::vector<EventRecords> result;
43 
44  LogTrace("") << " DIGI; det: " << rawDetId<<", strip: "<<digi.strip()<<", bx: "<<digi.bx();
45  int stripInDU = digi.strip();
46 
47  // decode digi<->map
48  typedef std::vector< std::pair< LinkBoardElectronicIndex, LinkBoardPackedStrip> > RawDataFrames;
49  RPCReadOutMapping::StripInDetUnit duFrame(rawDetId, stripInDU);
50  RawDataFrames rawDataFrames = readoutMapping->rawDataFrame(duFrame);
51 
52  for (RawDataFrames::const_iterator ir = rawDataFrames.begin(); ir != rawDataFrames.end(); ir++) {
53 
54  const LinkBoardElectronicIndex & eleIndex = (*ir).first;
55  const LinkBoardPackedStrip & lbPackedStrip = (*ir).second;
56 
57  if (eleIndex.dccId == currentFED) {
58 
59  LogTrace("pack:")
60  <<" dccId= "<<eleIndex.dccId
61  <<" dccInputChannelNum= "<<eleIndex.dccInputChannelNum
62  <<" tbLinkInputNum= "<<eleIndex.tbLinkInputNum
63  <<" lbNumInLink="<<eleIndex.lbNumInLink;
64 
65  // BX
66  int current_BX = trigger_BX+digi.bx();
67  RecordBX bxr(current_BX);
68 
69  // LB
70  int tbLinkInputNumber = eleIndex.tbLinkInputNum;
71  int rmb = eleIndex.dccInputChannelNum;
72  RecordSLD lbr( tbLinkInputNumber, rmb);
73 
74  // CD record
75  int lbInLink = eleIndex.lbNumInLink;
76  int eod = 0;
77  int halfP = 0;
78  int packedStrip = lbPackedStrip.packedStrip();
79  int partitionNumber = packedStrip/8;
80  RecordCD cdr(lbInLink, partitionNumber, eod, halfP, vector<int>(1,packedStrip) );
81 
82  result.push_back( EventRecords(trigger_BX, bxr, lbr, cdr) );
83  }
84  }
85  return result;
86 }
87 
89  const EventRecords & event,
91 {
92 
95  int currentRMB = event.recordSLD().rmb();
96  int currentTbLinkInputNumber = event.recordSLD().tbLinkInputNumber();
97 
98  LinkBoardElectronicIndex eleIndex;
99  eleIndex.dccId = currentFED;
100  eleIndex.dccInputChannelNum = currentRMB;
102  eleIndex.lbNumInLink = event.recordCD().lbInLink();
103 
104 
105  if( event.recordCD().eod() ) {
106  if(counter) counter->addReadoutError(currentFED, ReadoutError(eleIndex,ReadoutError::EOD));
107  }
108 
109  if(readoutMapping == nullptr) return error.type();
110  const LinkBoardSpec* linkBoard = readoutMapping->location(eleIndex);
111  if (!linkBoard) {
112  if (debug) LogDebug("")<<" ** PROBLEM ** Invalid Linkboard location, skip CD event, "
113  << "dccId: "<<eleIndex.dccId
114  << "dccInputChannelNum: " <<eleIndex.dccInputChannelNum
115  << " tbLinkInputNum: "<<eleIndex.tbLinkInputNum
116  << " lbNumInLink: "<<eleIndex.lbNumInLink;
117  error = ReadoutError(eleIndex,ReadoutError::InvalidLB);
118  if(counter) counter->addReadoutError(currentFED,error );
119  return error.type();
120  }
121 
122 
123  std::vector<int> packStrips = event.recordCD().packedStrips();
124  if (packStrips.empty()) {
125  error = ReadoutError(eleIndex,ReadoutError::EmptyPackedStrips);
126  if(counter) counter->addReadoutError(currentFED, error);
127  return error.type();
128  }
129 
130  for(std::vector<int>::iterator is = packStrips.begin(); is != packStrips.end(); ++is) {
131 
134 
135  uint32_t rawDetId = duFrame.first;
136  int geomStrip = duFrame.second;
137  if (!rawDetId) {
138  if (debug) LogTrace("") << " ** PROBLEM ** no rawDetId, skip at least part of CD data";
139  error = ReadoutError(eleIndex,ReadoutError::InvalidDetId);
140  if (counter) counter->addReadoutError(currentFED, error);
141  continue;
142  }
143  if (geomStrip==0) {
144  if(debug) LogTrace("") <<" ** PROBLEM ** no strip found";
145  error = ReadoutError(eleIndex,ReadoutError::InvalidStrip);
146  if (counter) counter->addReadoutError(currentFED, error);
147  continue;
148  }
149 
150  // Creating RPC digi
151  RPCDigi digi(geomStrip,event.dataToTriggerDelay()-3);
152 
154  if (debug) {
155  //LogTrace("") << " LinkBoardElectronicIndex: " << eleIndex.print();
156  LogTrace("")<<" DIGI; det: "<<rawDetId<<", strip: "<<digi.strip()<<", bx: "<<digi.bx();
157  }
158  if (prod) prod->insertDigi(RPCDetId(rawDetId),digi);
159 
160 // if (RPCDetId(rawDetId).region() == -1 ) {
161 // RPCDetId det(rawDetId);
162 // if (det.ring()== 2 ) takeIt = true;
163 // if (det.station() == 1)
164 // takeIt = true;
165 // LogInfo("RPCRecordFormatter") <<"ENDCAP Region: "<<det.region()<<" disk: "<<det.station()<<" ring: "<<det.ring() <<" sector: "<<det.sector()<<" digiBX: "<<digi.bx()<< std::endl;
166 // }
167 
168  }
169 
170  if(synchro) synchro->push_back( make_pair(eleIndex,event.dataToTriggerDelay() ));
171 
172  return error.type();
173 }
#define LogDebug(id)
int eod() const
Definition: RecordCD.cc:32
int bx() const
Definition: RPCDigi.h:28
static MessageDrop * instance()
Definition: MessageDrop.cc:59
std::pair< uint32_t, int > StripInDetUnit
first member is DetUnit ID, second strip in DetUnit frame
int dataToTriggerDelay() const
Definition: EventRecords.cc:11
ReadoutErrorType type() const
Definition: ReadoutError.cc:14
const RecordCD & recordCD() const
Definition: EventRecords.h:39
int strip() const
Definition: RPCDigi.h:27
std::vector< std::pair< LinkBoardElectronicIndex, int > > ProdItem
Definition: RPCRawSynchro.h:9
std::vector< rpcrawtodigi::EventRecords > recordPack(uint32_t rawDetId, const RPCDigi &digi, int trigger_BX) const
virtual StripInDetUnit detUnitFrame(const LinkBoardSpec &location, const LinkBoardPackedStrip &packedStrip) const
convert strip location as in raw data (LB and LBchannel) to detUnit frame
#define LogTrace(id)
virtual const LinkBoardSpec * location(const LinkBoardElectronicIndex &ele) const
conversion between electronic and detector indexing
#define debug
Definition: HDRShower.cc:19
void addReadoutError(int fedId, const rpcrawtodigi::ReadoutError &error, int weight=1)
std::vector< std::pair< LinkBoardElectronicIndex, LinkBoardPackedStrip > > rawDataFrame(const StripInDetUnit &duFrame) const
connection "paths" that lead from one digi to one strip
int recordUnpack(const rpcrawtodigi::EventRecords &event, RPCDigiCollection *prod, RPCRawDataCounts *counter, RPCRawSynchro::ProdItem *synchro)
~RPCRecordFormatter()
Destructor.
HLT enums.
Definition: event.py:1
RPCRecordFormatter(int fedId, const RPCReadOutMapping *readoutMapping)
Creator.
const RPCReadOutMapping * readoutMapping