CMS 3D CMS Logo

RPCUnpackingModule Class Reference

Driver class for unpacking RPC raw data (DCC format). More...

#include <EventFilter/RPCRawToDigi/plugins/RPCUnpackingModule.h>

Inheritance diagram for RPCUnpackingModule:

edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

void produce (edm::Event &ev, const edm::EventSetup &es)
 Retrieves a RPCDigiCollection from the Event, creates a FEDRawDataCollection (EDProduct) using the DigiToRaw converter, and attaches it to the Event.
 RPCUnpackingModule (const edm::ParameterSet &pset)
 Constructor.
virtual ~RPCUnpackingModule ()
 Destructor.

Private Attributes

edm::InputTag dataLabel_
bool doSynchro_
unsigned long eventCounter_
const RPCReadOutMappingtheCabling


Detailed Description

Driver class for unpacking RPC raw data (DCC format).

Date
2008/07/30 10:37:44
Revision
1.5
Author:
Ilaria Segoni - CERN

Definition at line 19 of file RPCUnpackingModule.h.


Constructor & Destructor Documentation

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

Constructor.

Definition at line 37 of file RPCUnpackingModule.cc.

References doSynchro_.

00038   : dataLabel_(pset.getUntrackedParameter<edm::InputTag>("InputLabel",edm::InputTag("source"))),
00039     doSynchro_(pset.getParameter<bool>("doSynchro")),
00040     eventCounter_(0),
00041     theCabling(0)
00042 {
00043   produces<RPCDigiCollection>();
00044   produces<RPCRawDataCounts>();
00045   if (doSynchro_) produces<RPCRawSynchro::ProdItem>();
00046 }

RPCUnpackingModule::~RPCUnpackingModule (  )  [virtual]

Destructor.

Definition at line 48 of file RPCUnpackingModule.cc.

References theCabling.

00049 { 
00050   delete theCabling;
00051 }


Member Function Documentation

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

References FEDHeader::bxID(), FEDTrailer::check(), FEDHeader::check(), edm::ESWatcher< T >::check(), rpcrawtodigi::EventRecords::complete(), FEDTrailer::crc(), data, FEDRawData::data(), dataLabel_, debug, edm::MessageDrop::debugEnabled, doSynchro_, lat::endl(), event(), eventCounter_, FEDTrailer::evtStatus(), edm::EventSetup::get(), edm::Event::getByLabel(), FEDNumbering::getRPCFEDIds(), header, RPCRawDataCounts::HeaderCheckFail, RPCRawDataCounts::InconsistentDataSize, RPCRawDataCounts::InconsitentFedId, RPCReadOutMappingWithFastSearch::init(), edm::MessageDrop::instance(), FEDTrailer::lenght(), LogDebug, LogTrace, FEDHeader::lvl1ID(), FEDHeader::moreHeaders(), FEDTrailer::moreTrailers(), print(), rpcrawtodigi::DataRecord::print(), edm::Event::put(), RPCRecordFormatter::recordUnpack(), FEDRawData::size(), FEDHeader::sourceID(), StDecayID::status, theCabling, RPCRawDataCounts::TrailerCheckFail, FEDHeader::triggerType(), FEDTrailer::ttsBits(), rpcrawtodigi::DataRecord::type(), RPCReadOutMapping::version(), and FEDHeader::version().

