File indexing completed on 2024-04-06 12:22:26
0001 #include <iomanip>
0002 #include <iostream>
0003
0004 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0005
0006 #include "FWCore/Framework/interface/Event.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0008
0009 #include "FWCore/Framework/interface/EventSetup.h"
0010 #include "FWCore/Framework/interface/ESHandle.h"
0011
0012 #include "CondFormats/L1TObjects/interface/L1TUtmTriggerMenu.h"
0013 #include "CondFormats/DataRecord/interface/L1TUtmTriggerMenuRcd.h"
0014 #include "CondFormats/DataRecord/interface/L1TUtmTriggerMenuO2ORcd.h"
0015
0016 #include "FWCore/ServiceRegistry/interface/Service.h"
0017 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
0018
0019 class L1MenuWriter : public edm::one::EDAnalyzer<> {
0020 private:
0021 bool isO2Opayload;
0022
0023 public:
0024 void analyze(const edm::Event&, const edm::EventSetup&) override;
0025 const edm::ESGetToken<L1TUtmTriggerMenu, L1TUtmTriggerMenuRcd> l1GtMenuToken_;
0026 const edm::ESGetToken<L1TUtmTriggerMenu, L1TUtmTriggerMenuO2ORcd> l1GtMenuO2OToken_;
0027
0028 explicit L1MenuWriter(const edm::ParameterSet& pset)
0029 : edm::one::EDAnalyzer<>(),
0030 l1GtMenuToken_(esConsumes<L1TUtmTriggerMenu, L1TUtmTriggerMenuRcd>()),
0031 l1GtMenuO2OToken_(esConsumes<L1TUtmTriggerMenu, L1TUtmTriggerMenuO2ORcd>()) {
0032 isO2Opayload = pset.getUntrackedParameter<bool>("isO2Opayload", false);
0033 }
0034 ~L1MenuWriter(void) override = default;
0035 };
0036
0037 void L1MenuWriter::analyze(const edm::Event& iEvent, const edm::EventSetup& evSetup) {
0038 edm::ESHandle<L1TUtmTriggerMenu> handle1;
0039
0040 if (isO2Opayload)
0041 handle1 = evSetup.getHandle(l1GtMenuO2OToken_);
0042 else
0043 handle1 = evSetup.getHandle(l1GtMenuToken_);
0044
0045 std::shared_ptr<L1TUtmTriggerMenu> ptr1(new L1TUtmTriggerMenu(*(handle1.product())));
0046
0047 edm::Service<cond::service::PoolDBOutputService> poolDb;
0048 if (poolDb.isAvailable()) {
0049 cond::Time_t firstSinceTime = poolDb->beginOfTime();
0050 poolDb->writeOneIOV(*ptr1, firstSinceTime, (isO2Opayload ? "L1TUtmTriggerMenuO2ORcd" : "L1TUtmTriggerMenuRcd"));
0051 }
0052 }
0053
0054 #include "FWCore/PluginManager/interface/ModuleDef.h"
0055 #include "FWCore/Framework/interface/MakerMacros.h"
0056 #include "FWCore/Framework/interface/ModuleFactory.h"
0057
0058 DEFINE_FWK_MODULE(L1MenuWriter);