File indexing completed on 2024-04-06 12:02:00
0001
0002
0003
0004
0005
0006
0007 #include <stdexcept>
0008 #include <string>
0009 #include <iostream>
0010 #include <fstream>
0011 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0012 #include "FWCore/Framework/interface/Event.h"
0013 #include "FWCore/Framework/interface/MakerMacros.h"
0014
0015 #include "FWCore/Framework/interface/EventSetup.h"
0016 #include "FWCore/Utilities/interface/ESGetToken.h"
0017 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0018
0019 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0020
0021 #include "CondFormats/CSCObjects/interface/CSCDBGains.h"
0022 #include "CondFormats/DataRecord/interface/CSCDBGainsRcd.h"
0023
0024 namespace edmtest {
0025 class CSCGainsDBReadAnalyzer : public edm::one::EDAnalyzer<> {
0026 public:
0027 explicit CSCGainsDBReadAnalyzer(edm::ParameterSet const& p) : token_{esConsumes()} {}
0028 ~CSCGainsDBReadAnalyzer() override {}
0029 void analyze(const edm::Event& e, const edm::EventSetup& c) override;
0030
0031 private:
0032 edm::ESGetToken<CSCDBGains, CSCDBGainsRcd> token_;
0033 };
0034
0035 void CSCGainsDBReadAnalyzer::analyze(const edm::Event& e, const edm::EventSetup& context) {
0036 using namespace edm::eventsetup;
0037 std::ofstream DBGainsFile("dbgains.dat", std::ios::out);
0038 int counter = 0;
0039
0040 edm::LogInfo log("CSCDBGains");
0041 log << " I AM IN RUN NUMBER " << e.id().run() << std::endl;
0042 log << " ---EVENT NUMBER " << e.id().event() << std::endl;
0043
0044 const CSCDBGains* mygains = &context.getData(token_);
0045 std::vector<CSCDBGains::Item>::const_iterator it;
0046
0047 for (it = mygains->gains.begin(); it != mygains->gains.end(); ++it) {
0048 counter++;
0049 DBGainsFile << counter << " " << it->gain_slope << std::endl;
0050 }
0051 }
0052 DEFINE_FWK_MODULE(CSCGainsDBReadAnalyzer);
0053 }