CMS 3D CMS Logo

SiStripPayloadMapTableCreator.cc
Go to the documentation of this file.
1 // system includes
2 #include <iostream>
3 
4 // user includes
6 #include "CoralBase/Attribute.h"
7 #include "CoralBase/AttributeList.h"
8 #include "CoralBase/TimeStamp.h"
14 #include "RelationalAccess/ISchema.h"
15 #include "RelationalAccess/ISessionProxy.h"
16 #include "RelationalAccess/ITable.h"
17 #include "RelationalAccess/ITransaction.h"
18 #include "RelationalAccess/TableDescription.h"
19 
21 public:
22  explicit SiStripPayloadMapTableCreator(const edm::ParameterSet& iConfig);
23  ~SiStripPayloadMapTableCreator() override = default;
24  void analyze(const edm::Event& evt, const edm::EventSetup& evtSetup) override;
25 
26 private:
29 };
30 
32  : m_connectionPool(), m_configMapDb(iConfig.getParameter<std::string>("configMapDatabase")) {
35 }
36 
38  std::shared_ptr<coral::ISessionProxy> cmDbSession = m_connectionPool.createCoralSession(m_configMapDb, true);
39  coral::TableDescription mapTable;
40  mapTable.setName("STRIP_CONFIG_TO_PAYLOAD_MAP");
41  mapTable.insertColumn("CONFIG_HASH", coral::AttributeSpecification::typeNameForType<std::string>());
42  mapTable.insertColumn("PAYLOAD_HASH", coral::AttributeSpecification::typeNameForType<std::string>());
43  mapTable.insertColumn("PAYLOAD_TYPE", coral::AttributeSpecification::typeNameForType<std::string>());
44  mapTable.insertColumn("CONFIG_STRING", coral::AttributeSpecification::typeNameForType<std::string>());
45  mapTable.insertColumn("INSERTION_TIME", coral::AttributeSpecification::typeNameForType<coral::TimeStamp>());
46  mapTable.setPrimaryKey("CONFIG_HASH");
47  mapTable.setNotNullConstraint("CONFIG_HASH");
48  mapTable.setNotNullConstraint("PAYLOAD_HASH");
49  mapTable.setNotNullConstraint("PAYLOAD_TYPE");
50  mapTable.setNotNullConstraint("CONFIG_STRING");
51  mapTable.setNotNullConstraint("INSERTION_TIME");
52 
53  cmDbSession->transaction().start(false);
54  cmDbSession->nominalSchema().createTable(mapTable);
55  cmDbSession->transaction().commit();
56 }
57 
58 // ------
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
cond::persistency::ConnectionPool m_connectionPool
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void analyze(const edm::Event &evt, const edm::EventSetup &evtSetup) override
void setParameters(const edm::ParameterSet &connectionPset)
SiStripPayloadMapTableCreator(const edm::ParameterSet &iConfig)
std::shared_ptr< coral::ISessionProxy > createCoralSession(const std::string &connectionString, bool writeCapable=false)
~SiStripPayloadMapTableCreator() override=default