Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-02-16 06:12:13

0001 // system include files
0002 #include <iostream>
0003 #include <stdio.h>
0004 #include <sys/time.h>
0005 
0006 // user include files
0007 #include "CalibFormats/SiStripObjects/interface/SiStripGain.h"
0008 #include "CalibTracker/Records/interface/SiStripGainRcd.h"
0009 #include "FWCore/Framework/interface/Event.h"
0010 #include "FWCore/Framework/interface/EventSetup.h"
0011 #include "FWCore/Framework/interface/Frameworkfwd.h"
0012 #include "FWCore/Framework/interface/MakerMacros.h"
0013 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0014 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0015 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0016 #include "FWCore/ServiceRegistry/interface/Service.h"
0017 
0018 //
0019 // class decleration
0020 //
0021 class SiStripGainReader : public edm::one::EDAnalyzer<> {
0022 public:
0023   explicit SiStripGainReader(const edm::ParameterSet&);
0024   ~SiStripGainReader() = default;
0025 
0026   void analyze(const edm::Event&, const edm::EventSetup&);
0027 
0028 private:
0029   bool printdebug_;
0030   edm::ESGetToken<SiStripGain, SiStripGainRcd> gainToken;
0031 };
0032 
0033 SiStripGainReader::SiStripGainReader(const edm::ParameterSet& iConfig)
0034     : printdebug_(iConfig.getUntrackedParameter<bool>("printDebug", false)), gainToken(esConsumes()) {}
0035 
0036 void SiStripGainReader::analyze(const edm::Event& e, const edm::EventSetup& iSetup) {
0037   const auto& SiStripGain_ = &iSetup.getData(gainToken);
0038   edm::LogInfo("SiStripGainReader") << "[SiStripGainReader::analyze] End Reading SiStripGain";
0039 
0040   std::vector<uint32_t> detid;
0041   SiStripGain_->getDetIds(detid);
0042 
0043   SiStripApvGain::Range range = SiStripGain_->getRange(detid[0]);
0044 
0045   edm::LogInfo("SiStripApvGainReader") << "Number of detids: " << detid.size();
0046   int apv = 0;
0047   edm::LogInfo("SiStripApvGainReader") << " First det gain values";
0048   for (int it = 0; it < range.second - range.first; it++) {
0049     edm::LogInfo("SiStripApvGainReader") << "detid " << detid[0] << " \t"
0050                                          << " apv " << apv++ << " \t" << SiStripGain_->getApvGain(it, range) << " \t";
0051   }
0052 
0053   if (printdebug_) {
0054     for (size_t id = 0; id < detid.size(); id++) {
0055       SiStripApvGain::Range range = SiStripGain_->getRange(detid[id]);
0056       apv = 0;
0057 
0058       for (int it = 0; it < range.second - range.first; it++) {
0059         edm::LogInfo("SiStripGainReader") << "detid " << detid[id] << " \t"
0060                                           << " apv " << apv++ << " \t" << SiStripGain_->getApvGain(it, range) << " \t";
0061       }
0062     }
0063   }
0064 }
0065 
0066 DEFINE_FWK_MODULE(SiStripGainReader);