CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/DQM/SiStripMonitorHardware/src/SiStripFEDDump.cc

Go to the documentation of this file.
00001 #include <sstream>
00002 
00003 #include "FWCore/Framework/interface/Frameworkfwd.h"
00004 #include "FWCore/Framework/interface/EDAnalyzer.h"
00005 #include "FWCore/Framework/interface/Event.h"
00006 #include "FWCore/Framework/interface/EventSetup.h"
00007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00008 #include "FWCore/Utilities/interface/InputTag.h"
00009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00010 
00011 #include "EventFilter/SiStripRawToDigi/interface/SiStripFEDBuffer.h"
00012 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
00013 #include "DataFormats/FEDRawData/interface/FEDRawData.h"
00014 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
00015 
00016 //
00017 // Class declaration
00018 //
00019 
00020 class SiStripFEDDumpPlugin : public edm::EDAnalyzer
00021 {
00022  public:
00023   explicit SiStripFEDDumpPlugin(const edm::ParameterSet&);
00024   ~SiStripFEDDumpPlugin();
00025  private:
00026   virtual void beginJob();
00027   virtual void analyze(const edm::Event&, const edm::EventSetup&);
00028   virtual void endJob();
00029 
00030   //tag of FEDRawData collection
00031   edm::InputTag rawDataTag_;
00032   //FED ID to dump
00033   unsigned int fedIdToDump_;
00034 };
00035 
00036 
00037 //
00038 // Constructors and destructor
00039 //
00040 
00041 SiStripFEDDumpPlugin::SiStripFEDDumpPlugin(const edm::ParameterSet& iConfig)
00042   : rawDataTag_(iConfig.getUntrackedParameter<edm::InputTag>("RawDataTag",edm::InputTag("source",""))),
00043     fedIdToDump_(iConfig.getUntrackedParameter<unsigned int>("FEDID",50))
00044 {
00045   if ( (fedIdToDump_ > FEDNumbering::MAXSiStripFEDID) || (fedIdToDump_ < FEDNumbering::MINSiStripFEDID) )
00046     edm::LogError("SiStripFEDDump") << "FED ID " << fedIdToDump_ << " is not valid. "
00047                                     << "SiStrip FED IDs are " << uint16_t(FEDNumbering::MINSiStripFEDID) << "-" << uint16_t(FEDNumbering::MAXSiStripFEDID);
00048 }
00049 
00050 SiStripFEDDumpPlugin::~SiStripFEDDumpPlugin()
00051 {
00052 }
00053 
00054 
00055 //
00056 // Member functions
00057 //
00058 
00059 // ------------ method called to for each event  ------------
00060 void
00061 SiStripFEDDumpPlugin::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00062 {
00063   //get raw data
00064   edm::Handle<FEDRawDataCollection> rawDataCollectionHandle;
00065   iEvent.getByLabel(rawDataTag_,rawDataCollectionHandle);
00066   const FEDRawDataCollection& rawDataCollection = *rawDataCollectionHandle;
00067   
00068   const FEDRawData& rawData = rawDataCollection.FEDData(fedIdToDump_);
00069   const sistrip::FEDBufferBase buffer(rawData.data(),rawData.size(),true);
00070   std::ostringstream os;
00071   os << buffer << std::endl;
00072   buffer.dump(os);
00073   edm::LogVerbatim("SiStripFEDDump") << os.str();
00074 }
00075 
00076 // ------------ method called once each job just before starting event loop  ------------
00077 void 
00078 SiStripFEDDumpPlugin::beginJob()
00079 {
00080 }
00081 
00082 // ------------ method called once each job just after ending the event loop  ------------
00083 void 
00084 SiStripFEDDumpPlugin::endJob()
00085 {
00086 }
00087 
00088 //
00089 // Define as a plug-in
00090 //
00091 
00092 #include "FWCore/Framework/interface/MakerMacros.h"
00093 DEFINE_FWK_MODULE(SiStripFEDDumpPlugin);