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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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 20 of file RPCUnpackingModule.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 41 of file RPCUnpackingModule.cc.

References dataLabel_, doSynchro_, and fedToken_.

42  : dataLabel_(pset.getParameter<edm::InputTag>("InputLabel")),
43  doSynchro_(pset.getParameter<bool>("doSynchro")),
44  eventCounter_(0),
45  theCabling(nullptr)
46 {
47  produces<RPCDigiCollection>();
48  produces<RPCRawDataCounts>();
49  if (doSynchro_) produces<RPCRawSynchro::ProdItem>();
50  fedToken_=consumes<FEDRawDataCollection>(dataLabel_);
51 
52 }
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 54 of file RPCUnpackingModule.cc.

References theCabling.

55 {
56  delete theCabling;
57 }
const RPCReadOutMapping * theCabling

Member Function Documentation

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

Definition at line 67 of file RPCUnpackingModule.cc.

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

68 {
69  if (theRecordWatcher.check(es)) {
70  LogTrace("") << "record has CHANGED!!, (re)initialise readout map!";
71  delete theCabling;
72  ESTransientHandle<RPCEMap> readoutMapping;
73  es.get<RPCEMapRcd>().get(readoutMapping);
74  theCabling = readoutMapping->convert();
76  LogTrace("") <<" READOUT MAP VERSION: " << theCabling->version() << endl;
77  }
78 }
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:57
T get() const
Definition: EventSetup.h:63
RPCReadOutMapping const * convert() const
Definition: RPCEMap.h:67
edm::ESWatcher< RPCEMapRcd > theRecordWatcher
void RPCUnpackingModule::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 59 of file RPCUnpackingModule.cc.

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

59  {
61  desc.add<edm::InputTag>("InputLabel",edm::InputTag("rawDataCollector"));
62  desc.add<bool>("doSynchro",true);
63  descriptions.add("rpcUnpackingModule",desc);
64 }
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 81 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(), l1t::stage2::layer2::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(), 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().

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

Member Data Documentation

edm::InputTag RPCUnpackingModule::dataLabel_
private

Definition at line 39 of file RPCUnpackingModule.h.

Referenced by RPCUnpackingModule().

bool RPCUnpackingModule::doSynchro_
private

Definition at line 40 of file RPCUnpackingModule.h.

Referenced by produce(), and RPCUnpackingModule().

unsigned long RPCUnpackingModule::eventCounter_
private

Definition at line 41 of file RPCUnpackingModule.h.

Referenced by produce().

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

Definition at line 46 of file RPCUnpackingModule.h.

Referenced by produce(), and RPCUnpackingModule().

const RPCReadOutMapping* RPCUnpackingModule::theCabling
private

Definition at line 44 of file RPCUnpackingModule.h.

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

RPCReadOutMappingWithFastSearch RPCUnpackingModule::theReadoutMappingSearch
private

Definition at line 45 of file RPCUnpackingModule.h.

Referenced by beginRun(), and produce().

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

Definition at line 43 of file RPCUnpackingModule.h.

Referenced by beginRun().