CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
RPCRecordFormatter Class Reference

#include <RPCRecordFormatter.h>

Public Member Functions

std::vector
< rpcrawtodigi::EventRecords
recordPack (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 17 of file RPCRecordFormatter.h.

Constructor & Destructor Documentation

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

Creator.

Definition at line 33 of file RPCRecordFormatter.cc.

34  : currentFED(fedId), readoutMapping(r)
35 { }
const RPCReadOutMapping * readoutMapping
RPCRecordFormatter::~RPCRecordFormatter ( )

Destructor.

Definition at line 37 of file RPCRecordFormatter.cc.

38 { }

Member Function Documentation

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

Definition at line 41 of file RPCRecordFormatter.cc.

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

Referenced by RPCPackingModule::eventRecords().

43 {
44  std::vector<EventRecords> result;
45 
46  LogTrace("") << " DIGI; det: " << rawDetId<<", strip: "<<digi.strip()<<", bx: "<<digi.bx();
47  int stripInDU = digi.strip();
48 
49  // decode digi<->map
50  typedef std::vector< std::pair< LinkBoardElectronicIndex, LinkBoardPackedStrip> > RawDataFrames;
51  RPCReadOutMapping::StripInDetUnit duFrame(rawDetId, stripInDU);
52  RawDataFrames rawDataFrames = readoutMapping->rawDataFrame(duFrame);
53 
54  for (RawDataFrames::const_iterator ir = rawDataFrames.begin(); ir != rawDataFrames.end(); ir++) {
55 
56  const LinkBoardElectronicIndex & eleIndex = (*ir).first;
57  const LinkBoardPackedStrip & lbPackedStrip = (*ir).second;
58 
59  if (eleIndex.dccId == currentFED) {
60 
61  LogTrace("pack:")
62  <<" dccId= "<<eleIndex.dccId
63  <<" dccInputChannelNum= "<<eleIndex.dccInputChannelNum
64  <<" tbLinkInputNum= "<<eleIndex.tbLinkInputNum
65  <<" lbNumInLink="<<eleIndex.lbNumInLink;
66 
67  // BX
68  int current_BX = trigger_BX+digi.bx();
69  RecordBX bxr(current_BX);
70 
71  // LB
72  int tbLinkInputNumber = eleIndex.tbLinkInputNum;
73  int rmb = eleIndex.dccInputChannelNum;
74  RecordSLD lbr( tbLinkInputNumber, rmb);
75 
76  // CD record
77  int lbInLink = eleIndex.lbNumInLink;
78  int eod = 0;
79  int halfP = 0;
80  int packedStrip = lbPackedStrip.packedStrip();
81  int partitionNumber = packedStrip/8;
82  RecordCD cdr(lbInLink, partitionNumber, eod, halfP, vector<int>(1,packedStrip) );
83 
84  result.push_back( EventRecords(trigger_BX, bxr, lbr, cdr) );
85  }
86  }
87  return result;
88 }
int bx() const
Definition: RPCDigi.cc:49
std::pair< uint32_t, int > StripInDetUnit
first member is DetUnit ID, second strip in DetUnit frame
int strip() const
Definition: RPCDigi.cc:47
tuple result
Definition: query.py:137
#define LogTrace(id)
std::vector< std::pair< LinkBoardElectronicIndex, LinkBoardPackedStrip > > rawDataFrame(const StripInDetUnit &duFrame) const
connection &quot;paths&quot; that lead from one digi to one strip
const RPCReadOutMapping * readoutMapping
int RPCRecordFormatter::recordUnpack ( const rpcrawtodigi::EventRecords event,
RPCDigiCollection prod,
RPCRawDataCounts counter,
RPCRawSynchro::ProdItem synchro 
)

Committing digi to the product

Definition at line 90 of file RPCRecordFormatter.cc.

References RPCRawDataCounts::addReadoutError(), currentFED, currentTbLinkInputNumber, rpcrawtodigi::EventRecords::dataToTriggerDelay(), LinkBoardElectronicIndex::dccId, LinkBoardElectronicIndex::dccInputChannelNum, debug, edm::MessageDrop::debugEnabled, RPCReadOutMapping::detUnitFrame(), rpcrawtodigi::RecordCD::eod(), error, edm::MessageDrop::instance(), LinkBoardElectronicIndex::lbNumInLink, RPCReadOutMapping::location(), LogDebug, LogTrace, readoutMapping, rpcrawtodigi::EventRecords::recordCD(), RPCDetId, LinkBoardElectronicIndex::tbLinkInputNum, and rpcrawtodigi::ReadoutError::type().

Referenced by RPCUnpackingModule::produce().

93 {
94 
97  int currentRMB = event.recordSLD().rmb();
98  int currentTbLinkInputNumber = event.recordSLD().tbLinkInputNumber();
99 
100  LinkBoardElectronicIndex eleIndex;
101  eleIndex.dccId = currentFED;
102  eleIndex.dccInputChannelNum = currentRMB;
104  eleIndex.lbNumInLink = event.recordCD().lbInLink();
105 
106 
107  if( event.recordCD().eod() ) {
108  if(counter) counter->addReadoutError(currentFED, ReadoutError(eleIndex,ReadoutError::EOD));
109  }
110 
111  if(readoutMapping == 0) return error.type();
112  const LinkBoardSpec* linkBoard = readoutMapping->location(eleIndex);
113  if (!linkBoard) {
114  if (debug) LogDebug("")<<" ** PROBLEM ** Invalid Linkboard location, skip CD event, "
115  << "dccId: "<<eleIndex.dccId
116  << "dccInputChannelNum: " <<eleIndex.dccInputChannelNum
117  << " tbLinkInputNum: "<<eleIndex.tbLinkInputNum
118  << " lbNumInLink: "<<eleIndex.lbNumInLink;
119  error = ReadoutError(eleIndex,ReadoutError::InvalidLB);
120  if(counter) counter->addReadoutError(currentFED,error );
121  return error.type();
122  }
123 
124 
125  std::vector<int> packStrips = event.recordCD().packedStrips();
126  if (packStrips.size() ==0) {
127  error = ReadoutError(eleIndex,ReadoutError::EmptyPackedStrips);
128  if(counter) counter->addReadoutError(currentFED, error);
129  return error.type();
130  }
131 
132  for(std::vector<int>::iterator is = packStrips.begin(); is != packStrips.end(); ++is) {
133 
136 
137  uint32_t rawDetId = duFrame.first;
138  int geomStrip = duFrame.second;
139  if (!rawDetId) {
140  if (debug) LogTrace("") << " ** PROBLEM ** no rawDetId, skip at least part of CD data";
141  error = ReadoutError(eleIndex,ReadoutError::InvalidDetId);
142  if (counter) counter->addReadoutError(currentFED, error);
143  continue;
144  }
145  if (geomStrip==0) {
146  if(debug) LogTrace("") <<" ** PROBLEM ** no strip found";
147  error = ReadoutError(eleIndex,ReadoutError::InvalidStrip);
148  if (counter) counter->addReadoutError(currentFED, error);
149  continue;
150  }
151 
152  // Creating RPC digi
153  RPCDigi digi(geomStrip,event.dataToTriggerDelay()-3);
154 
156  if (debug) {
157  //LogTrace("") << " LinkBoardElectronicIndex: " << eleIndex.print();
158  LogTrace("")<<" DIGI; det: "<<rawDetId<<", strip: "<<digi.strip()<<", bx: "<<digi.bx();
159  }
160  if (prod) prod->insertDigi(RPCDetId(rawDetId),digi);
161 
162 // if (RPCDetId(rawDetId).region() == -1 ) {
163 // RPCDetId det(rawDetId);
164 // if (det.ring()== 2 ) takeIt = true;
165 // if (det.station() == 1)
166 // takeIt = true;
167 // LogInfo("RPCRecordFormatter") <<"ENDCAP Region: "<<det.region()<<" disk: "<<det.station()<<" ring: "<<det.ring() <<" sector: "<<det.sector()<<" digiBX: "<<digi.bx()<< std::endl;
168 // }
169 
170  }
171 
172  if(synchro) synchro->push_back( make_pair(eleIndex,event.dataToTriggerDelay() ));
173 
174  return error.type();
175 }
#define LogDebug(id)
int eod() const
Definition: RecordCD.cc:39
static MessageDrop * instance()
Definition: MessageDrop.cc:65
std::pair< uint32_t, int > StripInDetUnit
first member is DetUnit ID, second strip in DetUnit frame
static bool debugEnabled
Definition: MessageDrop.h:105
int dataToTriggerDelay() const
Definition: EventRecords.cc:11
ReadoutErrorType type() const
Definition: ReadoutError.cc:14
const RecordCD & recordCD() const
Definition: EventRecords.h:39
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
void addReadoutError(int fedId, const rpcrawtodigi::ReadoutError &error, int weight=1)
#define debug
Definition: MEtoEDMFormat.h:34
const RPCReadOutMapping * readoutMapping

Member Data Documentation

int RPCRecordFormatter::currentFED
private

Definition at line 34 of file RPCRecordFormatter.h.

Referenced by recordPack(), and recordUnpack().

int RPCRecordFormatter::currentTbLinkInputNumber
private

Definition at line 35 of file RPCRecordFormatter.h.

Referenced by recordUnpack().

const RPCReadOutMapping* RPCRecordFormatter::readoutMapping
private

Definition at line 37 of file RPCRecordFormatter.h.

Referenced by recordPack(), and recordUnpack().