CMS 3D CMS Logo

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

#include <RPCUnpackingModule.h>

Inheritance diagram for RPCUnpackingModule:
edm::stream::EDProducer<>

Public Member Functions

void beginRun (const edm::Run &run, const edm::EventSetup &es) override
 
void produce (edm::Event &ev, const edm::EventSetup &es) override
 
 RPCUnpackingModule (const edm::ParameterSet &pset)
 Constructor. More...
 
 ~RPCUnpackingModule () override
 Destructor. More...
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Attributes

edm::InputTag dataLabel_
 
bool doSynchro_
 
unsigned long eventCounter_
 
edm::EDGetTokenT< FEDRawDataCollectionfedToken_
 
const RPCReadOutMappingtheCabling
 
RPCReadOutMappingWithFastSearch theReadoutMappingSearch
 
edm::ESWatcher< RPCEMapRcdtheRecordWatcher
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

unpacking RPC raw data

Definition at line 22 of file RPCUnpackingModule.h.

Constructor & Destructor Documentation

◆ RPCUnpackingModule()

RPCUnpackingModule::RPCUnpackingModule ( const edm::ParameterSet pset)

Constructor.

Definition at line 40 of file RPCUnpackingModule.cc.

41  : dataLabel_(pset.getParameter<edm::InputTag>("InputLabel")),
42  doSynchro_(pset.getParameter<bool>("doSynchro")),
43  eventCounter_(0),
44  theCabling(nullptr) {
45  produces<RPCDigiCollection>();
46  produces<RPCRawDataCounts>();
47  if (doSynchro_)
48  produces<RPCRawSynchro::ProdItem>();
49  fedToken_ = consumes<FEDRawDataCollection>(dataLabel_);
50 }

References dataLabel_, doSynchro_, and fedToken_.

◆ ~RPCUnpackingModule()

RPCUnpackingModule::~RPCUnpackingModule ( )
override

Destructor.

Definition at line 52 of file RPCUnpackingModule.cc.

52 { delete theCabling; }

References theCabling.

Member Function Documentation

◆ beginRun()

void RPCUnpackingModule::beginRun ( const edm::Run run,
const edm::EventSetup es 
)
override

Definition at line 61 of file RPCUnpackingModule.cc.

61  {
62  if (theRecordWatcher.check(es)) {
63  LogTrace("") << "record has CHANGED!!, (re)initialise readout map!";
64  delete theCabling;
65  ESTransientHandle<RPCEMap> readoutMapping;
66  es.get<RPCEMapRcd>().get(readoutMapping);
67  theCabling = readoutMapping->convert();
69  LogTrace("") << " READOUT MAP VERSION: " << theCabling->version() << endl;
70  }
71 }

References edm::ESWatcher< T >::check(), RPCEMap::convert(), edm::EventSetup::get(), get, RPCReadOutMappingWithFastSearch::init(), LogTrace, theCabling, theReadoutMappingSearch, theRecordWatcher, and RPCReadOutMapping::version().

◆ fillDescriptions()

void RPCUnpackingModule::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 54 of file RPCUnpackingModule.cc.

54  {
56  desc.add<edm::InputTag>("InputLabel", edm::InputTag("rawDataCollector"));
57  desc.add<bool>("doSynchro", true);
58  descriptions.add("rpcUnpackingModule", desc);
59 }

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, and HLT_FULL_cff::InputTag.

◆ produce()

void RPCUnpackingModule::produce ( edm::Event ev,
const edm::EventSetup es 
)
override

Retrieves a RPCDigiCollection from the Event, creates a FEDRawDataCollection (EDProduct) using the DigiToRaw converter, and attaches it to the Event.

Definition at line 73 of file RPCUnpackingModule.cc.

