Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-02 03:38:57

0001 /*----------------------------------------------------------------------
0002 
0003 Toy EDProducers and EDProducts for testing purposes only.
0004 
0005 ----------------------------------------------------------------------*/
0006 
0007 #include <stdexcept>
0008 #include <string>
0009 #include <map>
0010 #include <vector>
0011 #include "FWCore/Framework/interface/global/EDAnalyzer.h"
0012 #include "FWCore/Framework/interface/Event.h"
0013 #include "FWCore/Framework/interface/ESHandle.h"
0014 #include "FWCore/Framework/interface/MakerMacros.h"
0015 
0016 #include "FWCore/Framework/interface/EventSetup.h"
0017 #include "FWCore/Utilities/interface/ESGetToken.h"
0018 
0019 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0020 
0021 #include "CondFormats/CSCObjects/interface/CSCGains.h"
0022 #include "CondFormats/DataRecord/interface/CSCGainsRcd.h"
0023 
0024 using namespace std;
0025 
0026 namespace edmtest {
0027   class CSCGainsReadAnalyzer : public edm::global::EDAnalyzer<> {
0028   public:
0029     explicit CSCGainsReadAnalyzer(edm::ParameterSet const& p) : gainsToken_{esConsumes()} {}
0030     ~CSCGainsReadAnalyzer() override {}
0031     void analyze(edm::StreamID, const edm::Event& e, const edm::EventSetup& c) const override;
0032 
0033   private:
0034     edm::ESGetToken<CSCGains, CSCGainsRcd> gainsToken_;
0035   };
0036 
0037   void CSCGainsReadAnalyzer::analyze(edm::StreamID, const edm::Event& e, const edm::EventSetup& context) const {
0038     using namespace edm::eventsetup;
0039 
0040     edm::LogSystem log("CSCGains");
0041     log << " I AM IN RUN NUMBER " << e.id().run() << std::endl;
0042     log << " ---EVENT NUMBER " << e.id().event() << std::endl;
0043 
0044     const CSCGains* mygains = &context.getData(gainsToken_);
0045     std::map<int, std::vector<CSCGains::Item> >::const_iterator it;
0046     for (it = mygains->gains.begin(); it != mygains->gains.end(); ++it) {
0047       log << "layer id found " << it->first << std::endl;
0048       std::vector<CSCGains::Item>::const_iterator gainsit;
0049       for (gainsit = it->second.begin(); gainsit != it->second.end(); ++gainsit) {
0050         log << "  gains:  " << gainsit->gain_slope << " intercept: " << gainsit->gain_intercept << std::endl;
0051       }
0052     }
0053   }
0054   DEFINE_FWK_MODULE(CSCGainsReadAnalyzer);
0055 }  // namespace edmtest