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
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

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::ESGetToken< RPCEMap, RPCEMapRcdtheReadoutMappingToken
 
edm::ESWatcher< RPCEMapRcdtheRecordWatcher
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

unpacking RPC raw data

Definition at line 23 of file RPCUnpackingModule.h.

Constructor & Destructor Documentation

◆ RPCUnpackingModule()

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

Constructor.

Definition at line 38 of file RPCUnpackingModule.cc.

References dataLabel_, doSynchro_, and fedToken_.

39  : dataLabel_(pset.getParameter<edm::InputTag>("InputLabel")),
40  doSynchro_(pset.getParameter<bool>("doSynchro")),
41  eventCounter_(0),
42  theReadoutMappingToken(esConsumes<edm::Transition::BeginRun>()),
43  theCabling(nullptr) {
44  produces<RPCDigiCollection>();
45  produces<RPCRawDataCounts>();
46  if (doSynchro_)
47  produces<RPCRawSynchro::ProdItem>();
48  fedToken_ = consumes<FEDRawDataCollection>(dataLabel_);
49 }
edm::ESGetToken< RPCEMap, RPCEMapRcd > theReadoutMappingToken
edm::InputTag dataLabel_
const RPCReadOutMapping * theCabling
edm::EDGetTokenT< FEDRawDataCollection > fedToken_
unsigned long eventCounter_

◆ ~RPCUnpackingModule()

RPCUnpackingModule::~RPCUnpackingModule ( )
override

Destructor.

Definition at line 51 of file RPCUnpackingModule.cc.

References theCabling.

51 { delete theCabling; }
const RPCReadOutMapping * theCabling

Member Function Documentation

◆ beginRun()

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

Definition at line 60 of file RPCUnpackingModule.cc.

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

60  {
61  if (theRecordWatcher.check(es)) {
62  LogTrace("") << "record has CHANGED!!, (re)initialise readout map!";
63  delete theCabling;
65  theCabling = readoutMapping->convert();
67  LogTrace("") << " READOUT MAP VERSION: " << theCabling->version() << endl;
68  }
69 }
RPCReadOutMappingWithFastSearch theReadoutMappingSearch
const std::string & version() const
version as string
void init(const RPCReadOutMapping *arm)
takes ownership of map
#define LogTrace(id)
RPCReadOutMapping const * convert() const
Definition: RPCEMap.h:64
edm::ESGetToken< RPCEMap, RPCEMapRcd > theReadoutMappingToken
const RPCReadOutMapping * theCabling
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
ESTransientHandle< T > getTransientHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:162
edm::ESWatcher< RPCEMapRcd > theRecordWatcher

◆ fillDescriptions()

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

Definition at line 53 of file RPCUnpackingModule.cc.

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

53  {
55  desc.add<edm::InputTag>("InputLabel", edm::InputTag("rawDataCollector"));
56  desc.add<bool>("doSynchro", true);
57  descriptions.add("rpcUnpackingModule", desc);
58 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ 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 71 of file RPCUnpackingModule.cc.

References FEDHeader::bxID(), FEDHeader::check(), FEDTrailer::check(), FEDTrailer::crc(), debug, edm::MessageDrop::debugEnabled, TauDecayModes::dec, doSynchro_, makeMEIFBenchmarkPlots::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, AlCaHarvesting_cff::record, RPCRecordFormatter::recordUnpack(), FEDHeader::sourceID(), mps_update::status, str, theCabling, theReadoutMappingSearch, FEDHeader::triggerType(), FEDTrailer::ttsBits(), and FEDHeader::version().

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

Member Data Documentation

◆ dataLabel_

edm::InputTag RPCUnpackingModule::dataLabel_
private

Definition at line 41 of file RPCUnpackingModule.h.

Referenced by RPCUnpackingModule().

◆ doSynchro_

bool RPCUnpackingModule::doSynchro_
private

Definition at line 42 of file RPCUnpackingModule.h.

Referenced by produce(), and RPCUnpackingModule().

◆ eventCounter_

unsigned long RPCUnpackingModule::eventCounter_
private

Definition at line 43 of file RPCUnpackingModule.h.

Referenced by produce().

◆ fedToken_

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

Definition at line 49 of file RPCUnpackingModule.h.

Referenced by produce(), and RPCUnpackingModule().

◆ theCabling

const RPCReadOutMapping* RPCUnpackingModule::theCabling
private

Definition at line 47 of file RPCUnpackingModule.h.

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

◆ theReadoutMappingSearch

RPCReadOutMappingWithFastSearch RPCUnpackingModule::theReadoutMappingSearch
private

Definition at line 48 of file RPCUnpackingModule.h.

Referenced by beginRun(), and produce().

◆ theReadoutMappingToken

edm::ESGetToken<RPCEMap, RPCEMapRcd> RPCUnpackingModule::theReadoutMappingToken
private

Definition at line 46 of file RPCUnpackingModule.h.

Referenced by beginRun().

◆ theRecordWatcher

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

Definition at line 45 of file RPCUnpackingModule.h.

Referenced by beginRun().