Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:26:39

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 "DataFormats/Common/interface/Handle.h"
0006 #include "DataFormats/Luminosity/interface/LumiDetails.h"
0007 #include "DataFormats/Luminosity/interface/LumiSummary.h"
0008 #include "FWCore/Framework/interface/MakerMacros.h"
0009 
0010 #include <cmath>
0011 #include <iostream>
0012 
0013 namespace edm {
0014   class EventSetup;
0015 }
0016 
0017 using namespace std;
0018 using namespace edm;
0019 
0020 namespace edmtest {
0021 
0022   class TestExpressLumiProducer : public edm::one::EDAnalyzer<edm::one::WatchLuminosityBlocks> {
0023   public:
0024     explicit TestExpressLumiProducer(edm::ParameterSet const&);
0025 
0026     void beginLuminosityBlock(LuminosityBlock const& lumiBlock, EventSetup const& c) override {}
0027     void analyze(edm::Event const& e, edm::EventSetup const& c) override;
0028     void endLuminosityBlock(LuminosityBlock const& lumiBlock, EventSetup const& c) override;
0029   };
0030 
0031   // -----------------------------------------------------------------
0032 
0033   TestExpressLumiProducer::TestExpressLumiProducer(edm::ParameterSet const& ps) {
0034     consumes<LumiSummary, edm::InLumi>(edm::InputTag("expressLumiProducer", ""));
0035     consumes<LumiDetails, edm::InLumi>(edm::InputTag("expressLumiProducer", ""));
0036   }
0037 
0038   // -----------------------------------------------------------------
0039 
0040   void TestExpressLumiProducer::analyze(edm::Event const& e, edm::EventSetup const&) {}
0041 
0042   // -----------------------------------------------------------------
0043 
0044   void TestExpressLumiProducer::endLuminosityBlock(LuminosityBlock const& lumiBlock, EventSetup const& c) {
0045     Handle<LumiSummary> lumiSummary;
0046     lumiBlock.getByLabel("expressLumiProducer", lumiSummary);
0047     //std::cout<<"lumiSummary ptr "<<lumiSummary<<std::endl;
0048     if (lumiSummary->isValid()) {
0049       std::cout << *lumiSummary << "\n";
0050     } else {
0051       std::cout << "no valid lumi summary data" << std::endl;
0052     }
0053     Handle<LumiDetails> lumiDetails;
0054     lumiBlock.getByLabel("expressLumiProducer", lumiDetails);
0055     if (lumiDetails->isValid()) {
0056       std::cout << "valid detail" << std::endl;
0057       std::cout << "lumivalue bx 14 " << lumiDetails->lumiValue(LumiDetails::kOCC1, 14) << std::endl;
0058       std::cout << "lumivalue bx 214 " << lumiDetails->lumiValue(LumiDetails::kOCC1, 214) << std::endl;
0059       std::cout << "lumivalue bx 1475 " << lumiDetails->lumiValue(LumiDetails::kOCC1, 1475) << std::endl;
0060       std::cout << "lumivalue bx 2775 " << lumiDetails->lumiValue(LumiDetails::kOCC1, 2775) << std::endl;
0061       std::cout << "lumivalue bx 3500 " << lumiDetails->lumiValue(LumiDetails::kOCC1, 3500) << std::endl;
0062     } else {
0063       std::cout << "no valid lumi detail data" << std::endl;
0064     }
0065   }
0066 }  // namespace edmtest
0067 using edmtest::TestExpressLumiProducer;
0068 
0069 DEFINE_FWK_MODULE(TestExpressLumiProducer);