73  {
75  eventCounter_++;
76  if (debug)
77  LogDebug("RPCUnpacker::produce") << "Beginning To Unpack Event: " << eventCounter_;
78 
79  Handle<FEDRawDataCollection> allFEDRawData;
80  ev.getByToken(fedToken_, allFEDRawData);
81 
82  auto producedRPCDigis = std::make_unique<RPCDigiCollection>();
83  auto producedRawDataCounts = std::make_unique<RPCRawDataCounts>();
84  std::unique_ptr<RPCRawSynchro::ProdItem> producedRawSynchoCounts;
85  if (doSynchro_)
86  producedRawSynchoCounts = std::make_unique<RPCRawSynchro::ProdItem>();
87 
88  int status = 0;
90  const FEDRawData& rawData = allFEDRawData->FEDData(fedId);
91  RPCRecordFormatter interpreter =
93  int triggerBX = 0;
94  unsigned int nWords = rawData.size() / sizeof(Word64);
95  if (nWords == 0)
96  continue;
97 
98  //
99  // check headers
100  //
101  const Word64* header = reinterpret_cast<const Word64*>(rawData.data());
102  header--;
103  bool moreHeaders = true;
104  while (moreHeaders) {
105  header++;
106  FEDHeader fedHeader(reinterpret_cast<const unsigned char*>(header));
107  if (!fedHeader.check()) {
108  producedRawDataCounts->addReadoutError(fedId, ReadoutError(ReadoutError::HeaderCheckFail));
109  if (debug)
110  LogTrace("") << " ** PROBLEM **, header.check() failed, break";
111  break;
112  }
113  if (fedHeader.sourceID() != fedId) {
114  producedRawDataCounts->addReadoutError(fedId, ReadoutError(ReadoutError::InconsitentFedId));
115  if (debug)
116  LogTrace("") << " ** PROBLEM **, fedHeader.sourceID() != fedId"
117  << "fedId = " << fedId << " sourceID=" << fedHeader.sourceID();
118  }
119  triggerBX = fedHeader.bxID();
120  moreHeaders = fedHeader.moreHeaders();
121  if (debug) {
122  stringstream str;
123  str << " header: " << *reinterpret_cast<const bitset<64>*>(header) << endl;
124  str << " header triggerType: " << fedHeader.triggerType() << endl;
125  str << " header lvl1ID: " << fedHeader.lvl1ID() << endl;
126  str << " header bxID: " << fedHeader.bxID() << endl;
127  str << " header sourceID: " << fedHeader.sourceID() << endl;
128  str << " header version: " << fedHeader.version() << endl;
129  LogTrace("") << str.str();
130  }
131  }
132 
133  //
134  // check trailers
135  //
136  const Word64* trailer = reinterpret_cast<const Word64*>(rawData.data()) + (nWords - 1);
137  trailer++;
138  bool moreTrailers = true;
139  while (moreTrailers) {
140  trailer--;
141  FEDTrailer fedTrailer(reinterpret_cast<const unsigned char*>(trailer));
142  if (!fedTrailer.check()) {
143  producedRawDataCounts->addReadoutError(fedId, ReadoutError(ReadoutError::TrailerCheckFail));
144  if (debug)
145  LogTrace("") << " ** PROBLEM **, trailer.check() failed, break";
146  break;
147  }
148  if (fedTrailer.fragmentLength() != nWords) {
149  producedRawDataCounts->addReadoutError(fedId, ReadoutError(ReadoutError::InconsistentDataSize));
150  if (debug)
151  LogTrace("") << " ** PROBLEM **, fedTrailer.fragmentLength()!= nWords, break";
152  break;
153  }
154  moreTrailers = fedTrailer.moreTrailers();
155  if (debug) {
156  ostringstream str;
157  str << " trailer: " << *reinterpret_cast<const bitset<64>*>(trailer) << endl;
158  str << " trailer lenght: " << fedTrailer.fragmentLength() << endl;
159  str << " trailer crc: " << fedTrailer.crc() << endl;
160  str << " trailer evtStatus: " << fedTrailer.evtStatus() << endl;
161  str << " trailer ttsBits: " << fedTrailer.ttsBits() << endl;
162  LogTrace("") << str.str();
163  }
164  }
165 
166  //
167  // data records
168  //
169  if (debug) {
170  ostringstream str;
171  for (const Word64* word = header + 1; word != trailer; word++) {
172  str << " data: " << *reinterpret_cast<const bitset<64>*>(word) << endl;
173  }
174  LogTrace("") << str.str();
175  }
176  // if (triggerBX != 51) continue;
177  // if (triggerBX != 2316) continue;
178  EventRecords event(triggerBX);
179  for (const Word64* word = header + 1; word != trailer; word++) {
180  for (int iRecord = 1; iRecord <= 4; iRecord++) {
181  const DataRecord::Data* pRecord = reinterpret_cast<const DataRecord::Data*>(word + 1) - iRecord;
182  DataRecord record(*pRecord);
183  event.add(record);
184  if (debug) {
185  std::ostringstream str;
186  str << "record: " << record.print() << " hex: " << hex << *pRecord << dec;
187  str << " type:" << record.type() << DataRecord::print(record);
188  if (event.complete()) {
189  str << " --> dccId: " << fedId << " rmb: " << event.recordSLD().rmb()
190  << " lnk: " << event.recordSLD().tbLinkInputNumber() << " lb: " << event.recordCD().lbInLink()
191  << " part: " << event.recordCD().partitionNumber() << " data: " << event.recordCD().partitionData()
192  << " eod: " << event.recordCD().eod();
193  }
194  LogTrace("") << str.str();
195  }
196  producedRawDataCounts->addDccRecord(fedId, record);
197  int statusTMP = 0;
198  if (event.complete())
199  statusTMP = interpreter.recordUnpack(
200  event, producedRPCDigis.get(), producedRawDataCounts.get(), producedRawSynchoCounts.get());
201  if (statusTMP != 0)
202  status = statusTMP;
203  }
204  }
205  }
206  if (status && debug)
207  LogTrace("") << " RPCUnpackingModule - There was unpacking PROBLEM in this event" << endl;
208  if (debug)
209  LogTrace("") << DebugDigisPrintout()(producedRPCDigis.get()) << endl;
210  ev.put(std::move(producedRPCDigis));
211  ev.put(std::move(producedRawDataCounts));
212  if (doSynchro_)
213  ev.put(std::move(producedRawSynchoCounts));
214 }

