Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-05-31 22:25:56

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