Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 10:00:54

0001 // -*- C++ -*-
0002 //
0003 // Package:    RecoLuminosity/TestLumiProducerFromBrilcalc
0004 // Class:      TestLumiProducerFromBrilcalc
0005 //
0006 /**\class TestLumiProducerFromBrilcalc TestLumiProducerFromBrilcalc.cc RecoLuminosity/LumiProducer/test/TestLumiProducerFromBrilcalc.cc
0007 
0008    Description: A simple analyzer class to test the functionality of TestLumiProducerFromBrilcalc.
0009 
0010    Implementation:
0011    Get the luminosity and prints it out.
0012 */
0013 //
0014 // Original Author:  Paul Lujan
0015 //         Created:  Fri, 20 Mar 2020 09:32:27 GMT
0016 //
0017 //
0018 
0019 // system include files
0020 #include <memory>
0021 #include <iostream>
0022 
0023 // user include files
0024 #include "FWCore/Framework/interface/Frameworkfwd.h"
0025 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0026 
0027 #include "FWCore/Framework/interface/Event.h"
0028 #include "FWCore/Framework/interface/MakerMacros.h"
0029 
0030 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0031 #include "FWCore/Utilities/interface/InputTag.h"
0032 
0033 #include "DataFormats/Luminosity/interface/LumiInfo.h"
0034 
0035 //
0036 // class declaration
0037 //
0038 
0039 // If the analyzer does not use TFileService, please remove
0040 // the template argument to the base class so the class inherits
0041 // from edm::one::EDAnalyzer<>
0042 // This will improve performance in multithreaded jobs.
0043 
0044 class TestLumiProducerFromBrilcalc : public edm::one::EDAnalyzer<> {
0045 public:
0046   explicit TestLumiProducerFromBrilcalc(const edm::ParameterSet&);
0047   ~TestLumiProducerFromBrilcalc();
0048 
0049   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0050 
0051 private:
0052   virtual void beginJob() override;
0053   virtual void analyze(const edm::Event&, const edm::EventSetup&) override;
0054   virtual void endJob() override;
0055 
0056   // ----------member data ---------------------------
0057   edm::InputTag inputTag_;
0058   edm::EDGetTokenT<LumiInfo> lumiToken_;
0059 };
0060 
0061 //
0062 // constants, enums and typedefs
0063 //
0064 
0065 //
0066 // static data member definitions
0067 //
0068 
0069 //
0070 // constructors and destructor
0071 //
0072 TestLumiProducerFromBrilcalc::TestLumiProducerFromBrilcalc(const edm::ParameterSet& iConfig)
0073     : inputTag_(iConfig.getUntrackedParameter<edm::InputTag>("inputTag")), lumiToken_(consumes<LumiInfo>(inputTag_)) {}
0074 
0075 TestLumiProducerFromBrilcalc::~TestLumiProducerFromBrilcalc() {
0076   // do anything here that needs to be done at destruction time
0077   // (e.g. close files, deallocate resources etc.)
0078 }
0079 
0080 //
0081 // member functions
0082 //
0083 
0084 // ------------ method called for each event  ------------
0085 void TestLumiProducerFromBrilcalc::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0086   using namespace edm;
0087 
0088   const LumiInfo& lumi = iEvent.get(lumiToken_);
0089 
0090   std::cout << "Luminosity for " << iEvent.run() << " LS " << iEvent.luminosityBlock() << " is "
0091             << lumi.getTotalInstLumi() << std::endl;
0092 }
0093 
0094 // ------------ method called once each job just before starting event loop  ------------
0095 void TestLumiProducerFromBrilcalc::beginJob() {}
0096 
0097 // ------------ method called once each job just after ending the event loop  ------------
0098 void TestLumiProducerFromBrilcalc::endJob() {}
0099 
0100 // ------------ method fills 'descriptions' with the allowed parameters for the module  ------------
0101 void TestLumiProducerFromBrilcalc::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0102   // Allowed parameters
0103   edm::ParameterSetDescription desc;
0104   desc.addUntracked<edm::InputTag>("inputTag");
0105   descriptions.addDefault(desc);
0106 }
0107 
0108 //define this as a plug-in
0109 DEFINE_FWK_MODULE(TestLumiProducerFromBrilcalc);