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 
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/DataRecord/interface/L1TMuonEndCapParamsO2ORcd.h"
0013 #include "CondFormats/DataRecord/interface/L1TMuonEndCapParamsRcd.h"
0014 #include "CondFormats/L1TObjects/interface/L1TMuonEndCapParams.h"
0015 
0016 #include "FWCore/ServiceRegistry/interface/Service.h"
0017 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
0018 
0019 class L1TMuonEndCapParamsWriter : public edm::one::EDAnalyzer<> {
0020 private:
0021   edm::ESGetToken<L1TMuonEndCapParams, L1TMuonEndCapParamsO2ORcd> o2oToken_;
0022   edm::ESGetToken<L1TMuonEndCapParams, L1TMuonEndCapParamsRcd> token_;
0023   bool isO2Opayload;
0024 
0025 public:
0026   void analyze(const edm::Event&, const edm::EventSetup&) override;
0027 
0028   explicit L1TMuonEndCapParamsWriter(const edm::ParameterSet& pset) {
0029     isO2Opayload = pset.getUntrackedParameter<bool>("isO2Opayload", false);
0030     if (isO2Opayload) {
0031       o2oToken_ = esConsumes();
0032     } else {
0033       token_ = esConsumes();
0034     }
0035   }
0036 };
0037 
0038 void L1TMuonEndCapParamsWriter::analyze(const edm::Event& iEvent, const edm::EventSetup& evSetup) {
0039   edm::ESHandle<L1TMuonEndCapParams> handle1;
0040 
0041   if (isO2Opayload)
0042     handle1 = evSetup.getHandle(o2oToken_);
0043   else
0044     handle1 = evSetup.getHandle(token_);
0045 
0046   L1TMuonEndCapParams const& ptr1 = *handle1;
0047 
0048   edm::Service<cond::service::PoolDBOutputService> poolDb;
0049   if (poolDb.isAvailable()) {
0050     cond::Time_t firstSinceTime = poolDb->beginOfTime();
0051     poolDb->writeOneIOV(ptr1, firstSinceTime, (isO2Opayload ? "L1TMuonEndCapParamsO2ORcd" : "L1TMuonEndCapParamsRcd"));
0052   }
0053 }
0054 
0055 #include "FWCore/PluginManager/interface/ModuleDef.h"
0056 #include "FWCore/Framework/interface/MakerMacros.h"
0057 #include "FWCore/Framework/interface/ModuleFactory.h"
0058 
0059 DEFINE_FWK_MODULE(L1TMuonEndCapParamsWriter);