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::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

void beginRun (edm::Run &run, const edm::EventSetup &es)
 
void produce (edm::Event &ev, const edm::EventSetup &es)
 
 RPCUnpackingModule (const edm::ParameterSet &pset)
 Constructor. More...
 
virtual ~RPCUnpackingModule ()
 Destructor. More...
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Attributes

edm::InputTag dataLabel_
 
bool doSynchro_
 
unsigned long eventCounter_
 
const RPCReadOutMappingtheCabling
 
RPCReadOutMappingWithFastSearch theReadoutMappingSearch
 
edm::ESWatcher< RPCEMapRcdtheRecordWatcher
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

unpacking RPC raw data

Definition at line 19 of file RPCUnpackingModule.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 39 of file RPCUnpackingModule.cc.

References doSynchro_.

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

Destructor.

Definition at line 50 of file RPCUnpackingModule.cc.

References theCabling.

51 {
52  delete theCabling;
53 }
const RPCReadOutMapping * theCabling

Member Function Documentation

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

Reimplemented from edm::EDProducer.

Definition at line 55 of file RPCUnpackingModule.cc.

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

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

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

Implements edm::EDProducer.

Definition at line 69 of file RPCUnpackingModule.cc.

References FEDHeader::bxID(), FEDTrailer::check(), FEDHeader::check(), rpcrawtodigi::EventRecords::complete(), FEDTrailer::crc(), FEDRawData::data(), dataLabel_, debug, edm::MessageDrop::debugEnabled, doSynchro_, event(), eventCounter_, FEDTrailer::evtStatus(), edm::Event::getByLabel(), errorMatrix2Lands::header, 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().

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

Member Data Documentation

edm::InputTag RPCUnpackingModule::dataLabel_
private

Definition at line 36 of file RPCUnpackingModule.h.

Referenced by produce().

bool RPCUnpackingModule::doSynchro_
private

Definition at line 37 of file RPCUnpackingModule.h.

Referenced by produce(), and RPCUnpackingModule().

unsigned long RPCUnpackingModule::eventCounter_
private

Definition at line 38 of file RPCUnpackingModule.h.

Referenced by produce().

const RPCReadOutMapping* RPCUnpackingModule::theCabling
private

Definition at line 41 of file RPCUnpackingModule.h.

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

RPCReadOutMappingWithFastSearch RPCUnpackingModule::theReadoutMappingSearch
private

Definition at line 42 of file RPCUnpackingModule.h.

Referenced by beginRun(), and produce().

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

Definition at line 40 of file RPCUnpackingModule.h.

Referenced by beginRun().