CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/EventFilter/DTRawToDigi/plugins/DTUnpackingModule.cc

Go to the documentation of this file.
00001 
00010 #include <FWCore/Framework/interface/Event.h>
00011 #include <DataFormats/Common/interface/Handle.h>
00012 #include <FWCore/Framework/interface/ESHandle.h>
00013 #include <FWCore/Framework/interface/EventSetup.h>
00014 #include <FWCore/ParameterSet/interface/ParameterSet.h>
00015 
00016 #include <EventFilter/DTRawToDigi/plugins/DTUnpackingModule.h>
00017 #include <DataFormats/FEDRawData/interface/FEDRawData.h>
00018 #include <DataFormats/FEDRawData/interface/FEDNumbering.h>
00019 #include <DataFormats/FEDRawData/interface/FEDRawDataCollection.h>
00020 #include <DataFormats/DTDigi/interface/DTDigiCollection.h>
00021 #include <DataFormats/DTDigi/interface/DTLocalTriggerCollection.h>
00022 
00023 #include <CondFormats/DataRecord/interface/DTReadOutMappingRcd.h>
00024 
00025 #include <EventFilter/DTRawToDigi/plugins/DTDDUUnpacker.h>
00026 #include <EventFilter/DTRawToDigi/plugins/DTROS25Unpacker.h>
00027 #include <EventFilter/DTRawToDigi/plugins/DTROS8Unpacker.h>
00028 
00029 
00030 using namespace edm;
00031 using namespace std;
00032 
00033 
00034 
00035 #define SLINK_WORD_SIZE 8 
00036 
00037 
00038 DTUnpackingModule::DTUnpackingModule(const edm::ParameterSet& ps) : unpacker(0) {
00039 
00040   const string & dataType = ps.getParameter<string>("dataType");
00041 
00042   ParameterSet unpackerParameters = ps.getParameter<ParameterSet>("readOutParameters");
00043   
00044 
00045   if (dataType == "DDU") {
00046     unpacker = new DTDDUUnpacker(unpackerParameters);
00047   } 
00048   else if (dataType == "ROS25") {
00049     unpacker = new DTROS25Unpacker(unpackerParameters.getParameter<ParameterSet>("rosParameters"));
00050   } 
00051   else if (dataType == "ROS8") {
00052     unpacker = new DTROS8Unpacker(unpackerParameters);
00053   } 
00054   else {
00055     throw cms::Exception("InvalidParameter") << "DTUnpackingModule: dataType "
00056                                              << dataType << " is unknown";
00057   }
00058   
00059   fedbyType_ = ps.getParameter<bool>("fedbyType"); // default was: true
00060   inputLabel = ps.getParameter<InputTag>("inputLabel"); // default was: source
00061   useStandardFEDid_ = ps.getParameter<bool>("useStandardFEDid"); // default was: true
00062   minFEDid_ = ps.getUntrackedParameter<int>("minFEDid",770); // default: 770
00063   maxFEDid_ = ps.getUntrackedParameter<int>("maxFEDid",779); // default 779
00064   dqmOnly = ps.getParameter<bool>("dqmOnly"); // default: false
00065 
00066   if(!dqmOnly) {
00067     produces<DTDigiCollection>();
00068     produces<DTLocalTriggerCollection>();
00069   }
00070 }
00071 
00072 DTUnpackingModule::~DTUnpackingModule(){
00073   delete unpacker;
00074 }
00075 
00076 
00077 void DTUnpackingModule::produce(Event & e, const EventSetup& context){
00078 
00079   Handle<FEDRawDataCollection> rawdata;
00080   if (fedbyType_) {
00081     e.getByType(rawdata);
00082   }
00083   else {
00084     e.getByLabel(inputLabel, rawdata);
00085   }
00086 
00087   // Get the mapping from the setup
00088   ESHandle<DTReadOutMapping> mapping;
00089   context.get<DTReadOutMappingRcd>().get(mapping);
00090   
00091   // Create the result i.e. the collections of MB Digis and SC local triggers
00092   auto_ptr<DTDigiCollection> detectorProduct(new DTDigiCollection);
00093   auto_ptr<DTLocalTriggerCollection> triggerProduct(new DTLocalTriggerCollection);
00094 
00095 
00096   // Loop over the DT FEDs
00097   int FEDIDmin = 0, FEDIDMax = 0;
00098   if (useStandardFEDid_){
00099     FEDIDmin = FEDNumbering::MINDTFEDID;
00100     FEDIDMax = FEDNumbering::MAXDTFEDID;
00101   }
00102   else {
00103     FEDIDmin = minFEDid_;
00104     FEDIDMax = maxFEDid_;
00105   }
00106   
00107   for (int id=FEDIDmin; id<=FEDIDMax; ++id){ 
00108     
00109     const FEDRawData& feddata = rawdata->FEDData(id);
00110     
00111     if (feddata.size()){
00112       
00113       // Unpack the data
00114       unpacker->interpretRawData(reinterpret_cast<const unsigned int*>(feddata.data()), 
00115                                  feddata.size(), id, mapping, detectorProduct, triggerProduct);
00116     }
00117   }
00118 
00119   // commit to the event  
00120   if(!dqmOnly) {
00121     e.put(detectorProduct);
00122     e.put(triggerProduct);
00123   }
00124 }
00125