References FEDHeader::bxID(), FEDHeader::check(), FEDTrailer::check(), FEDTrailer::crc(), debug, edm::MessageDrop::debugEnabled, TauDecayModes::dec, doSynchro_, ev, edmPickEvents::event, eventCounter_, FEDTrailer::evtStatus(), FEDRawDataCollection::FEDData(), l1tstage2_dqm_sourceclient-live_cfg::fedId, fedToken_, FEDTrailer::fragmentLength(), RecoTauValidation_cfi::header, edm::MessageDrop::instance(), LogDebug, LogTrace, FEDHeader::lvl1ID(), FEDNumbering::MAXRPCFEDID, FEDNumbering::MINRPCFEDID, FEDHeader::moreHeaders(), FEDTrailer::moreTrailers(), eostools::move(), print(), l1tstage2_dqm_sourceclient-live_cfg::rawData, GlobalPosition_Frontier_DevDB_cff::record, RPCRecordFormatter::recordUnpack(), FEDHeader::sourceID(), mps_update::status, str, theCabling, theReadoutMappingSearch, FEDHeader::triggerType(), FEDTrailer::ttsBits(), and FEDHeader::version().

Member Data Documentation

◆ dataLabel_

edm::InputTag RPCUnpackingModule::dataLabel_
private

Definition at line 40 of file RPCUnpackingModule.h.

Referenced by RPCUnpackingModule().

◆ doSynchro_

bool RPCUnpackingModule::doSynchro_
private

Definition at line 41 of file RPCUnpackingModule.h.

Referenced by produce(), and RPCUnpackingModule().

◆ eventCounter_

unsigned long RPCUnpackingModule::eventCounter_
private

Definition at line 42 of file RPCUnpackingModule.h.

Referenced by produce().

◆ fedToken_

edm::EDGetTokenT<FEDRawDataCollection> RPCUnpackingModule::fedToken_
private

Definition at line 47 of file RPCUnpackingModule.h.

Referenced by produce(), and RPCUnpackingModule().

◆ theCabling

const RPCReadOutMapping* RPCUnpackingModule::theCabling
private

Definition at line 45 of file RPCUnpackingModule.h.

Referenced by beginRun(), produce(), and ~RPCUnpackingModule().

◆ theReadoutMappingSearch

RPCReadOutMappingWithFastSearch RPCUnpackingModule::theReadoutMappingSearch
private

Definition at line 46 of file RPCUnpackingModule.h.

Referenced by beginRun(), and produce().

◆ theRecordWatcher

edm::ESWatcher<RPCEMapRcd> RPCUnpackingModule::theRecordWatcher
private

Definition at line 44 of file RPCUnpackingModule.h.

