Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-11-11 03:56:57

0001 // user include files
0002 #include "CondFormats/DataRecord/interface/SiStripSummaryRcd.h"
0003 #include "CondFormats/SiStripObjects/interface/SiStripSummary.h"
0004 #include "FWCore/Framework/interface/ESHandle.h"
0005 #include "FWCore/Framework/interface/Event.h"
0006 #include "FWCore/Framework/interface/EventSetup.h"
0007 #include "FWCore/Framework/interface/Frameworkfwd.h"
0008 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0011 #include "FWCore/ServiceRegistry/interface/Service.h"
0012 
0013 // system include files
0014 #include <iostream>
0015 #include <string>
0016 #include <sstream>
0017 #include <cstdio>
0018 #include <sys/time.h>
0019 
0020 class SiStripSummaryReader : public edm::one::EDAnalyzer<> {
0021 public:
0022   explicit SiStripSummaryReader(const edm::ParameterSet&);
0023   ~SiStripSummaryReader() override = default;
0024 
0025   void analyze(const edm::Event&, const edm::EventSetup&) override;
0026 
0027 private:
0028   uint32_t printdebug_;
0029   const edm::ESGetToken<SiStripSummary, SiStripSummaryRcd> summaryToken_;
0030 };
0031 
0032 SiStripSummaryReader::SiStripSummaryReader(const edm::ParameterSet& iConfig)
0033     : printdebug_(iConfig.getUntrackedParameter<uint32_t>("printDebug", 1)), summaryToken_(esConsumes()) {}
0034 
0035 void SiStripSummaryReader::analyze(const edm::Event& e, const edm::EventSetup& iSetup) {
0036   const auto& summary = iSetup.getData(summaryToken_);
0037   edm::LogInfo("SiStripSummaryReader") << "[SiStripSummaryReader::analyze] End Reading SiStripSummary" << std::endl;
0038 
0039   std::vector<uint32_t> detid = summary.getDetIds();
0040 
0041   std::vector<std::string> userDB = summary.getUserDBContent();
0042   std::stringstream ss;
0043   for (size_t i = 0; i < userDB.size(); ++i)
0044     ss << userDB[i] << " \n";
0045 
0046   if (printdebug_)
0047     for (size_t id = 0; id < detid.size(); id++) {
0048       ss << "\n\tdetid " << detid[id];
0049       SiStripSummary::Range range = summary.getRange(detid[id]);
0050 
0051       size_t c = 0;
0052       for (SiStripSummary::ContainerIterator it = range.first; it != range.second; ++it) {
0053         ss << "\n\t\t " << userDB[c++] << " " << *it;
0054       }
0055     }
0056   edm::LogInfo("SiStripSummaryReader") << ss.str();
0057 }
0058 
0059 #include "FWCore/PluginManager/interface/ModuleDef.h"
0060 #include "FWCore/Framework/interface/MakerMacros.h"
0061 
0062 DEFINE_FWK_MODULE(SiStripSummaryReader);