CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
RPCUnpackingModule Class Reference

#include <RPCUnpackingModule.h>

Inheritance diagram for RPCUnpackingModule:
edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

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...
 
virtual ~RPCUnpackingModule ()
 Destructor. More...
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

edm::InputTag dataLabel_
 
bool doSynchro_
 
unsigned long eventCounter_
 
edm::EDGetTokenT
< FEDRawDataCollection
fedToken_
 
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, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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

References dataLabel_, doSynchro_, and fedToken_.

40  : dataLabel_(pset.getParameter<edm::InputTag>("InputLabel")),
41  doSynchro_(pset.getParameter<bool>("doSynchro")),
42  eventCounter_(0),
43  theCabling(0)
44 {
45  produces<RPCDigiCollection>();
46  produces<RPCRawDataCounts>();
47  if (doSynchro_) produces<RPCRawSynchro::ProdItem>();
48  fedToken_=consumes<FEDRawDataCollection>(dataLabel_);
49 
50 }
T getParameter(std::string const &) const
edm::InputTag dataLabel_
const RPCReadOutMapping * theCabling
edm::EDGetTokenT< FEDRawDataCollection > fedToken_
unsigned long eventCounter_
RPCUnpackingModule::~RPCUnpackingModule ( )
virtual

Destructor.

Definition at line 52 of file RPCUnpackingModule.cc.

References theCabling.

53 {
54  delete theCabling;
55 }
const RPCReadOutMapping * theCabling

Member Function Documentation

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

Reimplemented from edm::stream::EDProducerBase.

Definition at line 57 of file RPCUnpackingModule.cc.

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

58 {
59  if (theRecordWatcher.check(es)) {
60  LogTrace("") << "record has CHANGED!!, (re)initialise readout map!";
61  delete theCabling;
62  ESTransientHandle<RPCEMap> readoutMapping;
63  es.get<RPCEMapRcd>().get(readoutMapping);
64  theCabling = readoutMapping->convert();
66  LogTrace("") <<" READOUT MAP VERSION: " << theCabling->version() << endl;
67  }
68 }
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)
const T & get() const
Definition: EventSetup.h:55
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:58
edm::ESWatcher< RPCEMapRcd > theRecordWatcher
void RPCUnpackingModule::produce ( edm::Event ev,
const edm::EventSetup es 
)
overridevirtual

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

Implements edm::stream::EDProducerBase.

Definition at line 71 of file RPCUnpackingModule.cc.

References FEDHeader::bxID(), FEDTrailer::check(), FEDHeader::check(), rpcrawtodigi::EventRecords::complete(), FEDTrailer::crc(), FEDRawData::data(), debug, edm::MessageDrop::debugEnabled, doSynchro_, event(), eventCounter_, FEDTrailer::evtStatus(), fedToken_, edm::Event::getByToken(), edm::MessageDrop::instance(), FEDTrailer::lenght(), LogDebug, LogTrace, FEDHeader::lvl1ID(), FEDNumbering::MAXRPCFEDID, FEDNumbering::MINRPCFEDID, FEDHeader::moreHeaders(), FEDTrailer::moreTrailers(), reco::print(), rpcrawtodigi::DataRecord::print(), edm::Event::put(), record, RPCRecordFormatter::recordUnpack(), FEDRawData::size(), FEDHeader::sourceID(), ntuplemaker::status, theCabling, theReadoutMappingSearch, FEDHeader::triggerType(), FEDTrailer::ttsBits(), rpcrawtodigi::DataRecord::type(), and FEDHeader::version().

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

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

Member Data Documentation

edm::InputTag RPCUnpackingModule::dataLabel_
private

Definition at line 37 of file RPCUnpackingModule.h.

Referenced by RPCUnpackingModule().

bool RPCUnpackingModule::doSynchro_
private

Definition at line 38 of file RPCUnpackingModule.h.

Referenced by produce(), and RPCUnpackingModule().

unsigned long RPCUnpackingModule::eventCounter_
private

Definition at line 39 of file RPCUnpackingModule.h.

Referenced by produce().

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

Definition at line 44 of file RPCUnpackingModule.h.

Referenced by produce(), and RPCUnpackingModule().

const RPCReadOutMapping* RPCUnpackingModule::theCabling
private

Definition at line 42 of file RPCUnpackingModule.h.

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

RPCReadOutMappingWithFastSearch RPCUnpackingModule::theReadoutMappingSearch
private

Definition at line 43 of file RPCUnpackingModule.h.

Referenced by beginRun(), and produce().

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

Definition at line 41 of file RPCUnpackingModule.h.

Referenced by beginRun().