Referenced by beginRun().

edm::ESWatcher::check
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:52
RPCRecordFormatter
Definition: RPCRecordFormatter.h:15
RPCUnpackingModule::eventCounter_
unsigned long eventCounter_
Definition: RPCUnpackingModule.h:42
rpcrawtodigi::DataRecord
Definition: DataRecord.h:10
RPCEMap::convert
RPCReadOutMapping const * convert() const
Definition: RPCEMap.h:64
mps_update.status
status
Definition: mps_update.py:69
edm::MessageDrop::debugEnabled
bool debugEnabled
Definition: MessageDrop.h:63
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89285
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
l1tstage2_dqm_sourceclient-live_cfg.rawData
rawData
Definition: l1tstage2_dqm_sourceclient-live_cfg.py:162
GlobalPosition_Frontier_DevDB_cff.record
record
Definition: GlobalPosition_Frontier_DevDB_cff.py:10
RPCUnpackingModule::doSynchro_
bool doSynchro_
Definition: RPCUnpackingModule.h:41
RPCUnpackingModule::theRecordWatcher
edm::ESWatcher< RPCEMapRcd > theRecordWatcher
Definition: RPCUnpackingModule.h:44
rpcrawtodigi::ReadoutError
Definition: ReadoutError.h:8
RPCRecordFormatter::recordUnpack
int recordUnpack(const rpcrawtodigi::EventRecords &event, RPCDigiCollection *prod, RPCRawDataCounts *counter, RPCRawSynchro::ProdItem *synchro)
Definition: RPCRecordFormatter.cc:74
edm::Handle< FEDRawDataCollection >
FEDNumbering::MINRPCFEDID
Definition: FEDNumbering.h:59
RPCReadOutMapping::version
const std::string & version() const
version as string
Definition: RPCReadOutMapping.h:43
FEDRawData
Definition: FEDRawData.h:19
word
uint64_t word
Definition: CTPPSTotemDataFormatter.cc:29
debug
#define debug
Definition: HDRShower.cc:19
RPCUnpackingModule::theReadoutMappingSearch
RPCReadOutMappingWithFastSearch theReadoutMappingSearch
Definition: RPCUnpackingModule.h:46
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
RPCReadOutMappingWithFastSearch::init
void init(const RPCReadOutMapping *arm)
takes ownership of map
Definition: RPCReadOutMappingWithFastSearch.cc:30
str
#define str(s)
Definition: TestProcessor.cc:52
FEDRawDataCollection::FEDData
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
Definition: FEDRawDataCollection.cc:19
rpcrawtodigi::DataRecord::Data
uint16_t Data
Definition: DataRecord.h:12
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
FEDTrailer
Definition: FEDTrailer.h:14
print
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:46
rpcrawtodigi::EventRecords
Definition: EventRecords.h:11
Word64
uint64_t Word64
Definition: RPCUnpackingModule.cc:38
edmPickEvents.event
event
Definition: edmPickEvents.py:273
RPCUnpackingModule::dataLabel_
edm::InputTag dataLabel_
Definition: RPCUnpackingModule.h:40
l1tstage2_dqm_sourceclient-live_cfg.fedId
fedId
Definition: l1tstage2_dqm_sourceclient-live_cfg.py:88
get
#define get
RPCEMapRcd
Definition: RPCEMapRcd.h:5
RPCUnpackingModule::fedToken_
edm::EDGetTokenT< FEDRawDataCollection > fedToken_
Definition: RPCUnpackingModule.h:47
edm::ESTransientHandle
Definition: ESTransientHandle.h:41
RPCUnpackingModule::theCabling
const RPCReadOutMapping * theCabling
Definition: RPCUnpackingModule.h:45
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
ev
bool ev
Definition: Hydjet2Hadronizer.cc:95
edm::MessageDrop::instance
static MessageDrop * instance()
Definition: MessageDrop.cc:33
RecoTauValidation_cfi.header
header
Definition: RecoTauValidation_cfi.py:292
rpcrawtodigi::DebugDigisPrintout
Definition: DebugDigisPrintout.h:11
FEDNumbering::MAXRPCFEDID
Definition: FEDNumbering.h:60
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
event
Definition: event.py:1
FEDHeader
Definition: FEDHeader.h:14
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
edm::InputTag
Definition: InputTag.h:15
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27