Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:23:19

0001 // system includes
0002 #include <iostream>
0003 
0004 // user includes
0005 #include "CondCore/CondDB/interface/ConnectionPool.h"
0006 #include "CoralBase/Attribute.h"
0007 #include "CoralBase/AttributeList.h"
0008 #include "CoralBase/TimeStamp.h"
0009 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0010 #include "FWCore/Framework/interface/Event.h"
0011 #include "FWCore/Framework/interface/MakerMacros.h"
0012 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0013 #include "FWCore/ServiceRegistry/interface/Service.h"
0014 #include "RelationalAccess/ISchema.h"
0015 #include "RelationalAccess/ISessionProxy.h"
0016 #include "RelationalAccess/ITable.h"
0017 #include "RelationalAccess/ITransaction.h"
0018 #include "RelationalAccess/TableDescription.h"
0019 
0020 class SiStripPayloadMapTableCreator : public edm::one::EDAnalyzer<> {
0021 public:
0022   explicit SiStripPayloadMapTableCreator(const edm::ParameterSet& iConfig);
0023   ~SiStripPayloadMapTableCreator() override = default;
0024   void analyze(const edm::Event& evt, const edm::EventSetup& evtSetup) override;
0025 
0026 private:
0027   cond::persistency::ConnectionPool m_connectionPool;
0028   std::string m_configMapDb;
0029 };
0030 
0031 SiStripPayloadMapTableCreator::SiStripPayloadMapTableCreator(const edm::ParameterSet& iConfig)
0032     : m_connectionPool(), m_configMapDb(iConfig.getParameter<std::string>("configMapDatabase")) {
0033   m_connectionPool.setParameters(iConfig.getParameter<edm::ParameterSet>("DBParameters"));
0034   m_connectionPool.configure();
0035 }
0036 
0037 void SiStripPayloadMapTableCreator::analyze(const edm::Event& evt, const edm::EventSetup& evtSetup) {
0038   std::shared_ptr<coral::ISessionProxy> cmDbSession = m_connectionPool.createCoralSession(m_configMapDb, true);
0039   coral::TableDescription mapTable;
0040   mapTable.setName("STRIP_CONFIG_TO_PAYLOAD_MAP");
0041   mapTable.insertColumn("CONFIG_HASH", coral::AttributeSpecification::typeNameForType<std::string>());
0042   mapTable.insertColumn("PAYLOAD_HASH", coral::AttributeSpecification::typeNameForType<std::string>());
0043   mapTable.insertColumn("PAYLOAD_TYPE", coral::AttributeSpecification::typeNameForType<std::string>());
0044   mapTable.insertColumn("CONFIG_STRING", coral::AttributeSpecification::typeNameForType<std::string>());
0045   mapTable.insertColumn("INSERTION_TIME", coral::AttributeSpecification::typeNameForType<coral::TimeStamp>());
0046   mapTable.setPrimaryKey("CONFIG_HASH");
0047   mapTable.setNotNullConstraint("CONFIG_HASH");
0048   mapTable.setNotNullConstraint("PAYLOAD_HASH");
0049   mapTable.setNotNullConstraint("PAYLOAD_TYPE");
0050   mapTable.setNotNullConstraint("CONFIG_STRING");
0051   mapTable.setNotNullConstraint("INSERTION_TIME");
0052 
0053   cmDbSession->transaction().start(false);
0054   cmDbSession->nominalSchema().createTable(mapTable);
0055   cmDbSession->transaction().commit();
0056 }
0057 
0058 // ------
0059 DEFINE_FWK_MODULE(SiStripPayloadMapTableCreator);