00055 {
00056   static bool debug = edm::MessageDrop::instance()->debugEnabled;
00057   eventCounter_++; 
00058   if (debug) LogDebug ("RPCUnpacker::produce") <<"Beginning To Unpack Event: "<<eventCounter_;
00059  
00060   Handle<FEDRawDataCollection> allFEDRawData; 
00061   ev.getByLabel(dataLabel_,allFEDRawData); 
00062 
00063   static edm::ESWatcher<RPCEMapRcd> recordWatcher;
00064   static RPCReadOutMappingWithFastSearch readoutMappingSearch;
00065 
00066   if (recordWatcher.check(es)) {  
00067     delete theCabling; 
00068     ESHandle<RPCEMap> readoutMapping;
00069     if (debug) LogTrace("") << "record has CHANGED!!, initialise readout map!";
00070     es.get<RPCEMapRcd>().get(readoutMapping);
00071     theCabling = readoutMapping->convert();
00072     if (debug) LogTrace("") <<" READOUT MAP VERSION: " << theCabling->version() << endl;
00073     readoutMappingSearch.init(theCabling);
00074   }
00075 
00076   std::auto_ptr<RPCDigiCollection> producedRPCDigis(new RPCDigiCollection);
00077   std::auto_ptr<RPCRawDataCounts> producedRawDataCounts(new RPCRawDataCounts);
00078   std::auto_ptr<RPCRawSynchro::ProdItem> producedRawSynchoCounts;
00079   if (doSynchro_) producedRawSynchoCounts.reset(new RPCRawSynchro::ProdItem);
00080 
00081   std::pair<int,int> rpcFEDS=FEDNumbering::getRPCFEDIds();
00082  
00083 
00084   int status = 0;
00085   for (int fedId= rpcFEDS.first; fedId<=rpcFEDS.second; ++fedId){  
00086 
00087     const FEDRawData & rawData = allFEDRawData->FEDData(fedId);
00088     RPCRecordFormatter interpreter = 
00089         theCabling ? RPCRecordFormatter(fedId,&readoutMappingSearch) : RPCRecordFormatter(fedId,0);
00090     int triggerBX =0;
00091     int nWords = rawData.size()/sizeof(Word64);
00092     if (nWords==0) continue;
00093 
00094     //
00095     // check headers
00096     //
00097     const Word64* header = reinterpret_cast<const Word64* >(rawData.data()); header--;
00098     bool moreHeaders = true;
00099     while (moreHeaders) {
00100       header++;
00101       FEDHeader fedHeader( reinterpret_cast<const unsigned char*>(header));
00102       if (!fedHeader.check()) {
00103         producedRawDataCounts->addReadoutError(RPCRawDataCounts::HeaderCheckFail); 
00104         if (debug) LogTrace("") <<" ** PROBLEM **, header.check() failed, break"; 
00105         break; 
00106       }
00107       if ( fedHeader.sourceID() != fedId) {
00108         producedRawDataCounts->addReadoutError(RPCRawDataCounts::InconsitentFedId); 
00109         if (debug) LogTrace ("") <<" ** PROBLEM **, fedHeader.sourceID() != fedId"
00110             << "fedId = " << fedId<<" sourceID="<<fedHeader.sourceID(); 
00111       }
00112       triggerBX = fedHeader.bxID();
00113       moreHeaders = fedHeader.moreHeaders();
00114       if (debug) {
00115         ostringstream str;
00116         str <<"  header: "<< *reinterpret_cast<const bitset<64>*> (header) << endl;
00117         str <<"  header triggerType: " << fedHeader.triggerType()<<endl;
00118         str <<"  header lvl1ID:      " << fedHeader.lvl1ID() << endl;
00119         str <<"  header bxID:        " << fedHeader.bxID() << endl;
00120         str <<"  header sourceID:    " << fedHeader.sourceID() << endl;
00121         str <<"  header version:     " << fedHeader.version() << endl;
00122         LogTrace("") << str.str();
00123       }
00124     }
00125 
00126     //
00127     // check trailers
00128     //
00129     const Word64* trailer=reinterpret_cast<const Word64* >(rawData.data())+(nWords-1); trailer++;
00130     bool moreTrailers = true;
00131     while (moreTrailers) {
00132       trailer--;
00133       FEDTrailer fedTrailer(reinterpret_cast<const unsigned char*>(trailer));
00134       if ( !fedTrailer.check()) {
00135         producedRawDataCounts->addReadoutError(RPCRawDataCounts::TrailerCheckFail);
00136         if (debug) LogTrace("") <<" ** PROBLEM **, trailer.check() failed, break";
00137         break;
00138       }
00139       if ( fedTrailer.lenght()!= nWords) {
00140         producedRawDataCounts->addReadoutError(RPCRawDataCounts::InconsistentDataSize); 
00141         if (debug) LogTrace("")<<" ** PROBLEM **, fedTrailer.lenght()!= nWords, break";
00142         break;
00143       }
00144       moreTrailers = fedTrailer.moreTrailers();
00145       if (debug) {
00146         ostringstream str;
00147         str <<" trailer: "<<  *reinterpret_cast<const bitset<64>*> (trailer) << endl; 
00148         str <<"  trailer lenght:    "<<fedTrailer.lenght()<<endl;
00149         str <<"  trailer crc:       "<<fedTrailer.crc()<<endl;
00150         str <<"  trailer evtStatus: "<<fedTrailer.evtStatus()<<endl;
00151         str <<"  trailer ttsBits:   "<<fedTrailer.ttsBits()<<endl;
00152         LogTrace("") << str.str();
00153       }
00154     }
00155 
00156     //
00157     // data records
00158     //
00159     if (debug) {
00160       ostringstream str;
00161       for (const Word64* word = header+1; word != trailer; word++) {
00162         str<<"    data: "<<*reinterpret_cast<const bitset<64>*>(word) << endl; 
00163       }
00164       LogTrace("") << str.str();
00165     }
00166     EventRecords event(triggerBX);
00167     for (const Word64* word = header+1; word != trailer; word++) {
00168       for( int iRecord=1; iRecord<=4; iRecord++){
00169         typedef DataRecord::RecordType Record;
00170         const Record* pRecord = reinterpret_cast<const Record* >(word+1)-iRecord;
00171         DataRecord data(*pRecord);
00172         event.add(data);
00173         if (debug) {
00174           std::ostringstream str;
00175           str <<"record: "<<data.print()<<" hex: "<<hex<<*pRecord<<dec;
00176           str <<" type:"<<data.type()<<DataRecord::print(data);
00177           if (event.complete()) {
00178             str<< " --> dccId: "<<fedId
00179                << " dccInputChannelNum: " <<event.recordSLD().rmb()
00180                << " tbLinkInputNum: "<<event.recordSLD().tbLinkInputNumber()
00181                << " lbNumInLink: "<<event.recordCD().lbInLink()
00182                << " partition "<<event.recordCD().partitionNumber()
00183                << " cdData "<<event.recordCD().partitionData();
00184           }
00185           LogTrace("") << str.str();
00186         }
00187         producedRawDataCounts->addRecordType(fedId, data.type());
00188         int statusTMP = 0;
00189         if (event.complete()) statusTMP= 
00190             interpreter.recordUnpack( event, 
00191             producedRPCDigis.get(), producedRawDataCounts.get(), producedRawSynchoCounts.get()); 
00192         if (statusTMP != 0) status = statusTMP;
00193       }
00194     }
00195   }
00196   if (status && debug) LogTrace("") << " RPCUnpackingModule - There was unpacking PROBLEM in this event"<< endl;
00197   if (debug) LogTrace("") << DebugDigisPrintout()(producedRPCDigis.get()) << endl;
00198   ev.put(producedRPCDigis);  
00199   ev.put(producedRawDataCounts);
00200   if (doSynchro_) ev.put(producedRawSynchoCounts);
00201 }


Member Data Documentation

edm::InputTag RPCUnpackingModule::dataLabel_ [private]

Definition at line 34 of file RPCUnpackingModule.h.

Referenced by produce().

bool RPCUnpackingModule::doSynchro_ [private]

Definition at line 35 of file RPCUnpackingModule.h.

Referenced by produce(), and RPCUnpackingModule().

unsigned long RPCUnpackingModule::eventCounter_ [private]

Definition at line 36 of file RPCUnpackingModule.h.

Referenced by produce().

const RPCReadOutMapping* RPCUnpackingModule::theCabling [private]

Definition at line 37 of file RPCUnpackingModule.h.

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


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:31:13 2009 for CMSSW by  doxygen 1.5.4