CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
RPCRecordFormatter Class Reference

#include <RPCRecordFormatter.h>

Public Member Functions

std::vector< rpcrawtodigi::EventRecordsrecordPack (uint32_t rawDetId, const RPCDigi &digi, int trigger_BX) const
 
int recordUnpack (const rpcrawtodigi::EventRecords &event, RPCDigiCollection *prod, RPCRawDataCounts *counter, RPCRawSynchro::ProdItem *synchro)
 
 RPCRecordFormatter (int fedId, const RPCReadOutMapping *readoutMapping)
 Creator. More...
 
 ~RPCRecordFormatter ()
 Destructor. More...
 

Private Attributes

int currentFED
 
int currentTbLinkInputNumber
 
const RPCReadOutMappingreadoutMapping
 

Detailed Description

Definition at line 15 of file RPCRecordFormatter.h.

Constructor & Destructor Documentation

◆ RPCRecordFormatter()

RPCRecordFormatter::RPCRecordFormatter ( int  fedId,
const RPCReadOutMapping readoutMapping 
)

◆ ~RPCRecordFormatter()

RPCRecordFormatter::~RPCRecordFormatter ( )

Destructor.

Definition at line 30 of file RPCRecordFormatter.cc.

30 {}

Member Function Documentation

◆ recordPack()

std::vector< EventRecords > RPCRecordFormatter::recordPack ( uint32_t  rawDetId,
const RPCDigi digi,
int  trigger_BX 
) const

Definition at line 32 of file RPCRecordFormatter.cc.

References RPCDigi::bx(), currentFED, LinkBoardElectronicIndex::dccId, LinkBoardElectronicIndex::dccInputChannelNum, LinkBoardElectronicIndex::lbNumInLink, LogTrace, LinkBoardPackedStrip::packedStrip(), RPCReadOutMapping::rawDataFrame(), readoutMapping, mps_fire::result, RPCDigi::strip(), and LinkBoardElectronicIndex::tbLinkInputNum.

32  {
33  std::vector<EventRecords> result;
34 
35  LogTrace("") << " DIGI; det: " << rawDetId << ", strip: " << digi.strip() << ", bx: " << digi.bx();
36  int stripInDU = digi.strip();
37 
38  // decode digi<->map
39  typedef std::vector<std::pair<LinkBoardElectronicIndex, LinkBoardPackedStrip> > RawDataFrames;
40  RPCReadOutMapping::StripInDetUnit duFrame(rawDetId, stripInDU);
41  RawDataFrames rawDataFrames = readoutMapping->rawDataFrame(duFrame);
42 
43  for (RawDataFrames::const_iterator ir = rawDataFrames.begin(); ir != rawDataFrames.end(); ir++) {
44  const LinkBoardElectronicIndex& eleIndex = (*ir).first;
45  const LinkBoardPackedStrip& lbPackedStrip = (*ir).second;
46 
47  if (eleIndex.dccId == currentFED) {
48  LogTrace("pack:") << " dccId= " << eleIndex.dccId << " dccInputChannelNum= " << eleIndex.dccInputChannelNum
49  << " tbLinkInputNum= " << eleIndex.tbLinkInputNum << " lbNumInLink=" << eleIndex.lbNumInLink;
50 
51  // BX
52  int current_BX = trigger_BX + digi.bx();
53  RecordBX bxr(current_BX);
54 
55  // LB
56  int tbLinkInputNumber = eleIndex.tbLinkInputNum;
57  int rmb = eleIndex.dccInputChannelNum;
58  RecordSLD lbr(tbLinkInputNumber, rmb);
59 
60  // CD record
61  int lbInLink = eleIndex.lbNumInLink;
62  int eod = 0;
63  int halfP = 0;
64  int packedStrip = lbPackedStrip.packedStrip();
65  int partitionNumber = packedStrip / 8;
66  RecordCD cdr(lbInLink, partitionNumber, eod, halfP, vector<int>(1, packedStrip));
67 
68  result.push_back(EventRecords(trigger_BX, bxr, lbr, cdr));
69  }
70  }
71  return result;
72 }
int bx() const
Definition: RPCDigi.h:28
#define LogTrace(id)
std::vector< std::pair< LinkBoardElectronicIndex, LinkBoardPackedStrip > > rawDataFrame(const StripInDetUnit &duFrame) const
connection "paths" that lead from one digi to one strip
int strip() const
Definition: RPCDigi.h:27
std::pair< uint32_t, int > StripInDetUnit
first member is DetUnit ID, second strip in DetUnit frame
const RPCReadOutMapping * readoutMapping

◆ recordUnpack()

int RPCRecordFormatter::recordUnpack ( const rpcrawtodigi::EventRecords event,
RPCDigiCollection prod,
RPCRawDataCounts counter,
RPCRawSynchro::ProdItem synchro 
)

Committing digi to the product

Definition at line 74 of file RPCRecordFormatter.cc.

References currentFED, currentTbLinkInputNumber, LinkBoardElectronicIndex::dccId, LinkBoardElectronicIndex::dccInputChannelNum, debug, edm::MessageDrop::debugEnabled, RPCReadOutMapping::detUnitFrame(), relativeConstraints::error, edm::MessageDrop::instance(), LinkBoardElectronicIndex::lbNumInLink, RPCReadOutMapping::location(), LogDebug, LogTrace, dumpMFGeometry_cfg::prod, readoutMapping, and LinkBoardElectronicIndex::tbLinkInputNum.

