File indexing completed on 2024-04-06 12:02:44
0001 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0002 #include "FWCore/Framework/interface/Event.h"
0003 #include "FWCore/Framework/interface/EventSetup.h"
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005 #include "FWCore/Utilities/interface/Exception.h"
0006 #include "CondFormats/DQMObjects/interface/DQMSummary.h"
0007 #include "CondFormats/DataRecord/interface/DQMSummaryRcd.h"
0008 #include "FWCore/Framework/interface/MakerMacros.h"
0009
0010 namespace edmtest {
0011 class DQMSummaryEventSetupAnalyzer : public edm::one::EDAnalyzer<> {
0012 public:
0013 explicit DQMSummaryEventSetupAnalyzer(const edm::ParameterSet& pset);
0014 explicit DQMSummaryEventSetupAnalyzer(int i);
0015 ~DQMSummaryEventSetupAnalyzer() override;
0016 void analyze(const edm::Event& event, const edm::EventSetup& setup) override;
0017
0018 private:
0019 const edm::ESGetToken<DQMSummary, DQMSummaryRcd> dqmSummaryToken_;
0020 };
0021
0022 DQMSummaryEventSetupAnalyzer::DQMSummaryEventSetupAnalyzer(const edm::ParameterSet& pset)
0023 : dqmSummaryToken_(esConsumes()) {
0024 edm::LogPrint("DQMSummaryEventSetupAnalyzer") << "DQMSummaryEventSetupAnalyzer" << std::endl;
0025 }
0026
0027 DQMSummaryEventSetupAnalyzer::DQMSummaryEventSetupAnalyzer(int i) : dqmSummaryToken_(esConsumes()) {
0028 edm::LogPrint("DQMSummaryEventSetupAnalyzer") << "DQMSummaryEventSetupAnalyzer" << i << std::endl;
0029 }
0030
0031 DQMSummaryEventSetupAnalyzer::~DQMSummaryEventSetupAnalyzer() {
0032 edm::LogPrint("DQMSummaryEventSetupAnalyzer") << "~DQMSummaryEventSetupAnalyzer" << std::endl;
0033 }
0034
0035 void DQMSummaryEventSetupAnalyzer::analyze(const edm::Event& event, const edm::EventSetup& setup) {
0036 edm::LogPrint("DQMSummaryEventSetupAnalyzer") << "### DQMSummaryEventSetupAnalyzer::analyze" << std::endl;
0037 edm::LogPrint("DQMSummaryEventSetupAnalyzer") << "--- RUN NUMBER: " << event.id().run() << std::endl;
0038 edm::LogPrint("DQMSummaryEventSetupAnalyzer") << "--- EVENT NUMBER: " << event.id().event() << std::endl;
0039 edm::eventsetup::EventSetupRecordKey recordKey(
0040 edm::eventsetup::EventSetupRecordKey::TypeTag::findType("DQMSummaryRcd"));
0041 if (recordKey.type() == edm::eventsetup::EventSetupRecordKey::TypeTag()) {
0042 throw cms::Exception("Record not found") << "Record \"DQMSummaryRcd"
0043 << "\" does not exist!" << std::endl;
0044 }
0045
0046 edm::LogPrint("DQMSummaryEventSetupAnalyzer") << "got EShandle" << std::endl;
0047 edm::ESHandle<DQMSummary> sum = setup.getHandle(dqmSummaryToken_);
0048 edm::LogPrint("DQMSummaryEventSetupAnalyzer") << "got the Event Setup" << std::endl;
0049 const DQMSummary* summary = sum.product();
0050 edm::LogPrint("DQMSummaryEventSetupAnalyzer") << "got DQMSummary* " << std::endl;
0051 edm::LogPrint("DQMSummaryEventSetupAnalyzer") << "print result" << std::endl;
0052 summary->printAllValues();
0053 }
0054
0055 DEFINE_FWK_MODULE(DQMSummaryEventSetupAnalyzer);
0056 }