CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
< FEDRawDataCollection
fedToken_
 
const RPCReadOutMappingtheCabling
 
RPCReadOutMappingWithFastSearch theReadoutMappingSearch
 
edm::ESGetToken< RPCEMap,
RPCEMapRcd
theReadoutMappingToken
 
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 ( 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
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< FEDRawDataCollection > fedToken_
unsigned long eventCounter_
RPCUnpackingModule::~RPCUnpackingModule ( )
override

Destructor.

Definition at line 51 of file RPCUnpackingModule.cc.

References theCabling.

51 { delete theCabling; }
const RPCReadOutMapping * theCabling

Member Function Documentation

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(), 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
void init(const RPCReadOutMapping *arm)
takes ownership of map
#define LogTrace(id)
const std::string & version() const
version as string
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:168
edm::ESWatcher< RPCEMapRcd > theRecordWatcher
void RPCUnpackingModule::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 53 of file RPCUnpackingModule.cc.

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

53  {
55  desc.add<edm::InputTag>("InputLabel", edm::InputTag("rawDataCollector"));
56  desc.add<bool>("doSynchro", true);
57  descriptions.add("rpcUnpackingModule", desc);
58 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
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(), rpcrawtodigi::EventRecords::complete(), FEDTrailer::crc(), FEDRawData::data(), debug, edm::MessageDrop::debugEnabled, TauDecayModes::dec, doSynchro_, edmPickEvents::event, eventCounter_, FEDTrailer::evtStatus(), l1tstage2_dqm_sourceclient-live_cfg::fedId, fedToken_, FEDTrailer::fragmentLength(), edm::Event::getByToken(), edm::MessageDrop::instance(), LogDebug, LogTrace, FEDHeader::lvl1ID(), FEDNumbering::MAXRPCFEDID, FEDNumbering::MINRPCFEDID, FEDHeader::moreHeaders(), FEDTrailer::moreTrailers(), eostools::move(), print(), rpcrawtodigi::DataRecord::print(), edm::Event::put(), GlobalPosition_Frontier_DevDB_cff::record, RPCRecordFormatter::recordUnpack(), FEDRawData::size(), FEDHeader::sourceID(), mps_update::status, str, theCabling, theReadoutMappingSearch, FEDHeader::triggerType(), FEDTrailer::ttsBits(), rpcrawtodigi::DataRecord::type(), 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 =
90  theCabling ? RPCRecordFormatter(fedId, &theReadoutMappingSearch) : RPCRecordFormatter(fedId, nullptr);
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 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
RPCReadOutMappingWithFastSearch theReadoutMappingSearch
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
static MessageDrop * instance()
Definition: MessageDrop.cc:33
list status
Definition: mps_update.py:107
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
#define LogTrace(id)
uint64_t word
def move
Definition: eostools.py:511
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
const RPCReadOutMapping * theCabling
uint64_t Word64
#define debug
Definition: HDRShower.cc:19
int recordUnpack(const rpcrawtodigi::EventRecords &event, RPCDigiCollection *prod, RPCRawDataCounts *counter, RPCRawSynchro::ProdItem *synchro)
edm::EDGetTokenT< FEDRawDataCollection > fedToken_
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
#define str(s)
unsigned long eventCounter_
cms_uint64_t Word64
#define LogDebug(id)

Member Data Documentation

edm::InputTag RPCUnpackingModule::dataLabel_
private

Definition at line 41 of file RPCUnpackingModule.h.

Referenced by RPCUnpackingModule().

bool RPCUnpackingModule::doSynchro_
private

Definition at line 42 of file RPCUnpackingModule.h.

Referenced by produce(), and RPCUnpackingModule().

unsigned long RPCUnpackingModule::eventCounter_
private

Definition at line 43 of file RPCUnpackingModule.h.

Referenced by produce().

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

Definition at line 49 of file RPCUnpackingModule.h.

Referenced by produce(), and RPCUnpackingModule().

const RPCReadOutMapping* RPCUnpackingModule::theCabling
private

Definition at line 47 of file RPCUnpackingModule.h.

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

RPCReadOutMappingWithFastSearch RPCUnpackingModule::theReadoutMappingSearch
private

Definition at line 48 of file RPCUnpackingModule.h.

Referenced by beginRun(), and produce().

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

Definition at line 46 of file RPCUnpackingModule.h.

Referenced by beginRun().

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

Definition at line 45 of file RPCUnpackingModule.h.

Referenced by beginRun().