CMS 3D CMS Logo

RunConfigDat.cc
Go to the documentation of this file.
1 #include <stdexcept>
2 #include <string>
4 
7 
8 using namespace std;
9 using namespace oracle::occi;
10 
12  m_env = nullptr;
13  m_conn = nullptr;
14  m_writeStmt = nullptr;
15  m_readStmt = nullptr;
16 
17  m_configTag = "none";
18  m_configVer = 0;
19 }
20 
22 
24  this->checkConnection();
25 
26  try {
27  m_writeStmt = m_conn->createStatement();
28  m_writeStmt->setSQL(
29  "INSERT INTO run_config_dat (iov_id, logic_id, "
30  "config_tag, config_ver) "
31  "VALUES (:iov_id, :logic_id, "
32  ":config_tag, :config_ver)");
33  } catch (SQLException& e) {
34  throw(std::runtime_error("RunConfigDat::prepareWrite(): " + e.getMessage()));
35  }
36 }
37 
38 void RunConfigDat::writeDB(const EcalLogicID* ecid, const RunConfigDat* item, RunIOV* iov) noexcept(false) {
39  this->checkConnection();
40  this->checkPrepare();
41 
42  int iovID = iov->fetchID();
43  if (!iovID) {
44  throw(std::runtime_error("RunConfigDat::writeDB: IOV not in DB"));
45  }
46 
47  int logicID = ecid->getLogicID();
48  if (!logicID) {
49  throw(std::runtime_error("RunConfigDat::writeDB: Bad EcalLogicID"));
50  }
51 
52  try {
53  m_writeStmt->setInt(1, iovID);
54  m_writeStmt->setInt(2, logicID);
55  m_writeStmt->setString(3, item->getConfigTag());
56  m_writeStmt->setInt(4, item->getConfigVersion());
57 
58  m_writeStmt->executeUpdate();
59  } catch (SQLException& e) {
60  throw(std::runtime_error("RunConfigDat::writeDB(): " + e.getMessage()));
61  }
62 }
63 
64 void RunConfigDat::fetchData(map<EcalLogicID, RunConfigDat>* fillMap, RunIOV* iov) noexcept(false) {
65  this->checkConnection();
66  fillMap->clear();
67 
68  iov->setConnection(m_env, m_conn);
69  int iovID = iov->fetchID();
70  if (!iovID) {
71  // throw(std::runtime_error("RunConfigDat::writeDB: IOV not in DB"));
72  return;
73  }
74 
75  try {
76  m_readStmt->setSQL(
77  "SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
78  "d.config_tag, d.config_ver "
79  "FROM channelview cv JOIN run_config_dat d "
80  "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
81  "WHERE d.iov_id = :iov_id");
82  m_readStmt->setInt(1, iovID);
83  ResultSet* rset = m_readStmt->executeQuery();
84 
85  std::pair<EcalLogicID, RunConfigDat> p;
86  RunConfigDat dat;
87  while (rset->next()) {
88  p.first = EcalLogicID(rset->getString(1), // name
89  rset->getInt(2), // logic_id
90  rset->getInt(3), // id1
91  rset->getInt(4), // id2
92  rset->getInt(5), // id3
93  rset->getString(6)); // maps_to
94 
95  dat.setConfigTag(rset->getString(7));
96  dat.setConfigVersion(rset->getInt(8));
97 
98  p.second = dat;
99  fillMap->insert(p);
100  }
101  } catch (SQLException& e) {
102  throw(std::runtime_error("RunConfigDat::fetchData(): " + e.getMessage()));
103  }
104 }
RunIOV
Definition: RunIOV.h:13
funct::false
false
Definition: Factorize.h:29
RunIOV.h
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
RunConfigDat.h
RunConfigDat
Definition: RunConfigDat.h:11
RunConfigDat::setConfigVersion
void setConfigVersion(int ver)
Definition: RunConfigDat.h:24
RunConfigDat::~RunConfigDat
~RunConfigDat() override
Definition: RunConfigDat.cc:21
oracle::occi
Definition: ConnectionManager.h:7
EcalLogicID
Definition: EcalLogicID.h:7
RunConfigDat::fetchData
void fetchData(std::map< EcalLogicID, RunConfigDat > *fillMap, RunIOV *iov) noexcept(false)
Definition: RunConfigDat.cc:64
RunConfigDat::prepareWrite
void prepareWrite() noexcept(false) override
Definition: RunConfigDat.cc:23
RunConfigDat::setConfigTag
void setConfigTag(std::string tag)
Definition: RunConfigDat.h:21
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
RunConfigDat::writeDB
void writeDB(const EcalLogicID *ecid, const RunConfigDat *item, RunIOV *iov) noexcept(false)
Definition: RunConfigDat.cc:38
std
Definition: JetResolutionObject.h:76
RunConfigDat::RunConfigDat
RunConfigDat()
Definition: RunConfigDat.cc:11
Oracle.h
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37