File indexing completed on 2023-03-17 11:20:00
0001 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0002 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0003 #include "FWCore/Framework/interface/Event.h"
0004 #include "FWCore/Framework/interface/LuminosityBlock.h"
0005 #include "FWCore/Framework/interface/NoDataException.h"
0006 #include "FWCore/Framework/interface/NoRecordException.h"
0007 #include "FWCore/Framework/interface/ESHandle.h"
0008 #include "FWCore/Framework/interface/MakerMacros.h"
0009 #include "FWCore/Framework/interface/EventSetup.h"
0010 #include "FWCore/Framework/interface/EventSetupRecord.h"
0011 #include "RecoLuminosity/LumiProducer/interface/DIPLumiSummary.h"
0012 #include "RecoLuminosity/LumiProducer/interface/DIPLumiDetail.h"
0013 #include "RecoLuminosity/LumiProducer/interface/DIPLuminosityRcd.h"
0014
0015 #include <iostream>
0016
0017 namespace edm {
0018 class EventSetup;
0019 }
0020
0021 using namespace std;
0022 using namespace edm;
0023
0024 class TestDIPLumiProducer : public edm::one::EDAnalyzer<edm::one::WatchLuminosityBlocks> {
0025 public:
0026 explicit TestDIPLumiProducer(edm::ParameterSet const&);
0027
0028 void beginLuminosityBlock(LuminosityBlock const& lumiBlock, EventSetup const& c) override {}
0029 void analyze(edm::Event const& e, edm::EventSetup const& c) override;
0030 void endLuminosityBlock(LuminosityBlock const& lumiBlock, EventSetup const& c) override;
0031
0032 private:
0033 edm::ESGetToken<DIPLumiSummary, DIPLuminosityRcd> token_;
0034 };
0035
0036
0037
0038 TestDIPLumiProducer::TestDIPLumiProducer(edm::ParameterSet const& ps) : token_(esConsumes()) {}
0039
0040
0041
0042 void TestDIPLumiProducer::analyze(edm::Event const& e, edm::EventSetup const&) {}
0043
0044
0045
0046 void TestDIPLumiProducer::endLuminosityBlock(edm::LuminosityBlock const& lumiBlock, EventSetup const& es) {
0047 std::cout << " I AM IN RUN NUMBER " << lumiBlock.run() << " LS NUMBER " << lumiBlock.luminosityBlock() << std::endl;
0048 edm::eventsetup::EventSetupRecordKey recordKey(
0049 edm::eventsetup::EventSetupRecordKey::TypeTag::findType("DIPLuminosityRcd"));
0050 if (recordKey.type() == edm::eventsetup::EventSetupRecordKey::TypeTag()) {
0051 std::cout << "Record \"DIPLuminosityRcd"
0052 << "\" does not exist " << std::endl;
0053 }
0054 try {
0055 edm::ESHandle<DIPLumiSummary> datahandle = es.getHandle(token_);
0056 if (datahandle.isValid()) {
0057 const DIPLumiSummary* mydata = datahandle.product();
0058 if (!mydata->isNull()) {
0059 std::cout << "from Run " << mydata->fromRun() << " from LS " << mydata->fromLS() << std::endl;
0060 std::cout << mydata->intgDelLumiByLS() << std::endl;
0061 } else {
0062 std::cout << "data empty" << std::endl;
0063 }
0064 } else {
0065 std::cout << "no valid record found" << std::endl;
0066 }
0067 } catch (const edm::eventsetup::NoRecordException<DIPLuminosityRcd>& er) {
0068 std::cout << "no data found" << std::endl;
0069 } catch (const cms::Exception& ee) {
0070 std::cout << ee.what() << std::endl;
0071 }
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089 }
0090
0091 DEFINE_FWK_MODULE(TestDIPLumiProducer);