Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-31 23:14:00

0001 #include <sstream>
0002 
0003 #include "FWCore/Utilities/interface/EDGetToken.h"
0004 #include "FWCore/Framework/interface/Frameworkfwd.h"
0005 #include "FWCore/Framework/interface/Event.h"
0006 #include "FWCore/Framework/interface/EventSetup.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0008 #include "FWCore/Utilities/interface/InputTag.h"
0009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0010 
0011 #include "EventFilter/SiStripRawToDigi/interface/SiStripFEDBuffer.h"
0012 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
0013 #include "DataFormats/FEDRawData/interface/FEDRawData.h"
0014 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
0015 
0016 #include "DQMServices/Core/interface/DQMEDAnalyzer.h"
0017 
0018 //
0019 // Class declaration
0020 //
0021 
0022 class SiStripFEDDumpPlugin : public DQMEDAnalyzer {
0023 public:
0024   explicit SiStripFEDDumpPlugin(const edm::ParameterSet&);
0025   ~SiStripFEDDumpPlugin() override;
0026 
0027 private:
0028   void analyze(const edm::Event&, const edm::EventSetup&) override;
0029   void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
0030 
0031   //tag of FEDRawData collection
0032   edm::InputTag rawDataTag_;
0033   edm::EDGetTokenT<FEDRawDataCollection> rawDataToken_;
0034   //FED ID to dump
0035   unsigned int fedIdToDump_;
0036 };
0037 
0038 //
0039 // Constructors and destructor
0040 //
0041 
0042 SiStripFEDDumpPlugin::SiStripFEDDumpPlugin(const edm::ParameterSet& iConfig)
0043     : rawDataTag_(iConfig.getUntrackedParameter<edm::InputTag>("RawDataTag", edm::InputTag("source", ""))),
0044       fedIdToDump_(iConfig.getUntrackedParameter<unsigned int>("FEDID", 50)) {
0045   rawDataToken_ = consumes<FEDRawDataCollection>(rawDataTag_);
0046   if ((fedIdToDump_ > FEDNumbering::MAXSiStripFEDID) || (fedIdToDump_ < FEDNumbering::MINSiStripFEDID))
0047     edm::LogError("SiStripFEDDump") << "FED ID " << fedIdToDump_ << " is not valid. "
0048                                     << "SiStrip FED IDs are " << uint16_t(FEDNumbering::MINSiStripFEDID) << "-"
0049                                     << uint16_t(FEDNumbering::MAXSiStripFEDID);
0050 }
0051 
0052 SiStripFEDDumpPlugin::~SiStripFEDDumpPlugin() {}
0053 
0054 //
0055 // Member functions
0056 //
0057 
0058 // ------------ method called to for each event  ------------
0059 void SiStripFEDDumpPlugin::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0060   //get raw data
0061   edm::Handle<FEDRawDataCollection> rawDataCollectionHandle;
0062   iEvent.getByToken(rawDataToken_, rawDataCollectionHandle);
0063   const FEDRawDataCollection& rawDataCollection = *rawDataCollectionHandle;
0064 
0065   const FEDRawData& rawData = rawDataCollection.FEDData(fedIdToDump_);
0066   const auto st_buffer = sistrip::preconstructCheckFEDBufferBase(rawData, false);
0067   if (sistrip::FEDBufferStatusCode::SUCCESS != st_buffer) {
0068     throw cms::Exception("FEDBuffer") << st_buffer;
0069   }
0070   const sistrip::FEDBufferBase buffer{rawData};
0071   std::ostringstream os;
0072   os << buffer << std::endl;
0073   buffer.dump(os);
0074   edm::LogVerbatim("SiStripFEDDump") << os.str();
0075 }
0076 
0077 void SiStripFEDDumpPlugin::bookHistograms(DQMStore::IBooker& ibooker,
0078                                           const edm::Run& run,
0079                                           const edm::EventSetup& eSetup) {}
0080 
0081 //
0082 // Define as a plug-in
0083 //
0084 
0085 #include "FWCore/Framework/interface/MakerMacros.h"
0086 DEFINE_FWK_MODULE(SiStripFEDDumpPlugin);