Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 11:16:06

0001 // -*- C++ -*-
0002 //
0003 // Package:    PhysicsTools/NanoAOD
0004 // Class:      LHCInfoProducer
0005 //
0006 /**\class LHCInfoProducer LHCInfoProducer.cc PhysicsTools/NanoAOD/plugins/LHCInfoProducer.cc
0007  Description: [one line class summary]
0008  Implementation:
0009      [Notes on implementation]
0010 */
0011 //
0012 // Original Author:  Justin Williams
0013 //         Created: 05 Jul 2019 14:06:12 GMT
0014 //
0015 //
0016 
0017 // System include files
0018 #include <memory>
0019 #include <map>
0020 #include <string>
0021 #include <vector>
0022 #include <iostream>
0023 
0024 // user include files
0025 #include "FWCore/Framework/interface/Frameworkfwd.h"
0026 #include "FWCore/Framework/interface/global/EDProducer.h"
0027 
0028 #include "FWCore/Framework/interface/Event.h"
0029 #include "FWCore/Framework/interface/MakerMacros.h"
0030 
0031 #include "FWCore/Framework/interface/ESHandle.h"
0032 #include "FWCore/Framework/interface/ESProducer.h"
0033 #include "FWCore/Framework/interface/EventSetup.h"
0034 #include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h"
0035 #include "FWCore/Framework/interface/SourceFactory.h"
0036 
0037 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0038 #include "FWCore/Utilities/interface/StreamID.h"
0039 
0040 #include "CommonTools/Egamma/interface/EffectiveAreas.h"
0041 
0042 #include "DataFormats/NanoAOD/interface/FlatTable.h"
0043 #include "DataFormats/Common/interface/ValueMap.h"
0044 #include "DataFormats/NanoAOD/interface/MergeableCounterTable.h"
0045 
0046 #include "FWCore/Utilities/interface/transform.h"
0047 
0048 #include "CondFormats/RunInfo/interface/LHCInfo.h"
0049 #include "CondFormats/DataRecord/interface/LHCInfoRcd.h"
0050 
0051 class LHCInfoProducer : public edm::global::EDProducer<edm::BeginLuminosityBlockProducer> {
0052 public:
0053   LHCInfoProducer(edm::ParameterSet const&) : lhcinfoToken_(esConsumes<edm::Transition::BeginLuminosityBlock>()) {
0054     produces<nanoaod::MergeableCounterTable, edm::Transition::BeginLuminosityBlock>();
0055   }
0056   ~LHCInfoProducer() override {}
0057 
0058   // ------------ method called to produce the data  ------------
0059   void produce(edm::StreamID id, edm::Event& iEvent, const edm::EventSetup& iSetup) const override {}
0060 
0061   void globalBeginLuminosityBlockProduce(edm::LuminosityBlock& iLumi, edm::EventSetup const& iSetup) const override {
0062     const auto& info = iSetup.getData(lhcinfoToken_);
0063     auto out = std::make_unique<nanoaod::MergeableCounterTable>();
0064     out->addFloat("crossingAngle", "LHC crossing angle", info.crossingAngle());
0065     out->addFloat("betaStar", "LHC beta star", info.betaStar());
0066     out->addFloat("energy", "LHC beam energy", info.energy());
0067     iLumi.put(std::move(out));
0068   }
0069 
0070   // ------------ method fills 'descriptions' with the allowed parameters for the module  ------------
0071   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0072     edm::ParameterSetDescription desc;
0073     descriptions.addWithDefaultLabel(desc);
0074   }
0075   edm::ESGetToken<LHCInfo, LHCInfoRcd> lhcinfoToken_;
0076 };
0077 
0078 DEFINE_FWK_MODULE(LHCInfoProducer);