Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-11-11 03:56:55

0001 #include "FWCore/Framework/interface/EventSetup.h"
0002 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0003 #include "CondFormats/DataRecord/interface/SiStripCondDataRecords.h"
0004 #include "CondFormats/SiStripObjects/interface/SiStripApvSimulationParameters.h"
0005 #include "CommonTools/ConditionDBWriter/interface/ConditionDBWriter.h"
0006 
0007 class SiStripApvSimulationParametersBuilder : public edm::one::EDAnalyzer<> {
0008 public:
0009   explicit SiStripApvSimulationParametersBuilder(const edm::ParameterSet& iConfig) : m_parametersToken(esConsumes()) {}
0010   ~SiStripApvSimulationParametersBuilder() override {}
0011 
0012   void analyze(const edm::Event&, const edm::EventSetup&) override;
0013 
0014 private:
0015   const edm::ESGetToken<SiStripApvSimulationParameters, SiStripApvSimulationParametersRcd> m_parametersToken;
0016 };
0017 
0018 void SiStripApvSimulationParametersBuilder::analyze(const edm::Event&, const edm::EventSetup& evtSetup) {
0019   // copy; DB service needs non-const pointer but does not take ownership
0020   auto obj = std::make_unique<SiStripApvSimulationParameters>(evtSetup.getData(m_parametersToken));
0021 
0022   edm::Service<cond::service::PoolDBOutputService> mydbservice;
0023   if (mydbservice.isAvailable()) {
0024     if (mydbservice->isNewTagRequest("SiStripApvSimulationParametersRcd")) {
0025       mydbservice->createOneIOV<SiStripApvSimulationParameters>(
0026           *obj, mydbservice->beginOfTime(), "SiStripApvSimulationParametersRcd");
0027     } else {
0028       mydbservice->appendOneIOV<SiStripApvSimulationParameters>(
0029           *obj, mydbservice->currentTime(), "SiStripApvSimulationParametersRcd");
0030     }
0031   } else {
0032     edm::LogError("SiStripApvSimulationParametersBuilder") << "Service is unavailable";
0033   }
0034 }
0035 
0036 #include "FWCore/PluginManager/interface/ModuleDef.h"
0037 #include "FWCore/Framework/interface/MakerMacros.h"
0038 DEFINE_FWK_MODULE(SiStripApvSimulationParametersBuilder);