Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-11-25 03:29:19

0001 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0003 #include "FWCore/ServiceRegistry/interface/Service.h"
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005 #include "FWCore/Framework/interface/Event.h"
0006 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
0007 #include "FWCore/Framework/interface/EventSetup.h"
0008 #include "FWCore/Framework/interface/ESHandle.h"
0009 #include "FWCore/Framework/interface/MakerMacros.h"
0010 #include "CondFormats/Common/interface/FileBlob.h"
0011 #include "Geometry/Records/interface/GeometryFileRcd.h"
0012 
0013 #include <string>
0014 #include <vector>
0015 #include <fstream>
0016 
0017 class XMLGeometryBuilder : public edm::one::EDAnalyzer<edm::one::WatchRuns> {
0018 public:
0019   XMLGeometryBuilder(const edm::ParameterSet&);
0020 
0021   void beginJob() override;
0022   void beginRun(edm::Run const& iEvent, edm::EventSetup const&) override {}
0023   void analyze(edm::Event const& iEvent, edm::EventSetup const&) override {}
0024   void endRun(edm::Run const& iEvent, edm::EventSetup const&) override {}
0025 
0026 private:
0027   std::string m_fname;
0028   bool m_zip;
0029   std::string m_record;
0030 };
0031 
0032 XMLGeometryBuilder::XMLGeometryBuilder(const edm::ParameterSet& iConfig) {
0033   m_fname = iConfig.getUntrackedParameter<std::string>("XMLFileName", "test.xml");
0034   m_zip = iConfig.getUntrackedParameter<bool>("ZIP", true);
0035   m_record = iConfig.getUntrackedParameter<std::string>("record", "GeometryFileRcd");
0036 }
0037 
0038 void XMLGeometryBuilder::beginJob() {
0039   edm::LogInfo("XMLGeometryBuilder") << "XMLGeometryBuilder::beginJob";
0040   edm::Service<cond::service::PoolDBOutputService> mydbservice;
0041   if (!mydbservice.isAvailable()) {
0042     edm::LogError("XMLGeometryBuilder") << "PoolDBOutputService unavailable";
0043     return;
0044   }
0045 
0046   FileBlob pgf(m_fname, m_zip);
0047 
0048   if (mydbservice->isNewTagRequest(m_record)) {
0049     mydbservice->createOneIOV(pgf, mydbservice->beginOfTime(), m_record);
0050   } else {
0051     edm::LogError("XMLGeometryBuilder") << "GeometryFileRcd Tag already exist";
0052   }
0053 }
0054 
0055 DEFINE_FWK_MODULE(XMLGeometryBuilder);