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 hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () 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 ( const edm::ParameterSet pset)

Constructor.

Definition at line 40 of file RPCUnpackingModule.cc.

References dataLabel_, doSynchro_, and fedToken_.

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 }
T getParameter(std::string const &) const
edm::InputTag dataLabel_
const RPCReadOutMapping * theCabling
edm::EDGetTokenT< FEDRawDataCollection > fedToken_
unsigned long eventCounter_
RPCUnpackingModule::~RPCUnpackingModule ( )
override

Destructor.

Definition at line 52 of file RPCUnpackingModule.cc.

References theCabling.

52 { delete theCabling; }
const RPCReadOutMapping * theCabling

Member Function Documentation

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

Definition at line 61 of file RPCUnpackingModule.cc.

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

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 }
RPCReadOutMappingWithFastSearch theReadoutMappingSearch
void init(const RPCReadOutMapping *arm)
takes ownership of map
const std::string & version() const
version as string
const RPCReadOutMapping * theCabling
#define LogTrace(id)
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:52
T get() const
Definition: EventSetup.h:73
RPCReadOutMapping const * convert() const
Definition: RPCEMap.h:64
edm::ESWatcher< RPCEMapRcd > theRecordWatcher
void RPCUnpackingModule::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 54 of file RPCUnpackingModule.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), and HLT_2018_cff::InputTag.

54  {
56  desc.add<edm::InputTag>("InputLabel", edm::InputTag("rawDataCollector"));
57  desc.add<bool>("doSynchro", true);
58  descriptions.add("rpcUnpackingModule", desc);
59 }
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 73 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_, event(), eventCounter_, FEDTrailer::evtStatus(), FEDRawDataCollection::FEDData(), l1tstage2_dqm_sourceclient-live_cfg::fedId, fedToken_, FEDTrailer::fragmentLength(), edm::Event::getByToken(), RecoTauValidation_cfi::header, edm::MessageDrop::instance(), LogDebug, LogTrace, FEDHeader::lvl1ID(), FEDNumbering::MAXRPCFEDID, FEDNumbering::MINRPCFEDID, FEDHeader::moreHeaders(), FEDTrailer::moreTrailers(), eostools::move(), rpcrawtodigi::DataRecord::print(), edm::print(), edm::Event::put(), l1tstage2_dqm_sourceclient-live_cfg::rawData, record, RPCRecordFormatter::recordUnpack(), FEDRawData::size(), FEDHeader::sourceID(), mps_update::status, str, theCabling, theReadoutMappingSearch, FEDHeader::triggerType(), FEDTrailer::ttsBits(), rpcrawtodigi::DataRecord::type(), and FEDHeader::version().

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

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 }
#define LogDebug(id)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
RPCReadOutMappingWithFastSearch theReadoutMappingSearch
JetCorrectorParameters::Record record
Definition: classes.h:7
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
#define nullptr
static MessageDrop * instance()
Definition: MessageDrop.cc:59
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
uint64_t word
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
uint64_t Word64
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
const RPCReadOutMapping * theCabling
#define LogTrace(id)
#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_
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1

Member Data Documentation

edm::InputTag RPCUnpackingModule::dataLabel_
private

Definition at line 40 of file RPCUnpackingModule.h.

Referenced by RPCUnpackingModule().

bool RPCUnpackingModule::doSynchro_
private

Definition at line 41 of file RPCUnpackingModule.h.

Referenced by produce(), and RPCUnpackingModule().

unsigned long RPCUnpackingModule::eventCounter_
private

Definition at line 42 of file RPCUnpackingModule.h.

Referenced by produce().

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

Definition at line 47 of file RPCUnpackingModule.h.

Referenced by produce(), and RPCUnpackingModule().

const RPCReadOutMapping* RPCUnpackingModule::theCabling
private

Definition at line 45 of file RPCUnpackingModule.h.

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

RPCReadOutMappingWithFastSearch RPCUnpackingModule::theReadoutMappingSearch
private

Definition at line 46 of file RPCUnpackingModule.h.

Referenced by beginRun(), and produce().

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

Definition at line 44 of file RPCUnpackingModule.h.

Referenced by beginRun().