Referenced by RPCUnpackingModule::produce().

77  {
80  int currentRMB = event.recordSLD().rmb();
81  int currentTbLinkInputNumber = event.recordSLD().tbLinkInputNumber();
82 
83  LinkBoardElectronicIndex eleIndex;
84  eleIndex.dccId = currentFED;
85  eleIndex.dccInputChannelNum = currentRMB;
87  eleIndex.lbNumInLink = event.recordCD().lbInLink();
88 
89  if (event.recordCD().eod()) {
90  if (counter)
91  counter->addReadoutError(currentFED, ReadoutError(eleIndex, ReadoutError::EOD));
92  }
93 
94  if (readoutMapping == nullptr)
95  return error.type();
96  const LinkBoardSpec* linkBoard = readoutMapping->location(eleIndex);
97  if (!linkBoard) {
98  if (debug)
99  LogDebug("") << " ** PROBLEM ** Invalid Linkboard location, skip CD event, "
100  << "dccId: " << eleIndex.dccId << "dccInputChannelNum: " << eleIndex.dccInputChannelNum
101  << " tbLinkInputNum: " << eleIndex.tbLinkInputNum << " lbNumInLink: " << eleIndex.lbNumInLink;
102  error = ReadoutError(eleIndex, ReadoutError::InvalidLB);
103  if (counter)
104  counter->addReadoutError(currentFED, error);
105  return error.type();
106  }
107 
108  std::vector<int> packStrips = event.recordCD().packedStrips();
109  if (packStrips.empty()) {
110  error = ReadoutError(eleIndex, ReadoutError::EmptyPackedStrips);
111  if (counter)
112  counter->addReadoutError(currentFED, error);
113  return error.type();
114  }
115 
116  for (std::vector<int>::iterator is = packStrips.begin(); is != packStrips.end(); ++is) {
118 
119  uint32_t rawDetId = duFrame.first;
120  int geomStrip = duFrame.second;
121  if (!rawDetId) {
122  if (debug)
123  LogTrace("") << " ** PROBLEM ** no rawDetId, skip at least part of CD data";
124  error = ReadoutError(eleIndex, ReadoutError::InvalidDetId);
125  if (counter)
126  counter->addReadoutError(currentFED, error);
127  continue;
128  }
129  if (geomStrip == 0) {
130  if (debug)
131  LogTrace("") << " ** PROBLEM ** no strip found";
132  error = ReadoutError(eleIndex, ReadoutError::InvalidStrip);
133  if (counter)
134  counter->addReadoutError(currentFED, error);
135  continue;
136  }
137 
138  // Creating RPC digi
139  RPCDigi digi(geomStrip, event.dataToTriggerDelay() - 3);
140 
142  if (debug) {
143  //LogTrace("") << " LinkBoardElectronicIndex: " << eleIndex.print();
144  LogTrace("") << " DIGI; det: " << rawDetId << ", strip: " << digi.strip() << ", bx: " << digi.bx();
145  }
146  if (prod)
147  prod->insertDigi(RPCDetId(rawDetId), digi);
148 
149  // if (RPCDetId(rawDetId).region() == -1 ) {
150  // RPCDetId det(rawDetId);
151  // if (det.ring()== 2 ) takeIt = true;
152  // if (det.station() == 1)
153  // takeIt = true;
154  // LogInfo("RPCRecordFormatter") <<"ENDCAP Region: "<<det.region()<<" disk: "<<det.station()<<" ring: "<<det.ring() <<" sector: "<<det.sector()<<" digiBX: "<<digi.bx()<< std::endl;
155  // }
156  }
157 
158  if (synchro)
159  synchro->push_back(make_pair(eleIndex, event.dataToTriggerDelay()));
160 
161  return error.type();
162 }
static MessageDrop * instance()
Definition: MessageDrop.cc:33
#define LogTrace(id)
virtual const LinkBoardSpec * location(const LinkBoardElectronicIndex &ele) const
conversion between electronic and detector indexing
#define debug
Definition: HDRShower.cc:19
virtual StripInDetUnit detUnitFrame(const LinkBoardSpec &location, const LinkBoardPackedStrip &packedStrip) const
convert strip location as in raw data (LB and LBchannel) to detUnit frame
Definition: event.py:1
std::pair< uint32_t, int > StripInDetUnit
first member is DetUnit ID, second strip in DetUnit frame
#define LogDebug(id)
const RPCReadOutMapping * readoutMapping

Member Data Documentation

◆ currentFED

int RPCRecordFormatter::currentFED
private

Definition at line 31 of file RPCRecordFormatter.h.

Referenced by recordPack(), and recordUnpack().

◆ currentTbLinkInputNumber

int RPCRecordFormatter::currentTbLinkInputNumber
private

Definition at line 32 of file RPCRecordFormatter.h.

Referenced by recordUnpack().

◆ readoutMapping

const RPCReadOutMapping* RPCRecordFormatter::readoutMapping
private

Definition at line 34 of file RPCRecordFormatter.h.

Referenced by recordPack(), and recordUnpack().