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