Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:02:00

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