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 <fstream>
0011 
0012 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0013 #include "FWCore/Framework/interface/Event.h"
0014 #include "FWCore/Framework/interface/MakerMacros.h"
0015 
0016 #include "FWCore/Framework/interface/EventSetup.h"
0017 #include "FWCore/Utilities/interface/ESGetToken.h"
0018 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0019 
0020 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0021 
0022 #include "CondFormats/CSCObjects/interface/CSCDBCrosstalk.h"
0023 #include "CondFormats/DataRecord/interface/CSCDBCrosstalkRcd.h"
0024 
0025 namespace edmtest {
0026   class CSCCrossTalkDBReadAnalyzer : public edm::one::EDAnalyzer<> {
0027   public:
0028     explicit CSCCrossTalkDBReadAnalyzer(edm::ParameterSet const& p) : token_{esConsumes()} {}
0029     ~CSCCrossTalkDBReadAnalyzer() override {}
0030     void analyze(const edm::Event& e, const edm::EventSetup& c) override;
0031 
0032   private:
0033     edm::ESGetToken<CSCDBCrosstalk, CSCDBCrosstalkRcd> token_;
0034   };
0035 
0036   void CSCCrossTalkDBReadAnalyzer::analyze(const edm::Event& e, const edm::EventSetup& context) {
0037     std::ofstream DBXtalkFile("dbxtalk.dat", std::ios::out);
0038     int counter = 0;
0039     using namespace edm::eventsetup;
0040 
0041     edm::LogInfo log("CSCDBCrosstalk");
0042     log << " I AM IN RUN NUMBER " << e.id().run() << std::endl;
0043     log << " ---EVENT NUMBER " << e.id().event() << std::endl;
0044 
0045     const CSCDBCrosstalk* mycrosstalk = &context.getData(token_);
0046     std::vector<CSCDBCrosstalk::Item>::const_iterator it;
0047     for (it = mycrosstalk->crosstalk.begin(); it != mycrosstalk->crosstalk.end(); ++it) {
0048       counter++;
0049       DBXtalkFile << counter << "  " << it->xtalk_slope_right << "  " << it->xtalk_intercept_right << "  "
0050                   << it->xtalk_slope_left << "  " << it->xtalk_intercept_left << std::endl;
0051     }
0052   }
0053   DEFINE_FWK_MODULE(CSCCrossTalkDBReadAnalyzer);
0054 }  // namespace edmtest