Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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