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/L1TMuonGlobalParamsO2ORcd.h"
0012 #include "CondFormats/DataRecord/interface/L1TMuonGlobalParamsRcd.h"
0013 #include "CondFormats/L1TObjects/interface/L1TMuonGlobalParams.h"
0014 
0015 #include "FWCore/ServiceRegistry/interface/Service.h"
0016 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
0017 
0018 class L1TMuonGlobalParamsWriter : public edm::one::EDAnalyzer<> {
0019 private:
0020   edm::ESGetToken<L1TMuonGlobalParams, L1TMuonGlobalParamsO2ORcd> o2oToken_;
0021   edm::ESGetToken<L1TMuonGlobalParams, L1TMuonGlobalParamsRcd> token_;
0022   bool isO2Opayload;
0023 
0024 public:
0025   void analyze(const edm::Event&, const edm::EventSetup&) override;
0026 
0027   explicit L1TMuonGlobalParamsWriter(const edm::ParameterSet& pset) {
0028     isO2Opayload = pset.getUntrackedParameter<bool>("isO2Opayload", false);
0029     if (isO2Opayload) {
0030       o2oToken_ = esConsumes();
0031     } else {
0032       token_ = esConsumes();
0033     }
0034   }
0035 };
0036 
0037 void L1TMuonGlobalParamsWriter::analyze(const edm::Event& iEvent, const edm::EventSetup& evSetup) {
0038   edm::ESHandle<L1TMuonGlobalParams> handle1;
0039 
0040   if (isO2Opayload)
0041     handle1 = evSetup.getHandle(o2oToken_);
0042   else
0043     handle1 = evSetup.getHandle(token_);
0044 
0045   L1TMuonGlobalParams const& ptr1 = *handle1;
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 ? "L1TMuonGlobalParamsO2ORcd" : "L1TMuonGlobalParamsRcd"));
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(L1TMuonGlobalParamsWriter);