Back to home page

Project CMSSW displayed by LXR

 
 

    


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 #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/L1TGlobalPrescalesVetosO2ORcd.h"
0012 #include "CondFormats/DataRecord/interface/L1TGlobalPrescalesVetosRcd.h"
0013 #include "CondFormats/L1TObjects/interface/L1TGlobalPrescalesVetos.h"
0014 
0015 #include "FWCore/ServiceRegistry/interface/Service.h"
0016 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
0017 
0018 class L1TGlobalPrescalesVetosWriter : public edm::one::EDAnalyzer<> {
0019 private:
0020   edm::ESGetToken<L1TGlobalPrescalesVetos, L1TGlobalPrescalesVetosO2ORcd> o2oToken_;
0021   edm::ESGetToken<L1TGlobalPrescalesVetos, L1TGlobalPrescalesVetosRcd> token_;
0022   bool isO2Opayload;
0023 
0024 public:
0025   void analyze(const edm::Event&, const edm::EventSetup&) override;
0026 
0027   explicit L1TGlobalPrescalesVetosWriter(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 L1TGlobalPrescalesVetosWriter::analyze(const edm::Event& iEvent, const edm::EventSetup& evSetup) {
0038   edm::ESHandle<L1TGlobalPrescalesVetos> handle1;
0039 
0040   if (isO2Opayload)
0041     handle1 = evSetup.getHandle(o2oToken_);
0042   else
0043     handle1 = evSetup.getHandle(token_);
0044 
0045   L1TGlobalPrescalesVetos 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(
0051         ptr1, firstSinceTime, (isO2Opayload ? "L1TGlobalPrescalesVetosO2ORcd" : "L1TGlobalPrescalesVetosRcd"));
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(L1TGlobalPrescalesVetosWriter);