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/CSCNoiseMatrix.h"
0022 #include "CondFormats/DataRecord/interface/CSCNoiseMatrixRcd.h"
0023 
0024 using namespace std;
0025 
0026 namespace edmtest {
0027   class CSCNoiseMatrixReadAnalyzer : public edm::global::EDAnalyzer<> {
0028   public:
0029     explicit CSCNoiseMatrixReadAnalyzer(edm::ParameterSet const& p) : noiseToken_{esConsumes()} {}
0030     ~CSCNoiseMatrixReadAnalyzer() override {}
0031     void analyze(edm::StreamID, const edm::Event& e, const edm::EventSetup& c) const override;
0032 
0033   private:
0034     edm::ESGetToken<CSCNoiseMatrix, CSCNoiseMatrixRcd> noiseToken_;
0035   };
0036 
0037   void CSCNoiseMatrixReadAnalyzer::analyze(edm::StreamID, const edm::Event& e, const edm::EventSetup& context) const {
0038     using namespace edm::eventsetup;
0039     edm::LogSystem log("CSCNoiseMatrix");
0040     log << " I AM IN RUN NUMBER " << e.id().run() << std::endl;
0041     log << " ---EVENT NUMBER " << e.id().event() << std::endl;
0042 
0043     const CSCNoiseMatrix* myNoiseMatrix = &context.getData(noiseToken_);
0044     std::map<int, std::vector<CSCNoiseMatrix::Item> >::const_iterator it;
0045     for (it = myNoiseMatrix->matrix.begin(); it != myNoiseMatrix->matrix.end(); ++it) {
0046       log << "layer id found " << it->first << std::endl;
0047       std::vector<CSCNoiseMatrix::Item>::const_iterator matrixit;
0048       for (matrixit = it->second.begin(); matrixit != it->second.end(); ++matrixit) {
0049         log << "  matrix elem33:  " << matrixit->elem33 << " matrix elem34: " << matrixit->elem34 << std::endl;
0050       }
0051     }
0052   }
0053   DEFINE_FWK_MODULE(CSCNoiseMatrixReadAnalyzer);
0054 }  // namespace edmtest