File indexing completed on 2024-04-06 12:23:42
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #include <memory>
0019 #include <map>
0020 #include <string>
0021 #include <vector>
0022 #include <iostream>
0023
0024
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 "CondTools/RunInfo/interface/LHCInfoCombined.h"
0049
0050 class LHCInfoProducer : public edm::global::EDProducer<edm::BeginLuminosityBlockProducer> {
0051 public:
0052 LHCInfoProducer(edm::ParameterSet const& iConfig)
0053 : lhcinfoToken_(esConsumes<edm::Transition::BeginLuminosityBlock>(
0054 edm::ESInputTag("", iConfig.getParameter<std::string>("lhcInfoLabel")))),
0055 lhcinfoPerLSToken_(esConsumes<edm::Transition::BeginLuminosityBlock>(
0056 edm::ESInputTag("", iConfig.getParameter<std::string>("lhcInfoPerLSLabel")))),
0057 lhcinfoPerFillToken_(esConsumes<edm::Transition::BeginLuminosityBlock>(
0058 edm::ESInputTag("", iConfig.getParameter<std::string>("lhcInfoPerFillLabel")))),
0059 useNewLHCInfo_(iConfig.getParameter<bool>("useNewLHCInfo")) {
0060 produces<nanoaod::MergeableCounterTable, edm::Transition::BeginLuminosityBlock>();
0061 }
0062 ~LHCInfoProducer() override {}
0063
0064
0065 void produce(edm::StreamID id, edm::Event& iEvent, const edm::EventSetup& iSetup) const override {}
0066
0067 void globalBeginLuminosityBlockProduce(edm::LuminosityBlock& iLumi, edm::EventSetup const& iSetup) const override {
0068 LHCInfoCombined lhcInfoCombined(iSetup, lhcinfoPerLSToken_, lhcinfoPerFillToken_, lhcinfoToken_, useNewLHCInfo_);
0069 auto out = std::make_unique<nanoaod::MergeableCounterTable>();
0070 out->addFloat("crossingAngle", "LHC crossing angle", lhcInfoCombined.crossingAngle());
0071 out->addFloat("betaStar", "LHC beta star", lhcInfoCombined.betaStarX);
0072 out->addFloat("energy", "LHC beam energy", lhcInfoCombined.energy);
0073 iLumi.put(std::move(out));
0074 }
0075
0076
0077 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0078 edm::ParameterSetDescription desc;
0079 desc.add<std::string>("lhcInfoLabel", "")->setComment("label used for LHCInfo");
0080 desc.add<std::string>("lhcInfoPerLSLabel", "")->setComment("label of the LHCInfoPerLS record");
0081 desc.add<std::string>("lhcInfoPerFillLabel", "")->setComment("label of the LHCInfoPerFill record");
0082 desc.add<bool>("useNewLHCInfo", true)
0083 ->setComment("flag whether to use new LHCInfoPerLS/Fill records or old LHCInfo");
0084 descriptions.addWithDefaultLabel(desc);
0085 }
0086 edm::ESGetToken<LHCInfo, LHCInfoRcd> lhcinfoToken_;
0087 edm::ESGetToken<LHCInfoPerLS, LHCInfoPerLSRcd> lhcinfoPerLSToken_;
0088 edm::ESGetToken<LHCInfoPerFill, LHCInfoPerFillRcd> lhcinfoPerFillToken_;
0089 bool useNewLHCInfo_;
0090 };
0091
0092 DEFINE_FWK_MODULE(LHCInfoProducer);